PWM Input and DC Voltage Output Linear Relationship

tispo

Joined Aug 26, 2019
36
Hello everyone, I am trying to have a linear relationship between the PWM input at 40kHZ and output DC voltage. The Linear equation should be something like this (Voltage= PWM*25 ). Where PWM is the values between 1 and 256. I have implemented the circuit by use of the LM358 opamp, 25VDC input, an inverter circuit, and a transformer. Within the circuit, i have included the PWM test values and the output voltages expected. The challenge is as I increase the PWM towards the maximum (24.9 uS) , the linearity aspect disappears, and i have to change the transformer to get the expected voltage. This then messes up the previous PWM test levels' results. I would appreciate if anyone was able to advise me on how to get a good linear relationship. I have also tried using variable feedback resistors on the opamp, but it doesn't help. Can a demultiplexer be used to select different gains (feedback resistors) according to PWM levels, if so , how can that be implemented?
Regards

Attachments

• 3 KB Views: 15
Last edited by a moderator:

crutschow

Joined Mar 14, 2008
25,383
That's a rather strange circuit.
What's the purpose of the transformer?
Why not just average the PWM waveform and convert it directly to DC?

tispo

Joined Aug 26, 2019
36
That's a rather strange circuit.
What's the purpose of the transformer?
Why not just average the PWM waveform and convert it directly to DC?
Hello thanks for the reply and advice, I used the transformer for Galvanic Isolation considering the high voltage DC expected. I thought it was necessary to isolate the input PWM circuit and the desired high DC voltage . Even if i was to average the PWM, how can i accurately obtain the linear amplification factor of (PWM*25), on the DC output as this is one of my challenges. Kindly advice.
Regards

crutschow

Joined Mar 14, 2008
25,383
How much current does the high voltage output require?

Sensacell

Joined Jun 19, 2012
2,595
What DC high voltage? where?

Why not use a simple high-speed optoisolator?

The circuit you have now has many non-linear attributes, the output will always be very non-linear.

tispo

Joined Aug 26, 2019
36
The expected current is quite low it should be at a maximum of 200uA

tispo

Joined Aug 26, 2019
36
Thank you for the advice, i will also have a look at the optoisolator. I had no circuit to refer to and hence i came up with this mode. The voltage in question is the one marked as DC Output.
What DC high voltage? where?

Why not use a simple high-speed optoisolator?

The circuit you have now has many non-linear attributes, the output will always be very non-linear.

Sensacell

Joined Jun 19, 2012
2,595
Perhaps if you explain the overall concept more clearly, we can help you converge on a good solution.

What is the desired output voltage range?
Stated output current = 200 uA
Where is the isolation required? why?
How fast does the output need to change (bandwidth of the system?)
What power supplies are available?
What is the input signal?

tispo

Joined Aug 26, 2019
36
Perhaps if you explain the overall concept more clearly, we can help you converge on a good solution.

What is the desired output voltage range?
Stated output current = 200 uA
Where is the isolation required? why?
How fast does the output need to change (bandwidth of the system?)
What power supplies are available?
What is the input signal?
1. The desired Output Voltage range is

INPUT PWM(uS) ------------------- EXPECTED DC OUTPUT(V)
2.4415 ------------------- 590
5.371 ------------------- 1294
6.34775 ------------------- 1529
9.082 ------------------- 2188
11.81625 ------------------- 2847
24.908 ------------------- 5900

Stated output current = 200 uA

2. The transformer boosts the AC current from the Inverter and also provides isolation from the Opamp Amplification stage. But its main role is to boost secondary voltage. The isolation was just a precaution as the voltage is high albeit low current.
3. The settling time of each output voltage is 10 mS at each of the specified Input PWM levels
4. The power supply is 25V DC and 350mA input
5. Signal is 5V 40 kHZ CMOS pwm push-pull type drivers

Sensacell

Joined Jun 19, 2012
2,595
!!! 5.9 kV???

Doesn't sound like you really need isolation- you will refer the output to ground anyway?

It needs to go from 590 volts to 5900 V in 10 ms?

What level of linearity do you need?

What is this thing for?

Maybe get one of these, add a simple Low Pass filter to convert the PWM to DC at the input.

http://www.analogtechnologies.com/High_Voltage_Amplifier.html

Last edited:

tispo

