This example shows how to model a controller for the DC/DC buck converter using the Embedded Coder Support Package for Texas Instruments® C2000 Processors. The model runs on a TI F28377S or F28379D Launchpad connected to the C2000 DPS BoosterPack.
By running the models provided in this example on the host computer, you can:
Simulate a controller for the DC/DC buck converter plant model.
Generate code for the controller and load it on the LaunchPad.
Monitor signals and tune parameters on the host computer.
Before you start with this example, install these MathWorks® products:
Instrument Control Toolbox™
DCDC_Buck_Sim.slx can be used to simulate the controller for the DC/DC buck converter.
f28379D_DCDC_Buck.slx can be used to generate code and load it on the F8379D LaunchPad.
f28377s_DCDC_Buck.slx can be used to generate code and load it on the F8377S LaunchPad.
c2000_host_read_12M.slx can be run on the host computer to log signals and tune parameters.
The f28379D_DCDC_Buck model consists of these subsystems:
Controller: The discrete proportional integral (PI) controller minimizes the error between the reference voltage and the output voltage. The duty cycle of the PI controller is limited to 60% of the PWM time period.
DC/DC Buck Converter: Simscape™ blocks are used to model the DC/DC buck converter circuitry.
Dashboard Controls: Used to set the reference voltage, switch on/off active load, and tune proportional and integral gains.
Run the Model
Open the f28379D_DCDC_Buck model, and click the Run button to simulate the model. The initialization file
DCDC_Buck_Param.m loads the variables required for the simulation.
Observe the output waveforms on the scope blocks. You can tune the input parameters using the dashboard controls.
In the f28379D_DCDC_Buck model, the PI controller is configured to run on the F28379D Launchpad. The Hardware Interrupt block schedules the interrupt service routine (ISR) tasks.
Run the Model on the LaunchPad
Open the f28379D_DCDC_Buck model and generate code by pressing Ctrl+B.
Follow the build process by opening the diagnostic viewer using the link provided at the bottom of the model canvas. After the code is loaded on the board, a blue LED blinks on the LaunchPad, indicating that the code is running.
Note: On the F28379D processor, this example runs on CPU1. Ensure that the program running on CPU2 is not using the peripherals that are used by CPU1.
Configure and Run the Model on the Host Computer
1. On the host computer, browse to Device Manager > Ports (COM & LPT) to find the COM port.
2. Set the COM ports of the following blocks in the c2000_host_read_12M model to match the COM port of the host computer:
c2000_host_read_12M > Serial Configuration
c2000_host_read_12M > Serial Receive
c2000_host_read_12M > Serial Send > Serial Send
3. Click on the Run button to run the model.
For more information on using the serial connection for your hardware, see http://processors.wiki.ti.com/index.php/Using_the_serial_adapter_of_XDS100.
Monitor the Signals
While the model runs, you can monitor the following signals on the scope:
I_FB Current: The real-time current flowing through the inductor (L1). 4095 ADC counts is equivalent to 6.8333 A inductor current.
V_FB Voltage: The measured output voltage of the system. 4095 ADC counts is equivalent to 6.0909 V output voltage.
Tune the Parameters
While the model runs, you can tune parameters using the following dashboard blocks:
Voltage Request: Change the output voltage demand. This parameter is the main request for the control loop. The controller algorithm compares the Voltage Request value with the measured output voltage and adjusts the PWM duty cycle towards achieving the output voltage.
Active load: Turn the active load present on the hardware on or off. This parameter allows you to add an extra load resistor to study the effect of abrupt changes in the load circuit.
P Gain: Change the proportional gain of the controller algorithm. You can change this parameter to study the robustness of the controller. Large, abrupt changes may lead to instability of the controller; apply changes smoothly.
I Gain: Change the integral gain of the controller algorithm. You can change this parameter to study the robustness of the controller. Large, abrupt changes may lead to instability of the controller; apply changes smoothly.