For low-speed local data transfer, it’s tough to beat the simplicity of an IR link, which is so common in TV remote controls. This circuit idea combines a transmitter/receiver pair with low-cost microcontroller to provide smooth control of a model train over 50- to 75-ft. range (see Fig. 1 and Fig. 2).
The transmitter is a Holtek IC, the HT12A. It features a typical idle current of 0.1 mA, so no power switch is necessary. It has eight pins (1-8) to apply a pass code, similar to a garage door opener; all eight pins are left floating in this design. The IC also can run on a 3 V supply with only one IR LED, incurring a 30% loss in operating range. In 3-V operation, make sure the FET driver can trigger at 3 V.
The receiver is an IR Control Receiver Module, internally timed for 40-kHz carrier. Its output is a digital low when a valid signal is received, which is then inverted by Q1. The decoder chip is the Holtek HT12D. It has eight pins (1-8) to detect the proper pass code, which also are left floating. The decoder’s output is an active high on pin 17 while receiving a valid decoded pulse train (i.e., sync plus the proper 8-bit code three times in a row). To control multiple trains, use a unique code for each transmitter/receiver pair.
The HC705 microcontroller controls a pulse-widthmodulated H-drive to control the train motor bidirectionally. Upon HC705 reset, the motor output is zero. When an UP command is received, the duty cycle immediately jumps to 15% (to overcome motor friction, etc). As the UP button is held down, the duty cycle slowly increases to 100%. This takes about eight seconds, which simulates a slowly accelerating train.
When the UP button is released, the duty cycle holds at its current value, allowing the train to stay at the selected speed. Similarly, when the DOWN button is held down, the train slowly decreases the duty cycle, slowing to 15%, then to off. This simulates a slowly stopping train. Pressing the DELTA button (even momentarily) while the train is moving activates a panic stop command (moving the duty cycle to 0% in about one second). This isn’t how a real train stops, but provides a panic stop function if the user wants it. Pressing the DELTA control while the train is at rest changes( the train’s direction. Pressing the WHISTLE command raises HC705 pin A6, allowing the user to control a commercially available train-mounted sound module if desired.
The software provides two jumper-selected control options. Jumpering A4 high will program a faster (four second) accelerate/decelerate time into the train movement, simulating a commuter train. The default setting will more accurately simulate a freight train. Jumpering A5 high will allow the train to stop immediately, upon receipt of a stop command (pressing DELTA while the train is moving).
The power to the unit comes from the track. It is full-wave rectified, and filtered via C6. VCC is provided by a low-dropout three-terminal regulator. Its input is buffered and filtered by C5. The reset line to the HC705 has a long (one second) time constant, determined by R4 and C3. The rather high values of C3, C5, and C6 in this design were chosen by experience from actual practice.
Model railroad tracks often have areas of corrosion, which momentarily stop power to the motor and the HC705. These rather large value capacitors allow smooth operation over questionable track. The power could be supplied by on-board batteries, at the user’s discretion. CR4, C7, and C8 are added to keep motor noise from affecting the HC705.
This design is adapted from the controller built to control multiple trains on an in-plant G-gauge model railroad. This model was used to demonstrate the railroad signal and communications products produced by our company. Note: The Holtek chips and the IR Control Receiver Module are available from Digikey, part numbers: HT12A-ND, HT-12D-ND, and LT 1060-ND, respectively.
Ed: The program listing for this design idea can be found on our web site at www.elecdesign.com. Click on the “Ideas For Design” icon.