# Duty Cycle of PWM

1. Mar 14, 2005

### rhia

I am getting confused between duty cycle and frequency of a pwm.
Isn't duty cycle related to frequency?
Can someone explain?
Thanks & regards

2. Mar 14, 2005

### chroot

Staff Emeritus
Duty cycle is the ratio of "on time" to "off time" during one period. It is not related to frequency.

- Warren

3. Mar 14, 2005

### faust9

Duty cycle has very lttle to do with frequency. Here, do this: On a piece of graph paper draw a square wave 6 blocks high and 8 blocks wide for a complete cycle. Split the cycle so the 'on part covers the first four blocks and the off cycle covers the last four blocks of the cycle. The 8 block total width is the frequency, and the duty cycle is 50% (the on off periods are equal).

Now directly below you first graph draw another 8 block cycle but this time draw it so the 'on' time only covers two blocks and the off time covers the remaining 6 blocks. See, the frequency did not change but the duty cycle did. The new duty cycle is 25%.

Frequency is the a measure of (actually, 1 over the measure of) the time required for a signal to complete 1 full cycle. The cycle does not have to be symetric though.

The duty cycle is a measure of a signals divergence from symmetry. 50%--signal is symmetric. less than 50% and the on time is less than the off time. Greater than 50% and the on time is greater than the off time. But, as illustrated above the frequency of the signal is unchanged by the duty cycle.

Hope this helped.
Good luck.

4. Mar 14, 2005

### rhia

How can there be frequency in off state? off state = no signal =>no freq.

Can you give real world examples where cycle is not symmetric?

Thanks a lot for helping.

Rhia

5. Mar 14, 2005

### faust9

Well, my question for you then what is the definition of frequency? How can a sinusoidal wave form have a frequency if half of it goes below some arbitrary point?

As for a real world example, look up servo control on google.

 For more real world examples just do a google search on PWM. You'll find motor controls, timing controls, lighting controls, etc to name a few. PWM is quite common.

Last edited: Mar 14, 2005
6. Mar 14, 2005

### chroot

Staff Emeritus
rhia,

"Frequency" means how often a pattern repeats. "Duty cycle" means how much of each period the signal is high versus how much it is low. They are not related.

Two signals, same frequency, different duty cycle:

Code (Text):

------|      |------|      |------
|      |      |      |
|------|      |------|

----------|  |----------|  |------
|  |          |  |
|--|          |--|

- Warren

7. Mar 14, 2005

### rhia

I think I got it now.Thanks to everybody.
The source of confusion was 'off state' which actually is '-ve state' .( hope i am right now!?)

8. Mar 14, 2005

### cyeokpeng

The OFF state doesn't mean the -ve state though. It may mean 0 volts or it may mean other voltages, depending on how you define it.

Usually, the OFF state for PWM signal is close to 0V, and the ON state is voltage HIGH.

Even in the OFF state (0V), there are signals generated. How do you think your digital data in serial communications get transmitted?

9. Mar 14, 2005

### cyeokpeng

One of the simple application of PWM signals is DC motor control using the H-bridge. I am doing a project on it right now to control two motors, one left and one right for the navigation of RC boat.

The idea behind using the PWM is very simple: that is to control the angular velocity of the motor. The ENABLE pins of the H-bridge is fed with the PWM signal to control its speed. The higher the duty cycle of the PWM input, the faster the motor runs.

Say, you fed the ENABLE pin with constant HIGH i.e. 100% duty cycle. The motor runs at top speed. If you use 90% PWM, the H-bridge effectively "sees" a slightly reduced mean dc voltage, and the H-bridge will then generate slightly less current to the motor i.e. slightly less speed but fast nevertheless. Using this concept, if you use 50% PWM, then the motor will run at roughly half the full speed. Of course if you feed the ENABLE pin with constant LOW (0% duty cycle), the H-bridge is shut off and the motor will not run.

10. Mar 14, 2005

### chroot

Staff Emeritus
The "off" state certainly can be a negative voltage. There's no a priori restriction on what "off" means.
This is nonsense. This is like saying "the usual voltage on wires is 5V." Pulse-width-modulation has nothing to do with actual voltages; it's simply a means of encoding information by changing back and forth between two states, regardless of what voltages (or currents, or whatever) actually define those states.

- Warren

11. Nov 5, 2010

### luizsalomon

