To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.generalOpen lugnet.general in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 General / 54493
     
   
Subject: 
Re: Power Functions infra-red RC protocol released!
Newsgroups: 
lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics
Date: 
Fri, 1 Feb 2008 19:38:18 GMT
Highlighted: 
! (details)
Viewed: 
24692 times
  

In lugnet.general, Philippe Hurbain wrote:

The LEGO company just released a document detailing the complete protocol
used by Power Functions RC receiver.

In collaboration with Jason Railton I have modified/extended the NBC and NXC API
functions for the HiTechnic iRLink device in support of the newly documented
Power Function modes as well as the R/C Train IR protocol.  I uploaded a new
test_release zip to the BricxCC page with NBC and BricxCC executable updates
with these new API functions included in the compiler and BricxCC syntax
highlighter/code completion support for NBC and NXC programs.  These updates
will be in the next beta release of NBC/NXC and the next official BricxCC
release.

http://bricxcc.sourceforge.net/test_release.zip

The old HTPowerFunctionCommand API function is gone.  It is replaced by the new
HTPFComboDirect function.

All the new NXC functions are listed below.  For NBC the status is returned via
an additional parameter but otherwise the function signatures are identical.

HTPFComboDirect(port, channel, outa, outb)
HTPFSinglePin(port, channel, out, pin, func, bContinuous)
HTPFSingleOutputCST(port, channel, out, func)
HTPFSingleOutputPWM(port, channel, out, func)
HTPFComboPWM(port, channel, outa, outb)
HTPFTrain(port, channel, func)
HTIRTrain(port, channel, func)
HTPFRawOutput(port, nibble0, nibble1, nibble2)
HTPFRepeat(port, count, delay)

The HTPFRepeat function allows you to send the previous command again in a loop
count number of times with a wait of delay milliseconds between each
transmission.

The following constants are HTPFComboDirect output commands.

#define HTPF_CMD_STOP  0
#define HTPF_CMD_FWD   1
#define HTPF_CMD_REV   2
#define HTPF_CMD_BRAKE 3

For all Power Function API calls you can use the channel constants shown here:

#define HTPF_CHANNEL_1 0
#define HTPF_CHANNEL_2 1
#define HTPF_CHANNEL_3 2
#define HTPF_CHANNEL_4 3

These power function mode constants are used internally by the API functions
listed above.

#define PF_MODE_TRAIN             0
#define PF_MODE_COMBO_DIRECT      1
#define PF_MODE_SINGLE_PIN_CONT   2
#define PF_MODE_SINGLE_PIN_TIME   3
#define PF_MODE_COMBO_PWM         4
#define PF_MODE_SINGLE_OUTPUT_PWM 4
#define PF_MODE_SINGLE_OUTPUT_CST 6

When calling either HTIRTrain (for use with R/C Train receivers) or HTPFTrain
(for use with the Power Function receiver) you should use one of these four
train functions.  The "unused" mode 0 in the Power Function receiver operates
identically to the standard R/C Train IR receiver with respect to controlling
the attached motor/light.

#define TRAIN_FUNC_STOP         0
#define TRAIN_FUNC_INCR_SPEED   1
#define TRAIN_FUNC_DECR_SPEED   2
#define TRAIN_FUNC_TOGGLE_LIGHT 4

The HTIRTrain function uses a different IR protocol than the HTPFTrain function
and the receiver interprets channel #3 as ALL so you should use these channel
constants instead of the Power Function-specific channel constants when calling
HTIRTrain.

#define TRAIN_CHANNEL_1   0
#define TRAIN_CHANNEL_2   1
#define TRAIN_CHANNEL_3   2
#define TRAIN_CHANNEL_ALL 3

For SingleOutput and SinglePin power function modes you should use these output
constants.

#define PF_OUT_A 0
#define PF_OUT_B 1

Use the pin constants with the SinglePin function listed above.

#define PF_PIN_C1 0
#define PF_PIN_C2 1

These constants are SinglePin operation which can be used with the HTPFSinglePin
function listed above.

#define PF_FUNC_NOCHANGE 0
#define PF_FUNC_CLEAR    1
#define PF_FUNC_SET      2
#define PF_FUNC_TOGGLE   3

The SingleOutputCST API function uses these func constants:

#define PF_CST_CLEAR1_CLEAR2 0
#define PF_CST_SET1_CLEAR2   1
#define PF_CST_CLEAR1_SET2   2
#define PF_CST_SET1_SET2     3
#define PF_CST_INCREMENT_PWM 4
#define PF_CST_DECREMENT_PWM 5
#define PF_CST_FULL_FWD      6
#define PF_CST_FULL_REV      7
#define PF_CST_TOGGLE_DIR    8

The SingleOutputPWM and ComboPWM API functions both use these constants for
specifying the speed and direction of the motor(s).

