Silicon ChipAutomatic Train Controller - October 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: I3C: Coming soon to an IC near you
  4. Feature: Display Technologies, Part 2 by Dr David Maddison
  5. Project: 30V 2A Bench Supply, Part 1 by John Clarke
  6. Feature: New PICs & AVRs from Microchip by Tim Blythman
  7. Project: PIC & AVR Breakout Boards by Tim Blythman
  8. Subscriptions
  9. Feature: Buck/Boost Battery Charging by Tim Blythman
  10. Project: Multi-Stage Buck/Boost Charger by Tim Blythman
  11. Project: Automatic Train Controller by Les Kerr
  12. Serviceman's Log: Fixing feline follies by Dave Thompson
  13. Feature: Mouser Q & A by Nicholas Vinen & Mark Burr-Lonnon
  14. Project: WiFi Programmable DC Load, Part 2 by Richard Palmer
  15. PartShop
  16. Vintage Radio: STC model 510 portable by Associate Professor Graham Parslow
  17. Market Centre
  18. Advertising Index
  19. Notes & Errata: History of Op Amps, August 2021; AVO Valve Testers, August 2022; iSoundbar, August 2022
  20. Outer Back Cover

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

You can view 44 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.

Articles in this series:
  • Display Technologies, Part 1 (September 2022)
  • Display Technologies, Part 1 (September 2022)
  • Display Technologies, Part 2 (October 2022)
  • Display Technologies, Part 2 (October 2022)
Items relevant to "30V 2A Bench Supply, Part 1":
  • 30V 2A Bench Supply front panel control PCB [04105222] (AUD $2.50)
  • 30V 2A Bench Supply main PCB [04105221] (AUD $5.00)
  • INA282AIDR shunt monitor IC and 20mΩ 1W shunt resistor for 30V 2A Bench Supply (Component, AUD $10.00)
  • 30V 2A Bench Supply PCB patterns (PDF download) [04105221/2] (Free)
  • 30V 2A Bench Supply front panel artwork (PDF download) (Free)
Articles in this series:
  • 30V 2A Bench Supply, Part 1 (October 2022)
  • 30V 2A Bench Supply, Part 1 (October 2022)
  • 30V 2A Bench Supply, Part 2 (November 2022)
  • 30V 2A Bench Supply, Part 2 (November 2022)
Items relevant to "PIC & AVR Breakout Boards":
  • PIC16F18xxx DIP Breakout PCB [24110222] (AUD $2.50)
  • PIC16F18xxx SOIC Breakout PCB [24110225] (AUD $2.50)
  • AVRxxDD32 TQFP Breakout PCB [24110223] (AUD $2.50)
  • PIC & AVR Breakout Board PCB patterns (PDF download) [24110222,3,5] (Free)
Items relevant to "Buck/Boost Battery Charging":
  • Complete kit for the High Power Buck-Boost LED Driver (Component, AUD $80.00)
Items relevant to "Multi-Stage Buck/Boost Charger":
  • Buck/Boost Charger Adaptor PCB [14108221] (AUD $5.00)
  • PIC16F1459-I/SO programmed for the Buck/Boost Battery Charger Adaptor (1410822A.HEX) (Programmed Microcontroller, AUD $15.00)
  • 1.3-inch blue OLED with 4-pin I²C interface (Component, AUD $15.00)
  • 1.3-inch white OLED with 4-pin I²C interface (Component, AUD $15.00)
  • Complete kit for the Buck/Boost Charger Adaptor (Component, AUD $40.00)
  • Complete kit for the High Power Buck-Boost LED Driver (Component, AUD $80.00)
  • Laser-cut clear acrylic front panel for Buck/Boost Charge Adaptor (PCB, AUD $2.50)
  • Buck/Boost Charger Adaptor software & laser cutting files (1410822A.HEX) (Free)
  • Buck/Boost Charger Adaptor PCB pattern (PDF download) (14108221) (Free)
