Plot square wave where duty cycle is a function

Thread Starter

anhnha

Joined Apr 19, 2012
905
I have a square wave where duty cycle is a function of time as below. How can I plot the square wave?
d(t) = 0.5 + 0.1cos(t).
I am confused because at each point in time there is a duty cycle but the definition of duty cycle should be in a period.
 

Thread Starter

anhnha

Joined Apr 19, 2012
905
What is the pulse period? Unless you know that you can't plot the waveform against an actual time scale.
Let's assume that the frequency is 1kHz or period 1ms.
BTW, I think that there is a contradiction here. The duty cycle can be a function of time but it should be constant in a period.
 

wayneh

Joined Sep 9, 2010
17,496
I've used this approach to throb an LED. I set the duty cycle of a PWM output to follow a sine wave. It produces a very nice effect.

Of course: PWM frequency >> throb frequency
 

Thread Starter

anhnha

Joined Apr 19, 2012
905
I've used this approach to throb an LED. I set the duty cycle of a PWM output to follow a sine wave. It produces a very nice effect.

Of course: PWM frequency >> throb frequency
With PWM frequency >> throb frequency, so in a period of PWM signal, duty cycle can be approximated as a constant but actually it is not a constant at all. So I am wondering what the PWM signal will be if duty cycle is not a constant.
Here is what I am confused from the power electronics lecture. How is it possible get a square wave gate drive from that duty cycle d(t)?

duty cycle.PNG
 

Alec_t

Joined Sep 17, 2013
14,280
BTW, I think that there is a contradiction here. The duty cycle can be a function of time but it should be constant in a period.
I don't see a contradiction. A period can have only one duty-cycle, but the 'mark' duration can vary from one period to another.
 

Thread Starter

anhnha

Joined Apr 19, 2012
905
I don't see a contradiction. A period can have only one duty-cycle, but the 'mark' duration can vary from one period to another.
I agree with you about this. However, for the definition of duty cycle function in post #1 or #5, it is a continuous with t and in a switching period the duty cycle is not a constant.
 

WBahn

Joined Mar 31, 2012
29,978
I have a square wave where duty cycle is a function of time as below. How can I plot the square wave?
d(t) = 0.5 + 0.1cos(t).
I am confused because at each point in time there is a duty cycle but the definition of duty cycle should be in a period.
This is similar to the instantaneous frequency in a frequency modulated system except that there it is a better defined since everything is continuous and so it make more sense to talk about different frequencies at different points within the same period.

Here I can imagine a few things. First, imagine that you have not only the rectangular wave output, but a linear ramp that goes from o to 1 over the course of the period. When that ramp first exceeds your d(t) signal that is when your rectangular wave drops from HI to LO. I could also imagine sampling d(t) at the beginning of each period to ensure that each period has one defined duty cycle.
 

wayneh

Joined Sep 9, 2010
17,496
How is it possible get a square wave gate drive from that duty cycle d(t)?
That depends on the details of the PWM generator. In my case I was changing the duty cycle setting every tenth of a second or so. Since the throb took several seconds, updating every tenth second gave very smooth operation.

The PWM would run at a constant duty cycle until the next update. I have no idea how it dealt with a change that arrived during a cycle. It's irrelevant at a practical level, since there were hundreds of full cycles for every one change cycle.
 

Thread Starter

anhnha

Joined Apr 19, 2012
905
Here I can imagine a few things. First, imagine that you have not only the rectangular wave output, but a linear ramp that goes from o to 1 over the course of the period. When that ramp first exceeds your d(t) signal that is when your rectangular wave drops from HI to LO. I could also imagine sampling d(t) at the beginning of each period to ensure that each period has one defined duty cycle.
This works but then the duty cycle is not actually the one defined above. It is sampled of d(t) and is discontinuous.

That depends on the details of the PWM generator. In my case I was changing the duty cycle setting every tenth of a second or so. Since the throb took several seconds, updating every tenth second gave very smooth operation.

The PWM would run at a constant duty cycle until the next update. I have no idea how it dealt with a change that arrived during a cycle. It's irrelevant at a practical level, since there were hundreds of full cycles for every one change cycle.
I see how it works in your case because d(t) is discontinuous here.
 

Alec_t

Joined Sep 17, 2013
14,280
To define the pulse width within any period you have to pick an end-of-pulse moment. Do you regard that as continuous or discontinuous?
 

Thread Starter

anhnha

Joined Apr 19, 2012
905
To define the pulse width within any period you have to pick an end-of-pulse moment. Do you regard that as continuous or discontinuous?
Not really sure what you mean here.
Here is what I meant by continuous or discontinuous:
d(t) = 0.5 + 0.1cos(t) for all positive value of t: this is a continuous. At each value of t there is one duty cycle. Even in a switching period, there is infinite duty cycle because there is infinite point in time t within that period.
d(t) = 0.5 + 0.1cos(t) is discontinuous if in each switching frequency there is only one value of at which the function is defined.
 

wayneh

Joined Sep 9, 2010
17,496
Suppose the PWM frequency is nearly the same as that of the sine wave, and suppose your job is running the PWM duty cycle in response to that sine wave. How would you decide what to do? There is no singular answer. Different designers would take different approaches. The question cannot be answered without looking at a specific device.

Using LTspice to model a simple 555-based PWM driver might give you what you want. It wouldn't be hard to simulate what you've described.
 

Alec_t

Joined Sep 17, 2013
14,280
Even LTspice will be 'discontinuous', since it calculates in discrete, albeit brief, time steps. Any practical pulse generator will also differ from the ideal continuous implementation.
 

wayneh

Joined Sep 9, 2010
17,496
I was picturing putting a sine wave onto the control pin of the 555, and watching the PWM. Or something like that. I don't know what the TS is looking for but maybe seeing a simulation would trigger the aha moment.
 
Top