#define PF_PWM_FLOAT 0
#define PF_PWM_FWD1  1
#define PF_PWM_FWD2  2
#define PF_PWM_FWD3  3
#define PF_PWM_FWD4  4
#define PF_PWM_FWD5  5
#define PF_PWM_FWD6  6
#define PF_PWM_FWD7  7
#define PF_PWM_BRAKE 8
#define PF_PWM_REV7  9
#define PF_PWM_REV6  10
#define PF_PWM_REV5  11
#define PF_PWM_REV4  12
#define PF_PWM_REV3  13
#define PF_PWM_REV2  14
#define PF_PWM_REV1  15

   
         
     
Subject: 
Re: Power Functions infra-red RC protocol released!
Newsgroups: 
lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics
Date: 
Sat, 2 Feb 2008 21:44:07 GMT
Viewed: 
22625 times
  

In lugnet.general, John Hansen wrote:
In lugnet.general, Philippe Hurbain wrote:

The LEGO company just released a document detailing the complete protocol
used by Power Functions RC receiver.

In collaboration with Jason Railton I have modified/extended the NBC and NXC API
functions for the HiTechnic iRLink device in support of the newly documented
Power Function modes as well as the R/C Train IR protocol.  I uploaded a new
test_release zip to the BricxCC page with NBC and BricxCC executable updates
with these new API functions included in the compiler and BricxCC syntax
highlighter/code completion support for NBC and NXC programs.  These updates
will be in the next beta release of NBC/NXC and the next official BricxCC
release.


<snip>

Nicely done John!

Is there a tentative timeframe when NQC for the RCX will be updated to support
IR to the LEGO powerfunctions?

Dave K

    
          
     
Subject: 
Re: Power Functions infra-red RC protocol released!
Newsgroups: 
lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics
Date: 
Sun, 3 Feb 2008 22:12:03 GMT
Viewed: 
22346 times
  

In lugnet.general, David Koudys wrote:
In lugnet.general, John Hansen wrote:
In lugnet.general, Philippe Hurbain wrote:

The LEGO company just released a document detailing the complete protocol
used by Power Functions RC receiver.

In collaboration with Jason Railton I have modified/extended the NBC and NXC API
functions for the HiTechnic iRLink device in support of the newly documented
Power Function modes as well as the R/C Train IR protocol.  I uploaded a new
test_release zip to the BricxCC page with NBC and BricxCC executable updates
with these new API functions included in the compiler and BricxCC syntax
highlighter/code completion support for NBC and NXC programs.  These updates
will be in the next beta release of NBC/NXC and the next official BricxCC
release.


<snip>

Nicely done John!

Is there a tentative timeframe when NQC for the RCX will be updated to support
IR to the LEGO powerfunctions?

Dave K

I doubt that's possible - a bytecode program just can't run fast enough to do
the timing for the IR commands, on either brick.  The NXT can only manage it
because it sends them over a slow comms link to a HiTechnic IRLink sensor, then
that handles the actual transmission.  The only way the RCX could do it with
it's built-in IR LED is to code the functions into a replacement firmware, as
with Bob Kojima's BrickOS example:

http://news.lugnet.com/general/?n=54443

Jason R

    
          
     
Subject: 
Re: Power Functions infra-red RC protocol released!
Newsgroups: 
lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics
Date: 
Mon, 4 Feb 2008 15:31:11 GMT
Viewed: 
22510 times
  

In lugnet.general, Jason J Railton wrote:

<snip>

I doubt that's possible - a bytecode program just can't run fast enough to do
the timing for the IR commands, on either brick.  The NXT can only manage it
because it sends them over a slow comms link to a HiTechnic IRLink sensor, then
that handles the actual transmission.  The only way the RCX could do it with
it's built-in IR LED is to code the functions into a replacement firmware, as
with Bob Kojima's BrickOS example:

http://news.lugnet.com/general/?n=54443

Jason R

I'm runnign Dick Swan's alternate firmware that he sent me a while back.

Dave K

    
          
     
Subject: 
Re: Power Functions infra-red RC protocol released!
Newsgroups: 
lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics
Date: 
Mon, 4 Feb 2008 20:06:55 GMT
Viewed: 
23051 times
  

In lugnet.general, David Koudys wrote:
I'm runnign Dick Swan's alternate firmware that he sent me a while back.

Dave K

Dick Swan's replacement RCX firmware also does not support directly manipulating
the IR led and it doesn't support microsecond timing control.  Both of these
features would be required in order to send the IR messages to a Power Function
or R/C train receiver.  The only way RCX firmwares that are VM-based could
support emitting PF IR streams is if some setting in the UART area of the
firmware could be tweaked to emit bytes in a PF-compatible mode.  To the best of
my knowledge this is not possible in either the standard RCX firmware or in
Dick's RCX-compatible firmware.  John Barnes or Michael Barrett Anderson
(amongst others) would probably know for certain.

John Hansen

    
          
     
Subject: 
Re: Power Functions infra-red RC protocol released!
Newsgroups: 
lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics
Date: 
Mon, 4 Feb 2008 20:43:06 GMT
Viewed: 
22967 times
  

