| ..................
|
Modified 11/13/07
|
This schematic and source code are intended
for demonstration purposes only. They are offered "as-is". Use at your
own risk.
Code and circuits (and more) are here.
|
Introduction
This project is for the hobbiest who wants to build a
measurement and display unit for an Awana Grand Prix® track
(also known as a Pinewood Derby track.)
The racetrack for which I designed this unit is a 4-car track.
A car is approximately seven inches long, is released by a gate at the starting line,
rolls down the ramp by gravity, and crosses the finish line in approximately five
seconds.
 Click on photo to display full size version.
This circuit is contained in three places: in the controller/display box, in the finish line
"bridge" unit, and at the start gate.
The power supply, the controller/display box, and the start gate
switch/servo each connect to the track finish line "bridge."
The controller box also has a 9-pin serial jack for connection to a computer
with appropriate software. Recommended and tested race management software is
"GrandPrix Race Manager" from
GrandPrix Software Central.
This software is well-written by Rando Lisano, highly configurable (easily customized to work
with this track controller) and produces a full-screen image that is very suitable
for use with a video projector.
 Click on photo to display full size version.
C code
Schematic
My other projects
Questions? Please
me. Jon Fick
Features
Timing is initiated either by pressing the push button or by computer control.
The controller waits for one or more cars to cross the
finish line and displays the order of finish as well as elapsed timing
information.
Specifications
- Control modes:Manual (pushbutton) or Automatic (computer)
- Power:12V
- Serial:9600-8-N-1
Manual operation
The timing process is started when the button is pressed.
The order of finish and elapsed times are displayed, as illustrated below:
|
|
1st #3 5.344 2nd #1 5.381 3rd #4 5.720 4th #2 6.101
|
|
If one or more times are the same, TIE! is inserted on the display.
|
|
1st #3 5.344 TIE! #1 5.381 TIE! #4 5.381 4th #2 6.101
|
|
The maximum elapsed time is 9.999 seconds.
Any car that does not finish will time out at the maximum.
When the button is pressed, the controller will not start timing if
the start gate is down or if any photocell is blocked.
A screen message will be displayed accordingly.
Remote operation (computer controlled)
The computer may send commands to the controller/display unit and
expect responses.
If using Race Manager V3.0 software, these commands are entered into
the custom setup screen to define what the computer will send via it's
serial port in each instance, and what it will expect to receive back
from the controller box. These uppercase commands are:
- "R" - reset
- "F" - force elapsed times to be returned immediately for any lane that
has finished before race is completed. Unfinished lanes are returned
as 9.999 seconds.
- "A" - return elapsed times again. (Don't use this with
Race Manager V3.0 software because the controller automatically
sends results to the computer.)
- "C" - check start gate to ensure it's up, If the start gate is down
or if any photocell is blocked, "NG" is returned to the computer
to alert it that the start conditions aren't met.
- "T" - trigger the start gate to drop (same as pushbutton) and
start the timer
The controller/display unit returns elapsed times to the computer
with the format (from the same race as the example above):
1 5.381 2 6.101 3 5.344 4 5.720
Diagnostics mode
Diagnostics mode is entered by holding down the pushbutton while
powering up. Live start gate position (up or down) and track photocell
status is displayed until the button is released, after which the
controller resets and resumes normal operation.
The example below shows the start gate in the up (ready) position,
and that someone is testing the track by blocking the Red, Blue, and
Yellow lane photocells, but not the Green photocell.
|
|
DIAGNOSTICS MODE Start gates:UP Lane finish:RB Y
|
|
Technical Reference
HARDWARE - Controller
- Ethernet cable and RJ-45 connectors were used to connect the controller/display
unit to the finish line "bridge" unit. The other connector is the
9-pin serial connector.
 Click on photo to display full size version.
- The four-pin header between the two dip modules is the ICSP port
by which the PIC can be programmed in-circuit. All that is needed is
RB6 (clock), RB7 (data), and MCLR/RA5 (Vpp). The 16F628 in particular,
needs the LVP pin (RB4, pin 10) pulled down to keep it out of low-voltage
programming mode during programming. Hence, the 5K resistor on pin 10.
- MCLR is not active in this application because "NOMCLR"
is in the configuration word.
The only reason MCLR (RA5) has a pullup resistor is because RA5
is also used as the manual pushbutton input.
HARDWARE - Start gate actuator and switch
- The actuator for the start gate is a standard three-wire radio-control servo unit. These have
enough torque to pull a small cable that pulls a (lightly loaded) bolt latch or similar. The
controller box code rotates the servo approximately 110 degrees. The connection between servo and latch
must be such that either the servo or the manual pull string can actuate the latch without damagine the servo.
 Click on photo to display full size version.
