PWM duty cycle detector

Thread Starter

Martino Chiro

Joined May 1, 2015
128
A PWM signal has a minimum duty cycle of 5% and a max d.c. of 95%. I need to switch on a LED when the d.c. is above or equal to 10%. And switch when d.c. il less then 10%.
Thank You for any suggestion.
 

MikeML

Joined Oct 2, 2009
5,444
Low pass filter it to average it.

Assuming that it is a fixed maximum amplitude PWM signal, voltage compare to 10% of peak amplitude.

To design a circuit I would need the frequency and amplitude of the PWM signal.
 

jpanhalt

Joined Jan 18, 2008
11,087
Do you want an analog solution or do you prefer a digital (microcontroller) solution?

For an analog solution, you could use a low-pass filter which will give a voltage proportional to the duty cycle. Then a comparator could assess that voltage for your LED's.

John
 

Thread Starter

Martino Chiro

Joined May 1, 2015
128
Low pass filter it to average it.

Assuming that it is a fixed maximum amplitude PWM signal, voltage compare to 10% of peak amplitude.

To design a circuit I would need the frequency and amplitude of the PWM signal.
Thank You MikeML,
f=5KHz and V=5V
 

MikeML

Joined Oct 2, 2009
5,444
This sounds like the PWM is already coming out of a microcontroller. Can you just use a new port pin and do the comparison in code?
 

wayneh

Joined Sep 9, 2010
18,093
I don't usually say this, but wouldn't the digital solution be a lot easier here, assuming the TS is savvy with a micro?
 

AnalogKid

Joined Aug 1, 2013
12,077
The trip point is exactly twice the pulse width, so you don't need a reference. One-half of an LM393 is pretty simple. (OK, I frequently say that.)

ak
 

MikeML

Joined Oct 2, 2009
5,444
Green is 9% duty cycle, Red is 10% duty cycle, and Blue is 11% duty cycle. Note how the LED goes from full off to full on as the voltage from the LPF decays below the trip-point voltage of 528mV. Note that with R2 and R3 as shown, the trip point is ratiometric with the 5V supply, so if it is not exactly 5.00V, you will have to tweak R2/R3...202.gif
 

GopherT

Joined Nov 23, 2012
8,009
Green is 9% duty cycle, Red is 10% duty cycle, and Blue is 11% duty cycle. Note how the LED goes from full off to full on as the voltage from the LPF decays below the trip-point voltage of 528mV. Note that with R2 and R3 as shown, the trip point is ratiometric with the 5V supply, so if it is not exactly 5.00V, you will have to tweak R2/R3...View attachment 85016
Nice, any chance of helping him with the 90% duty cycle also?
 

Thread Starter

Martino Chiro

Joined May 1, 2015
128
Do you want an analog solution or do you prefer a digital (microcontroller) solution?

For an analog solution, you could use a low-pass filter which will give a voltage proportional to the duty cycle. Then a comparator could assess that voltage for your LED's.

John
I haven't a programmer background experience, so i use only analog or digital solution, but without micro and software.
Thank You
 

Thread Starter

Martino Chiro

Joined May 1, 2015
128
Green is 9% duty cycle, Red is 10% duty cycle, and Blue is 11% duty cycle. Note how the LED goes from full off to full on as the voltage from the LPF decays below the trip-point voltage of 528mV. Note that with R2 and R3 as shown, the trip point is ratiometric with the 5V supply, so if it is not exactly 5.00V, you will have to tweak R2/R3...View attachment 85016
Very good solution.
From the Linear Technology datasheet of the LT1018, it seems that it can be used as Op Amp also. It may be of some advantage, use the second half of the LT1018 as an active low pass filter ? For all i know, a comparator is not a good choice for an op amp, but in this case, LT seems to propose that.
Thank You MikeML.
 

MikeML

Joined Oct 2, 2009
5,444
You can use any comparitor. I used the LT1018 because I knew it works on a single , low voltage supply....

The only advantage an active filter over the single pole RC filter I used is that the LED would turn on more abruptly, and follow changes in duty cycle a bit faster.
 

Thread Starter

Martino Chiro

Joined May 1, 2015
128
You can use any comparitor. I used the LT1018 because I knew it works on a single , low voltage supply....

The only advantage an active filter over the single pole RC filter I used is that the LED would turn on more abruptly, and follow changes in duty cycle a bit faster.
Do you suggest a single or double pole active filter for this application ?
 
Top