Items relevant to "Automatic Train Controller":
  • Automatic Train Control PCB [09109221] (AUD $2.50)
  • Chuff Sound PCB [09109222] (AUD $2.50)
  • PIC16F1455-I/P programmed for the Automatic Train Controller (0910922A.HEX) (Programmed Microcontroller, AUD $10.00)
  • PIC12F675-I/P programmed for the Chuff Sound module (0910922C.HEX) (Programmed Microcontroller, AUD $10.00)
  • ISD1820-based voice recording and playback module (Component, AUD $7.50)
  • Firmware for the Automatic Train Controller (0910922A/C.HEX) (Software, Free)
  • Auto Train Control and Chuff Sound Generator PCB patterns (PDF download) [09109221/2] (Free)
Items relevant to "WiFi Programmable DC Load, Part 2":
  • WiFi-Controlled DC Electronic Load main PCB [04108221] (AUD $7.50)
  • WiFi-Controlled DC Electronic Load daughter PCB [04108222] (AUD $5.00)
  • WiFi-Controlled DC Electronic Load control PCB [18104212] (AUD $10.00)
  • 3.5-inch TFT Touchscreen LCD module with SD card socket (Component, AUD $35.00)
  • Laser-cut acrylic fan mounting-side panel for the WiFi DC Electronic Load (PCB, AUD $7.50)
  • WiFi-Controlled DC Electronic Load laser-cut front panel (2mm matte black acrylic) (PCB, AUD $10.00)
  • Software and laser-cutting files for the WiFi DC Electronic Load (Free)
  • WiFi-Controlled DC Electronic Load PCB patterns (PDF download) [04108221/2, 18104212] (Free)
  • Front panel decal and cutting diagrams for the WiFi DC Electronic Load (Panel Artwork, Free)
Articles in this series:
  • WiFi Programmable DC Load, Part 1 (September 2022)
  • WiFi Programmable DC Load, Part 1 (September 2022)
  • WiFi Programmable DC Load, Part 2 (October 2022)
  • WiFi Programmable DC Load, Part 2 (October 2022)

Purchase a printed copy of this issue for $11.50.

