Home / Sensors / Control the world with the HiTechnic IR Link

Control the world with the HiTechnic IR Link

IRLink Sensor The HiTechnic IR Link is capable of many things including controlling your Power Function devices.  The one thing you couldn’t do was transmit regular data.  That is, until now. 

The IR Link has several transmission modes, 0x02 for example is used for the PF functionality.  There is another mode 0x00, UART-mode, which can be used to transmit 8 bytes at a time at 2400 baud using a 38KHz carrier frequency.  It is also the mode that can be used for communicating with the RCX.

There are two ways you can use the IR Link to transmit your data.  The first method which can be used to send the same 8 bytes over and over again works by preloading the transmit buffer at 0x45 with the 8 bytes you wish to send, followed by the total message length (0x08) and the transmission mode to be used (0x00).  You can then trigger the IR Link to start transmitting by setting register 0x4F to 1 with another I2C message.  Care must be taken not to trigger a retransmission before the previous one is done or you’ll garble the currently transmitting message as it will immediately start transmitting from the first byte again.

If you don’t want to send just 8 bytes over and over again, you can also load up the transmit register at 0x45, followed by the message length (0x08), transmission mode (0x00) and the trigger (0x01). 

Due to the nature of UART-mode, the bytes are transmitted UART-style with odd parity.  That means that when you tell the sensor to transmit 0xAB (b10101011), the following is transmitted via IR:

Start B0 B1 B2 B3 B4 B5 B6 B7 Par Stop
1 0 0 1 0 1 0 1 0 0 0

Each data byte is preceded by a start bit which is always set to 1, then follows bits 0 through 7 of your data (least significant bit first), inverted (0 becomes 1, 1 becomes 0), the odd parity value and then a stop bit which is always 0.  Sounds complicated?  I agree, it took several edits of this blog entry to get this right!

For each bit set to 1, the IR Link’s transmitter goes high for 1/2400th of a second or about 0.42ms, that means that 2 consecutive bits set to 1 will mean an IR burst of a little more than 0.83ms. 

There is a gotcha with the IR Link’s transmission buffer;  its start register is counted backwards from 0x4D. That means that if you have an 8 byte message to send, the first data byte starts at 0x4D-0x08 = 0x45. So if you want to transmit the above sequence, you’ll have setup the IR Link’s buffer such that it looks like this:

Reg 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F
Data 0xCC 0x76 0x66 0xFF 0xCC 0x00 0xAB 0xAA 0x08 0x00 0x01

0x4D is the number of bytes to be transmitted
0x4E is the transmission mode
0X4F is the transmission trigger
You will nee to skip the transmission trigger (0x4F) if all you want to do is preload the transmission buffers. 

Please note that there is no way for the IR Link to know if transmission was successful.  An easy way to check if your IR Link is sending *any* IR signals is to point it at a digital camera and look through the viewfinder.  The IR light should appear as a dot the small screen on the front of the sensor.  Most digital cameras are extremely sensitive to IR light.  This is also a good way to check if your TV remote is still working!

I’ve included two NXC programs, one which transmits the same message over and over again as fast as possible, the other sends a single message every 50ms.

IR Beacon: [LINK] Generates 1200Hz IR signal, can be used with IR Seeker V2
IR Messenger: [LINK]

The functionality to send messages via IR will be included in the next release of the 3rd Party RobotC Driver Suite, so I didn’t include any here.

About Xander

Xander Soldaat is a Software Engineer and former Infrastructure Architect. He loves building and programming robots. He recently had the opportunity to turn his robotics hobby into his profession and has started working for Robomatter, the makers of ROBOTC and Robot Virtual Words.