Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

linear PWM to sawtooth generator

Status
Not open for further replies.

avihai

Newbie level 6
Newbie level 6
Joined
May 29, 2014
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
90
Hi!
I have a supply voltage of 3V-15V and a 100kHz PWM.
I'd like to generate a sawtooth that goes up from 0V to the supply voltage when the PWM is at "high" and falls very fast to zero when the PWM is "low".
The important thing is that it will be linear and the "ramp" will vary linearly according to the supply voltage and the falling PWM will cut immediately the sawtooth to zero.
So for example a simple diode and capacitor charging circuit is not good for me because of the diode's forward voltage and the capacitor charging shape exponentially.

I'd like also to do exactly the same on the inverted PWM but the sawtooth goes up to the supply voltage when PWM is "low" and falls very fast to zero when the PWM is "high. In this case, I also need that when the PWM finishes, the sawtooth will stop.

The limitation here is that I must do this in pure hardware, without MCU and coding.

Thank you for the ideas!
 

Solution
OK, thats what i showed you with icky processor solution.

For a discrete approach you could take PWM output, convert it to DC with a LPF,
and use that to control a current source that charges a cap. Reset of sawtooth simply
a MOSFET with a time element to guarantee MOSFET fully discharges cap. Thats all
run off PWM as well.

Note PWM LPF has a latency associated with it, how much time delay can you tolerate ?

Voltage controlled current source, single opamp type solution easy, just google

"voltage controlled current source", lots of hits on web.

1620249530913.png



Regards, Dana.
Hi,

please give some examples or sketches of the waveform ... regarding duty cycle amd supply voltage.

for generating a sawtooth you usually need a cpapcitor oand a constant current source. The capacitor then can´t charge up the supply voltage, because the constant current source needs some voltage headroom to work.

So we nned some definitions how close the PWM should go to the supply rails... and what "fast" means. Please: values with units.

Klaus
--- Updated ---

... and dv/dt proportional to 1/duty_cycle?

Klaus
 

So you want the ramp rate to track the duty cycle of the PWM ? Such that
in either half cycle of PWM the ramp goes from 0 to supply V ?

Is period of PWM fixed, or does that also vary ?

Regards, Dana.
 

for generating a sawtooth you usually need a cpapcitor oand a constant current source.
Yes. Current source has to be proportional to Vsupply to achieve the intended characteristic. PWM input controls an analog switch discharging the capacitor, a buffer can provide a low impedance "copy" of the ramp voltage. That's the basic design.
 

For future ref (an icky processor solution) something like this -

1620236779343.png


When PWM duty cycle is altered DMA changes the current source value. Current source drives a cap,
hence linear ramp created, When PWM finishes its high or low portion of period cap is reset. So ramp
rate is proportional to PWM duty cycle.

The XOR selects which polarity of PWM the ramp is generated from.

This is single chip solution. All these elements are in chip, and many more.

Code, 3 lines of code to start the 3 components, the IDAC, PWM, and OpAmp.
DMA code produced by a wizard and inserted into mainline code. And a line of code
to start the DMA.

I assume its a fixed 100 Khz, but varying duty cycle on the PWM. Latency to
duty cycle change is just settling time of IDAC, roughly 125 nS. Thats if duty cycle
change is done during ramp, if inactive portion of PWM cycle then latency is that
pulse width coming out of PWM you don't want ramp...

Note IDAC compliance range not R-R, so a PGA could be used versus OpAmp to get the
amplitude you want.

A capless design could be done with a little more code, just measure the PW you want ramp active,
calc needed current, hence step size, and write that out to a VDAC, also onchip. This would be a
more accurate approach.

Just for future reference.


Regards, Dana.
 
Last edited:

Hi,

please give some examples or sketches of the waveform ... regarding duty cycle amd supply voltage.

for generating a sawtooth you usually need a cpapcitor oand a constant current source. The capacitor then can´t charge up the supply voltage, because the constant current source needs some voltage headroom to work.

So we nned some definitions how close the PWM should go to the supply rails... and what "fast" means. Please: values with units.

Klaus
--- Updated ---

... and dv/dt proportional to 1/duty_cycle?

Klaus
So more information and a sketch:
I'd like to have pairs of supply voltage + duty cycle that will give me linearly a peak of 0.7V of the sawtooth.
Example:
for 15V and 17% I'll get a sawtooth that goes up to 0.7V
for 3V and 83% I'll also get 0.7V max in the sawtooth

It means that I need that the product of Vsupply with the duty cycle will be the same also between these two pairs.

An example from LTspice with a diode which is not good because the sawtooth is not going down to zero but only to Vforward which is approx 0.3-0.4V.

I hope it's clear now.

1620237619851.png


Thank you!
 
Hi,

So it does not need to go to supply voltage.
And dv/dt does not depend on duty cycle.

