Skip to content

Old LEGO infrared protocol (beforePower Functions) used with MINDSTORMS Spybotics, Bionicle Manas, etc.

License

Notifications You must be signed in to change notification settings

JorgePe/ir-spybotics

Repository files navigation

ir-spybotics

LEGO MINDSTORMS Spybotics had an infrared remote control. This protocol, based on a 76 kHz carrier, was also used on Bionicle Technic Manas, RC Nitro Flash, DUPLO RC Dozer and RC Train. It had a short lifespan and was replaced by LEGO Power Functions IR protocol, based on a 38 kHz carrier, still in use.

The name of this project is misleading bt when I started I was really only interested on controlling the Spybotics. After a while I found out that not just Spybotics but all LEGO IR devices and eve more.

Python scripts

'ir_generate.py' generates the signals to control this devices with Arduino using IRLib2 library, like their example sketch 'rawSend'.

'ir_generate_lirc.py' generates a LIRC configuration file so we can use any IR transmitter supported by LIRC. I use a FTDI adapter.

'lego_ir_ctrl.py' demonstrates how to use a LIRC suported transmitter (like a FTDI-X) to control a LEGO IR device with the keyboard (both old IR Protocol and Power Functions protocol)

Other files

  • 'all_commands.txt' contains all commands generated by 'ir_generate.py'.
  • 'LEGO_Old_RC.conf' contains the LIRC remote control configuration file generated by 'ir_generate_lirc.py'
  • 'AllComboDirect.conf' contains the LIRC remote control configuration file generated with [Diomidis Spinellis]{https://github.com/dspinellis/lego-lirc} Generate program for the LEGO Power Functions protocol
  • 'RemoteControl.ino' is an extended version of IRLib2 'rawSend' allowing control from the Arduino serial port

Usage

Arduino

A typical command is shown:

Command: Ch1_OrangeNop_YellowFwd
  Msg:     00000101011100010111011
  Size:    12
  Signal:  1040, 208, 208, 208, 208, 624, 624, 208, 208, 624, 208, 624

This is the command sent by the Remote Control when just the Yellow Forward button is pressed (since Spybotics command doesn't have collors we could also say Right Forward button).

It contains 12 transitions and the timings before each transition occurs. Since transmission always start with a '0', the signal consists in a '0' for 1040 us, followed by a '1' for 208 us, then another '0' for 208 us, etc.

To use this command with 'rawSend' we should include this definition:

#define Ch1_OrangeNop_YellowFwd_LEN 12
uint16_t Ch1_OrangeNop_YellowFwd[Ch1_OrangeNop_YellowFwd_LEN]={
  1040, 208, 208, 208, 208, 624, 624, 208, 208, 624, 208, 624
  };

Then to send the command we use:

mySender.send(Ch1_OrangeNop_YellowFwd,Ch1_OrangeNop_YellowFwd,76);

LIRC

Copy the 'LEGO_Old_RC.conf' file to the LIRC folder that contains the remotes definitions, like '/usr/local/etc/lirc/lircd.conf.d/'

If you already have LIRC working, restart it. Then check for the new remote:

sudo irsend -d/var/run/lirc/lircd LIST "" ""

...
LEGO_Old_RC
...

Now you can send a command with 'irsend':

sudo irsend -d /var/run/lirc/lircd SEND_ONCE LEGO_Old_RC Ch1_OrangeNop_YellowFwd

Examples

Arduino

'RemoteControl.ino' is an extended version of 'rawSend', it includes all signals generated with 'ir_generate.py' and accepts commands from the serial port so we can control a LEGO device with a computer.

It's configured to use All Channels and reacts to 4 keys moving both motors at the same time: 'F': Front 'B': Back 'L': Turn Left 'R': Turn Right

It also reacts to keys '0', '1', '2' and '3', making turns with just one motor (instead of using both)

In linux you can use it with 'screen' like this:

screen /dev/ttyACM0

or you can send commands from bash like this

echo F > /dev/ttyACM0

but you might need to set your Arduino serial connection with:

stty -F /dev/ttyACM0 ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo

Notes

DUPLO Dozer has a tendency to gasp after some commands

More

More details about my findings here: http://ofalcao.pt/blog/2017/decoding-old-lego-infrared-protocol

Future developments

I intend to discover why the DUPLO DC Dozer gasps so frequently. And will try to use other LIRC files to control some interesting non-LEGO devices with my MINDSTORMS EV3 (running ev3dev).

About

Old LEGO infrared protocol (beforePower Functions) used with MINDSTORMS Spybotics, Bionicle Manas, etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages