--- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@a...> wrote:
> 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.
Not impossible, just convoluted:
o Set PINSEL0 back to GPIO for that pin
o read input value from IOPIN
o change PINSEL0 back to timer capture
> 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.
You must service the interrupt before the capture is overwritten, otherwise
the measurement will be made longer by that time. I was looking for a way
to depend on hardware only in case the software was taking too long with
other interrupts. With one channel it can't be done but with two channels
(same timer) on two pins this can be captured in hardware and to prevent
the captured times from being overwritten, the match register is set to
stop the counter timer at a specified time and also generate the interrupt.
Originally I was getting a lot of noise using one channel trying to capture
both edges because I was doing this to two signals at the same time. When
I rearranged my state machine for that timer to time the two signals sequentially
instead of parallel, most of the noise went away. Now I only get an occasional
time, out of parameter. Also I'm not catching each edge since that would be
too much data. I'm only catching one pulse out of one hundred so I don't have
the preceding edge times to calculate the period. I figure I'll capture the
period data initially and then use in subsequent calculations since the
period is constant.
The next step is to take this data and process it. The data is coming from
a tilt sensor and I want to be able to discern the following patterns in time:
o angle of tilt (easy just read the average value)
o a tap; (not sure how to do this yet)
o a shake; (again not sure how to do this either)
The duty cycle of the sensor is proportional to accelleration due to movement
or gravity (ADXL202) and I'm taking a sample every 100 ms. If anyone else has
experience in classifiying inputs over time, I'd be interested in your stories.
RobMessage
Re: accurate pulse measurements and tilt classification
2005-01-23 by chazeltopman
Attachments
- No local attachments were found for this message.