In my previous post, I described how to set up a serial data link between the PIC18F4620 and the PC using the PICkit2. In this post, I’ll describe a simple modification to that set up which facilitates wireless data transmission using an infrared (IR) LED and receiver.
The modified circuit is shown below. Here, the PIC acts as the transmitter and the PICkit2 acts as the receiver.
Just as in the previous post, any text printed by the program running on the PIC (for example using the printf function) can be displayed on the PC’s screen using the PICkit 2 application.
The IR receiver used in this example is the GP1UX31QS (manufactured by SHARP and available from radionics.ie for about 48 cent). This is the type of component that is used in most television sets to receive IR signals from a remote control. This component has three pins:
- Vcc, connected to 5V.
- GND, connected to 0V.
- Vout, which outputs the received data signal.
This device is precisely tuned to only respond to IR light that is modulated at 36kHz (i.e. that is turning on and off 36,000 times a second). It does not respond to IR light that isn’t modulated in this way (which includes most background IR). The output voltage (Vout) is normally high, but drops low whenever 36kHz IR is detected.
The key to the operation of the PIC transmitter is that CCP1 (pin 17) has been configured to generate a square wave at a frequency very close to 36kHz. Current only flows through the IR LED when CCP1 is high and TX (pin 25) is low. Whenever TX is low, the IR LED pulses at 36kHz. When TX is high, the LED either has no voltage across it or is reverse biased, so no light is emitted. The net effect is that the sequence of bits (represented by voltage highs and lows) outputted from TX are transformed into bursts of 36kHz IR light. When a burst of 36kHz IR reaches the receiver attached to the PICkit 2, its output voltage drops low. When no 36kHz IR is detected, the output of the receiver rests high.
So, to summarise,
- TX high results is no 36kHz IR and Vout remaining high at the receiver.
- TX low results in IR pulses at 36kHz, sending Vout low at the receiver.
Hopefully the following diagram will help to explain this more clearly.