Silicon ChipReverse Loop Controller For DCC Model Railways - October 2012 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: The attractions of electric cars
  4. Feature: Electric Remotely Piloted Aircraft . . . With Wings by Bob Young
  5. Feature: HAARP: Researching The Ionosphere by Dr. David Maddison
  6. Project: LED Musicolour: Light Up Your Music, Pt.1 by Nicholas Vinen
  7. Project: Reverse Loop Controller For DCC Model Railways by Jeff Monegal
  8. Project: The Nick-Off Bad Cat Deterrent by Greg Swain and Nicholar Vinen
  9. Project: Colour MaxiMite Microcomputer, Pt.2 by Geoff Graham
  10. Project: Wireless Remote Control For The Barking Dog Blaster by Ross Tester
  11. Vintage Radio: The Philips twins: the Dutch BX462A & the Australian model 115 by Rodney Champness
  12. PartShop
  13. Order Form
  14. Book Store
  15. Market Centre
  16. Advertising Index
  17. Outer Back Cover

This is only a preview of the October 2012 issue of Silicon Chip.

You can view 21 of the 104 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.

Articles in this series:
  • Radio Control (November 1996)
  • Radio Control (November 1996)
  • Radio Control (February 1997)
  • Radio Control (February 1997)
  • Radio Control (March 1997)
  • Radio Control (March 1997)
  • Radio Control (May 1997)
  • Radio Control (May 1997)
  • Radio Control (June 1997)
  • Radio Control (June 1997)
  • Radio Control (July 1997)
  • Radio Control (July 1997)
  • Radio Control (November 1997)
  • Radio Control (November 1997)
  • Radio Control (December 1997)
  • Radio Control (December 1997)
  • Autopilots For Radio-Controlled Model Aircraft (April 1999)
  • Autopilots For Radio-Controlled Model Aircraft (April 1999)
  • Model Plane Flies The Atlantic (May 1999)
  • Model Plane Flies The Atlantic (May 1999)
  • Tiny, Tiny Spy Planes (July 1999)
  • Tiny, Tiny Spy Planes (July 1999)
  • 2.4GHz DSS Radio Control Systems (February 2009)
  • 2.4GHz DSS Radio Control Systems (February 2009)
  • Unmanned Aerial Vehicles: An Australian Perspective (June 2010)
  • Unmanned Aerial Vehicles: An Australian Perspective (June 2010)
  • RPAs: Designing, Building & Using Them For Business (August 2012)
  • Flying The Parrot AR Drone 2 Quadcopter (August 2012)
  • Multi-Rotor Helicopters (August 2012)
  • Multi-Rotor Helicopters (August 2012)
  • Flying The Parrot AR Drone 2 Quadcopter (August 2012)
  • RPAs: Designing, Building & Using Them For Business (August 2012)
  • Electric Remotely Piloted Aircraft . . . With Wings (October 2012)
  • Electric Remotely Piloted Aircraft . . . With Wings (October 2012)
Items relevant to "LED Musicolour: Light Up Your Music, Pt.1":
  • LED Musicolour PCB [16110121] (AUD $25.00)
  • dsPIC33FJ128GP802-I/SP programmed for the LED Musicolour [1611012A.HEX] (Programmed Microcontroller, AUD $25.00)
  • LED Musicolour front & rear panels [16110122/16110123] (PCB, AUD $20.00)
  • LED Musicolour Firmware (HEX/C - zipped) [1611012A.HEX] (Software, Free)
  • LED Musicolour PCB pattern (PDF download) [16110121] (Free)
  • LED Musicolour front & rear panel artwork (PDF download) [16110122/16110123] (Free)
Articles in this series:
  • LED Musicolour: Light Up Your Music, Pt.1 (October 2012)
  • LED Musicolour: Light Up Your Music, Pt.1 (October 2012)
  • LED Musicolour: Light Up Your Music, Pt.2 (November 2012)
  • LED Musicolour: Light Up Your Music, Pt.2 (November 2012)
