To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.trainsOpen lugnet.trains in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Trains / 29991
29990  |  29992
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: 
2622 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



Message has 3 Replies:
  Re: Power Functions infra-red RC protocol released!
 
(...) <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 (17 years ago, 2-Feb-08, to lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics)
  Re: PF IR RC protocol released! - NXC
 
(...) 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 (...) (17 years ago, 5-Feb-08, to lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics)
  Re: Power Functions infra-red RC protocol released!
 
(...) 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 (...) (17 years ago, 6-Feb-08, to lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics)

Message is in Reply To:
  Power Functions infra-red RC protocol released!
 
(2 URLs) The LEGO company just released a document detailing the complete protocol used by Power Functions RC receiver. I host the document on my (URL) Power Functions presentation page>. As you can see this opens up a new world of possibilities... (...) (17 years ago, 25-Jan-08, to lugnet.general, lugnet.technic, lugnet.trains, lugnet.robotics, lugnet.announce, FTX) !! 

19 Messages in This Thread:









Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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