speedometer
Hello!
How do i measure the time betvin two pulses.
it's goning to be used in a speedometer and the sensor gives one pulse per each rotation.
The speead never goes faster then 50kmh (30mph).
/Martin
Sweden
How do i measure the time betvin two pulses.
it's goning to be used in a speedometer and the sensor gives one pulse per each rotation.
The speead never goes faster then 50kmh (30mph).
/Martin
Sweden
Comments
You then wait for the beginning of the second pulse, then subtract the saved value from CNT to get the time difference in system clock time (12.5ns for an 80MHz system clock).
Look in the manual for descriptions of WAITPNE, WAITPEQ, and CNT.
You can also use the WAITPNE and WAITPEQ to instructions to wait for the transitions:
Wait for pin to go high
record cnt value
wait for pin to go low
record new cnt value
subtract the 2 values to determine speed.
This relies on Spin though, and can suffer from some delay in spin whereas the counters don't.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
SelmaWare Solutions - StampPlot GUI for controllers, XBee and Propeller Application Boards
Southern Illinois University Carbondale, Electronic Systems Technologies
American Technical Educator's Assoc. Conference·- April, Biloxi, MS. -- PROPELLER WORKSHOP!
Counters:
www.parallax.com/tabid/442/Default.aspx
Post Edited (Bob Lawrence (VE1RLL)) : 2/21/2008 9:24:54 PM GMT
The inaccuracy caused by SPIN is generally overestimated. When using such a SYMMETRIC design as Martin gives here, all SPIN delays will compensate and the result will be AS PRECISE AS WITH COUNTERS!!
obex.parallax.com/objects/256/
There's a slightly newer version of this in the VGA learning driver (search this forum for it if you want that). I'll try to get a new rev up soon, but my evenings have been filled trying to get a graphics object working for that driver
Cheers,
--fletch