Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

RE: [AVR-Chat] Re: Speed Trap

RE: [AVR-Chat] Re: Speed Trap

2004-03-10 by Clark, Andy

> Bullets are typically fast, designing around 1400M/S at the high end

You need to start somewhere so try over the top, using Timer1 of a Mega8 running at 16MHz - before firing, clear Timer1, sit in a tight asm loop looking for your first edge (it's probably best to feed your two optos into an RS latch so you can look for edges rather than fast pulses), start Timer1 with no prescaling then loop waiting for the second edge and stop the timer, TCNT1 will represent the time between detectors. Stumbling blindly into flakey math and ignoring the cycles lost to your asm, Timer1 count will theoretically measure a time period up to 4mS (65536/16MHz) with a resolution of 62.5nS, which would equate to a minimum measureable velocity over your inch of ~6M/S (0.025M / 4mS), maximum velocity would depend upon cycles lost in your edge polling loops (in which there will be few cycles of uncertainty) and timer start/stopping - but at 1400M/S it would take ~18uS to cross the gap giving you a count of ~285.

Possibly ;-)

AndyC

http://pages.zoom.co.uk/andyc forgive the cobwebs!

Re: [AVR-Chat] Re: Speed Trap

2004-03-11 by Bernd Felsche

On Wednesday 10 March 2004 23:42, Clark, Andy wrote:
> > Bullets are typically fast, designing around 1400M/S at the high end

But the AVR is faster than a speeding bullet. :-)

> You need to start somewhere so try over the top, using Timer1 of a Mega8
> running at 16MHz - before firing, clear Timer1, sit in a tight asm loop

You could use a free-running timer and use an external interrupt to
capture the initial value.

Then use another interrupt to capture the second value.

Just remember to count the intermediate overflows of the time.

Depending on the method used, you may even be able to go into a
low-power mode up to the first interrupt.

-- 
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ /  ASCII ribbon campaign | I'm a .signature virus!
 X   against HTML mail     | Copy me into your ~/.signature
/ \  and postings          | to help me spread!

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.