1/ 100th second Slot car Timer


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50

    Default 1/ 100th second Slot car Timer

    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)
    Beer is proof that God loves us and wants us to be happy.

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Snap View Post
    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.

  3. #3
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50

    Default

    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
    Beer is proof that God loves us and wants us to be happy.

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Snap View Post
    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.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358

    Default

    Do a search on the forum for Olympic Timer.

  6. #6
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50

    Default

    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
    Beer is proof that God loves us and wants us to be happy.

  7. #7
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Snap View Post
    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?

  8. #8
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50

    Default

    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.
    Beer is proof that God loves us and wants us to be happy.

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    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...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Snap View Post
    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?

  11. #11
    Join Date
    Apr 2007
    Location
    UK
    Posts
    5

    Default Crystal speed

    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.

  12. #12
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by KeithH View Post
    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.

  13. #13
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50

    Default Thanks For The Help

    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
    Beer is proof that God loves us and wants us to be happy.

  14. #14
    Join Date
    Apr 2007
    Location
    Southern Ontario
    Posts
    50

    Talking Sorry, I was misled by the positive results

    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
    Beer is proof that God loves us and wants us to be happy.

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. 32 bit square root
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 6th May 2009, 03:37
  4. one line led light make image
    By bioul in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 12:19
  5. HSERIN doesn´t work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts