Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Re: accurate pulse measurements and tilt classification

2005-01-23 by onestone

chazeltopman wrote:

> 
> --- 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.

Unless you have really poorly written software (like monstrous ISR's) it 
is highly unlikely that you w9ill miss any edge event when using an 
ADXL202. The devuice is simply too slow. I often run them at 1kHz sample 
rate or higher. An 8MHz MSP430 gives me 8000 clock cycles for the entire 
period. the actual measssurement range covers just the centre 50% of the 
duty cycle, so 50% = 0g, -25% = -2g 75% = +2g. Therefore the shortest 
time between edges will be at the -2g or +2g points, these are, 
nominally of course, 2000 clock cycles apart at 8MHz, at LPC2000 clock 
speeds this should be even easier. Certainly I would look very closely 
at any system that could not service interrupts that occurred at such 
large intervals.

> 
> 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.

Why waste your time with a wider bandwidth then? set the ADXL202 to 1Hz 
or whatever sample rate you actually need, this reduces noise as well.

> 
> 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)

You need to extract any possible motion from this. If you have no motion 
then low pass filtering or very slow sampling will give you tilt angle.

>   o a tap; (not sure how to do this yet)

Probably can't do this decently at such low sample rates. Either a 
sustained peak detector or a bandpass filter will get you this. Just 
look for the centre of a stretched peak if using an IIR filter, or 
moving average. Generally the peak acceleration is in one direction for 
a tap (although it could occur between the 2 sensing axes).

>   o a shake; (again not sure how to do this either)

Same as above, but look for oscillations not peaks. A shake will 
transition either side of 0g probably with similar sized peaks.

Al

> 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.
> 
> Rob
> 
> 
> 
> 
> ------------------------------------------------------------------------
> Yahoo! Groups Links
> 
>     * To visit your group on the web, go to:
>       http://groups.yahoo.com/group/lpc2000/
>        
>     * To unsubscribe from this group, send an email to:
>       lpc2000-unsubscribe@yahoogroups.com
>       <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>        
>     * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>. 
> 
>

Attachments

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.