PWM provoques a lot of discussion. Part of the time answers are clear, part of the time they are not. This, by itself is a PWM. I would say the duty cycle of the answers is the period between people answering and you getting more confused.
But, your question was duty cycle.
Duty cycle is the amount of "ON" or "OFF" inside a PWM frequency that would affect a load. Still confused? Let me try to explain using analog:
Imagine a 2V lamp connected to a 2V battery. It is connected directly. If you let go one of the wires that's connected to the battery, the lamp will go out, as expected. Now, imagine the same experience and you are kind of a superhero with supervision powers and a superfast fingers to manipulate a stopwatch and the battery wire connected to the lamp.
With your right hand holding the stopwatch (you are a right handed superhero) and the left hand holding the wire, you connect the wire and at the exactly same time you start the stopwatch. With your superhero precision vision, you can precisely determine when the bulb reaches its plenitude of brightness and stop the stopwatch.
You look at the stopwatch with your ultra-high-precision vision and it reads 50ms.
It took the lamp to go from complete darkness to full brightness in 50ms. You imagine, with your superhero imagination that it might take the same amount of time to go from full brightness to complete darkness in the same amount of time.
So, you reset your stopwatch, and pull the wire away from the battery and watch the light diminish until it's gone. You stop the stopwatch and it reads, with no coincidence, 50ms.
So, you analyze the data you have and discover that you need, at least, 50ms to turn the lamp on and another 50ms to turn the lamp off. You need one 100ms cycle (word cycle here is important) to manipulate the lamp completely. But, but, and one more but, you need 50ms to make something happen. You need 50ms to turn it on, and you need another 50ms to turn it off. But, another but, it was already in one state, and it took you 50ms to reach the exact other end of your initial state.
So your PWM period will be 50ms or 20Hz.
So, (so much so's) if you want to develop a gadget that will turn on the lamp with half of it's brightness, you would use a 50% duty cycle.
The exact math for this is using integrals. And it's easy for a superhero...
For a real world example, I like doing slot car racing. A slot car usually has a 12V DC motor. I think you may have tried this experiment at home, when you got a 9V battery and a variable resistor and tried speeding up the motor?
If you don't, I will try to illustrate what happens, using a 9V battery, a variable resistor and a 9V motor.
When you apply 9V thru a variable resistor, the motor will get variable voltage (right to say would be variable current, but let's pretend we don't understand that far). So, you start your experiment, having a voltage meter at the motor wires, and see that you got 1V and the motor doesn't do anything (using your superhero temperature detection, you see it is getting slightly warm, even for a superhero to detect). You turn the variable resistor to 2V and the motor doesn't start spinning, but, but, and another but, you start hearing and feeling a "hummmmm" from the motor (you are holding the motor between your fingers). You keep on turning up the variable resistor. When you get 2.75V, the motor starts spinning. But you see that it started spinning at 100rpm instead of 1rpm. Why is this?
It's because of something called slip, but this is not the point. Our point is PWM and how to start spinning a motor at 1rpm.
We said that the motor is powered by 9V. It was constructed and engineered for 9V. To get full rotation, you need to apply 9V. So what if I apply 9V to the motor, for a period that is so short (duty cycle), and repeat this at regular intervals (PWM frequency)?
The engine will receive all the power it needs for that period you determined and will react at it.
You'll see that it will spin very slowly. This is a real example and easy to do at home.

It's 3:30 am, woke up, got on the internet, and my wife is complaining that I'm typing. I think I'll go back to sleep. Hope it helped explaining.

12. Sep 13, 2012

### susi2603

I have a doubt and maybe someone in here can help me. I'm controling an electric motor and the PWM signal that I used at first had a frecuency of 50Hz but I'm not going to be able to generate that same signal, so I'm going to generate a PWM signal with 100 Hz. So my question is, how those that affect the information I alredy had about the duty cicle and the angle of the motor.

13. Sep 14, 2012

### DragonPetter

The motor's inductance and its mechanical friction and inertia acts like a low pass filter, and so if your frequency is too high, the majority of the energy will be dissipated as heat. You still want it high enough that only the DC component of your PWM signal gets through. If you PWM a low frequency, its sideband components could be within the bandwidth of the motor such that it responds directly to those components - the motor will appear to turn on and off with each cycle rather than average.

I don't know what kind of motor you are using, but 50Hz seems pretty low for a PWM DC motor unless you are trying to attain very low speeds.

Last edited: Sep 14, 2012
14. Sep 14, 2012

### susi2603

I'm ussing a Standar Hitec HS-311, I had send the PWM using the Arguino U3 and I measure the PWM signal in a Scope, taking in consideration the frecuency 50 Hz, which gives me a period of 0.02, so I took the duty cycle for a number of angles, so I could have the expression that relates the PWM duty cycle and the angle. My doudbt is, now that I'm going to replicate the PWM ussing the LAbjack U3 with a frecuency of 100 Hz does the expression relatint the PWM duty cycle and the angle of the motor changes or is the same??

I don't know if I explain my self correctly...

15. Sep 14, 2012

### DragonPetter

I think you will get different results, but 50Hz and 100Hz might not be a significant change. That was my experience when I played with frequency on my motor controller. When I increased frequency to a certain point, my motor became less efficient. The thing is that if you have a closed loop regulation of the controller with PWM, the change in frequency should be compensated for automatically by increasing or decreasing the PWM by a certain factor.

16. Sep 14, 2012

### susi2603

yes in the future I will insert a PID to control the PWM that I'm going to send to the motor, so I guess that will do it.

Thank you very much