Shop OBEX P1 Docs P2 Docs Learn Events
Race timer — Parallax Forums

Race timer

arendarend Posts: 4
edited 2011-11-20 19:16 in BASIC Stamp
I need help with the code for this project.


Its Pinewood Derby time. I want to do the following:

-Set a control switch at the top of the track
-Set photo sensors under the track at the bottom (for 4 - 6 lanes)
-Set up either a LCD and standard digit segment

The Cars pass over the photo sensors.
There will be a digit segmant display over each track to display (1st 2, 3, etc)
There will be a LCD in the center that will read out the speed for each track
There will be a reset and recall button for the speed.
It will be able to upload each race's speed

I have a Basic Stamp Home Work Board (with a serial port)
Any Ideas on coding this. (I am new to the langueage but familiar with java and C++ and basic bread boarding)

Thank you very much for your help.


Also if you have any sugestions of a better sensor to use for judging when the cars pass over the finish line I'm open to suggestions.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-11-20 08:52
    arend,

    Welcome to the forum! It's been a half century since my pinewood derby days, so you'll have to bear with me. What, time-wise, is the average length of a race? To what degree of accuracy do you need to measure the time? Or is it good enough just to know the order of finish?

    Regarding the photo sensors: Is it safe to assume that the winner is determined by which car breaks an imaginary plane across the finish line first, regardless of which part of the car it is? Or is their another criterion? Are you planning to use reflective sensors or transmissive sensors?

    -Phil
  • W9GFOW9GFO Posts: 4,010
    edited 2011-11-20 10:55
    It's been a few years since my kids raced. What I remember is that the finish line had four holes in the track in which I assumed IR LEDs were installed. The display board directly above the finish line would show the numbers one through four indicating the order of finishing. The elapsed time was not calculated. There was only a single button on the display board to clear the numbers and be ready for the next race.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-11-20 13:26
    That's good to know, Rich; thanks. The actual times would be a problem for the BASIC Stamp. The rest of the app might be doable with a Stamp, though.

    -Phil
  • arendarend Posts: 4
    edited 2011-11-20 13:30
    I want the have each car have its time calculated. Because there will be 4 cars running at the same time I want to pair the cars for the next round based on speed so that everyone gets to race against a fair appoinent.
  • arendarend Posts: 4
    edited 2011-11-20 13:32
    Can the basic stamp keep track of time?, or can i put an IC chip on the board to give it the ability?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-11-20 13:50
    That's going to be tricky, if it's possible at all with a BASIC Stamp. The BASIC Stamp does not have a timer that runs in the background. All timing that spans multiple PBASIC statements has to be done by considering the execution time of each statement, and that quickly becomes insurmountably complex. Although the actual timing could be done with external counter ICs that are started and stopped by the trigger at the top of the track and the sensors at the bottom, then read out by the BASIC Stamp, that gets pretty messy, too. Other than that, a more capable micro, like the Propeller, may be your only recourse -- unless someone else can here think of a better solution that uses the Stamp.

    -Phil

    Addendum:
    or can i put an IC chip on the board to give it the ability?

    I was going to mention a clock chip, like the DS1302, but its resolution is one full second, and reading out the time for one car could interfere with detecting the finish of another if they're at all close.
  • arendarend Posts: 4
    edited 2011-11-20 17:55
    What about at timer like in a stop watch. It has a ready out ability. all you have to do is start it, then read the time and then store the value in a varrible for each track, while the stop continues to count up.

    -When the race starts the triger calls a {start coup up} function that turns on the stop watch.
    -As each car pases the finish line each indiviual sensor calls a {end time} function that reads the current time on the counter and stores the value.
    -After all four sensors have called their function an {end race} function is trigered that calls the display function and shows the results.

    Can the BASIC stamp handle this code if I use a counter like the one in a stop watch or in IC555 timer?
  • LevLev Posts: 182
    edited 2011-11-20 18:00
    Arend,

    Here is another option:

    http://www.parallax.com/dl/docs/cols/nv/vol8/col/nv141.pdf

    I built it, bit never used it. I'll give it to you if you think it is suitable.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2011-11-20 19:16
    This is similar to a program I helped with for a game, where the order of winners was predicated on how fast and in what order they pressed their response buttons. I set it up as a state machine on a BS2, with a main loop that ran in about 4 milliseconds, and responses within that interval would be considered ties. The code and explanation is at this URL if you want to take a look. The variable named "drum" could be captured when each car crossed the finish line as a surrogate for elapsed time.
Sign In or Register to comment.