cancel
Showing results for 
Search instead for 
Did you mean: 

Duty cycle detection using single pin.

luter
Associate II
Posted on October 13, 2005 at 16:44

Duty cycle detection using single pin.

6 REPLIES 6
luter
Associate II
Posted on October 13, 2005 at 05:14

Hi, All.

Could anybody suggest me the way how to detect duty cycle or pulse width of external PWM using single pin of micro? I can do it using 16bit timer, input capture and having PWM on 2 pins: first pin is for rising edge and second one--for falling edge interrupt sensivity. But I would like to use only one pin.

Tnx for all ideas.

fggnrc
Associate II
Posted on October 13, 2005 at 06:55

Luter,

I may have misunderstood what you need...

My 1 eurocent idea is to use the input capture interrupt.

In the handler code which is called for both the rising and falling edge, you can poll the input capture pin state.

If it is high, compute the low signal duration and acquire the start of the high state.

If it is low, compute the high signal duration and acquire the start og the low state.

I hope this is what you need...

EtaPhi

luter
Associate II
Posted on October 13, 2005 at 07:22

Exactly, i m using input capture int. but it is possible to choose either falling or rising edge, but not both simultaneuosly. or possible? I am using st7mc2.

fggnrc
Associate II
Posted on October 13, 2005 at 08:22

I see that ST7MC2 are different beasts from ST7FLITEs...

However, why do you not toggle the input sensibility inside the interrupt handling routine?

Regards,

EtaPhi

luter
Associate II
Posted on October 13, 2005 at 09:39

I got this idea. but the problem is that i have 2 high-priority relatively long interrupts. It could bring problems if pulse width is relatilely short. I see some solutions, but still opened for another ideas.

Anyway, tnx for help.

info45
Associate II
Posted on October 13, 2005 at 16:44

Hy,

I have used this method, detect the value pin to toggle the interrupt polarity

This permit to measure duty cycle from minimun( != 0%) and maximum ( !=100%).

These extreme cases are recognized from polling

By