Cub Scout Pinewood Derby Race Start Interface
An electronic "Christmas Tree" and Solenoid interface for Grand Prix Race Manager software
A friend of mine is the Racemaster for Cub Scout Pinewood Derby events in the Frederick, MD area. He uses Grand Prix Race Manager (GPRM) software to run his events. He was planning to build a pretty standard "Christmas Tree" & Solenoid interface using a parallel port, but newer versions of the software dropped the parallel port interface in favor a serial port. Unlike the parallel port versions, where the software controlled timing, the serial port versions provide only a single line each for the "Christmas Tree" & Solenoid. I was asked to help create a workable interface between the new software and the hardware.
Theory and Design
- The race timer operates using a light beam across the track, triggered by the cars as they pass; therefore, race timing is independent of "Christmas Tree" & Solenoid function.
- As GPRM only provides a single "trigger" line for the "Christmas Tree", we'll have to provide all the logic to sequence the lights.
- If we must sequence the "Christmas Tree" ourselves, we may as well trigger the Solenoid as well. This will also remove the requirement to work out timing between "Christmas Tree" & Solenoid trigger events in GPRM.
- We'd like a "Christmas Tree" that resembles those used in NHRA drag races, but the way the track works, we don't have the true functionality of the Pre-Stage, Stage, and Red lights. A little fudging is in order to obtain the "feel" of a drag race for the kids.
- To avoid cabling issues and reduce circuitry, we'll use an on-board USB-Serial converter to provide the Request To Send (RTS) line. This also leaves a laptop's onboard serial port for the race timer (To use an RS-232 serial interface rather than the USB-Serial converter, see the "Oct, 2008 Conversion from USB to Serial Interface" below).
- A 12VDC "Christmas Tree" will be supported and will provide power for both lamps and the Solenoid.
- A 120VAC "Christmas Tree" will be supported by providing "dry" contacts, with the "Christmas Tree" providing its own power.
- The "Christmas Tree" and Solenoid will sequence as follows:
- Pre-Stage - This will be the "holding" state of the device between race starts. This state will be maintained until the trigger signal is seen on the RTS line of the serial interface.
- Stage - This light will be on for 3 seconds following the trigger signal.
- Countdown - Three "yellow" lights will sequence for 1 second each following Stage.
- Go - This light and the solenoid will be on for 3 seconds following the end of the Countdown. After the 3 seconds, the light and solenoid turn off and the interface returns to Pre-Stage.
- Red Light - There will be no Red Light as there is no way for a car to be released early.
Schematic and Major Components
The circuit is divided into 3 pieces: the Logic Board, the Interface Board, and the Relay Harness.
- Logic Board. The Logic Board (schematic, 26KB PDF file) consists of the following components: A USB-Serial converter, a 74C04 Hex Inverter, a 4027 Dual J-K Flip-flop, and a 4017BC Decade Counter. A 14-pin ribbon cable connnects the Logic Board to the Interface Board.
- Interface Board. The Interface Board (schematic, 26KB PDF file) consists of 6 identical circuits, each of which is based on an IRF510 MOSFET transistor.
- Relay Harness. The Relay Harness consists of the relay sockets, wiring, and connectors that provide the actual interface to the "Christmas Tree" and Solenoid. This schematic (76KB PDF file) shows the wiring between the Interface Board and the Relay Harness.
- DLP Design TTL232R-PCB USB-Serial converter. I chose this particular device as its outputs are already the correct TTL logic levels, rather than RS-232 levels. If I had used a converter with an RS-232 output, I would have had to include a MAX232 chip to convert the levels and invert the data (RS-232 uses a begative voltage for logic "1"). Using this converter eliminates the need for extra circuitry. I bought mine from Mouser Electronics.
- Omron MK2PNSDC12 Relays. In order to have the circuit trigger both a 12VDC "Christmas Tree"/Solenoid and a 120VDC "Christmas Tree", I needed DPDT relays. I also needed relays with 12VDC coils. The Omron relay I chose also has an LED indicator to show when it's "on". The octal sockets for the relays can mount on DIN rail, which makes mounting much easier. I bought relays, sockets, and DIN rail from MSC Industrial Supply.
- 12VDC Solenoid. My friend bought an automotive power lock motor from a local auto parts store. I tested it ans it would trigger at 12VDC, drawing around 10A.
- CMOS logic chips. These are "off-the-shelf" chips in plastic DIP packages. I bought them from Mouser Electronics.
- ISF510 MOSFET transistors. This is a generic n-channel enhancement mode 4A power MOSFET that is triggered very well at 5V logic levels. My friend bought them at Radio Shack (P/N 276-2072).
- Power Supply. My friend had an old Data General external SCSI hard drive case (old enough to use full-height drives). The case contained a usable power supply with both 5VDC and 12VDC outputs. The power supply was capable of driving the solenoid (12VDC at about 10A) without a significant voltage drop on the 12VDC line. Any PC-type power supply (new or used) rated 300W or better should work fine. The logic draws negligible current off the 5VDC rail, and the relays only draw about 100mA from the 12VDC rail. As long as the power supply can drive the solenoid should work fine.
- Connectors. We needed separate, noninterchangeable connectors for the 12VDC and 120VAC outputs. I chose AMP "Mate-N-Lok" connectors, using a 9-pin connectors for the 12VDC output and 15-pin connectors for the 120VAC outputs. I chose specific models that isolated the contacts from each other for safety. I bought them from Mouser Electronics and have provided the Mouser part numbers as it took me a long time to work this all out.
- 9-pin plug housing. Mouser P/N 571-14807060, 1 each.
- 9-cap plug housing. Mouser P/N 571-14807070, 1 each.
- Strain Relief for 9-pin connector (half - 2 required). Mouser P/N 571-6407161, 2 each.
- 15-pin plug housing. Mouser P/N 571-14807100, 1 each.
- 15-cap plug housing. Mouser P/N 571-14807110, 1 each.
- Strain Relief for 15-pin connector (half - 2 required). Mouser P/N 571-6407181, 2 each.
- Pins, Mouser P/N 571-3506901, 30 each.
- Sockets, Mouser P/N 571-3506891, 30 each.
Theory of Operation
- Three 74C04 inverter sections form a logical oscillator to clock the circuit. Think of the three inverters in a loop as a dog chasing its own tail (see Fairchild Semiconductor AN-118 for an excellent treatment on logical oscillators). The capacitor and two resistors slow down the rise/fall times, effectively setting the oscillation frequency at about 1Hz (my measurements show the period to be pretty stable at about 960mS). Fortunately, this application doesn't need a high-accurancy timing source, only close enough to 1Hz to give the kids a countdown to the race start. The output clocks both the 4027 J-K dlip-flop and the 4017BC decade counter.
- While the USB-Serial converter RTS signal remains low, the 4027 J-K flip-flop holds the 4017BC RST pin high, holding it at the "zero" state (i.e., only output "0" is high) .
- At the start of a race, the USB-Serial Converter's RTS signal goes high and a 74C04 inverter inverts the signal to the 4027 "J" input, causing the 4027 J-K flip-flop to "set" at the next clock cycle (this means that the RTS signal needs to stay high for at least one second. Two seconds works fine and makes sure the RTS signal is low again before the end of the cycle). This lowers the 4017BC RST pin and allows it to cycle through its outputs.
- When output "9" of the 4017BC goes high, it raises the 4027 "K" input, causing the 4027 J-K flip-flop to "reset" at the next clock cycle (assuming that the RTS signal has already gone low). This raises the 4017BC RST pin, causing it to hold output "0" high. The circuit waits in this state until the next time the USB-Serial Converter's RTS signal goes high.
- On the Interface Board, the 4017BC outputs are used as follows:
- Output "0" becomes the Pre-Stage signal, which is illuminated between races.
- Outputs "1", "2", and "3" are connected through diodes to illuminate the Stage light for three seconds. The diodes keep low and high signals from pulling at each other.
- Outputs "4", "5" and "6" are each illuminate the coundown lights for one second, providing a three second countdown to the race start.
- Outputs "7", "8", and "9" are connected through diodes and provide the race start signal The Start light illuminates and the Solenoid triggers for three seconds. The diodes keep low and high signals from pulling at each other.
- For each of the six signals described above (Pre-Stage, Stage, Three, Two, One, and Start), there is a relay-triggering circuit, centered around an IRF510 MOSFET transistor. The IRF510 gate is grounded with a 100K resistor to keep it from floating, particularly for those signals with in-line diodes. The IRF510 source is grounded and its drain connects to the negative side of the relay coil (Make sure this is correct, for the IRF510 has an internal drain-source zener diode for static protection. Reversing the drain and source will forward-bias the zener and damage the IRF510). The relay coil is powered from the 12VDC power supply. A reverse-biased "free-running" diode is placed across the relay coil to supress voltage spikes that occur when the power is removed from the relay coil. An LED was installed on the Interface Board and placed across the relay coil to indicate correct operation of the circuit.
- The positive lead of each relay's coil wires back to the appropriate IRF510 drain on the Interface Board.
- One set of relay contacts connects to the 9-pin connector for the 12VDC "Christmas Tree" amd Solenoid, energizing the appropriate pin.
- The other set of relay contacts connects to pins on the 15-pin connectors, providing a "dry contact" for the 120VAC "Christmas Tree".
Both the Logic and Interface boards were built on Radio Shack prototyping boards. I chose this particular model because it wires like a solderless breadboard, letting me move my breadboard model directly to the board.
Logic Board. The components are, from right to left: USB-Serial Converter, 74C04 Hex Inverter, 4027 Dual J-K Flip-flop, 4017BC Decade Counter, and the 14-pin DIP socket (for the ribbon cable to the Interface Board). 5VDC power is provided from the Interface Board.
Interface Board. The lower board in the picture is the Interface Board. The diodes for the Pre-Stage, Stage, and Start signals are installed next to the 14-pin DIP socket (connection to the Logic Board). There are six IRF510 MOSFETs, each with an LED indicator. There are no heat sinks on the MOSFETs as they only operate in cutoff or saturation (i.e., they dissipate no significant power). The blue wires connect the Interface Board to the relay coils, via a terminal strip.
Relay Harness. As shown in the picture, I built a crude bracket to mount the electronics, relays, and wiring in the Data General drive case. I painted parts of the bracket black so that it wouldn't be visible from the open front of the case. Six relay sockets mount on one side of the vertical board. A terminal strip mounts on the other side of the board to interconnect wires from the Interface Board and relay coils. The "free-running" diodes were installed across the relay coil contacts on each relay socket (they need to be as close to the coil as possible - if you look at the front view with the sockets, you can barely see the free-running diodes attached to each socket in the gap between the socket rows [the bare wires]). I wired up the 9-pin and 15-pin chassis connectors and wired them into the relay sockets. The barely-visible number correspond to circuit numbers on the Interface Board. I used the female end of a PC hard drive power cable splitter to provide 12VDC power from the case power supply to the relay contacts for the 9-pin connector.
The following pictures show the completed mechanism before the case was assembled:
- The front view shows the installed relays (sorry for the glare) installed in the bracket, all installed on top of the case power supply (the pen is there to hold the bracket position for the picture before I screwed everything down).
- The top view shows all electronics, relays, and wiring between the Interface Board and relays. The PC hard-drive power connector at the top of the picture with orange, black, and red wires is the connection where the electronics draw power from the case power supply. The blue wires connect the Interface Board to the terminal strip, which connects to the relay coils. The USB-Serial Converter is connected by 2 cables and a USB "gender bender" to interface to a panel-mount USB Type A connector (it was a real mess to connect a USB Type A male serial converter to a USB Type A female panel mount connector ).
- The side view shows the entire assembly, including the 9-pin and 15-pin connectors installed in the case. Because of a warp in the plywood I used for the bracket, the circuits boards have a bit of a bend, but it doesn't seem to hurt anything.
The fully assembled case:
From the front, you can see the six relays, labled for their function. An LED lights up on each relay as it is triggered, providing a "closed-case" view of proper operation. It was my intention to cover the front opening with a piece of plexiglas to keep enterprising fingers out, but I didn't get around to it before I delivered the system.
From the rear, you can see the 9-pin and 15-pin connector, as well as the panel-mount USB connector.
External Wiring Harnesses
Wiring is provided for the 12VDC "Christmas Tree" and Solenoid (schematic, 19KB PDF file) and the 120VAC "Christmas Tree" (schematic, 22KB PDF file) for creating your own setup. The 12VDC harness is powered from the power supply and the 120VAC harness is powered externally.
The labor was all mine, so the total cost was materials. The material cost was about $400 (I spent around $300 for materials and my friend provided about another $100 in parts, as well as the case/power supply). The parts cost was rather expensive, as we were purchasing small quantities at retail and paying shipping. My labor and out-of-pocket expenses were donated to the Cub Scout program.
Without the USB cable connected, when the system is powered up, it cycles continuously through the stages. When the USB-Serial Converter is powered up (it's powered from the computer's USB port) and its driver initiailizes, the cycle stops at "Pre-Stage" and waits an RTS signal from the race software, indicating that a new race it to begin.
When my friend first tried to use the system at a race night, it didn't work. GPRM wasn't propertly initializing the USB-Serial interface and the system just cycled continuously. He also uses a serial race timer and GPRM didn't seem to want to talk to both serial interfaces (the race timer and my box). Afterward, the unit tested out OK, so I built a small test program to exercise the unit, which my friend used to manually trigger the unit for his second race night. His conversations with the GPRM author indicated that GPRM wasn't properly using data from its own configuration file. The author provided a patched version, which my friend used without problem in his third race night (his largest race of the season, a full-day event). Looking at the GPRM Web Site, the updates page seems to indicate that GPRM versions 7.0.1515 and later should work fine.
Oct, 2008 Conversion from USB to Serial Interface
After the end of the 2008 race season, my friend approached me about modifying the device to connect using RS-232 vice the USB interface. He obtained a Lantronix "WiBox" dual-port WiFi-to-serial converter (WB2100E). His intention was to interface to both the Christmas Tree device and his Race Timer to the WiBox and connect his laptop to the Wibox using WiFi. The Lantronix "Com Port Redirector" software will make the WiBox serial ports appear as local serial ports on his laptop.
To convert from USB to serial, I needed to remove the USB-Serial converter shown above, and replace it with a converter circuit. The obvious way would be to use a MAX-232 chip, but I only need to convert an incoming RTS line. I found a nice, simple converter circuit at Dale Botkin's web site. The circuit was workable, but I was concerned that his MOSFET "open" and "floating" gate design (the line from pin 3 on his web page) wouldn't cut it. The device will be unplugged and stored almost all the time, and I was afraid of static discharge a the serial connector. I was also afraid that there was no overvoltage protection for the MOSFET in case something stupid happened.
My solution is shown in this updated Logic Board schematic( 35KB PDF file). I made the following changes to Dale Botkin's design:
- I added a 100k resistor from the 2N7000 gate to ground to keep it from floating. This assures that the serial input is always "off", holding the device at "Pre-Stage" until triggered (an improvement over continuous cycling of the device when the USB interface is not connected to a computer).
- I added "back-to-back" 1N5244B 14-Volt Zener diodes to limit the gate voltage to no more than +/- 14 volts, well within the 2N7000 maximum of +/- 20 Volts. The RS-232 standard permits as high as 25 volts, but PC's tend to power serial interfaces off the + and - 12V lines, so I don't expect to see any sustained overvoltages; but this also provides static discharge protection.
- I added a 10k resistor in between the 2N7000 gate and the RS-232 connector. This limits overvoltage current to around 1.5-3mA, protecting the Zener diodes from overcurrent.
Below is a picture of the modified Logic Board showing the new circuit installed on the right side where the USB interface formerly resided. The "orange" components in the lower right-hand corner are the 1N5244B Zener diodes and the 2N7000 MOSFET is located toward the upper-left-hand corner of the circuit board. The green and white wires are the serial input with the RTS (DB-9 pin 7) on the green wire and GND (DB-9 pin 5) on the white wire.
I also modified the rear panel to accept a DB-9 female connector. The device still triggers on the RTS pin, just as the USB version did, so device operation has not changed (only the interface). The connector fit is a bit tight, but workable. There's also a bit of messiness where I modified the USB connector cutout to accept the DB-9 connector. Not pretty, but I wasn't prepared to cut out a new rear panel. The "Christmas Tree" connector positions were reversed because I reinstalled the panel insert backward (not paying attention to what I was doing).
The cost of this mod was pretty trivial. From Mouser Electronics, the 2N7000 MOSFETs cost about 30 cents each and the 1N5244B Zener diodes cost about 3 cents each. I bought extras and still paid more for First Class Mail than the cost of the components. The DB-9 female crimp-style connector cost about $2.50 at Radio Shack. The resistors were from my stores (one of those monster-size resistor assortments).
- Using my benchtop power supplies, I cycled the RS-232 RTS input pin over a +/- 30Volt range several times, while monitoring the MOSFET gate voltage. The voltage at the gate never exceeded +/- 13.5 Volts. I'm satisfied that the MOSFET is protected from the full range of RS-232 voltages and that it should be sufficiently protected from static discharge during connection, disconnection, transport, and storage.
- A test program cycled the device 1400 times in an 8-hour period with no problems, so I'm satisfied that the modified device is stable.
Copyright 2001-2009, Tim Sharpe. You are free to use this information for personal, non-commerical use without restriction. All rights reserved for commerical, organizational, or government use. Questions or comments to firstname.lastname@example.org. Flames to /dev/nul.