USB IR Toy: IRIO raw receive/transmit mode
IRIO is a raw infrared input/output mode, it sends and receives raw IR waveforms. This mode can clone remote controls, and playback the signals to operate devices from a computer.
Click for full screenshot. In the screenshot we're running two IR toys on the same PC. One is in IRIO mode (left) the other is in RC5 decoder mode. First, we pressed #1 on a remote. The left screen shows the raw 10khz waveform samples (black text). The right screen shows the RC5 decoded output. We copied the waveform bitmap from the terminal and sent it back to the IR toy to transmit (pink text). The second IR toy received and decoded the signal just like it came from the original remote control.
IRIO mode is always in the receive state, except during transmission. Any activity on the IR receiver triggers sampling at 10kHz.
7F C0 1F E0 0F F8 07 FC 03 FE 01 FF 00 FF FF 80 3F E0 00 1F FF F8 07 FC 03 FE 01 FF 00 00 00 00 00
Each bit represents a sample of the IR signal state taken every 100us (10kHz), most significant bit first. Sampling stops after 40 consecutive samples (5 bytes) with no change on the IR receiver pin. The LED will light each time a sampling period starts, and turn off when it ends.
If there's ever so many samples that the IR Toy can't push data to the PC fast enough, the LED will stop blinking but data will continue. This is known as a buffer overflow. We haven't encountered it 10kHz, but it's a concern at higher sampling rates.
The IRIO mode exits the receive state and begins transmitting when it receives a data bitmap. Data bitmaps represent the IR waveform to reproduce in 100us (10kHz) segments.
Data bitmaps are single byte values that carry 7 'frames' of an IR transmission. The most significant bit of the byte is set to 1 to indicate a transmission bitmap. The remaining 7 bits toggle the modulated IR LED on (1) or off (0) for 1 time period. The default time period is 100us (10kHz).
The indicator LED will light while the transmitter is active. The IRIO mode returns to receive state when there's no data left to transmit.
Reset 0×00 (returns to remote decoder mode) Setup sample timer 0×01 (send 2 bytes) Setup TX modulation 0×02 (send 2 bytes) 8bit TX enable 0×03
Commands available from IRIO mode
Send 'X' to put the IR Toy in raw infrared input/output mode. The IR Toy will respond 'X01', where 01 is the protocol version. Once in IRIO mode, use the commands to send and receive raw infrared signals.
0x00 returns the IR Toy to remote control decoder mode. This command is consistent across all modes (IRIO, SUMP), you can always send 0x00 to exit to remote control decoder mode.
Setup sample timer
IRIO mode starts with a 10kHz sample and playback timer. This can be changed by sending the the setup timer command, followed by two bytes that set the timer 1 offset. The first byte is the high 8bits, the second byte is the low 8bits. Use a PIC timer calculator to find the values (key calculation constants: timer 1, 1:1 prescaler, 48MHz fosc, 12MHz fcyc). See an example.
Setup TX modulation
The default infrared transmitter is modulated at 36kHz with a 50% duty cycle. This can be changed by sending the setup PWM command, a byte for the PR2 period register, and a don't care byte. The duty cycle is always 50%. Use a PIC timer calculator (update: our favorite online PWM calculator) to find the value (key calculation constants: timer 2/PR2, 48MHz fosc, 12MHz fcyc, 4x prescaler). See an example.
8bit TX enable
Send this command to enable 8bit transmit mode. The IR Toy transmits all 8bits of every byte it receives, instead of the 7bits described above. This mode works with the same 8bit values that the IRIO mode outputs when it receives a signal. It allows more data using fewer bytes, but there's no exit command. You'll have to unplug the IR Toy from the USB port to get out of raw mode.