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.

PWM duty cycle as a percentage.

Status
Not open for further replies.

Suraj143

Active Member
In an eight bit register I’m turning ON a bit 100 times & the other 155 balance I’m turning OFF.
So how can I tell this as a percentage I mean the duty cycle?

Thanks
 
It is approximately 39% duty cycle. (It should really be 100 and 156 for a total of 256 states) 100 / (100+156) = 39.06%
 
Oh thank you very much kchriste now I understood.

Is there any frequency in my application?Is it 256?
 
Is there any frequency in my application?
Yes. I assume you are using a PIC (From your other posts). The PWM frequency depends on the PICs clock frequency and the values in the PR2 and T2CON registers. From a datasheet:
PWM period = [(PR2) + 1] * 4 * TOSC * (TMR2 prescale value)
PWM frequency = 1 / PWM period.
 
Oh I see I have to study that a little bit.

But in my application i'm not using any Timers its just a basic software type one.Incrementing a register 100 times while the bit is turned ON & the other balance counting upto 256 while the bit turns OFF.

My XT is 4mhz.In this situation how to tell the frequency?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top