- The start gate switch is used to check if the gate is up or down. The switch is closed when
the start gate is up. The white switch in the photo is a reed switch and magnet.
HARDWARE - Finish line "Bridge"
- DC lamps are mounted above each track lane an a "bridge" assembly to
illuminate CdS photocells in the base of the bridge which is under the track.
The end of the track is inserted through this bridge and the vertical
bolts and wingnuts secure the bridge to the track. There are four holes
in the track that align with the photocells in the lanes.
When a car breaks the
light beam the microprocessor registers the finish on that track.
 Click on photo to display full size version.
- The #1891 or #1893 automotive lamps (bayonet base, also Radio Shack)
are designed for 14V and should last a long time when run at 12V.
However, today's white LED's are quite bright and would likely make a nice
substitute that would never burn out when run within their current limits.
- The reason for the 1K resistor in series with the signal wire (yellow)
on the servo is to limit possible current from the 5V at the tip of the
1/4" plug when it's first inserted into the jack and slides past the
sleeve ring.
- The particular CdS photocells in my unit are relatively insensitive.
The measure approximately 20K when illuminated and and over 1Meg when dark.
The 100K base pullup value worked well for these photocells but you
may need to vary this resistance to suit the photocells you use.
You must ensure that when the photocell is properly illuminated, the
voltage at the FET gate is below the logic threshold, that is, make
sure that the gate voltage is approximately 1.0 volt or less. If
higher, it's too close to the FET threshold and the FET could trigger
due to power supply noise, etc. The symptom is that the lane
finishes and displays a time, but no car went through that lane
across the finish line.
- In the process of debug, I noticed that some Radio
Shack CdS cells had very slow response times...almost as though
they had some significant capacitance in
parallel with their resistance! These were
found to be quite unsuitable. You may need to experiment.
- The photo circuitry will respond to the 60/50Hz line frequency
of fluorescent lamps at certain brightness levels so it's a good idea to
shield or baffle the CdS photocells so that the only light reaching the photocell
is from the DC lamp directly above the track. This may be done by housing each
photocell in a relatively narrow, cylindrical sleeve (such as shrink tubing). If
the length is three or four times the diameter of the sleeve,
light coming in at an angle will be suitably blocked.
- Any type of photo-sensing circuitry may be employed; all that is necessary
to trigger the microprocessor is an active-low. FET's make a good high-gain
single-stage solution.
- Care must be taken to ensure
that no debris falls into or over the photocell and blocks the light.
While this rarely occurs during the course of a race, it will be sensed by the
controller box so that it can be rectified before continuing:
- If the manual pushbutton is used to start the race, any blocked photocell will
result in a message on the display. The blocked photocell must be cleared before
the controller box will start timing a race.
- If the computer software is used to start the race,
the "start gate" check that is sent to the controller box will result in
the "NG" error message if any photocell is blocked.
- This unit is shown without it's "L-shaped" cover over the upper section.
This nicely-built, robust bridge was constructed by Bruce Singer.
 Click on photo to display full size version.
SOFTWARE
- If the start gate actuator (R/C servo) is not used,
the code may be modified to use the start switch to trigger timing.
- Accurate race timing is accomplished by a one-millisecond
interrupt.
- Timing accuracy may be adjusted in the timer interrupt code.
The "set_rtcc()" instruction reloads the clock/counter at the beginning of
each interrupt cycle to prestart the timer count at a suitable value that
results in a precise 1mS interrupt rate.
However, absolute accuracy is not really important in this application.
Relative accuracy is quite fine. What is important is that the four
lanes are checked simulaneously, that is, no lane has any priority over
any other.
- The timing resolution of this design is therefore 1mS. If two cars finish in the same 1mS time
window, they will show a tie. At this resolution, once in awhile you might see a tie.
- The code consumes almost 98% of the program memory! When I need
more memory, I'll move to the 16F648, pin-compatible PIC.
|