circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

Issue 138 January 2002
An RF-Controlled Irrigation System


by Brian Millier

Start Controller/Receiver Encoder/Decoder The Firmware Time's Up Sources & PDF

Encoder/decoder

To address these concerns, it made sense to use the inexpensive line of encoder/ decoder devices from Holtek (HT12D/E) rather than roll my own. These matching chips address the concerns, at least for applications that need only to transmit the status of a small number of switches.

There are a number of good reasons for choosing this device. The HT12E encoder chip consumes only about 0.1 µA in Standby mode, so it can be left permanently connected across the small transmitter battery. It comes in a small, 20-pin SOP and fits in a small transmitter case (the same could be said for the Atmel ATiny and smaller PIC processors). To reduce parts count and cost, it uses a single resistor to set its internal RC clock. RC clocks are not known for their frequency stability; the design of this encoder/ decoder pair allows the receiver to be able to lock onto the transmitter’s data clock frequency even though it may vary considerably over time or temperature. Refer to Figure 2 for the schematic of the transmitter module.

  Figure 2—There isn’t too much to the schematic diagram of the keyfob transmitter. However, getting it to fit into the small keyfob was another matter!

Both the encoder and decoder sample eight lines (A0 through A7), which act as device address inputs. That is to say, a given encoder/decoder pair can be set to operate at one of 256 discrete addresses. This strategy, for example, prevents your neighbor’s remote control from operating your garage door opener.

Addressing can be done with a dip switch, jumpers, or by cutting traces on a PCB. Modern encoder/decoder chipsets used in remote car starters use, by necessity, a much more complex addressing scheme because there’s a much greater chance of false triggering by other, unintended transmitters in the vicinity. Obviously, this leads to worse repercussions.

The data packet sent by the HT12E consists of the 8-bit address followed by a 4-bit data field corresponding to the state of up to four switches connected to inputs D8–D11. The datasheets for the HT12D/E devices don’t mention a preamble being sent before the data, nor do they mention a checksum nor CRC bytes for data checking. [3, 4]

In place of this, the data packet is transmitted three times for each switch closure and then checked for equality by the receiver. Holding the switch down for any more than an instant, will result in the repetition of the datastream. Presumably this is how the lack of a preamble is handled—the receiver likely misses out on the first occurrence of the data packet, but catches subsequent ones.

The Abacom AT-MT1 transmitter has a maximum data transmission rate of 2400 bps. There-fore, I set the encoder’s oscillator of the HT12E to 2 kHz by using a 1.5-MW resistor across OSC1 and OSC2. [4]

The AT-MT1 transmitter is a two-wire device. It is not modulated per se; instead it is powered up and down in step with the datastream. The SAW oscillator used in this module is able to turn on and off quickly—fast enough to handle the maximum data rate. The output of an encoder chip is supposed to directly power the AT-MT1, according to its datasheet. Although the data output pin of the HT12E is capable of sourcing up to 1.6 mA, the AT-MT1 requires up to 9 mA at 12 V to operate. So, in this case, I had to add a 2N3904 emitter follower to provide the necessary current boost.

I intended to use a Linx Splatch antenna, which is a small PCB containing a 418-MHz antenna and ground plane. Unfortunately, this small antenna radiated much less signal than a quarter-wave whip antenna and would not provide the range I wanted. However, it wasn’t too great a loss because I was having trouble fitting everything into the keyfob anyway. I ended up using a 6.25² piece of flexible wire as an antenna, which just hangs out of the keyfob case and doesn’t mind being stuffed into my pocket.

Photo 2 is a close-up of the transmitter PCB, which has to fit in the case and line up with the switch cutouts. I included the PCB layout in PDF format along with the firmware files, because the design of the transmitter PCB is tedious.

Photo 2—The PCB that I fabricated for the transmitter sits below the keyfob case. You can see a bit of the thin black wire, which forms the antenna, connected to the tiny transmitter module.

Choosing a battery for the transmitter wasn’t difficult. There seems to be only two choices in small batteries: 3.6-V coin cells and the 12-V alkaline batteries used in many remote car starters. The HT12E encoder would have worked fine at 3.6 V, but the output power of the transmitter module would have been low. Thus, I chose the 12-V batteries.