I am trying to simulate an inverter with 4 ideal switching devices in LTSpice. I have the compensator working, however I don't the correct equation in terms of calculating the duty cycle.
What I have tried is this:
V=limit(abs((V(V_OUT))/391 + 1.1*V(Icomp)/391) ,0.01,0.99)
Which is essentially limiting the duty cycle from 0.01 to 0.99 and adds sinusoidal voltage output scaled down by 391 and the compensator signal. Is there a problem in the way I generate the duty cycle signal, because it has distortion and reduction in amplitude of the output signal when inductive load is simulated.
NOTE: ADC range is from 0-686, 391 is just a fixed scaler.
I could provide more details, but I just want to find out the correct way of calculating the duty cycle. Nonetheless if more information is needed I will post it.