Automatic Level Crossing & Semaphore Control with chuff and whistle sounds This project combines the Model Railway Level Crossing and Semaphore Signal projects with a Li’l Pulser Mk.2 train controller to automate a model railway layout. It also adds chuffing and whistle sounds to make it as realistic as possible. T he Automatic Train Controller makes your train pull up to the Semaphore Signal, triggering the Level Crossing, then proceed through the crossing when safe, all automatically and with accompanying sound effects. It made sense to integrate this with my Li’l Pulser Mk.2 Model Train Controller. All of the projects required to build the Automatic Train Controller are listed in the adjacent panel; except the Carriage Lights which are optional. To make it more realistic, I added two sound modules, one to produce steam whistle sounds and another to add engine chuff noises. You can see a video of all these devices operating in concert at siliconchip.au/Videos/ Automatic+Train+Controller 70 Silicon Chip In that video, the Signal goes up to alert the train to stop, then the train slows down and stops at the Signal. The barriers on the Level Crossing close, the bells sound and lights flash, then the Signal goes down and after a delay, the train moves off slowly. As the train approaches the Level Crossing, the whistle sounds. Once the train has passed through the crossing, it resets. A beautiful feature of the Li’l Pulser train controller is its built-in inertia, which means that the train slows down like its full-size version and moves off slowly. It does this simply by charging and discharging a capacitor. BY LES KERR Australia's electronics magazine In case you only want to make the chuff sound module and not the train controller, I have split the design up into two separate circuits and PCBs. Automatic train control The overall arrangement of the Train Controller is shown in the block diagram, Fig.1. It still allows you to operate the Level Crossing and Semaphore Signals manually by associated toggle switches. Double-pole, double-throw (DPDT) toggle switch S1 switches between automatic and manual control. In manual mode, the Li’l Pulser controller operates as usual. So that the Crossing and Signal can be utilised in each mode, we use diode OR gates on their control inputs. This means that siliconchip.com.au Fig.1: the overall arrangement of the modules in this system. Most of them are linked to the Automatic Control Module (the Chuff module is not shown here as it operates independently). The Control Module can start or stop the train by using RLY1 to change how the Li’l Pulser operates. When required, it also triggers the Steam Whistle, Semaphore Signal and Level Crossing modules. Fig.2: this timing diagram shows the sequence of events. If this is unclear, see siliconchip.au/Videos/ Automatic+Train+Controller Three of the delays are adjustable using trimpots VR1-VR3 on the Control Module. the automatic control board drives the control inputs of these modules when it is selected, while the manual switches drive them when the Automatic Controller is disabled. A reed switch under the track is used to start the automatic process. In automatic mode, a magnet on the engine closes this reed switch as the engine passes, starting the timing sequence shown in Fig.2. Timer 1 (adjustable from half a second to 10 seconds) starts, the Signal goes up and the relay on the PCB operates, closing contacts RLY1b. The closure of those contacts connects the 250kW brake potentiometer to the 47μF capacitor on the positive input of IC3b in the Li’l Pulser controller, stopping the train. At the end siliconchip.com.au of Timer 1’s period, the Signal goes down. Timer 1 is adjusted so that the Signal goes down one second after the train has stopped. Timer 3 (0.5 to 10 seconds) is adjusted for the driver’s reaction time to start the train. I set that to one second for my layout. When Timer 3 expires, the Level Crossing closes and the relay is de-energised, opening contacts RLY1b. The 47μF capacitor is now connected to the 1MW inertia pot, causing the train to move off slowly as the capacitor charges. Then there is a fixed four-second delay before a signal is sent to operate the whistle in the sound module. The train runs on through the Level Crossing and then, when the train has passed and Timer 2 expires, the Level Crossing opens. Control circuit details The circuit of the “Auto Control Module” black box from Fig.1 is shown in Fig.3. It is pretty straightforward as most of the functions are provided by the PIC16F1455 microcontroller, IC1. Projects needed to build the Automatic Train Controller Li’l Pulser Mk.2 Model Train Controller, July 2013; siliconchip.au/Series/178 Model Railway Level Crossing, July 2021; siliconchip.au/Article/14921 Model Railway Semaphore Signal, April 2022; siliconchip.au/Article/15273 Model Railway Carriage Lights, November 2021; siliconchip.au/Article/15106 Australia's electronics magazine October 2022  71 Fig.3: the Control Module is based around microcontroller IC1, which uses internal timers to generate the control signals at RA5, RC4 and RC5 when appropriate. Those timer durations are adjusted using trimpots VR1-VR3 that apply varying DC voltages to the AN4, AN6 and AN3 analog inputs. The close of the reed switch at pin 9 of IC1 (the RC1 input) starts the whole sequence. When the reed switch closes, the RC1 input (pin 9) of IC1 that is usually held low by the 10kW resistor is pulled high. This triggers the software into action. It uses three identical 0.5-to-10-second timers, adjusted using trimpots VR1-VR3. The 680W padder resistors set the minimum voltage achievable for each pot’s wiper to about 0.5V, which corresponds to half a second. Taking Timer 1 as an example, VR1 adjusts the voltage at analog input pin RC0 (AN4) of IC1. The 100nF capacitor filters out any ripple or interference, so there is a steady voltage at that pin. The microcontroller’s internal analog-­ to-digital converter (ADC) is used to turn this voltage into a number to calculate the time delay. The other two timers are similar, using VR2/RC2/ AN6 and VR3/RA4/AN3. IC1’s RC3 digital output (pin 7) is used to switch NPN transistor Q1 which controls the coil of relay RLY1. IN4004 diode D1 protects the transistor from the back-EMF generated by the coil’s inductance when the relay switches off. Contact RLY1a switches yellow LED4 while contacts RLY1b are used to change the Li’l Pulser between the brake and run modes. 72 Silicon Chip IC1’s digital outputs RA5, RC4 and RC5 are used to produce the three control signals to trigger the Semaphore Signal, Level Crossing and Whistle Sound modules, respectively. These signals are also applied to LEDs LED1LED3 via 1kW current-limiting resistors so you can see when different modules are being triggered. Output RC4 (pin 6), when high, closes the Level Crossing and switches on blue LED2. Similarly, when output RC5 goes high (pin 5), the Signal goes up and red LED1 lights. Then, when output RA5 goes high (pin 2), the whistle module is triggered and white LED3 flashes for 200ms. The only other components are the 10kW pull-up resistor at the MCLR input of IC1 (pin 4), to prevent spurious resets, and the 100nF and 100μF supply bypass capacitors, mainly for the benefit of IC1. Chuff Sound circuit details Greg Hunter’s March 2006 Circuit Notebook contribution (siliconchip. au/Article/2601) was for producing the ‘chuff’ sound of a steam locomotive. I based my design on his. The voltage supplied to the locomotive is sensed to vary the chuff rate. The higher the Australia's electronics magazine voltage, the faster the ‘chuffs’. When the locomotive is stationary (no track voltage), it produces a ‘panting’ sound that is like an engine compressor running. The resulting circuit is shown in Fig.4. It is separate from the other modules; while they are great in combination, it can also be used as a standalone device. The voltage from the rails is applied to a bridge rectifier, and the resulting DC is reduced by an adjustable resistive divider, clamped to a safe level by an LM4040 IC acting like a 5V zener diode and filtered by a 10μF electrolytic capacitor. The result is a 0-5V signal applied to the GP2 analog input (pin 5) of PIC12F675 microcontroller IC1 that, when VR4 is adjusted correctly, lets it measure what speed the train is currently moving at. VR4 is adjusted for 3.3V at its wiper when the train is running at a realistic maximum speed. Depending on the make of your controller, you might have to change the 15kW resistor value to achieve that. Note that this won’t work with a DCC system since those systems do not vary the voltage across the tracks but instead send digital signals to the locomotives. siliconchip.com.au Fig.4: the Chuff Sound Module is pleasingly simple. The voltage across the rails is rectified, filtered, reduced and then applied to the GP2 analog input of IC2 so it can sense the train speed. It produces the panting or chuff sounds at its pin 6 digital output (GP1), and these signals are fed to audio amplifier IC3 and ultimately, the speaker. Microcontroller IC2 and LM386 audio amplifier IC3 are powered from a separate 5V DC regulated supply. This 5V supply must be floating with respect to the track supply; one can be Earthed, or the other, but not both. Otherwise, the supplies will be shorted out via the bridge rectifier. A separate 5V DC regulated plugpack is a good option here. The voltage applied to the GP2 input of IC1 is converted to an 8-bit digital number (0-255) by IC1’s internal ADC. This number is proportional to the locomotive speed. A nice feature of this PIC is its internal square-wave oscillator that can be programmed to produce 127 tones and 128 notes of white noise. To simulate the hissing noise of the engine, we use a couple of the white noise outputs. The output is switched on and off depending on the ADC voltage, so we get more chuff pulses as the train accelerates. The reverse happens when the train slows down. When the train is stopped, the panting sound is generated by another white noise channel with the pulses separated by a few milliseconds. These waveforms are applied to the GP1 digital output (pin 6), which is AC-coupled to the input of IC3 via a variable attenuator. In this configuration, IC3 has a gain of 20 and can deliver up to 300mW into the 8W speaker. The 1kW potentiometer VR5 determines the output volume. I used a 57mm diameter speaker with a 100mm square white card mounted on its back to stop the siliconchip.com.au reflected sound, which resulted in just the right amount of bass to match my Peckett tank engine. Depending on what you are running, you may have to experiment to get the optimal sound for your engine. Putting the speaker in a box will increase the bass. Construction The first step is to assemble the PCB module(s). For the Li’l Pulser, Semaphore and Level Crossing modules, see the instructions in the July 2013, July 2021 and April 2022 issues respectively (links above). There was an update to the Li’l Pulser in January 2014 to stop the train lurching at switch-off. The Train Control module is built on a single-sided PCB coded 09109221 that measures 50 x 51mm. The necessary parts are in the parts list, and the component layout (overlay) is shown in Fig.5. While the PCB is a single-sided design, if you buy it from our Online Shop, we will supply a double-sided board that will save you having to fit the two wire links. Start by fitting the PCB pins, followed by the IC and relay sockets. Take care to orientate the sockets correctly. There is no onboard programming This shot shows off the semaphore signalling section of the project. Australia's electronics magazine October 2022  73 Fig.5: assemble the Control Module as shown here. It can be etched as a singlesided design, but then two wire links are needed (shown in red). They are already part of the commercially-made double-sided PCBs we supply. When building it, watch the orientations of the IC, relay, diodes, transistor and electrolytic capacitors. header, so you will need to remove the chip from the socket later if you wish to re-program it. Next, fit the resistors (mounted vertically), followed by the capacitors and trimmer potentiometers. The electrolytic capacitors are polarised (longer lead to + pad), but the ceramic capacitors are not. If you have a single-sided PCB, fit the two wire links now using resistor lead off-cuts. Next, install the diode, LEDs and transistor. They all need to go in the right way round; check Fig.5 if you are unsure. Then plug in the relay, orientated as shown. Don’t plug in the PIC microprocessor yet. If you have purchased this from the Silicon Chip Online Shop, it will already have the firmware loaded. If you have a blank micro and need to program it yourself, you can download the HEX file from the Silicon Chip website. You will need a PICkit 4, Snap programmer or similar to load the file along with a socket adaptor for the PIC16F1455. mid positions. Switch the power on and momentarily connect a wire link between the reed switch terminals, SW and SW+. Upon doing that, the red and yellow LEDs should light. About five seconds later, the red LED should go out. After a further five or so seconds, the yellow LED should extinguish and the blue LED should light. Four seconds later, the white LED should switch on for 200ms and in a further five or so seconds, the blue LED should go out. If that all went well, power it off and give the bottom of the PCB a coat of clear varnish to protect it from corrosion. Whistle Sound module My initial plan was to add the Whistle Sound to the Chuff generator, but it is difficult to produce a whistle sound electronically that covers the full range of possible locomotives. PCB testing First, inspect the board for dry solder joints and check that the diode, capacitors and sockets are inserted correctly. Connect the PCB to a 5V DC power supply, switch it on and connect the negative lead of a voltmeter to pin 14 of IC1’s socket. Probe pin 1 of that socket with the positive lead and the meter should read close to +5V. If it doesn’t, check the power supply and socket polarity. Switch off power and plug in IC1, checking that it is correctly orientated, then adjust the three trimpots to their 74 Silicon Chip The ISD1820-based module we supply is slightly different in appearance from the version Jaycar sells. However, the required connections are the same. Australia's electronics magazine Instead, I decided to use the simple ISD1820-based sound recording and playback module. This means that you can record a suitable locomotive whistle sound from the internet. Another advantage of this approach is that the chuff sound and the whistle sound are present simultaneously. The first step in setting this up is to record the whistle sound onto the module. Connect the 76mm 8W loudspeaker (SPK1) to the green terminal block marked “speaker”, then wire a 5V DC supply between the terminals marked VCC and GND on the module. Looking at the component side of the module with the green terminal block on the left, ensure that the two slide switches marked FT and repeat are to the left-hand side (both open). For the jumper-based version pictured below, the jumper positions shown highlighted in red should be suitable. Next, find the whistle sound file you need via an internet search. Hold the module so that the electret microphone is about 100mm from the computer’s loudspeaker and set the sound to maximum volume. Hold down the REC button on the module, then hit play on the computer. Continue holding down the record button until LED1 goes out (the maximum recording time is around 10 seconds). Now momentarily press the PLAYE button. You now should hear the recording of the whistle. If it sounds distorted, try turning the computer playback volume down and re-record it. Chuff sound PCB assembly The Chuff circuit is built on a 59 × 30mm single-sided PCB coded 09109222. Refer to its overlay diagram, Fig.6, during assembly. As mentioned earlier, it could be used independently, not just as part of the automatic system. Start assembly by fitting the PCB pins and the IC sockets, ensuring the latter are orientated correctly. Like the Control board, there is no provision for onboard programming of the microcontroller. Now add the resistors, mounted vertically, followed by the capacitors; the electrolytics are polarised (the longer lead goes to the + pad), but the others aren’t. Follow with the two trimmer potentiometers but don’t get the two different values mixed up. If using a single-sided board, you can fit the wire link now (which can be siliconchip.com.au Fig.6: assembly of the Chuff Sound Module is similar to the Control Module, just simpler as there are fewer parts. The parts where polarity is critical are the diodes, ICs and electrolytic capacitors. The LM4040 is ideal, but a 4.7V zener diode can be used instead, with the cathode (striped) end to the middle pad and the other lead to the bottom-most pad. made from a component lead off-cut); it isn’t needed for the double-sided version. Solder in the diodes next; they need to be the right way around. If using a 4.7V zener diode rather than the LM4040, solder its cathode (striped) end lead to the centre pad of the TO-92 footprint, and the other (anode) lead to the LM4040 pad closest to the edge of the board. Otherwise, if using the LM4040, mount it as shown in Fig.6. Temporarily connect the positive of the 5V power pack to the +5V PCB pin, and the negative to 0V. Also wire in the loudspeaker as shown. At this stage, don’t plug in the audio amplifier (IC3) or the PIC microprocessor (IC2). If you have purchased the microprocessor from the Silicon Chip Online Shop, it will already have the firmware loaded. If you have a blank chip and need to do this yourself, you can download the HEX file from the Silicon Chip website. Use a PICkit 3, PICkit 4, Snap programmer or similar to load the HEX file into the chip via a socket adaptor. You can use the free Microchip MPLAB IPE software. Testing the Chuff module First, inspect the board for dry solder joints and check that the diodes, capacitors and sockets are inserted correctly. Switch on the power supply and connect the negative lead of a voltmeter to pin 8 of IC2’s socket, with the positive lead to pin 1. The meter should read close to +5V. If it doesn’t, you have likely wired the power supply the wrong way round or the socket is reversed. Assuming it’s OK, switch off the power and insert the two ICs, checking that they are correctly orientated and not swapped. Adjust both potentiometers to the mid position. Switch the power on and you should Silicon Chip as PDFs on USB ¯ A treasure trove of Silicon Chip magazines on a 32GB custom-made USB. ¯ Each USB is filled with a set of issues as PDFs – fully searchable and with a separate index – you just need a PDF viewer. ¯ 10% off your order (not including postage cost) if you are currently subscribed to the magazine. ¯ Receive an extra discount If you already own digital copies of the magazine (in the block you are ordering). The USB also comes with its own case EACH BLOCK OF ISSUES COSTS $100 OR PAY $500 FOR ALL SIX (+POSTAGE) NOVEMBER 1987 – DECEMBER 1994 JANUARY 1995 – DECEMBER 1999 JANUARY 2000 – DECEMBER 2004 JANUARY 2005 – DECEMBER 2009 JANUARY 2010 – DECEMBER 2014 JANUARY 2015 – DECEMBER 2019 WWW.SILICONCHIP.COM.AU/SHOP/DIGITAL_PDFS Ordering the USB also provides you with download access for the relevant PDFs, once your order has been processed siliconchip.com.au Australia's electronics magazine October 2022  75 Fig.7: once you’ve built all the modules, wire them up as shown here. The manual switches can still be used to control the Semaphore and Level Crossing if S1 is in the manual position. The Chuff Module wiring is shown separately, in Fig.6. Note that you will need to cut a track on the Li’l Pulser Mk2 PCB before adding the four wires that go to S1 and the Control Module. hear a ‘panting’ sound coming from the speaker. Adjust VR5 so that the sound is at a comfortable level. Connect a 12V variable supply to the track inputs and slowly wind up the supply. The speaker should now emit a chuffing sound with the frequency increasing as the voltage rises. Finally, give the bottom of the PCB a coat of clear varnish to protect it from corrosion. Wiring it up We need to determine where to place the reed switch in relation to the Signal. To do this, we first have the train running at a realistic speed in the normal mode and apply the brake. Measure its stopping distance and place the reed switch under and perpendicular to the rails at that distance before the Signal. I set the reed switch in a groove so that its cylindrical top was level with the bottom of the rail. You may have to experiment with this, depending on the type of engine you have and where you place the magnet within it. Be careful not to place the magnet in direct contact with the reed switch, as this can demagnetise it, causing it to fail. I built the Li’l Pulser Mk2 Train Controller in a larger enclosure than specified, Jaycar HB6128 ABS, measuring 171 × 121 × 56mm. This was so that I would have more room to mount the Automatic Control PCB, its corresponding on/off switch, the manual whistle push button, the manual signal toggle switch and the manual crossing toggle switch. If you have already built the Li’l Pulser into the smaller specified case, you will need another box to house these components. Either way, once you’ve mounted all those components in the box, it’s just a matter of wiring it up as per the wiring diagram, Fig.7. The only tricky part is interfacing with the Li’l Pulser Train Controller. To do this, you must cut the connection between the middle contact of switch S1 and the 47μF capacitor and attach flying leads to the brake side of S1, the run side of S1, the central contact of S1 and the positive terminal of the 47μF capacitor. Getting it all going The Chuff Sound module is simple enough to breadboard, otherwise you can purchase a double-sided PCB from our Online Shop. Before applying power to the finished system, check the wiring to the modules. Attach the small magnet to the front of the locomotive, ideally on the underside near the front. Also Australia's electronics magazine siliconchip.com.au 76 Silicon Chip Parts List – Automatic Train Controller with Whistle Sounds 1 assembled Li’l Pulser Model Train Controller, Mk2 (July13, Jan14) 1 assembled Steam Train Whistle module (Sept18) 1 assembled Level Crossing (July21) 1 assembled Semaphore Signal (Apr22) 1 assembled Chuff Sound module (see below) 1 ISD1820-based sound recording & playback module (MOD1) [Jaycar XC4605, SC5081] 1 single-sided or double-sided PCB coded 09109221, 50 × 51mm 1 5V DC 500mA supply 3 5kW mini single-turn top-adjust trimpots (VR1-VR3) 1 16-pin DIL IC socket (for RLY1) 1 14-pin DIL IC socket (for IC1) 1 DPDT toggle switch (S1) [Jaycar ST0355] 1 SPST momentary pushbutton (S2) [Jaycar SP0711] 1 76mm 8W loudspeaker (SPK1) [Jaycar AS3006] 1 TE Connectivity V23105A5001A201 5V DC coil DPDT 3A relay or equivalent (RLY1) [element14 1652604, Digi-Key PB383-ND] 1 Comus RI80SMDM-0510-G1 miniature SPST reed switch [Digi-Key 1835-1161-1-ND] 1 small rare earth magnet [Jaycar LM1622] 11 1mm PCB pins various lengths of light-duty hookup wire Semiconductors 1 PIC16F1455-I/P microcontroller programmed with 0910922A.HEX, DIP-14 (IC1) 1 BC547 45V 100mA NPN transistor, TO-92 (Q1) 1 5mm red LED (LED1) 1 5mm blue LED (LED2) 1 5mm white LED (LED3) 1 5mm yellow LED (LED4) 1 1N4004 400V 1A diode (D1) 6 1N4148 75V 200mA signal diodes (D2-D7) Capacitors 1 100μF 16V radial electrolytic 8 100nF 50V radial multi-layer ceramic or MKT check that the train rails and wheels are clean before proceeding. Switch the Auto on/off switch to off (ie, manual control). Increase the train’s speed to that previously used to determine where to place the reed switch. Now change the switch back to on (ie, automatic control) and adjust potentiometer VR1 on the Automatic Controller PCB so that the Signal goes green close to one second after the train has stopped. Next, adjust VR3 to what you think the driver’s reaction time should be to start the train once the Signal goes green. I set this to one second. Once the Semaphore goes off, the train should start to move away and the Level Crossing should close, flashing its LEDs siliconchip.com.au Resistors (all 1/4W 1% axial) 2 10kW 1 4.7kW 1 1.5kW 4 1kW 3 680W Chuff Sound module 1 single-sided or double-sided PCB coded 09109222, 59 × 30mm 1 5V DC regulated plugpack or other 5V floating supply (cannot be shared with the Train Controller module) 2 8-pin DIL IC sockets (optional; for IC2 & IC3) 1 10kW mini single-turn top-adjust trimpot (VR4) 1 1kW mini single-turn top-adjust trimpot (VR5) 1 SPDT toggle switch (S3) [Jaycar ST0335] 1 57mm 8W 250mW loudspeaker (SPK2) [Jaycar AS3000] 6 1mm PCB pins various lengths of light-duty hookup wire Semiconductors 1 PIC12F675-I/P 8-bit microcontroller programmed with 0910922C.HEX, DIP-8 (IC2) 1 LM386N-1 audio amplifier, DIP-8 (IC3) [Jaycar ZL3386] 1 LM4040 5V shunt regulator or 1N4732 4.7V zener diode (ZD1) 4 1N4148 75V 200mA signal diodes (D8-D11) Capacitors 2 100μF 16V radial electrolytic 1 10μF 16V radial electrolytic 1 100nF 50V radial multi-layer ceramic 1 47nF 63V MKT 1 22nF 63V MKT Resistors (all 1/4W 1% axial) 1 15kW 1 10kW 1 8.2kW 1 10W and playing bell sounds. The whistle should sound four seconds after the train starts moving again. Finally, adjust VR2 so that the crossing opens once the train has passed through. Note that if this time is set too long, the train could pass the reed switch again before the crossing closes. The result is that the train won’t stop when it passes over the reed switch. Chuff Module wiring Connect the track input wires on the Chuff module to the railway tracks and wire in the on/off switch and power supply, as shown in Fig.6. Switch it on and adjust the speed controller so that the train is travelling at a maximum realistic speed (not necessarily Australia's electronics magazine the speed it runs with the controller supplying full voltage). Using a digital voltmeter, measure the voltage between the GP2 input (pin 5) of IC1 and ground, and adjust VR4 until the voltage reads 3.3V. Wind back the speed and the chuff rate should decrease until the train is stopped, at which point the sound will revert to panting. The sound level can be adjusted using potentiometer VR5. As mentioned earlier, if you can’t achieve 3.3V at pin 5 of IC1 by adjusting VR4, you’ll have to replace the 15kW resistor with a higher or lower value. You shouldn’t have to increase the value, but you might have to reduce it if you don't get 3.3V at pin 5 of IC1 even with VR4 at its maximum. SC October 2022  77