Items relevant to "Reverse Loop Controller For DCC Model Railways":
  • DCC Reverse Loop Controller PCB [09110121] (AUD $10.00)
  • PIC12F675-I/P programmed for the DCC Automatic Reverse Loop Controller [0911012A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC12F675-I/P programmed for the DCC Block Switch [0911012B.HEX] (Programmed Microcontroller, AUD $10.00)
  • Pair of ZXCT1009 Current Shunt Monitor ICs for DCC Reverse Loop Controller project (Component, AUD $10.00)
  • Firmware (HEX) files for the DCC Automatic Reverse Loop Controller [0911012A and 0911012B] (Software, Free)
  • DCC Reverse Loop Controller PCB pattern (PDF download) [09110121] (Free)
Items relevant to "The Nick-Off Bad Cat Deterrent":
  • Nick-Off! Proximity Alarm PCB [03110121] (AUD $5.00)
  • Nick-Off! Proximity Alarm PCB pattern (PDF download) [03110121] (Free)
  • Nick-Off! Proximity Alarm front panel artwork (PDF download) [03110122] (Free)
Items relevant to "Colour MaxiMite Microcomputer, Pt.2":
  • Colour Maximite PCB [07109121] (AUD $17.50)
  • Colour MaxiMite Firmware, Documentation and Demo software (Free)
Articles in this series:
  • Colour MaxiMite Microcomputer, Pt.1 (September 2012)
  • Colour MaxiMite Microcomputer, Pt.1 (September 2012)
  • Colour MaxiMite Microcomputer, Pt.2 (October 2012)
  • Colour MaxiMite Microcomputer, Pt.2 (October 2012)
Items relevant to "Wireless Remote Control For The Barking Dog Blaster":
  • ETD29 transformer components (AUD $15.00)
  • Barking Dog Blaster panel artwork (PDF download) (Free)
Articles in this series:
  • Barking Dog Blaster: Shut That Annoying Mutt Up! (September 2012)
  • Barking Dog Blaster: Shut That Annoying Mutt Up! (September 2012)
  • Wireless Remote Control For The Barking Dog Blaster (October 2012)
  • Wireless Remote Control For The Barking Dog Blaster (October 2012)

Purchase a printed copy of this issue for $10.00.

Another project for DCC Model Railway enthusiasts . . . Automatic reverse loop controller for DCC model railways A “real” reversing loop at one of the Gladstone (Qld) bulk coal loaders. (Aerial photo courtesy Nearmap.com). Many model railway layouts have reverse loops since they enable a whole train to travel back and forth along a length of single track and hence make operation more interesting. But reverse loops are a problem on DCC layouts as there is an inevitable short circuit as the loco crosses the points. This project solves that problem. I n the real world, reverse loops are used at the end of long section of track so that a complete train can change direction. They are used for large “block trains” which carry bulk loads like iron ore and coal. The train is unloaded at one end (usually without stopping) and then proceeds around the loop and goes back to be loaded again, perhaps hundreds of kilometres away at the mine. The photo above is a satellite view 38  Silicon Chip of a real-world loop at one of the coal loaders in Gladstone, on the central Queensland coast. In fact, there are reverse loops for several coal loaders in Queensland and they used at other bulk loaders around Australia, so they are not simply a feature enjoyed by the model railway fraternity. In the modelling world, a reverse By Jeff Monegal loop (or two) on a layout will allow a train to change direction without it having to be physically picked up and swapped around. But as noted above, the model reverse loop has a serious problem which does not affect realworld railways – shorts in the track. Note that while shorts in reverse loops are problem with all model railways, we should state at the outset that this project is only suitable for DCC layouts. For more information on DCC siliconchip.com.au can change the track polarity as the train traverses the loop. In effect, the loop is set to the same polarity as the track when the train enters the loop and then before it fully traverse it, the points need to be set the other way. However, polarity of the loop must stay the same while the train is traversing it, otherwise the locomotive would abruptly reverse direction, with dire consequences. This presents a problem of timing, in coordinating the switching of track polarity with pointing changeover. In DCC systems, the problem is slightly different because the direction of the locomotive and train is not affected by track polarity; it is controlled by the DCC data. However, the problem of the short circuit in the loop still remains, so the track polarity still has to be changed. Unfortunately, humans will not be quick enough to toggle the switch at the precise moment needed to prevent a short occurring. That is of course, even if we remember to toggle the switch as the train travels round the loop! That is where this project comes to the rescue. Instead of avoiding the occurrence of the short as the locomotive bridges the gaps in the tracks, it senses the inevitable short-circuit current and then switches the track polarity to avoid it. This then avoids the nasty situation when a momentary short in the loop is enough to shut down the entire DCC layout, as the base station or DCC It’s all built on one small PCB with just two connectors – in (from tracks) and out (to reverse loop). Note that this will NOT work with DC or PWM setups! operation have a look at the article in the February 2012 issue and the high power DCC booster project featured in the July 2012 issue. To repeat, this project will not work on model railway layouts which employ conventional (ie, variable DC or PWM) controllers. Fig.1a shows how a reverse loop works in a conventional layout. As you can see, a reverse loop has one set of points (in US parlance, switch or turnout) which is set one way to allow the train to enter the loop. It is then set the other way to allow the train to travel out of the loop, in the opposite direction along the single track with the loco still leading the train. However, if you follow the top (red) rail from point “A” all the way around the loop to point “B” you will see that there is a short circuit. The rail (red & black) colours in the diagram highlight this major problem on any model railway layout. So what can be done? One solution would be to cut the rails at two places inside the loop. These gaps are shown in Fig.1b. If we use a DPDT switch to connect power to the isolated section of the loop we RELAY ON CONTROLLER PCB “A” POINTS SWITCHED TO UPPER TRACK ISOLATING GAPS IN BOTH RAILS Fig.1a: this simple diagram of a reversing loop shows why we have a problem – with both standard and DCC layouts. The red and black lines represent the two rails – as you can see, regardless of which way the points are set (in this case the train is traversing the loop clockwise) there will always be a short circuit between two of the tracks (shown here with the green circle). In real life, this doesn’t matter – but for model railroaders, where the tracks supply the loco power, it is a serious problem! siliconchip.com.au “B” Fig.1b: and here’s the solution – a relay switches the polarity of the tracks at precisely the right moment so that the short is eliminated. This arrangement would not work for standard (DC) tracks (the train would go backwards) but is perfect for DCC layouts. A microcontroller takes care of the timing. October 2012  39 OUT 78L05 GND C B A 1 3 2 10k ZXCT1009 K D8 1N4004 A A K SC 2012 Fig.2: the controller takes some of the DCC signal from the rails and rectifies it to provide power fot the rest of the circuit. 0.15 ZXCT1009 D3 IC2 3 2 +Vs –Vs 1 Iout K A AUTO REVERSING LOOP DCC CONTROLLER 470 K LED2 A K VR1 1k CON1 DCC INPUT FROM MAIN TRACK A D1–D7: 1N4148 Vss 8  A D4 2 330 A K D7 K GP4 GP5 2 K LED1 4  1 OPTO1 4N28 5 10k K A D2 K D1 + BR1 – How does it work? 3 7 6 A 10F 100F Iout 1 3 2 0.15  470 4 GP3 1 Vdd IC3 GP2 GP1 PIC12F675 GP0 5 2.2F +5V 78L05 IN OUT REG1 GND +Vs –Vs IC1 ZXCT1009 1N4004 B 10k 10k 330 G OPTO2 2N28 A K 2 E C  1 Q1 BC548 5 4 A D6 D5 K A LEDS E E Q2 BC548 C B RELAY1 BC337 G D IN S CON2 DCC OUTPUT TO LOOP TRACKS D IRF1405 10k K G Q4 IRF1405 S D D S Q3 IRF1405 40  Silicon Chip booster current limit is exceeded. Our automatic reverse loop controller performs the above procedure automatically. The train and the operator is not even aware that the polarity has been changed. All anyone might notice is the train entering the loop using points (or turnout in US model railroad parlance), travelling round the loop then exiting the loop using the same set of points. In fact, the only indication that the track polarity was changed is that the on-board LEDs on the auto controller will toggle. All the operator has to do is to remember to change the points after the train has entered the loop. Even this task can be automated but that’s a story for another time. As with many circuits these days, this device is under the control of a small microcontroller, a PIC12F675. It constantly looks for the short circuit current that is caused whenever the locomotive’s drive wheels bridge the isolating gap in the rails. The track current is sensed by two Zetex ZXCT1009 high-side current monitors. These surface mounted devices each monitor the voltage across an associated 0.15Ω shunt resistor and convert this voltage to a current. We need to sense currents of either polarity and that is why two such sensors are required. The output currents of both sensors are fed via diodes D2 & D4, trimpot VR1 and a 330Ω resistor to the junction of diodes D1 & D3 and these four diodes act as a bridge rectifier for the sensor output currents. If a short circuit does occur, the resulting voltage across trimpot VR1 and the 330Ω resistor will be sufficient to turn on the infrared LED inside optocoupler OPTO1. This will pull the GP3 input, pin 4, of the PIC controller low. As soon as this happens, the micro switches off the DCC signal then toggles the relay so that the polarity to the loop is now reversed. A delay of 20 milliseconds allows the relay contacts to move before the DCC signal is switched back on. Hence the track polarity is reversed and the train has continued along on its merry way all in the space of 20ms; much quicker than we humans could do the job. siliconchip.com.au REG1 78L05 Q3 Q4 0.15 IC1 ZXCT1009 10k CON2 4148 4148 2.2F OPTO2 4N28 BR1 MWJ C D6 RELAY1 337 D8 4004 D7 470 10k 0.15 2km - LRA LED2 LED1 Q2 12101190 470 4148 10k IC3 PIC12F675 10k OPTO1 4N28 Q1 09110121 4148 D4 D5 VR1 1k 4148 D3 390 330 D2 4148 C 100F JWM CON1 D1 4148 10k 10F IC2 ZXCT1009 ARL - mk2 BC337 TOP OF BOARD UNDERSIDE OF BOARD (COPPER TRACK SIDE) Figs. 3 & 4 above show the component layout for both sides of the PCB. On the left is the conventional (ie above board) component layout, also shown in the photo at left. There are two SMD components soldered to the underside of the board (right); also shown in the partial board photo at right. Sensing a real short-circuit But what if there is a short-circuit which was not caused by a locomotive crossing the gaps but in fact a genuine short-circuit, maybe because of a metal object dropped across the track? Then as soon as the program switches the DCC signal back on it will again detect a short-circuit. The micro then “knows” that if a shortcircuit is still present after the track polarity is changed, a problem other than a locomotive crossing the gaps is causing the fault. In this case, the track power is again switched off but the relay is not changed over. The micro simply holds the power off for one second. After this time the power is turned back on. If the short-circuit still exists the program will cycle around continuously waiting for the source of the short to be removed. Switching the track power on and off is done with two back-to-back IRF1405 power Mosfets. By connecting two Mosfets this way we can build a very effective switch, with very low voltage loss, that will pass the bipolar DCC signal without problems. The PIC drives OPTO2 via transistor Q1, to switch the Mosfets. Diode D7 uses the DCC signal to charge a 2.2µF siliconchip.com.au capacitor, providing a boosted gate voltage supply for the Mosfets. This is switched by OPTO2 which performs level translation and isolation to the output of the PIC controller. LED1 & LED2 are used to indicate the switching action of the PIC microcontroller. If IC1’s GP5 output is low, Parts List – DCC Reversing Loop Controller 1 PCB coded 09110121, 74 x 48mm * 1 5V DPDT relay, PCB mounting 2 2-pin PCB mounting sockets (2.54mm pitch) 2 plugs to suit above Semiconductors 1 PIC12F675 microcontroller loaded with 0911012A.hex* 2 4N28 opto coupler 2 IRF1405 Mosfets (any general-purpose N-channel Mosfet with RDS <0.05Ω will do) 2 ZXCT1009 high-side current monitors (SMD) [Element14 part # 1132757]* 1 78L05 3 terminal regulator 1 KBP01 in-line bridge rectifier 2 BC548 NPN transistor 7 IN914/1N4148 signal diodes 1 1N4001 diode (* The PCB, programmed microcontroller and 1 5mm red LED ZXCT1009 ICs are available from SILICON CHIP 1 5mm green LED – See page 96) Capacitors 1 100µF 25V electrolytic 1 10µF 16V electrolytic 1 2.2µF 16V electrolytic Resistors (all 1/4 W carbon film unless stated) 1 330Ω 1 390Ω 2 x 470Ω 5 x 10kΩ 2 0.15Ω 3W ceramic [Element14 part # MCKNP03WJ015KAA9] 1 1kΩ trimpot October 2012  41 An alternative use for the Auto Reverse Loop Controller Another very useful project for use on DCC layouts is a Block Overload Switch. This allows the output of your booster to be divided up into however many sections you want. As an example, say you have a shunting yard and a main line runs through or along the edge of this yard. Your booster would be powering both the main line and the yard. This is not an ideal situation. A derailment or other problem causing a short circuit will shut down the yard as well as the main line. To overcome this problem you might want to isolate the yard from the main line then power each with their own booster. This way a short in the yard will allow the main line to operator unimpeded. However, two boosters is an expensive option. Enter the Block Overload Switch This item will take the output of any booster and divide it up into isolated channels. If we connect the yard to the main line booster via a block switch, any fault in the yard will now only shut down the yard and not the main line. The Auto Reverse Loop project presented here can easily be converted into a Block Switch with a few simply modifications. the green LED lights, while if high, the red LED lights. The relay is controlled by transistor Q2 which is switched by the micro from its GP4 output at pin 3. That’s really all there is to the circuit apart from the use of the 78L05 3-terminal regulator, REG1, which in conjunction with the bridge rectifier BR1 is used to produce a 5V DC rail for the microcontroller. Putting it together The entire circuit is accommodated on a small PCB measuring 75 x 48mm and coded 09110121. Assembly is straightforward except for the two ZXCT1009 surface mount current monitors. These should be soldered onto the underside of the PCB before any other components are installed. Many constructors are scared off when a project uses SMDs but (a) you shouldn’t be – they’re not that hard to solder, especially if you follow a few The relay is left out and a new program is loaded into the microcontroller. Upon detection of a short circuit, the reverse loop program switches the DCC signal off then toggles the relay before switching the DCC signal back on. The new version of the software eliminates that step and simply switches off the DCC signal for four seconds. The extra time is needed because it is not a good idea to switch power off to a sound-fitted loco then almost immediately back on again. The 4s delay makes sound decoders much happier. How many Block Switches? In theory there is no limit to the number of Block Switches that can be connected to a booster. However, a good rule to follow is to divide the output current of the booster by the trip current of the block switch. For example, your booster is a 10A job. Each block switch trips at 2A. 10 divided by 2 equals 5. This would mean you would use four block switches with a 10A booster. Is that right, did I not just calculate 5 block switches? Yes, but there is no error. Remember that the booster is powering our main line as well, so this counts as output channel one. simple rules and (b) you’d better get used to them or your project building days could be over. Many components are now only available in SMD packages and that’s likely to increase in future. Use a temperature-regulated iron with a fine chisel or conical point, well wetted with solder. Hold the PCB steady and carefully hold the device you want to solder in position with, say, a toothpick or similar nonsolderable and heat-insulating “tool”. Tack solder a couple of opposite pins to hold the device in place while you solder the rest of the pins (in this case there are only three pins total). Make sure your original tack-soldered pins are properly soldered and don’t worry if you accidentally solder a bridge between pins – these are almost inevitable and can be removed, one side at a time, with solder wick. Finally, check your soldered component under a (preferably illuminated) magnifying glass to ensure there are no bridges or dry joints. Once satisfied, turn the board over and solder the top-side components in the normal way – just be mindful that some components also solder to the same pads as the underside SMDs. The resistors can go in first, followed by the eight diodes. IC sockets are recommended for the micro and maybe the opto-couplers. The remaining components can now be installed, leaving the relay and large electro until last (they get in the way when soldering smaller components). Take care with the orientation of the diodes and electrolytic capacitors. The single link can be made from a resistor lead offcut. At this stage you will be ready to connect power. At first leave out the microcontroller. Wire the system to the output of your DCC command station or booster. Switch on and look for the tell-tale Resistor Colour Codes No. o 5 o 2 o 1 o 1 o 2 42  Silicon Chip Value 10kΩ 470Ω 390Ω 330Ω 0.15Ω 3W 4-Band Code (5%) brown black orange gold yellow violet brown gold orange white brown gold orange orange brown gold not applicable 5-Band Code (1%) brown black black red brown yellow violet black black brown orange white black black brown orange orange black black brown not applicable siliconchip.com.au signs of the infamous escaping blue smoke. If all appears OK, measure the voltage across pins 1 and 8 of the micro socket with your DMM. You should read close to 5V DC. If so, switch off, leave a few seconds or so then insert the microcontroller (make sure you get it the right way around!). Switch on again. This time the LEDs should toggle a couple of times and after this the DCC signal should appear at the output terminals. This can be verified by wiring the output to a piece of track and trying to control a locomotive using your DCC controller. Or you can just connect it to your reverse loop and again try controlling a train. A multimeter set to AC volts can also be used to detect the DCC signal. Note that this will not be an accurate reading but is simply an indication that the DCC signal is passed to the output terminals. The next step is to see if the unit will swap the output. Remove any locos from the loop and using a short piece of wire, quickly short out the track – touch the wire to the tracks then remove it again. If you do this within about 50ms (that’s pretty quick!) the relay should toggle. If you take longer then the relay should toggle but the DCC signal will drop off for one second. Now place a loco on the loop and start it moving. Do the short circuit trick again with the short length of wire. If you are quick enough the loco should continue on without stopping. The final test is to see what happens as the loco crosses the gaps in the reverse loop. Remember here that if the polarity is the same on both sides of the gaps, nothing will happen. At some point however one of the gaps will have opposite polarities and this is where you will see the action of the system. If all is OK then that is it. You can install the unit permanently under the layout. Once operational there is no maintenance required. Adjusting the current limit The onboard trimpot is used to set the trip point current level. In most case you can just leave the trimpot centered. This will give about 2A before the unit toggles. If you really want to set the level then the best way is to simply and progressively connect a bunch of 5W resistors across the track to build up the load on the unit. The load current can be monitored at the DC input to the booster or DCC system. Using a multimeter set to the 10A range, connect it in series with the DC power supply to either your DCC system or Booster. With no load on the reverse loop take a reading of the current being drawn by the DCC system or booster and note it down. Now, using 15 to 30Ω 5W resistors, connect one at a time across the reverse loop tracks. Depending on the voltage level from your booster or DCC system each resistor will increase the current by a certain amount. Start with some 30-odd ohm resistors. Each one will draw around 500mA or so. Keep monitoring the multimeter and when the load current has increased by the amount you want your reverse loop unit to trip at, adjust the trimpot so that the unit triggers. Let the system go through its 1s off time then see if the power switches on and then off again almost immediately. If so then you have set your unit to your desired trip current. SC Micronix Handheld Spectrum Analyzer > Compact and lightweight - only 1.8kg. > Large colour display. > Battery operation. > Built in measurement functions. > Auto tune mode. > 3.3Ghz and 8.5GHz models available. For further information contact Vicom on 1300 360 251, or visit vicom.com.au HigH vAlue froM vicoM www.vicom.com.au siliconchip.com.au October 2012  43