Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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! :D

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top