In lugnet.general, John Hansen wrote:
In lugnet.general, David Koudys wrote:
I'm runnign Dick Swan's alternate firmware that he sent me a while back.

Dave K

Dick Swan's replacement RCX firmware also does not support directly manipulating
the IR led and it doesn't support microsecond timing control.  Both of these
features would be required in order to send the IR messages to a Power Function

rats!


or R/C train receiver.  The only way RCX firmwares that are VM-based could
support emitting PF IR streams is if some setting in the UART area of the
firmware could be tweaked to emit bytes in a PF-compatible mode.  To the best of
my knowledge this is not possible in either the standard RCX firmware or in
Dick's RCX-compatible firmware.  John Barnes or Michael Barrett Anderson
(amongst others) would probably know for certain.

John Hansen

Thanks for the heads up, John

Looks like I really have to start brushing up on my NXT 'bot building now.

Dave K

   
         
     
Subject: 
Re: PF IR RC protocol released! - NXC
Newsgroups: 
lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics
Date: 
Tue, 5 Feb 2008 17:16:13 GMT
Viewed: 
26079 times
  

In lugnet.general, John Hansen wrote:
In lugnet.general, Philippe Hurbain wrote:

The LEGO company just released a document detailing the complete protocol
used by Power Functions RC receiver.

In collaboration with Jason Railton I have modified/extended the NBC and NXC API
functions for the HiTechnic iRLink device in support of the newly documented
Power Function modes as well as the R/C Train IR protocol.  I uploaded a new
test_release zip to the BricxCC page with NBC and BricxCC executable updates
with these new API functions included in the compiler and BricxCC syntax
highlighter/code completion support for NBC and NXC programs.  These updates
will be in the next beta release of NBC/NXC and the next official BricxCC
release.

http://bricxcc.sourceforge.net/test_release.zip


Many thanks John and Jason for your work on this.  I am a comparative newbie to
NXC programming but I have my NXT working like a PF IR remote handset now that I
set up the sensor correctly!

NXC has given me the programming environment to replace the VB that I used with
my RCX (an NXT has no ActiveX control file so it could not use VB).  The 'C' is
returning to me from my university days!

With your HTPF commands and a few modded leads (the bottom right one here:
http://www.brickshelf.com/cgi-bin/gallery.cgi?i=2963520 ) to cascade a few IR
receivers, an NXT could now control up to 128 motors or 256 LEDs (like this:
http://www.brickshelf.com/cgi-bin/gallery.cgi?i=2957469 ) from one sensor port!

Could the NXC/NBC commands be extended to allow the IR Link sensor to receive PF
IR commands from a PF handset and convert them to PF channel, Motor A and Motor
B output variables (so that an NXT could act like a PF IR receiver)?

That would allow an NXT robot to interact with other PF robots in pack hunting
and other automatic machine activities, where motors move PF IR handset levers
like this: http://www.brickshelf.com/cgi-bin/gallery.cgi?i=2391291

I suppose a receive function would put the data into one variable, so perhaps a
long integer of the 16-bit IR message would do, allowing the programmer to pick
bits out by ANDing.

Mark

   
         
   
Subject: 
Re: Power Functions infra-red RC protocol released!
Newsgroups: 
lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics
Followup-To: 
lugnet.technic
Date: 
Wed, 6 Feb 2008 17:31:32 GMT
Viewed: 
23925 times
  

In lugnet.general, John Hansen wrote:
In lugnet.general, Philippe Hurbain wrote:

The LEGO company just released a document detailing the complete protocol
used by Power Functions RC receiver.

In collaboration with Jason Railton I have modified/extended the NBC and NXC API
functions for the HiTechnic iRLink device in support of the newly documented
Power Function modes as well as the R/C Train IR protocol.  I uploaded a new
test_release zip to the BricxCC page with NBC and BricxCC executable updates
with these new API functions included in the compiler and BricxCC syntax
highlighter/code completion support for NBC and NXC programs.  These updates
will be in the next beta release of NBC/NXC and the next official BricxCC
release.

http://bricxcc.sourceforge.net/test_release.zip


Many thanks John and Jason for your work on this.  I have been using the NXC
functions to control PF IR receivers from my NXT.

TLG has just released the following information:

"We have been testing the LPF RC Receiver today and discovered an error in the
RC Receiver firmware or chip masking. A register is not adressable. It affects
all the set, clear and toggle commands for single pins....and only these
commands.
We will do an update of the chip mask at some point (not too far into the
future). At that point it will be corrected."

This means that these commands will not yet work as advertised:
HTPFSinglePin(port, channel, out, pin, func, bContinuous)
HTPFSingleOutputCST(port, channel, out, func)
HTPFSingleOutputPWM(port, channel, out, func)

The HTPFSingleOutputCST commands affected are only the Set/Clear C1/C2 ones.  My
own experiments confirm that the others (inc/dec PWM, full power and toggle
direction) work well.

Mark

 

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR