PDA

View Full Version : 1/ 100th second Slot car Timer



Snap
- 25th April 2007, 21:46
I am trying to build a timer for my slot car track with VB and a pic. I am using a pic 16f84a but can also use the 877 for more I/O ports. My question is this ..
Can the 9800 baud (whatever) serial com port handle a 1000th of a SECOND input or will it crap out under the speed it takes to get the signal and process it into the monitor. I could just trigger the built in timer for VB but as we all know it is not the most accurate of controlls. I want the Pic to tell the PC the elasped time in real time. I might be able to use get time option in VB but I want to use the PIC. Once I get the signal into VB I can generate charts., graphs whatever I just need to know should I be trying to solve this in pic basic and send the info to VB or vice versa....
Any suggestions (There are no wrong answers)

skimask
- 25th April 2007, 22:23
I am trying to build a timer for my slot car track with VB and a pic. I am using a pic 16f84a but can also use the 877 for more I/O ports. My question is this ..
Can the 9800 baud (whatever) serial com port handle a 1000th of a SECOND input or will it crap out under the speed it takes to get the signal and process it into the monitor. I could just trigger the built in timer for VB but as we all know it is not the most accurate of controlls. I want the Pic to tell the PC the elasped time in real time. I might be able to use get time option in VB but I want to use the PIC. Once I get the signal into VB I can generate charts., graphs whatever I just need to know should I be trying to solve this in pic basic and send the info to VB or vice versa....
Any suggestions (There are no wrong answers)

9600 baud = 9,600 bits per second. One byte = 8 bits, plus one start bit, plus one stop bit = 10 bits total, plus an extra bit time for a space between bytes = 11 bits....
9,600 = 11 = 872.72 bytes per second = .00114583 seconds per byte.
Can the PIC handle the speed? Sure, the PIC can handle a lot of speed. But, as you can see, at 9600 baud, each byte takes more than 1/1000 of a second to transmit. So, if you have 2 cars hit the trap at the same time, and your max resolution is actually 1/1000 second, the second message might get missed.

Snap
- 26th April 2007, 01:07
Thank you for your answer I see I have a lot more work to do before I hammer out the details. I will post this when I get it going. As always I can't believe the speed and quality of help in this forum. Thanks again
Snap

skimask
- 26th April 2007, 05:08
Thank you for your answer I see I have a lot more work to do before I hammer out the details. I will post this when I get it going. As always I can't believe the speed and quality of help in this forum. Thanks again
Snap

You know, with a PIC, an LCD, a couple of push buttons, and a few IR LEDs and IR detectors, you can easily make a slot car track timer and wouldn't even need a PC. There's probably enough on chip eeprom to store several races (if that's one of your goals), then you could download the data to a PC later on thru a serial port.

Melanie
- 26th April 2007, 06:57
Do a search on the forum for Olympic Timer.

Snap
- 26th April 2007, 14:01
I did download your program and greatly apreciate the code but I would like to have it on the PC so I can show it on a projector and play with things like sound and pictures as well as generate an excel spread sheet. I have set up the light tripping start and got it working great I just have to do the homework and see how I can feed information to the PC and have it update every 1/100 th of a second. I will post the code for both when I get it right.
Thanks
Snap

skimask
- 26th April 2007, 15:07
I did download your program and greatly apreciate the code but I would like to have it on the PC so I can show it on a projector and play with things like sound and pictures as well as generate an excel spread sheet. I have set up the light tripping start and got it working great I just have to do the homework and see how I can feed information to the PC and have it update every 1/100 th of a second. I will post the code for both when I get it right.
Thanks
Snap

Do you really need it to update back to the PC every .01 second?
You'd figure a packet with the last second's information dumped once per second would do the trick. Or I don't really understand 'what' you want to display on the projector. Is it like a 'scoreboard' so others can see it easier?

Snap
- 26th April 2007, 19:13
Yes the projector is for the rest of the racers to see. It will display the real time race times and laps for each lane. There are a few programs out there that simply rely on the printer port for a on or off switch set up with light detectors and a bank of light over them, But the windows timers are not very accurate as far as timing go's. I am just trying to do this myself to see if I can improve on it. I need to time 2 cars and need a way of manually stopping the timers when there is a crash. I am just starting and will work these details out on my own I just needed a starting point. Should the 1/100th second timing be done on the pic and sent to the PC or should the pic only send a signal that the light has been tripped and do the timing in windows. VB does have a few different ways of timing so maybe one of them is better. If the pic and serial port can handle a real time 1/100th second update I will use it for timing if not I will only use it to start the windows timer.

mister_e
- 26th April 2007, 19:25
Any windows will be accurate as long as you can do software calibration... not much.

But the PC interface is a pretty nice option... on the other hand... it may need calibration as well...

skimask
- 26th April 2007, 19:59
Yes the projector is for the rest of the racers to see. It will display the real time race times and laps for each lane.
What I mean is...the spectators aren't going to be able to see the difference between updates every 1/100 of a second or 1/10 of a second anyways, so why not slow the updates down a bit. Let the PIC keep track of actual times down to whatever resolution you want, but only send them to the PC every 1/4 second or so.


I need to time 2 cars and need a way of manually stopping the timers when there is a crash.
Is the timer stopper also going to cut power to the track? (I'm assuming these are the powered type slot cars)


If the pic and serial port can handle a real time 1/100th second update I will use it for timing if not I will only use it to start the windows timer.
With the way Windows software and PC hardware is set up these days, an input from a PC's serial port would probably be buffered in some fashion, and due to Windows multi-tasking capabilities, quite possibly might not get acted upon for a number of milli-seconds (or seconds on a slow machine :) ). Therefore, I think the best way to do it would be to keep track of absolute time at the track with a PIC, and send off those elapsed times/lap times/etc to the PC once in awhile...whatever the PIC/PC combo can handle. But again, I wouldn't think it would have to be that fast. After all, wouldn't people be watching the actual race, and not a big ol' TV screen?

KeithH
- 30th April 2007, 15:23
I'm pretty new to this, though I do remember reading somewhere that if you run the Chip at 4Mhz, 9600 baud is just that but if you run the pic at a higher rate, the 9600 baud setting is also multiplied. so you could get the equivelant of 24000baud if you run the chip at 10Mhz?
Sorry if I am wrong.

skimask
- 30th April 2007, 15:47
I'm pretty new to this, though I do remember reading somewhere that if you run the Chip at 4Mhz, 9600 baud is just that but if you run the pic at a higher rate, the 9600 baud setting is also multiplied. so you could get the equivelant of 24000baud if you run the chip at 10Mhz?
Sorry if I am wrong.

You are correct. If you DEFINE OSC 4 for 4Mhz, but actually use 40Mhz, and your serial commands are setup for 9600 baud, you'll actually get 96,000 baud. But running 9600 baud @ 4Mhz, the bit timing is fairly tight and if you're running any kind of interrupts, that'll mess it up.
Better to use DEBUG serial commands @ 4Mhz since they take up less code space.

Snap
- 19th May 2007, 20:06
I finished the project. I ended up using the pic basic pot command to trip a cad to tell the PC a number. I then wrote a VB program with a more accurate Apps call to more or less get a very accurate 1 1000th sec timer. I needed the nice user interface VB provided. I will give out the code for free to anyone who wants it and can learn by it. I am on to my next project now.
Thanks to everyone who helped I hope I can return the favor.
Snap

Snap
- 7th December 2007, 20:25
I have finally finished my slot car timer, I had to totally scrap my pot the cad pin programming because it took to darm long. the better way was to use the IR beam break tecnology and use that for my signals. The biggest problem turnrd out to be DC EMI of spikes caused by the car motors. I fixed that in the programming E-mail me if you are designing a simular project and I will help as best I can. Thanks to the forum for all the help.
Snap