PDA

View Full Version : Measuring duty cycle when it can be 0 to 100.



Tobias
- 3rd December 2011, 16:02
I have this measuring duty cycle bit down pretty good until the duty is either 0 or 100. For example, using CCP and signal is high all the time (100%) won't the timers both overflow when looking for high to low and low to high? Whats a good route to take to test for either condition? We went to watch the Parade of Lights last night in Denver so my brain is still half frozen, maybe I am missing something obvious.

One thing is the frequency is a constant too.

bogdan
- 3rd December 2011, 16:34
you mean 0 to 255 ?

Tobias
- 3rd December 2011, 16:42
No I have in incoming signal that has a duty cycle from 0 to 100%. The signal is running a motor. 0% duty cycle is motor not running at all. 100% duty cycle the motor is running full speed. I want to measure the duty cycle controlling the motor. Frequency is 125 hz for this incoming PWM. When the PWM is between 0 and 100% duty cycle I am good to go. When it is either 0(low all the time) or 100(high all the time) the overflow occurs.

Acetronics2
- 3rd December 2011, 18:24
Hi, Tobias

your signal lasts 8 ms @ 125 hz ...

so , just measure time ...


if signal high > 8 ms then it's 100% ...
if signal low > 8 ms then it's 0% ...

Was VERY cold in Denver, last night !!! don't you think ?

Alain