roeltrain

LEGO RC Trains (not PowerFunctions) IR protocol explained

Recommended Posts

Hello LEGO Trainenthousiasts,

I've made a PowerFunctions-IRcontroller for 4 trains + lights + 3 railswitches with servo's based on an Arduino Uno R3 : https://forum.arduin...?topic=369292.0

One of demands was also using the older LEGO RC-trains.

But on the internet no information was found.

So with aid of a logicanalyzer I proudly presents the outcome of this investigation:

An experiment to make this functional: http://forum.arduino...?topic=320405.0

LEGO RC TRAINS PROTOCOL

note:

mu s means micro seconds

channel 4 means combichannel 1+2+3

This is not the LEGO PowerFunctions IR protocol version 1.20 as described at http://www.philohome...ons_RC_v120.pdf

This protocol described below is the predecessor of LEGO PF.

Start = Stop is bitstream 36kHz with 10 bits and pauze 1930 mu s

Uno is bitstream 36kHz with 10 bits and pauze 280 mu s

Zero is bitstream 36kHz with 10 bits and pauze 844 mu s

1 bit has a duty-cycle 16 mu s high and 11,5 mu s low

pauze (common factor 18 ms, so factors for

Channel actie bitstreams blok-pauze-blok-pauze-blok-pauze-blok)

1 up Start 1111 1111 1110 0001 Stop 3+2+2 = bitstream1 pauze = 3*18ms bitstream2 pauze = 2*18ms bitstream3 pauze = 3*18ms bitstream4

1000 0111 1111 1110 1001 1000 4+5+3

1 down Start 1111 1111 1101 0010 Stop 2+2+3

Start 0111 1111 1101 1010 Stop 3+2+3

1 stop Start 0111 1111 1111 1000 Stop 3+2+2

Start 1111 1111 1111 0000 Stop --------

1 horn Start 1111 1111 1100 0011 Stop --------

Start 0111 1111 1100 1011 Stop --------

2 up Start 1110 1111 1110 0010 Stop 2+3+5

Start 0110 1111 1110 1010 Stop --------

2 down Start 1110 1111 1101 0011 Stop 5+3+3

Start 0110 1111 1101 1011 Stop --------

2 stop Start 1110 1111 1111 0001 Stop 5+4+4

Start 0110 1111 1111 1001 Stop --------

2 horn Start 1110 1111 1100 0100 Stop --------

Start 0110 1111 1100 1100 Stop --------

3 up Start 1101 1111 1110 0011 Stop 5+4+2

Start 0101 1111 1110 1011 Stop --------

3 down Start 1101 1111 1101 0100 Stop 3+2+2

Start 0101 1111 1101 1100 Stop --------

3 stop Start 1101 1111 1111 0010 Stop 5+4+5

Start 0101 1111 1111 1010 Stop --------

3 horn Start 1101 1111 1100 0101 Stop --------

Start 0101 1111 1100 1101 Stop --------

4 up Start 1100 1111 1110 0100 Stop 2+3+5

Start 0100 1111 1110 1100 Stop --------

4 down Start 1100 1111 1110 0101 Stop 3+2+3

Start 0100 1111 1110 1101 Stop --------

4 stop Start 0100 1111 1111 1011 Stop 3+2+3

Start 1100 1111 1111 0011 Stop 2+3+3

4 horn Start 1100 1111 1100 0110 Stop --------

Start 0100 1111 1100 1110 Stop --------

