Can you help me time a millisecond event?
Posted: Tue May 11, 2010 7:13 pm
Hello all, this is my first time posting here and also my very first go at a PIC project of my own.
What I'm trying to do is build a chronometer to measure the velocity of a BB bullet, it should be somewhere in the region of 330 ft/s. give or take a bit, and display the result on an LCD.
The plan is to shot a BB down a short tube, looking through the tube are two pairs of photodiodes to detect the pellet, the first transmitter/reciever will start a timer and the second will stop the timer. So measuring the time taken, and knowing the distance between the sensors, it should be an easy calculation to arrive at the velocity. By rough calculations it should take about 0.1mS for the BB to pass between sensors that are 3 inches apart.
So far I have used flowcode to sucessfully get the LCD to display some menu instructions and respond to some switch inputs. The detector pairs are working too. The project is built around a 16F627 simply because I had one!
The point where I'm stuck at is how to do the timing. I don't fully understand how the different timers work but I'm guessing I could use TMR0 to do this. I also don't know how to initiate or program these timers in the flowcode program. Do I do it with an interupt? and what does the flowchart look like to do this. I did try to follow a tutorial but just could'nt figure things out on my own.
If someone could walk me through this I would appreciate it greatly.
Ralph
What I'm trying to do is build a chronometer to measure the velocity of a BB bullet, it should be somewhere in the region of 330 ft/s. give or take a bit, and display the result on an LCD.
The plan is to shot a BB down a short tube, looking through the tube are two pairs of photodiodes to detect the pellet, the first transmitter/reciever will start a timer and the second will stop the timer. So measuring the time taken, and knowing the distance between the sensors, it should be an easy calculation to arrive at the velocity. By rough calculations it should take about 0.1mS for the BB to pass between sensors that are 3 inches apart.
So far I have used flowcode to sucessfully get the LCD to display some menu instructions and respond to some switch inputs. The detector pairs are working too. The project is built around a 16F627 simply because I had one!
The point where I'm stuck at is how to do the timing. I don't fully understand how the different timers work but I'm guessing I could use TMR0 to do this. I also don't know how to initiate or program these timers in the flowcode program. Do I do it with an interupt? and what does the flowchart look like to do this. I did try to follow a tutorial but just could'nt figure things out on my own.
If someone could walk me through this I would appreciate it greatly.
Ralph