Silicon ChipRemote Control For A Model Train Layout - July 2004 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Standby power is a large hidden cost
  4. Feature: Silencing A Noisy PC by Ross Tester
  5. Project: Versatile Micropower Battery Protector by Peter Smith
  6. Project: Appliance Energy Meter, Pt.1 by John Clarke
  7. Project: A Poor Man’s Q Meter by Maurie Findlay
  8. Feature: Restoring Old Dials, Front Panels & Labels by Kevin Poulter
  9. Project: Regulated High-Voltage Supply For Valve Amplifiers by Leonid Lerner
  10. Project: Remote Control For A Model Train Layout by Greg Hunter
  11. Review: The BeeProg Universal Programmer by Peter Smith
  12. Vintage Radio: Meet a designer of the legendary WS122 transceiver by Rodney Champness
  13. Book Store
  14. Back Issues
  15. Advertising Index
  16. Outer Back Cover

This is only a preview of the July 2004 issue of Silicon Chip.

You can view 37 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "Versatile Micropower Battery Protector":
  • Micropower Battery Protector PCB pattern (PDF download) [11107041] (Free)
Items relevant to "Appliance Energy Meter, Pt.1":
  • PIC16F628A-I/P programmed for the Appliance Energy Meter [wattmetr.hex] (Programmed Microcontroller, AUD $10.00)
  • PIC16F628A firmware and source code for the Appliance Energy Meter [wattmetr.hex] (Software, Free)
  • Appliance Energy Meter PCB patterns (PDF download) [04107041/2] (Free)
  • Appliance Energy Meter front panel artwork (PDF download) (Free)
Articles in this series:
  • Appliance Energy Meter, Pt.1 (July 2004)
  • Appliance Energy Meter, Pt.1 (July 2004)
  • Appliance Energy Meter, Pt.2 (August 2004)
  • Appliance Energy Meter, Pt.2 (August 2004)
Items relevant to "Remote Control For A Model Train Layout":
  • PICAXE-08 BASIC source code for the DIY Model Train Remote Control (Software, Free)

Purchase a printed copy of this issue for $10.00.

D-I-Y remote control for a model train layout With the aid of a pair of UHF receiver & transmitter modules, this simple circuit provides direction, acceleration and braking controls for a model train layout. It could be used for a garden railway or with HO and N layouts as a “walkround” throttle. By GREG HUNTER PICAXE LISTING '----------------------------------------------------------'Train motor controller for use with Picaxe 08 micro and 'Oatley TX7 & RX7 UHF remote control modules. '23/2/04 '----------------------------------------------------------'assumes 4 outputs from R/C (active high inputs to picaxe) 'Accelerate - pin 2 'Brake - pin 3 (input only) 'Forward - pin 4 'Reverse - no pin '2 outputs from picaxe 'Motor - pin 0 (output only) 'Reverse relay - pin 1 (is also the analog capable pin) '----------------------------------------------------------symbol motor=0 symbol relay=1 'motor is pin 0 'reversing relay on pin 1 symbol rawspeed=b0 symbol MARK=b1 ' symbol Space=b2 symbol k=b3 symbol Period=16 symbol Numloops=8 'value 0 to 255 (max speed) 'MARK is motor on time '0 to period = rawspeed*Period/256 'SPACE is Period-MARK 'loop counter 'ms of motor control period MARK+SPACE=Period 'loops before reading inputs 'ACCTC=10s time to go from 0 to full in sec 'BRTC=5s time to stop from full speed in sec '(10s) '=255*Numloops*Period/ACCTC/1000 '(5s) '=255*Numloops-Period/BRTC/1000 'define when reached max speed... symbol ACCstep=4 symbol BRstep=6 symbol Maxspeed=224 '----------------------------------------------------------'read input buttons, do direction first. continued on page 86 84  Silicon Chip T HE BASIC SPECIFICATIONS of this circuit are as follows: (1) The transmitter has four buttons, labelled A, B, C & D. Pressing and holding “A” (accelerate) will slowly increase the track voltage. If held for about 8s, the voltage will reach the maximum. If “A” is released at any time before the maximum voltage is reached, that level will remain indefinitely. (2) Pressing and holding “B” (brake) for about 6s will reduce the voltage to zero. Again, if “B” is released at any time, the voltage will remain at that level indefinitely. (3) As the voltage reduces to less than 1/8th of maximum, the control becomes “finer”. As a result, “B” must be held for another 2s to reduce the voltage by the last 1/8th. This allows better shunting control. (4) Pressing button “C” for about 0.5s will select one direction of travel. Pressing “D” for 0.5s will select the other direction. These will work only if the speed is less than 1/8th of maximum. (5) If “C” or “D” are pressed when the voltage is greater than 1/8th maximum, this will result in an “emergency brake” application. This results in the output voltage being reduced from maximum to zero in 1s. The unit can be inserted between the existing train controller and the track to provide “walkround” control. If necessary, it could also be powered from a separate transformer. Pulse-width modulation Essentially, speed control is achieved by pulse-width modulating the motor drive voltage via a MOSFET switch (Q2). To control motor direction, the polarity of the applied siliconchip.com.au Fig.1: the circuit uses a standard UHF radio link to apply command signals to a Picaxe-08 microcontroller (IC1). IC1 provides PWM signals to MOSFET Q1 to control motor speed and switches relay RLY1 to control the motor direction. voltage is switchable with a DPDT relay (RLY1). Both of these functions are managed by a Picaxe-08 microcontroller, which receives its commands from the 4-button remote control over the UHF radio link. In more detail, the circuit receives input power via a 6A bridge rectifier (BR1). A 12V, 100W halogen lamp is included in series with the supply to limit short-circuit current, so protecting the MOSFET switch. A 470µF capacitor provides some filtering of the supply before it is applied to the motor circuit. Supply filtering Filtering of the motor supply was found necessary because without it, hunting was apparent. The capacitor value may need to be increased for large loads but note that this will siliconchip.com.au Silicon Chip Binders REAL VALUE A T $12.95 PLUS P& P H SILICON CHIP logo printed in goldcoloured lettering on spine & cover H Buy five and get them postage free! Available only in Australia. Buy five & get them postage free! Just fill in the handy order form in this issue; or fax (02) 9979 6503; or ring (02) 9979 5644 & quote your credit card number. Silicon Chip Publications, PO Box 139, Collaroy 2097 July 2004  85 PICAXE LISTING – continued from page 84 buttons: if rawspeed>16 and pin4=1 then Emergency if rawspeed>30 then accel if pin4=1 and pin3=0 then forwarder if pin4=1 and pin3=1 then reverser goto accel 'trying to reverse at speed=STOP! 'if moving, don’t look at reversing! 'forward Tx button pressed 'reverse Rx button pressed 'no call for direction change Emergency: PAUSE 10 if pin4=0 then buttons rawspeed = rawspeed/2 goto control '10ms delay to ensure is not interference 'emergency brake if hit direction buttons 'will stop from max in 1/2 sec approx. forwarder: LOW relay goto accel 'de-energise rev relay Receiver outputs reverser: HIGH relay Pause 500 ' 'energise rev relay 'delay so that if pin4 released before pin3 'it doesn’t go back to Forward direction. '----------------------------------------------------------'now look at accel and brake buttons accel: if rawspeed>=MaxSpeed then chkBrakeButton if pin2=1 then speedup if rawspeed<16 then control ' goto chkBrakeButton 'already at top speed '0-15 means already stopped. '(Note: 16=256/Period) speedup: rawspeed = rawspeed+ACCstep goto control 'increase raw speed by step chosen. chkBrakeButton: if pin3<>1 then control if rawspeed<48 then reduceBr rawspeed = rawspeed-BRstep goto control 'brake button not pressed. 'reduce brake rate for last two speed steps 'decrease rawspeed by usual step reduceBr: rawspeed=rawspeed-2 'reduce brake rate as approach stop '----------------------------------------------------------'now send control pulse to motor control: if rawspeed<16 then buttons MARK = rawspeed/16 Space = period-MARK for k=1 to numloops High motor if rawspeed>=MaxSpeed then buttons pause MARK Low motor Pause Space next k 'stopped so don’t process motor 86  Silicon Chip The receiver has four outputs, corresponding to the four buttons on the transmitter (A-D) as described above. These outputs are normally low, going high when the matching transmitter button is pressed. Also included is a “VT” (valid transmission) output. This is used to drive LED1 on the circuit, which illuminates when ever a valid button press is received from the transmitter. With only five input/output pins available on the Picaxe-08, it was necessary to combine the “B”, “C’, & “D” inputs from the receiver into two lines using diodes D1-D4. The program code running in the Picaxe is then responsible for determining which of the three lines is active. The 433MHz UHF transmitter and receiver pair are available as pre-assembled modules from Oatley Electronics, part numbers TX7 and RX7 – see www.oatleye.com for more information. Be sure to set the address (code) links on both modules as per the supplied instructions. Program listing 'leave on all the time for max speed 'motor on pulse for MARK ms goto buttons increase the average voltage and may effect the resolution of the 16-step speed control system. Diode D5 feeds the DC input to a 5V regulator (REG1) which is used to power the remaining circuitry. Ad- the motor. The gate of the MOSFET is driven directly from the output of the Picaxe on leg 7 (internal pin 0). For large loads, a “logic-level” type FET should be substituted here to ensure that it’s switched fully on with only 5V at the gate. The reversing relay (RLY1) is a DPDT 12V/1A type with a 330Ω coil. It's driven from leg 6 (internal pin 1) via a 3.3kΩ resistor and 2N3054 transistor (Q1). The coil has a 270Ω resistor in series for higher voltage operation. This resistor can be omitted if the supply rail is less than about 14V. ditional bulk filtering is provided by 470µF and 1000µF capacitors on either side of the regulator. As mentioned above, motor speed is controlled by pulse-width modulating a MOSFET switch (Q2) in series with The complete program listing for the Picaxe is included with this article. Note that a 16ms period was chosen for the variable mark/space (PWM) drive to MOSFET Q2 to avoid motor cogging at low speeds, as well as to allow enough time for other tasks. The “rawspeed” variable holds the basic motor speed value. Note, however, that the “motor on” portion of the period is 1/16th of this, resulting in 16 possible motor speeds. The rates of acceleration and braking (labelled “ACCTC” & “BRTC”) determine how many of the basic counts (of 255) are added or subtracted each SC time a button is read. siliconchip.com.au