Theory of Operation
Before the IR Tibbit can begin normal operation it must be properly reset and initialized.
Once initialized, the Tibbit is controlled through a number of registers. Registers are accessed through the SPI interface using SPI read and write transactions.
This Tibbit supports two commands, which are issued through the command register: receive (record) IR data, and transmit (reproduce) IR data.
The Tibbit looks at IR data as a sequence of "IR light ON" and "IR light OFF" times. No intelligent data analysis is performed. When recording an incoming IR signal, Tibbit #26 simply measures ON and OFF times and outputs the data as an array of measured ON and OFF lengths. Measured lengths represent demodulated IR signal, i.e. the signal without the carrier frequency. ON and OFF time lengths are expressed as the number of clock periods of the modulation frequency.
Modulated and unmodulated incoming IR streams
The IR Tibbit can work with IR receivers that output IR data intact, including the modulation frequency. The Tibbit also works with receivers that filter the carrier out. Option bit 4 in the command register determines what kind of incoming IR stream is expected.
If the Tibbit is set to record a modulated incoming IR stream, then it will demodulate the incoming signal. The modulation frequency will be filtered out, measured (with averaging), and the corresponding divider value will be stored into the carrier divider registers. The relationship between the divider value and the modulation frequency is as follows:
Modulation_frq = 12Mhz / divider_value
If the Tibbit is set to record a demodulated incoming RX stream then it will be expecting to work with data that doesn't contain the carrier frequency. In this case, your program must preset the carrier divider registers with the value corresponding to the expected modulation frequency before starting the recording.
In both cases, ON and OFF period lengths in the information-bearing (demodulated) signal are measured in periods of the carrier frequency and the resulting data is stored into the RX data buffer. The length of the recorded data (in bytes) can be obtained from the RX length registers.
After the Tibbit receives the command to record the data, it starts waiting for the first "IR light ON" state. The end of data is detected using a timeout method. After the recording ends, bit 0 of the status register is set to 1. Therefore, your program can poll this bit to determine when the data is ready (and if anything was received at all).
IR receivers vary in how they output "IR light ON" (detected) and "IR light OFF" (not detected) states. Many receivers output HIGH when the IR light is OFF, and LOW when it is ON. We refer to such output lines as "normal". Some receivers are doing this in reverse, meaning that LOW corresponds to the absence of the IR light, and HIGH corresponds to the presence of the IR light. We refer to such output lines as "inverted". Option bit 2 of the command register allows you to set the type of the attached IR receiver.
When storing the recorded IR signal, remember to preserve not only the data from the RX buffer (in the length determined by the RX length registers), but also the divider value from the carrier divider registers.
Outgoing IR streams
Your program shall prepare the data for the output IR stream in the TX data buffer. The format of data is the same wit the RX data buffer. Note that RX and TX buffers are physically separate so if you want to immediately play back the signal you've just recorded you still need to copy the data from the RX buffer into the TX buffer.
Prior to sending the "start transmitting data" command your program must preset the carrier divider registers. As explained above, the information about the modulation frequency should be stored along with the IR data itself.
IR emitters vary in the polarity of their control signal. Many emitters turn their IR LED on when the control line is LOW. We refer to such control lines as "normal". Some emitters turn their IR LED on when the control line is HIGH. We call this an inverted control line. Option bit 3 of the command register allows you to set the type of the attached IR emitter.