Joined Aug 26, 2019
36
Sorry, i had not understood your question correctly. I meant for each of the PWM test levels each output voltage time should have a settling time of 10ms. These are just test levels that must conform to the stated voltage to confirm linearity. The voltage needed at the end is 5.9kV. The time taken from 2.555u to 24.908u (590 to 5900V) is 15ms. The linear equation to be met is
(Vout =PWM * 25). Where PWM ranges from 1 to 256. I would like to have an accuracy of utmost plus or minus 50V. About the transformer, its true there is no real need for isolation, i just used it to boost the voltage, and yes i would like to refer it to the ground. I will have a look at the link attached....Thanks for the correspondence thus far.

Last edited:

tispo

Joined Aug 26, 2019
36
I think there is also a problem at the input low pass filter stage, when i put the 24.908 u PWM level, the voltage does not conform to the linear expected voltage after filtration. thats a source for the lack of linearity. Could anyone have an idea how to improve this part.

Sensacell

Joined Jun 19, 2012
2,595
In the real world, your transformer will have leakage inductance which will create nasty spikes at the inverter switching edges.
These spikes will pass through to the output, they become part of the output waveform- totally hosing any chance for linearity.

If I was trying to do this, I would close the loop completely - use a portion of the output voltage to feedback to the opamp- so it REGULATES the voltage.
The tricky part will be loop compensation, the phase shifts in the circuit make stabilizing this mess while still providing fast slew rate a difficult task.

Drive the inverter transistor bases from a separate oscillator running from a separate power source, so you don't have to worry about the thing starting up.

Last edited:

tispo

Joined Aug 26, 2019
36
In the real world, your transformer will have leakage inductance which will create nasty spikes at the inverter switching edges.
These spikes will pass through to the output, they become part of the output waveform- totally hosing any chance for linearity.

If I was trying to do this, I would close the loop completely - use a portion of the output voltage to feedback to the opamp- so it REGULATES the voltage.
The tricky part will be loop compensation, the phase shifts in the circuit make stabilizing this mess while still providing fast slew rate a difficult task.

Drive the inverter transistor bases from a separate oscillator running from a separate power source, so you don't have to worry about the thing starting up.
Thank you for the reply i will put the advice into place. I had not considered the impact of the spikes as you have mentioned. Thus i will have a look at the compensation loop as well.

tispo

Joined Aug 26, 2019
36
Hello all, i still have a simple problem that i cant seem to get rid off. The low pass filter that converts 3.3 V, 40kHZ PWM into DC voltage does not seem to be linear from 90 % onwards. Could anyone please guide me on what i can do to have linearity at the PWM Conversion stage.. I used a simple RC circuit to filter the PWM as seen in the image of the circuit.

Joined Feb 20, 2016
3,602
You will not get a PWM switching a transformer to work from 0% to 100% no matter what you do.
At either end, there will not be any switching going on so no transformer action.
The transformer needs enough current pulsed through the primary to create the varying magnetic field.
And running near 100% PWM will staurate the coil.
So just relying on PWM to control the output voltage accuratly is no the way to go. As mentioned earlier, close the loop and have that control the PWM.
The transformer winding ratio may need to be increased so the max desired voltage is output at less than your max PWM value.

ronsimpson

Joined Oct 7, 2019
907
DC voltage does not seem to be linear from 90 % onwards.
R3=500, most logic gates will not like driving 500 ohm load. Try 5k or higher. You can make C2 smaller at the same time.
Measure the voltage on C2. Is it linear? Next measure "V", is it linear?
I am not certain what you call linear. 50% should get you 1/2 of V1 voltage. (not uS but "%")
Until you prove the voltage at C2 is "linear" …………….

Sensacell

Joined Jun 19, 2012
2,595
You will not get a PWM switching a transformer to work from 0% to 100% no matter what you do.
At either end, there will not be any switching going on so no transformer action.
The transformer needs enough current pulsed through the primary to create the varying magnetic field.
And running near 100% PWM will saturate the coil.
So just relying on PWM to control the output voltage accurately is no the way to go. As mentioned earlier, close the loop and have that control the PWM.
The transformer winding ratio may need to be increased so the max desired voltage is output at less than your max PWM value.

The OP's it not trying to PWM the transformer, the PWM is converted to DC at the first RC stage of the input.
The output of the opamp is a variable DC voltage which is supposed to vary the output voltage of an astable multivibrator - driving the transformer with a 50-50 duty cycle.
The output rectification is half-wave, this WILL cause trouble as it's not symmetrical - the transformer will not see balanced magnetic flux.

tispo

Joined Aug 26, 2019
36
Thank you all for the help so far, i will use the ideas to improve my circuit. Regards