Last Updated:

Simulation of Buck Converter using discrete PID in LTSPICE

Andrew Mosqueda
Andrew Mosqueda

If you are in a hurry and want to immediately verify the simulation, download and unzipped the file below then run the buck.asc file in LTSPICE:

Discrete PWM buck converter

Below left is the schematic on the buck.asc file and below right should be the result of the LTSPICE simulation.
LTSPICE Digital PWM Buck Converter

Introduction

This article presents a LTSPICE simulation of a PWM buck converter controlled by a discrete PID. The simulation result will be compared to the result of the actual implementation of a digitally controlled buck converter (Buck converter). Below table is a comparison of the source code from the the actual implementation (DSPIC33 IC) and the components used in this LTSPICE simulation.

MPLAB (DSPIC33) Source CodeLTSPICE component / parameter

PARAMETERS

#define target_voltage  3.3
#define reference       666.7*target_voltage + 17.6
#define p_gain          0.1
#define i_gain          0.05

PARAMETERS

.param target_voltage=3.3 p_gain=0.1 i_gain=0.05
.param reference=(666.7*target_voltage)+17.6

ANALOG TO DIGITAL CONVERSION

(use the default configuration of ADC)

ANALOG TO DISCRETE CONVERSION

LTSPICE Analog to Digital Conversion

ERROR CALCULATION

n16_error = n16_reference - ADCBUF1;

ERROR CALCULATION

LTSPICE Error calculation

INTEGRATION

n16_integrator_memory = n16_integrator_memory +
 i_gain*n16_error;

INTEGRATION

LTSPICE Discrete Integrator

PROPORTIONAL

n16_proportional = p_gain*n16_error;

PROPORTIONAL

LTSPICE proportional computation

DUTY CYCLE

PG7DC = PG7PER - n16_integrator_memory
 - n16_proportional;

DUTY CYCLE

LTSPICE Duty Cycle

PWM GENERATION

Configured in MCC PWM7, pwm freq=40kHz,
master clock frequency=8MHz

PWM GENERATION

LTSPICE PWM Setting

LTSPICE PWM Generator

Note: I used the floor() function in LTSPICE to convert the values into discrete.

 

Result

Below is the resulting waveform from 9.68ms to 10ms of the simulation. We can see that the on time width measured is 3.34ms which is only 16.5% duty cycle. 

LTSPICE PWM waveform

In the actual implementation, the duty cycle measured by the oscilloscope was 20%. Most likely cause why the actual implementation has higher duty cycle is that the MOSFET used in the actual implementation has a higher turn on resistance (BSS308PE Rdson=130mΩ@4.5V). The MOSFET (IRF7210) I used in the LTSPICE simulation has a Rdson of only 5mΩ. I changed the MOSFET to part number FDC5614P which has a Rdson value of  105mΩ and run the simulation again, the result below is now similar to the actual implementation.

LTSPICE PWM Buck Converter waveform
PWM on pulse width increased with higher Rdson

Conclusion

It was demonstrated that discrete control of PWM can be simulated in LTSPICE that can generate similar result with an actual implementation. It is better if we use the right part model. For example, the Rdson has a significant impact on the duty cycle.

Comments