Wireless infrared data transmission from the PIC18F4620

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:

  1. Vcc, connected to 5V.
  2. GND, connected to 0V.
  3. 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.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Wireless infrared data transmission from the PIC18F4620

  1. gerriney says:

    Hi Ted,
    I have tried doing something to this myself using the arduino, controlling IR devices etc., quick question, what range are you getting from the particular IR LED you are using? I cant seem to get much out of mine, about 2 feet or so, I know it’s wavelength is 990nm, so I would be curious to know the wavelength of yours and the range if possible. Thanks!

    • batchloaf says:

      Hi Ger,
      Dave and I were experimenting with this set up on Friday and we were able to transmit fairly reliably over 2 or 3 metres without difficulty. However, last year I was experimenting with basically this same emitter circuit and receiver configuration and achieving distances of 8 metres or more. As a general rule, you should expect to get at least “TV remote control” type distances if things are set up right.

      In my experience, there are a few critical factors:

      1. These kind of IR receivers tend to be surprisingly frequency selective, so for example if it says it detects 36kHz IR, I really really try to get the microcontroller modulating its IR output signal at 36kHz. Even being a little bit off (e.g. 35kHz or 37kHz) seems to be enough to significantly impair the response of many receivers.
      2. You need to look out for the directionality of the IR LED and the receiver. If you get a very directional LED (which you can check either by reading the datasheet or just by looking at it with your camera phone) then it will probably allow you to transmit over a long distance, but you’ll need to line it up carefully. By contrast, an LED with a wide dispersion pattern won’t need to be lined up carefully, but will spread its energy widely so you probably won’t achieve as long distances.
      3. The IR LED current is very important because it determines the amount of light emitted, which affects the maximum achievable distance. Some TV remote controls drive their LEDs at relatively high current levels – between 50 and 100mA wouldn’t be unusual. They are only driven at this current for a short time (when a button is pressed), but it means they get good light intensity and therefore distance. Also, some LEDs have higher energy efficiency than others, which means you get more light for the same amount of current.
      4. I suppose IR wavelength must be important, but relative to the above factors, my guess (and it’s only a guess!) is that it’s by no means the most important factor. I’ve yet to find an IR emitter and receiver that didn’t work together due to wavelength differences.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s