Yahoo Groups archive

Lpc2000

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

Message

Re: [lpc2000] accurate pulse measurements

2005-01-22 by Bill Knight

We am doing something similar with two capture inputs to the
same timer.
 - setup 1st capture input to capture the time of the rising edge
 - setup 2nd capture input to capture the time of the falling edge
   and to cause an interrupt.
 - the interrupt routine saves the difference between the two as
   the pulse duration.
 - the interrupt routine could also save the raw values for period
   and duty cycle calculations (we don't need that so don't do it).

Regards
-Bill Knight
http://www.theARMPatch.com


On Fri, 21 Jan 2005 23:05:45 -0000, chazeltopman wrote:

 I'm trying to capture the width of a pulse using the capture
 timers on the LPC2106 and getting an accurate reading every
 time has proven difficult.  The pulses are 200 to 700
 microseconds long.  I thought that I could capture them in
 the following way:

 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
   o if high, remember captured time and wait for falling edge
   o when falling edge occurs subtract rising edge time and
     queue up the length of the pulse

 I implemented this algorithm and my numbers vary quite a bit.
 If I scope the signals, they are clean so the variance is not
 due to noise and is due to interrupt collision or a misunderstanding
 of the timer capture.  The above algorithm will fail if another
 interrupt occurs preventing the captured count from being read
 before another edge transition occurs.  This is probably what is
 happening in my case.  So I've been thinking about how else to
 capture the two edges without software getting in the way.  The
 only way I can think of is to use two capture inputs and a match
 register.

 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.

 While this algorithm seems like it should work, it uses two inputs
 per pulse input.  If someone else has a better idea please toss
 it into the arena.

 Rob






Yahoo! Groups Links

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.