My nephew loves slot car racing. He bought a nice track for him and his son to play on but his son didn't understand how proportional throttle worked; it was either on or off so the car would make it to the first turn and fly into the wall. My nephew asked me if there was a way to slow down the cars so his son could enjoy slot cars without destroying them or constantly putting them back on the track.
That got me thinking of how I could use Pulse Width Modulation (PWM) to control the speed of the slot cars. We do this all the time with robots, it should work fine for slot car too. After doing some research and buying a slot car track, I made a digital slot car controller.
Click for Larger Version
The controller grew into a complete slot car racing system. It features:
The code is rather large but only consume 1/4 of the available flash in the M32. This leaves plenty of room for more user menus or types of racing. I programmed the M32 using MCS Electronics basic compiler, BASCOM-AVR. This is by far my favorite compiler for the AVR class of microcontrollers.
- Precision analog throttle control
- Digitally proportional speed using PWM (pulse-width modulation)
- Adjustable maximum speed
- Drag Racing style starting lights
- Early start fault system
- Racing timer to 1/100 of a second
- Timed and free running modes
- Lap counting and lap timing
- Displays each drivers current and best lap speed
- Complete user interface for controlling all aspects of the system
- Settings are preserved when unit is powered off.
I came across the case at Cascade Surplus Electronics for $1.75. It has lots of room inside and a replaceable bezel to hold the LCD. I created a replacement using standard polystyrene.
Other than the M32, I put all of the electronics on a basic perf board.
The controller consists of 6 main parts:
InputsControlThe M32 receives input from 3 sources - the analog throttle control, the user interface and the lap counter.
Throttle Control - This was simple to design but tough to build. The typical speed control is a wire wound resistor with a metal wiper that slides alone the side. This would not work with any precision so I pulled it out and replaced it with a 10k pot and replaced the cable with a longer telephone handset cord. This provides extremely consistent and precise positioning of the throttle trigger. The M32 converts the analog voltage from the controllers into a 10-bit value, then applies the throttle percentage set by the driver. For children, you can set the speed down to less than 50% of maximum throttle and the cars won't fly off the track.
Lap Counter - The track had a mechanical lap counter section that used a wheel to display up to 9 laps. I considered using hall effect sensors but opted to use a similar method to the original counter. After removing the wheel lap counter, I installed a pair of roller switches in their place. These work extremely well and don't slow the cars down at all. The roller switches are attached to external interrupts on the M32. This allows for precise measurement of the lap speed and lap counts but also introduced a challenging noise problem. Slot cars create a lot of noise on the power line. I had to do a lot of filtering to reduce the noise but still had to compensate for false triggers in software.
User Interface - The 20x4 character LCD provides the visual interface for the drivers. It displays the race information and the user menu. 2 buttons allow for navigation of the menus. The user menus are 2 levels deep; first level selects the option to change, the second level changes the value for that option.
The DevBoard-M32 controller is the brain of the system. I used 17 of the available 32 I/O lines, 1/4 of the program space and less than 1/2 of the available memory - and it's only running at 4 MHz! 4 MHz simplified the math for the 1/100 of a sec timer. I decided to not use the .1" square post headers on this board and instead direct solder the wires, since I was dedicating the M32 to this project permanently. It doesn't look as clean as the push on crimp connectors but it did save some time.Output
PWM Speed Control - The M32 uses PWM to control the speed of the cars instead of the mechanical current limiting resistor in the original controllers. PWM is much cleaner way to vary the speed of a motor, giving smoother performance at lower speeds than just reducing the current to the motor. Since the M32 is actually controlling the cars, it's even possible to put in a demo mode that allows the cars to race without drivers. I haven't added this feature yet.Schematic
Racing Tree Lights - I added this just for fun. Drag racing uses a series of lights to tell the drivers when to go. If a driver takes before the green light comes on, a fault light comes on and the driver is penalized. I built on this concept to capture the reaction time of the drivers. When the race is ready to start, the racing lights blink yellow, yellow, yellow then green. If a driver pulls the trigger before the green light comes on, his car won't move and the fault light is lit. To make the car move, he has to release the trigger then pull it again.
Here is the schematic for the Digital Race Track Controller:
Click here to view the Bascom code or download the file.