My PWM generator has an offset error which gives my whole circuit an error above the allowed 0,1% of full scale which is 5V. The allowed error is 5 mV.

This error is noticed when i graph my input and output and use the least method sqaure on it.

here is the graph where excel did the calculation itself. enter image description here

I need a full PWM from 0% -100%, 0-5V.

These are my values of my error amp: R1 = 30K R2 = 30K

R3 = 33k R4 = 30K

Before i used the above value for R3, it was also 30K and used the underneath formula to calculate my offset with Vref 2,5V i get:

Vo= (1+ (R4/R3)) (R2/(R1+R2))Vref = 2.5V

When i calculate it witg R3 33K i get :

Vo= (1+ (R4/R3)) (R2/(R1+R2))Vref = 2.2V

My problem now is that when i use R3 = 33K for more "current or voltage sensing" my circuit is able to PWM from 0-100%, but with an error above 0.1% of full scale.

When i use R3 = 30K my circuit is not able to PWM from 0-100% in the range from 0V-5V. It than only needs around 0,5V to go from 0% dutycycle to 50% en 0,5V to 100%. in total it only needs 1V to go from 0% to 100%.

i tried to research the error amp, read numerous pdf's but i didn't get any wiser on how to solve this.

I will reiterate my question.

What do i need to change in order to have a full PWM from 0-100%, 0-5V, with an error thats is below 0,1% of fullscale (5mV)?

My professor gave me a hint that i needed to something special with Vref.

Do i need to change something about Vref or something else ? I hope i am clear in my explanation and question. I've been at it for a while, i hope someone can give me the solution!!!

Thanks in advance.

additional info. i cant have two or more links I removed the orginal schematic for my own so you can see what i have done. if you want to see the original, you can find it as an pdf called slau508. My use of PWM generator is slighly different than the slau508.

My schematic and its values, hope you can see it. I forgot to give additional information because i was focusing on the error amplifier

But my PWM is 1KHz, and the values on the sheet is what i had calculated for 1KHZ. I use a Buffer to connect my agilent Multimeter on to measure my average output (Y) enter image description here

  • 1
    \$\begingroup\$ Could you describe or show your graph so the type of error can be understood? Is this a gain error, the graph goes through 0,0 but not 5,5. Or is it an offset error, meaning 0,0 is 0,0.005 and 5,5 is 5,5.005? \$\endgroup\$
    – owg60
    Nov 19, 2016 at 19:45
  • \$\begingroup\$ Below you see all the information in my excel calculation of the least mean square and its graph. [![enter image description here][1]][1] and here is the graph where excel did the calculation itself. [![enter image description here][2]][2] \$\endgroup\$
    – D-Antonio
    Nov 20, 2016 at 18:09
  • \$\begingroup\$ I see i am not able to post a picture in the comments. But the formula i get from using the least mean square formula is : Y=0.9972X+0.0053. actually according to my proffessor i have a gain and offset error. This is due to the fact that my R3 and R4 are not equal to eachother to have a gain of 1. that is why h said i need to something special to my Vref. i hope this is enough clarification for you to understand. \$\endgroup\$
    – D-Antonio
    Nov 20, 2016 at 18:10
  • \$\begingroup\$ D-Antonio, under your question find edit. Then you can post the pictures to your question. Also, I did some more looking at the circuit and think you need to change the reference to the error amp. Please see my answer. \$\endgroup\$
    – owg60
    Nov 20, 2016 at 18:13
  • 1
    \$\begingroup\$ @D-Antonio If you put the links in as text then someone might edit them in as links for you. We try to be helpful :) \$\endgroup\$ Nov 20, 2016 at 18:56

1 Answer 1


Ok, we are closer to being to having the same understanding. I started with the schematic in your question and created this simulation;

PWM simulation

Here is the response with the schematic updated to match the photo and R3 changed to 30.3k.

Update plot with intentional gain error

I'm sure the components are better than 1%.

The plot says 5-vfilter because I used a filter block and subtracted the output from 5 to invert it. I did not model the inverter or filter. The inverter can introduce gain error the same as the error amp.

  • \$\begingroup\$ The divider of the for the non-inverting input already has VCC as input. this gives the non-inverting input Vref of 2,5V. i also tried to remove R2 before,so R1 has 5V ,but this did not work. i will try it with Vref as input. why wil i not be able to have a PWM of 0-100%? \$\endgroup\$
    – D-Antonio
    Nov 20, 2016 at 18:18
  • \$\begingroup\$ I don't know in the circuit where Y out is being measured. But looking at your graph and tables, this is a gain error. The slope of the line should be one and it is slightly different. The gain is set by resistors which have some tolerance. You could remove this error by selecting resistors. Find two that exactly match. The other way if to replace one with a little less than 30k and put a variable resistor in series with it so you can adjust to match the other. \$\endgroup\$
    – owg60
    Nov 20, 2016 at 19:19
  • \$\begingroup\$ I just added my own schematic to my question with all the values en where Y is measured. My frequency was 1Khz. So the tolerance of all my resistors should be equal and as low as possible ? \$\endgroup\$
    – D-Antonio
    Nov 20, 2016 at 21:46
  • \$\begingroup\$ Which simulation program do yu use , because my lt Spice is not coöperative.? \$\endgroup\$
    – D-Antonio
    Nov 21, 2016 at 16:57
  • \$\begingroup\$ I'm using a very old student version of pspice. It can be tricky to simulate circuits like this. The reason for the VCVS is because pspice doesn't have models for the opamp and comparitor. If you are using VCVS too, you might try adding some stray capacitance. In my answer schematic this was done to get convergence. The capacitor at the bottom labeled cstray is just to help the simulator. I've changed my components to match your photo as best I could. I can't read both resistor on the triangle so made both 12k. Normal schematic gives 4.992V. Change R3 to 30.3k gives 4.9674V. \$\endgroup\$
    – owg60
    Nov 22, 2016 at 2:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.