# How do calculate / determine the reference voltage for the error amplifier of my analog PWM generator for a 0-100% duty cycle

For a school project I am building an analog PWM generator with 0.1 to full-scale linearity and a duty cycle 0-100%. Powersupply is 5 Volt and 100% is equal to 5V at the output. The frequency 1 Khz.

My circuit is done for like 80%. The problem I have is with the reference voltage of my error amplifier. My research so far has shown that this gives you the ability to have the 0-100% duty cycle.

When I apply a reference of 2.5 Volt, I see that my dutycycle is 50%. When I change Vin to change the duty cycle , it changes with 0.5V to 0% or 100% from reference voltage.

So, 2V = 0%

2,5V = 50%

3V = 100%

Sidenote:

I used the slau508 design and theory, but my design differs slighty because mine is not going to be used for audio, hence why I need to adjust the reference voltage according to my teacher.

How can I fix this so that I can change the dutycycle from 0 to 100%?

I need to have a reference voltage for my error amplifier so that I can have a duty cycle from 0-100% with a voltage change of Vin from 0-5V.

With the reference of 2,5V that I have right now I can only go from 0 to 100 procent with an increase or decrease of 0,5V. This should be 5V in order to change between 0 and 100% dutycycle.

My question is:

How can I calculate or determine what I have to do with the reference voltage in order to have the 0-100% duty cycle with a voltage change of Vin from 0-5V?