At 11:05 PM 1/21/05 +0000, you wrote:
> Algorithm 1:
> o set up capture timer channel 0 to interrupt on each edge
> o on interrupt check level to see if high to indicate a
> rising edge
As I remember there was a discussion of this a while ago. The upshot was
it was impossible to read the actual level of a pin set up for input capture.
> Algorthm 2:
> o the first capture input captures the time on the rising edge
> o the second capture input captures the time on the falling edge
> o the match register provides a timed interrupt in which at
> least two edges have been captured
>
> In my case I'd set it to be a millisecond since the pulse is
> periodic with about a millisecond period (I'm really measuring the
> duty cycle). Then comparing the rising and falling edge capture
> times, I can deduce whether I've captured the low pulse (falling
> edge before rising edge) or the high pulse (rising edge before
> falling edge) and calculate the high pulse from the captured times.
> Also by taking a group of measurements, I should get some of
> the high pulse and some of the low pulse. Using this info, I
> should be able to deduce the period as well instead of measuring
> that independantly.
Actually you shouldn't need a another timer to make this work. As long as
both capture channels run off the same timer then
- on rising edge
- time from last rising edge gives you period
- time from last falling edge gives you low duty time
- on falling edge
- time from last falling edge gives you period
- time from last rising edge gives you high duty time.
As a nice benefit you period and duty cycle can be updated four times for
every period. Filter to suit.
Robert
" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "
Kelvin Throop, IIIMessage
Re: [lpc2000] accurate pulse measurements
2005-01-22 by Robert Adsett
Attachments
- No local attachments were found for this message.