(STOP- button keeps repeating when hold, all others (UP, DOWN, HORN) send only once a message

1e nibble: bit1 bit2 bit3 bit4

Kanaal 1 toggle 1 1 1

Kanaal 2 toggle 1 1 0

Kanaal 3 toggle 1 0 1

Kanaal 4 toggle 1 0 0

2e nibble 1 1 1 1

bit1 bit2 bit3 bit4

3e nibble 1 1

Up 1 0

Down 0 1

Stop 1 1

Horn 1 0

4e nibble toggle ? ? ? (checksum ???)

Togglebit reverse from 1st nibble bit1

Any additions/suggestions? I like them

post-94932-0-52548200-1456160143_thumb.png

post-94932-0-11183200-1456160158_thumb.png

post-94932-0-80043600-1456160162_thumb.png

Edited by roeltrain

Share this post


Link to post
Share on other sites

Unfortuneately that is not entirely true.
in the above listing the bits are swapped. High is Low and Low is High.

You'll find a description of the protocol in the file <LEGO_Power_Functions_RC_v120.pdf> that you can find on the Internet. I know that this is not the right specification as the power functions is a successor of the rc train base platform. The rc train base platform has been only used as an intermediate step towards the RC Power Functions protocol.

This means:
1. The checksum calculation is different. In deviation to the above mentioned document the checksum is calculated with the following formula:

(0xf ^ ((_nib1 + _nib2 + _nib3) % 0x10))


2. The timing parameters are different to the above mentioned document. You can use the values mentioned above:

It is a 36kHz signal base

Start/Stop is pause 1930 mus

Low bit  is pause 280 mu s

High bit is pause 844 mu s
 

3. The rc train bases in the market are having different firmware versions. THe newer ones obviously are already pretty close the commandset mentioned in the document. These are supporting the "Extended Mode", the "Single Output Mode" and also the "Combo PWM mode"  The older ones are just supporting the "Extended mode", so they are limited to the commands that you can also send with the remote control. Setting an absolute power step directly is unfortuneately not possible with the older rc train bases.

 

image.png.dc4456c5abb362636dd4c8b3090f6558.png

image.thumb.png.489e8bba8b34d697b500f4077cdef482.pngimage.png.e0247ad6742c7e6b6feb6b4e5473b01f.png

Share this post


Link to post
Share on other sites

@Martin0815. Thanks for the addition / correction. Apart from that:

1. Welcome to Eurobricks and Train Tech;
2. It would be very nice to share the data also as a text / csv file;
3. @roeltrain posted it almost 7 years ago so it would have been better to create a new topic on it and include this one, but at least it is very useful (i.e. for the people still using PF obviously).

Share this post


Link to post
Share on other sites

@Martin0815 and @JopieK:

Just FYI: The data encoding, particularly the checksum, is also briefly mentioned here:

Chapter "Protocol bit/byte streams encoding" further down, incl. references that I found/used. MuLPI still works; just tested it :D

ESP32 code (using Arduino c++/IDE) for MuLPI is available, if anyone is interested, just let me know.

Best wishes,
Thorsten

Share this post


Link to post
Share on other sites

  Having only used PF myself, I'm wondering if anyone knows if the "new" PF protocol was designed in such a way that it would not cause interference in the same play space with the "old" IR protocol, whether or not this had anything to do with subsequent feature additions?  Can they coexist if transmitting simultaneously?  Also, I know the ability to send PF commands was made available in PUp, but would the equivalent code theoretically be possible to support the earlier IR protocol?

Share this post


Link to post
Share on other sites
15 minutes ago, UltraViolet said:

if the "new" PF protocol

New as in PoweredUp? Or is there another, newer PF protocol?

If that "new" is PUp: That is transported via Bluetooth low energy, which uses 2.4 GHz radio. "old PF" uses modulated infrared light. They will absolutely not interfere with each other.

Best,
Thorsten

Share this post


Link to post
Share on other sites

I'm aware PUp is bluetooth.  I'm only distinguishing between the two 'vintage' IR protocols.  My subsequent mention of PUp only pertains to the ability to send commands from a PUp sensor element to allow controlling PU from PUp.

Share this post


Link to post
Share on other sites
55 minutes ago, UltraViolet said:

I'm only distinguishing between the two 'vintage' IR protocols.

As there are at least 4 "vintage" IR protocols [RC Car, RC Train, RCX (Scout, Spybotics, NXT w/IR sensor), PF], which one are you referring to? All these 4 do not interfere with each other unless two devices send out light at the same time, which scrambles the individual data streams.

But a command or the like encoded by one of the four protocols is only recognized by a receiver using the identical protocol. Shining IR light from the RC train remote does not cause any reaction in e.g. the RC car devices.

I am using all of the above in addition to BL and BLE on my layout without any problems. The control program I am using though makes sure that there is only one IR encoded signal at any one time emitted. 

Best,
Thorsten

Edited by Toastie

Share this post


Link to post
Share on other sites
19 minutes ago, JopieK said:

Thanks for the additional info

You are very, very welcome!

All the best,
Thorsten

On 1/23/2023 at 12:22 AM, Martin0815 said:

Setting an absolute power step directly is unfortuneately not possible with the older rc train bases.

Now that is good to know!!! Thank you very much, @Martin0815!!! Missed that entirely in your post. Cool. My RC train bases seem to be all the old kind. I have thus to use a stepping up/down procedure (lot of IR traffic) in my program.

Do you have any idea how to discern one version from the other?

Best wishes,
Thorsten

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.