Measuring the duty-cycle of a square wave

Status
Not open for further replies.

eng1

New Member
I'm planning to measure the duty-cycle of a square wave with interrupts: RB0INT for the signal and TIMER0 for timing. Considering one period, the PIC starts counting after the rising edge; then I fave to change the INTEDG bit; the PIC stops counting after the falling edge; this is Ton. After getting Toff in a similar way, the duty cicle will be calculated and displayed on an LCD.
Is this a valid method? Any alternatives?
Thanks
 
Be more specific about exactly what you're trying to do, it may be simpler to time it using software loops?.

You might also consider looking at the CCP module!.
 
Last edited:
I just want to measure the duty cycle of a square wave (low freq. TTL) and output the result on an LCD. I'd like to learn the simplest way to do that.

I will take a look at the CCP module. Thank you.
 
eng1 said:
I just want to measure the duty cycle of a square wave (low freq. TTL) and output the result on an LCD. I'd like to learn the simplest way to do that.

The 'low frequency' was the bit I wanted!

Makes it simple to do just with software loops.

You might try studying the code for the many frequency counters, these measure frequency at high frequencies and switch to pulse width measuring at low frequencies.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…