RC5 and RC6 theory pages, i plan to make a large scale project related with IR decoding and transmission protocols. Obviously, i must first make some test circuits to prove that some ideas that i have really work, and to write the necessary assembly libraries for the PIC microcontrollers.
To follow this circuit, you need to have some basic and advanced knowledge regarding the Philips RC5 protocol. Visit the references page of this article to find the necessary theory pages.
The single LED decoder-transmitter idea
short range IR Beam cut detector receiver. The IR LED is reversed biased (cathode to +V). When IR pulses fall on the LED, a voltage appears across the series resistor R1.
I will use this technique for this circuit again, but this time i will use a high brightness narrow beam IR LED. At this point, i must give credits once more to Alan Parekh from Hacked Gadgets for providing me some wonderful LEDs and IR transistors for my projects. You can find the same LEDs in his online store.
Since i will be using a PIC microcontroller, it will be very easy to change the LED bias on the fly - by connecting the LED leads on 2 I/O ports, i can bias it forward or reversed simply by changing the port output (HIGH-LOW). Having the anode HIGH and the cathode LOW, the LED is forward biased for transmitting pulses. On the other hand, having the anode LOW and the cathode HIGH, the LED is reverse-biased to receive pulses.
Here is the circuit schematic:
The interesting part is how the LED is connected to the PIC. R5 is a large 33K resistor. This resistor is used to generate the appropriate voltage drop across its leads when the LED is reverse-biased to read the incoming pulses from the remote controller. To receive the pulses, output RD3 is driven HIGH and output RD2 is driven LOW - thus reverse biasing the LED. R6 (100 Ohms) is relatively small compared to R5 so it takes no part during the reception cycle. When IR pulses reach the LED's PN contact, a small current goes through the LED and through R5. This small current is enough to generate some 3 V voltage drop across R5. These pulses are then driven to the inputs RB5 and RA4 which are programmed as inputs with a very high impedance.
RB5 is used to trigger the Timer 1 Gate of the PIC, and RA4 is used to count the pulses with the Timer 0 module of the PIC. Both modules are needed to fully decode the received signal down to its carrier frequency signal. It is obvious that the LED output during signal reception will generate the IR carrier frequency pulses. So, a sophisticated software is needed to read these pulses, extract the pulses and decode the bits. I've tried to document the assembly listing as detailed as possible, yet following the software might be an unpleasant situation for beginners.
Now let's see how the same circuit can transmit pulses. To transmit pulses, RA4 is programmed as an output and driven HIGH. The port RB5 is not used so it maintains as an input with high impedance. The output RD2 has no big effect due to the high resistor R5 which allows max 3.3/33000=100uA of current to go through. Bringing the output RD3 LOW, the LED turns on through the limiting resistor R6. The max current through the LED set by the small resistor R6 which provides the proper voltage drop so that we do not exceed the 25mA which a PIC port can handle. Bringing this output HIGH turns the LED off. This is how the pulses can be transmitted.
The Circuit Operation
Just approach the remote control close to the circuit's LED and press a button. The PIC will read, decode, save and display the signal data
So, here is how the circuit works: First, the circuit has to read one command from a remote protocol which uses the RC5 protocol. To do so, we approach the RC LED close to the circuit's IR LED (max distance 8mm) and we press a button to transmit the code. The PIC reads and decodes the received pulses to extract the toggle bit, the address and the code bits. These data are then shown on the 20x4 LCD display. Moreover, the PIC stores the received byte and the signal characteristics into the EEPROM memory in order to reproduce it later:
Then press the button to transmit the saved data with the same signal characteristics (carrier frequency, bit length etc)
EEPROM Offset 0x20: Received Byte (High)
EEPROM Offset 0x21: Received Byte (LOW)
EEPROM Offset 0x22: Bit Length - This number shows how many carrier signal pulses exist during a HIGH bit period
EEPROM Offset 0x23: Frequency - This byte holds the number of Fosc/4 pulses during one eights (1/8) of a carrier signal pulse
EEPROM Offset 0x24: BitPeriod - This byte holds the number of Fosc/4/64 pulses (precscaller 1:64) during a complete signal bit period. This number is not used during transmission instead is used during the reception. As a matter of fact, this number is used to reproduce the transmitter's clock according to the starting bit (as explained in the RC5 theory)
When a command is saved, the circuit can immediately reproduce it simply by pressing the push button. As long as this button is pressed, the circuit sends the saved data with approximately 90mSec interval. The circuit emulate also the toggle bit in order to operate normally. Thus, if the button is released and pressed back again, the same data will be sent again but the toggle bit will be inverted. Note that for the toggle bit the circuit does NOT use the data received during the teaching time (signal reception). The toggle bit during transmission is totally irrelevant to the data previously read.
This is actually everything that this circuit can do. Please do not ask for a more complex version with more buttons and such, because this is only a proof of concept for the single LED transceiver idea. A next circuit version will follow shortly with a programmable constant current driver to drive the LED with much higher current for longer transmission distance. With this setup i managed to effectively control my TV from about 4 meters away.
Bill Of Materials
The PIC Software
Here is the first version of the PIC software (assembly listing and HEX file):
Continue reading. Click here to view the references.