So what maximum voltage do you want? Let's say at 15V supply and 95% duty cycle. (100% makes no sense in your case)
And what minimum voltage do you need? (Zero is hard to achieve. Please don't say "as low as possible")
And how fast do you need it go from maximum to minimum voltage?

For good quality:
I'm thinking about
* a reference voltage
* an inverting Opamp circuit that generates: Vi = V_ref - a × V_supply
* an (inverting) integrator referenced to V_ref
* an analog switch for zeroing (PWM)

Klaus
 

Hi,

So it does not need to go to supply voltage.
And dv/dt does not depend on duty cycle.

So what maximum voltage do you want? Let's say at 15V supply and 95% duty cycle. (100% makes no sense in your case)
And what minimum voltage do you need? (Zero is hard to achieve. Please don't say "as low as possible")
And how fast do you need it go from maximum to minimum voltage?

For good quality:
I'm thinking about
* a reference voltage
* an inverting Opamp circuit that generates: Vi = V_ref - a × V_supply
* an (inverting) integrator referenced to V_ref
* an analog switch for zeroing (PWM)

Klaus
The maximum voltage is not a problem, because I'll need no more than 1V, I only need to have a linear dependency to the supply voltage.
Minimum voltage - Less than 0.1V.
Fall time from 1V to "zero" - less than 0.5us.

What is your opinion?
 

If PWM is 10% duty cycle what is ramp time beginning to end ?

Same but for PWM 80% ?

Regards, Dana.
 

If PWM is 10% duty cycle what is ramp time beginning to end ?

Same but for PWM 80% ?

Regards, Dana.
It "charges" when the PWM is high, so for 10% it's 1us and for 80% it's 8us.
The purpose is that it will charge in both edge cases that I mentioned earlier to 0.7V and discharge fast to zero wheb the PWM goes low.
 

So the ramp rate is changing, dV/dT ?

Stated another way the PWM is used to set supply voltage in a control loop,
and you want this sawtooth wave to linearly track its ramp rate to the supply
which is directly related to PWM duty cycle ?

Or am I missing something......?

What is PWM size ? 8 or 16 bits ?

Regards, Dana.
 

So the ramp rate is changing, dV/dT ?

Stated another way the PWM is used to set supply voltage in a control loop,
and you want this sawtooth wave to linearly track its ramp rate to the supply
which is directly related to PWM duty cycle ?

Or am I missing something......?

What is PWM size ? 8 or 16 bits ?

Regards, Dana.
The PWM is not the issue, the sawtooth generator is.
The ramp rate is indeed changing.
The purpose is to create this ramp from the PWM.
 

OK, thats what i showed you with icky processor solution.

For a discrete approach you could take PWM output, convert it to DC with a LPF,
and use that to control a current source that charges a cap. Reset of sawtooth simply
a MOSFET with a time element to guarantee MOSFET fully discharges cap. Thats all
run off PWM as well.

Note PWM LPF has a latency associated with it, how much time delay can you tolerate ?

Voltage controlled current source, single opamp type solution easy, just google

"voltage controlled current source", lots of hits on web.

1620249530913.png



Regards, Dana.
 
Last edited:

    avihai

    Points: 2
    Helpful Answer Positive Rating
Solution
Please review the clear description given by the original poster. No conversion of PWM to DC voltage is involved. Just a current source controlled by the supply voltage. And a discharge switch enabled when the PWM signal is low.
--- Updated ---

The maximum voltage is not a problem, because I'll need no more than 1V, I only need to have a linear dependency to the supply voltage.
Minimum voltage - Less than 0.1V.
Fall time from 1V to "zero" - less than 0.5us.
Absolutely feasible. Use a MOSFET as discharge switch. Regarding current source, you should talk about required accuracy. An OP based current source can achieve high control linearity, but may be a simpler approach, e.g. a current mirror is sufficient.

Post #15 looks good. A faster OP might be helpful to get a clean current not affected by the ramp voltage step.
 
Last edited:

Clear description, both Klaus and I confused over saw ramp rate constant or
proportional to duty cycle. We finally got that resolved.

My confusion over PWM, given its the source of duty cycle that controls ramp, we needed
to develop a current source proportional to duty cycle, I suspected, and asked, if PWM was being
used in a V controlled power loop, so that could be used as the V control. The alternative,
as I suggested, was LPF the PWM output.

Regards, Dana.
 

    avihai

    Points: 2
    Helpful Answer Positive Rating
OK, thats what i showed you with icky processor solution.

For a discrete approach you could take PWM output, convert it to DC with a LPF,
and use that to control a current source that charges a cap. Reset of sawtooth simply
a MOSFET with a time element to guarantee MOSFET fully discharges cap. Thats all
run off PWM as well.

Note PWM LPF has a latency associated with it, how much time delay can you tolerate ?

Voltage controlled current source, single opamp type solution easy, just google

"voltage controlled current source", lots of hits on web.

View attachment 169286


Regards, Dana.
This is probably my solution.
Thank you!
 

Hi,

is this still valid?
Example:
for 15V and 17% I'll get a sawtooth that goes up to 0.7V
for 3V and 83% I'll also get 0.7V max in the sawtooth
If yes, then ramp rate (dv/dt) does not depend on duty cycle.
(more precise 15V and 17% gives the same as 3V and 85% (not 83%), since 15 x 17 = 3 x 85 )

Klaus
 

Hi,

is this still valid?

If yes, then ramp rate (dv/dt) does not depend on duty cycle.
(more precise 15V and 17% gives the same as 3V and 85% (not 83%), since 15 x 17 = 3 x 85 )

Klaus
You are right, it was a specific example of some measurements that I had, but assuming that everything is perfectly linear, what you wrote will be correct.

Thank you
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top