cancel
Showing results for 
Search instead for 
Did you mean: 

measure or integrate an external pulse train

dthedens23
Associate II
Posted on May 20, 2013 at 18:12

I have an external device that I need to measure it's utilization.  I don't need code but I value the discussion and techniques offered.   target is STM32F407

The external device outputs a pulse.  minimum pulse width is 5ms and max is undefined, could be as much as one second high.  A good analogy is a PC disk drive light.  totally random utilization.

I need to measure the area under the curve, which is the amount of time (per some sample interval, say 100ms, 200ms) that the signal is high vs low.

A gated input capture is where I thinking of starting but I'm real new to ST timmers.

#timers-input-capture
1 REPLY 1
Posted on May 20, 2013 at 18:35

The frequency is quite low.

You could use the input capture mode, and latch the timebase (CNT) into a CCRx register on the rising/falling edge. The transition will cause an interrupt, you read the CCRx out and compute a delta wrt the previous edge. This will be in ticks of the time base.

One of the 32-bit timers would permit fine granularity, and long wrap times.

A secondary channel could presumably be set in output compare mode where the CCRx is advanced by the integration period and a interrupt generated to compute the current ON time for the other signal.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..