temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Mon Mar 07, 2011 6:17 am |
|
|
Yes...easy if they all start at the same time. Google 'pinewood derby stopwatch' or similar. Basically a 4 lane 'slot car' race timer,'who's first,2nd,3rd and last. Several variations,most PIC16F84 based.
If channels start/stop different times, can be done.
Overall...
setup a free running timer..
have 4 switches,dbeounced, on RB7...4
In an ISR( int_rb) 'flag' which pin is hi/lo, that triggered the ISR(details in the help of the compiler) and save the timer value.
Next time ISR occours, again, figure out which one triggered, if that is the 'end', then subtract first saved timer value with the new one. Difference is elapsed time.
In your main, just display the times.
You'll have to figure out how fast the timer should run, useconds,milliseconds, etc.as well as max time interval.
Also if the new timer value is less than the first, some math is invloved. |
|