..................

Modified 03/07/09

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. This was designed for Christ Memorial Church, Williston, Vermont, USA.


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. For computers lacking a serial jack, RS232-to-USB adapters may provide connectivity. 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 (push button) or Automatic (computer)
  • Power:12V
  • Serial:9600-8-N-1

Screens

Power on message (insert your own here.)

Awana Grand Prix
Christ Memorial
Church
Jon Fick v022109


Lane masking screen, after which instructions appear for masking one or more lanes. This allows defective lanes to be ignored. Lane masking setup may also be done remotely from software.

 
Press and hold
for LANE MASKING


Ready screen. To start the race timer, either press the push button or start remotely.

 
Ready



Lane color and times appear in order of finish.

1st   B   5.344
2nd G 5.381
3rd R 5.720
4th Y 6.101


If one or more lanes finish with the same same, TIE! is inserted on the display.

1st   B   5.344
TIE! G 5.381
TIE! R 5.381
4th Y 6.101


If one or more lanes are masked, MASKED appears in the bottom row(s).

1st   B   5.344
2nd G 5.381
3rd R 5.720
4th Y MASKED


The maximum elapsed time is 9.999 seconds. Any car that does not finish will time out at the maximum. Any lane that is masked appears as 9.999 seconds.

When the button is pressed, the controller will not start timing if any phototransistor is blocked. A screen message will be displayed accordingly.


Manual operation

There is only one control...the push button. Lane masking, if desired, is configured immediately after power up by pressing the button when prompted for lane masking and following the ensuing prompts. Unmasking is done by powering off and on, or by remote software. Race timing is started by pressing the button at the Ready prompt.

Remote operation (computer controlled)

The computer may send commands to the controller/display unit and expect responses. If using Race Manager V8.0 software (and maybe a few previous versions,) 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/ready
  • "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 (if needed.) Normally the controller sends the race results after all four lanes are finished, or time out, or are otherwise accounted for (when one or more lanes are masked.)
  • "C" - check track status. Depending on what checks were selected at compile time, either finish line phototransistors, or both finish phototransistors and start gate status are checked. If a finish line phototransistor is blocked it returns "NG" to the computer (unless it was masked.) If the start gate it down, it returns "NG" to the computer.
  • "T" - trigger the start gate to drop (same as push button) and start the timer
  • "M1" - (or M2, M3, M4) mask an individual lane.
  • "X" - unmask all lanes.

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

Any lane that doesn't finish times out at 9.999 seconds. Any lane that is masked appears as 9.999 seconds.


Diagnostics mode

Diagnostics mode is entered by holding down the push button while powering up. Live start gate position (up or down) and finish line phototransistor 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 phototransistors, but not the Green phototransistor.

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 16F648 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 push button 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"

  • IR LEDs are mounted above each track lane an a "bridge" assembly to illuminate IR phototransistors 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 phototransistors 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 IR LEDs are wired in series with a second visible red LED to show that the current is flowing (and to "reassure" people that there is a light beam there even though the IR LEDs look dead.)
  • 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 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 IR phototransistors so that the only light reaching the phototransistor is from the DC lamp directly above the track. This may be done by housing each phototransistor 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 phototransistor 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:
    1. If the manual push button is used to start the race, any blocked phototransistor will result in a message on the display. The blocked phototransistor must be cleared before the controller box will start timing a race.
    2. 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 phototransistor 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

  • Start gate status and finish line blocked phototransistors may be checked. Either no checks, or finish line only, or finish line and start line may be selected at compile time.
  • 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. It's accuray 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 1mS. If two cars finish in the same 1mS time window, they will show a tie. At this resolution you will rarely see a tie, (which shows how inaccurate finish results are when done purely by eye, where ties occur often.)