Infrared Remote Control

Infrared remote control is considered a bit quaint these days – radio frequency modules are now readily available that offer long range, easy interfacing, and low cost. Why create an IR system, then? Apart from having a very particular application in mind (more on this in the coming months), it was a good intellectual exercise that gave me some experience with the interrupt and timer features of the PICMicro microcontrollers.

Principle

At its most basic level, infrared (IR) remote control works by a transmitter emitting pulse infrared light that is then detected by a receiver. The frequency the IR is pulsed at is called the carrier frequency, and is usually between 30KHz and 56KHz (38KHz is very common). Most systems work by sending data that is encoded into the spaces between short bursts of the pulsed IR light. These short bursts are known as marks.

IR Marks and Spaces
Protocol

The protocol I’ve devised is much like many of protocols used in remote controls.

First, 2 ‘leader’ spaces of 932µs are sent to denote the start of a valid signal. The bits are then sent (starting with the least significant bit (LSB)) as 8 spaces; a 0 represented by as 580µs space, and a 1 represented by a 756µs space. A compliment of the byte is then sent for error detection.

IR Encoding Scheme
Hardware

Transmitting IR is simply a case of modulating the output of an IR LED. For short ranges the LED can be driven directly from a microcontroller, for longer ranges the LED can be driven with higher current via a transistor.

To receive the IR signal the receiver has to be able to detect the pulsing of the light at its carrier frequency. Fortunately, there are easy to use modules to achieve this. I’ve been using the Vishay TSOP1840 module; a 3 pin device that pulls an output pin low whenever IR at the carrier frequency is detected (the TSOP1840 is quite old, and has undoubtedly been superseded by newer devices). The TSOP1840 is optimised to detect a 40KHz carrier, but it will detect a 38KHz carrier albeit with reduced sensitivity.

Reference Implementation

The reference implementation for both receiving and transmitting uses a PIC16F628A microcontroller coded in assembler. Pinouts, circuits and links to code below:

Transmitter Reference Implementation
IR Transmitter Test Circuit
IR Transmitter Test Circuit
Receiver Reference Implementation
IR Receiver Test Circuit
IR Receiver Test Circuit

Source code on Github (GNU GPLv3 Licence).

This implementation is a Reference Implementation, which means exactly that – it’s not supposed to be deployed as-is, but to be the basis of a more featured system. I have, for example, modified the transmitter implementation to read the keyboard matrix of an old Atari Jaguar controller which I can now use a generic controller for future projects.

R/C Camera Truck

This project was all kinds of wrong; over engineered and built on untested assumptions. It subsequently took stupidly longer that it ought to.

The plan was to finally do something with the R/C truck that my nephew let me have after a clear-out and the wireless camera I bought off eBay many years ago “because it was cool”. This is the circuit I cam up with:

The 100R resistors connected in parallel (resulting in a combined 33R resistance) together with the 2200uF capacitor would filter out power noise from the battery (the battery also powers the truck’s drive motor and servo) before it got to the (rather excellent) Pololu 9V Step-up/down voltage regulator that would provide power to the camera/transmitter unit. The LEDs being driven through the four resistors would provide light so the operator could see where they were driving when it was dark. So far, so reasonable.

Well, rather than doing some experiments and testing the my assumptions I just started to build. Bad idea.

For a start, I discovered that the 100R resistors limited the current enough that when the camera was powered there wasn’t enough current the light the LEDs. I solved this by removing the resistors from the circuit by bypassing them with a patch wire – problem solved; the camera and lights could both operate together.

Secondly, when testing the truck in the dark it became apparent that while the now working headlights looked very cool, they didn’t really provide any meaningful amount of illumination!

Mostly unnecessary
Mostly unnecessary

It turns out that the following circuit was really the one I should’ve built (but not before testing it, obviously!):

Simple is efficient
Simple is efficient

Not only is the circuit simpler, but rather than having to construct a board and drill-out/mount a box, I could’ve just soldered everything together, wrapped it all in insulation tape and fixed it to the truck with cable-ties: Job done.

Always remember: “If you haven’t tested it, it doesn’t work

Completed Truck
Completed Truck

I’d hoped to embed a video of the view from the truck driving, but just as I’d finally go the thing working the receiver decided to go kaput. I’ve got another one on the way from China, so I hopefully I’ll be able to do that soon.