Integration_of_C2000_Microcontrollers_with_MATLAB_Simulink_Embedded_Coder_A_Real-Time_Control_Application
Integration_of_C2000_Microcontrollers_with_MATLAB_Simulink_Embedded_Coder_A_Real-Time_Control_Application
Control Application
Mohammad Abidur Rahman Ali A. Abushaiba Akrem M. Elrajoubi
Student Faculty advisor IEEE IEEE member
School of Engineering & School of Engineering & Engineering College of Engineering
Engineering Technology Technology University of Misurata
University of Arkansas University of Arkansas Misurata, Libya
Little Rock, AR, USA Little Rock, AR, USA [email protected].
[email protected] [email protected]
Abstract— C2000™ 32-bit microcontrollers excel in real- applications, such as regenerative braking for electric machines
time control, optimizing closed-loop performance for and active filtering [2]. These processors of the C2000
various applications such as industrial motor drives, solar microcontroller family can be used to develop a control model
inverters, digital power systems, and sensing. The lineup of micro-inverter topology with the help of MATLAB Simulink
offers Premium and Entry-performance microcontroller Embedded Coder and Code Composer Studio [3]. It does not
units (MCUs). This paper explores the integration process require hard programming, which saves time, is more efficient,
of Texas Instruments™ (TI) C2000 microcontroller units and can be executed faster. TMS320F28379D Digital Signal
with MATLAB and Simulink using Code Composer Studio Processor (DSP), a member of the C2000 microcontroller
(CCS) and Embedded Coder (EC) support package for family, is a faster and cheaper controller, proving its efficiency
C2000 microcontrollers. It shows how to set up Simulink to in designing effective PI-type controllers and Model Predictive
program the Digital Signal Processor (DSP) microcontroller Controllers (MPC) for PV systems and power electronic
unit and the communication between the host computer and converters [4], [5]. It has been proven efficient for Artificial
the C2000 target hardware using the LAUNCHXL- Neural Network-based control of five-level inverters to ensure
F28379D launchpad. Basic functions such as Pulse Width selective harmonic elimination [6]. The Embedded Coder
Modulation, Analog Digital Conversion, and Proportional- generates the code automatically, so less time is needed for
Integral controllers are explained. Finally, a closed-loop programming and control implementation. TI C2000 DSPs
control model for a C2000 Digital Power Buck Converter offer a practical and simple control design for DC motors [7].
BoosterPack is implemented, showcasing the effective MATLAB Simulink and Embedded Coder for DSP controller
integration of TI C2000 microcontroller units with help to develop automated control algorithm development
MATLAB, Simulink, and related tools for real-time control methods, solving the problems of long development cycles and
in the power system context. complicated programming for traditional embedded system
Keywords— TMS320F28379D DSP, Code Composer design [8]. MATLAB Simulink environment can also be used
Studio, Embedded Coder, MATLAB Simulink. for real-time simulation of power electronic systems [9].
Despite the widespread usage of C2000 MCUs, limited
I. INTRODUCTION documentation and scholarly articles address the integration of
C2000 microcontrollers, developed by Texas Instruments, it with MATLAB Simulink, with even fewer detailing
represent a family of 32-bit devices engineered explicitly for operational configurations. Moreover, existing resources lack a
real-time control applications. Known for their exceptional comprehensive illustration of the process. This paper endeavors
performance in processing, sensing, and actuation, C2000 to fill this gap by presenting a straightforward, thorough, and
microcontrollers find widespread use in diverse fields, such as accessible guide for programming Texas Instruments™ (TI)
industrial motor drives, solar inverters, digital power systems, C2000 microcontroller units using MATLAB Simulink
electric vehicles, transportation, and sensing and signal Embedded Coder. The paper demonstrates the communication
processing [1]. With a focus on optimizing closed-loop protocol between the host computer and the target model.
performance, the C2000 microcontroller family offers a range Additionally, it furnishes clear instructions for implementing
of models, each tailored to meet the demands of advanced fundamental functions such as Pulse Width Modulation
control applications. They can be used to control bidirectional (PWM), Analog Digital Conversion (ADC), and Proportional-
Buck-Boost DC-DC controllers to ensure improved dynamic Integral (PI) controllers using the MCUs along with
characteristics of the converter at different electrical mathematical calculations. Furthermore, the paper showcases
132
Authorized licensed use limited to: National Chung Hsing Univ.. Downloaded on March 11,2025 at 15:56:20 UTC from IEEE Xplore. Restrictions apply.
cycle, D= 0.5, since 4999.5/9999 = 0.5. As observed, input ports
or dialogs can be used to specify the frequency and duty cycle.
Under the General tab, the Timer period can be specified and
calculated using equations (1) and (2). Each action can be
selected from the list of options (Do nothing, Clear, Set,
and Toggle). For this operation, Action when counter=ZERO is
Set, and Action when counter=CMPA on up-count (CAU) is
Clear. Also, the counting mode can be chosen (Up, Down, or
Up-Down).
𝐶𝑙𝑜𝑐𝑘 𝐹𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦
Timer period = −1 ()
𝑒𝑃𝑊𝑀 𝐹𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦
133
Authorized licensed use limited to: National Chung Hsing Univ.. Downloaded on March 11,2025 at 15:56:20 UTC from IEEE Xplore. Restrictions apply.
Fig. 7. PI controller for the duty cycle of ePWM output.
to the ground point and the power supply DC voltage to pin have been provided to handle data transfer between blocks
ADCINA0 when you design, download, and execute this basic running at different speeds and to convert an input signal to a
model on the DSP board. So, by adjusting the voltage from 0 to specific data type.
3V, you can regulate the duty cycle of this PWM signal. Check
the option labeled "Enable ADC start of conversion for module The TMS320F28379D DSP can be programmed using these
A" on the ePWM block. Similarly, you may use the ADC input fundamental settings; however, a few more things may be done
to adjust the PWM output pulse's frequency when you make it to enhance the efficiency of code output. For example, under
an input port. the code generating advisor's Configuration Parameters box,
Fig. 7 shows an example model of using the PI controller to you can select objectives for the code output, like execution,
change the duty cycle of the ePWM output signal. Here, the ROM, and RAM efficiency. You will get a pop-up window
frequency was set to 40 kHz by making the time period 9999 when you click the "Set Objectives" button, allowing you to
and up counting mode. Convenience of design is crucial for the rank the alternatives. When a model is built, it may be analyzed
system controller to ensure the intended operation. It is evident using the verify model option, and
that the rate transition block and data type conversion block
134
Authorized licensed use limited to: National Chung Hsing Univ.. Downloaded on March 11,2025 at 15:56:20 UTC from IEEE Xplore. Restrictions apply.
directly linked to the pins of the SCI_A module in the F28379D voltage of the converter. Fig. 13 shows the output voltage and
launchpad. You can use Serial Transmit and Receive block, inductor current for different voltage requests. It was seen that
MATLAB script, or frame size for this launchpad to build serial the output voltage follows the reference voltage.
communication. Frame size is used to transmit data when the Alongside Voltage Mode Control (VMC), Average
transmit rate is faster than the receive rate [12]. Current Mode Control is also possible for the DC-DC Buck
converter module using the launchpad. For the Average Current
V. CLOSED LOOP CONTROL EXAMPLE Mode control of the Buck converter, the Control Law
The C2000 Digital Power BoosterPack, BOOSTXL- Accelerator (CLA), a 32-bit FPU processor, of the
BUCKCONV, features a non-isolated, digitally controlled DC- TMS320F28379D DSP can be used. It operates in parallel with
DC buck converter. It offers a quick and easy way to learn about the main CPU and is particularly useful for real-time control
digital power supply control using C2000 MCUs. It has Voltage applications where fast and deterministic execution of control
Mode Control (VMC) and Peak Current Mode Control algorithms is critical. Fig. 14 shows output voltage and inductor
(PCMC). A compatible C2000 launchpad can be used to control current of the Buck converter with Average Current Mode
the board. In this case, LAUNCHXL-28379D has been used to control using Control Law Accelerator (CLA) of TMS320
control the BOOSTXL-BUCKCONV. The DC-DC F28379D microcontroller. The spike in inductor current
synchronous buck power stage regulates the power terminal occurred due to rapid change of voltage request.
block at 2 VDC. The BoosterPack has a permanently connected
7.5-Ω resistive load and a 2-Ω software-controlled active load,
which is useful for testing transient performance and loop
tuning [13]. Fig. 11 shows BOOSTXL-BUCKCONV and its
key components. Fig. 12 shows the BOOSTXL-BUCKCONV
BoosterPack connected to the LAUNCHXL-28379D
launchpad. We used this setup to control the Buck converter
using the launchpad.
A model has been developed for the Voltage Mode Control
(VMC) of the Buck converter [14]. It employs a discrete
proportional-integral (PI) controller to minimize the reference
and output voltage error. The ePWM can be used to generate
gate signals for the voltage control of the converter. Fig. 12
shows the ePWM signals generated by the launchpad to control
the high side and low side of the converter to control the output
Fig. 13. Output voltage and inductor current of the Buck converter with Voltage
Mode Control (VMC).
Fig. 14. Output voltage and inductor current with Average Current Control.
135
Authorized licensed use limited to: National Chung Hsing Univ.. Downloaded on March 11,2025 at 15:56:20 UTC from IEEE Xplore. Restrictions apply.
VI. CONCLUSION [4] S. Lopez-Blandon, S. Pulgarin-Correa, and E. Giraldo, “Adaptive State
Space Embedded Control of a Synchronous Buck Converter,” in 2023
This paper demonstrates the successful integration of the IEEE 6th Colombian Conference on Automatic Control (CCAC), IEEE,
C2000 microcontroller units with MATLAB and Simulink, 2023, pp. 1–6.
facilitated by the Embedded Coder support package for C2000 [5] M. Metry and R. S. Balog, “An Adaptive Model Predictive Controller for
Current Sensorless MPPT in PV Systems,” IEEE Open J. Power
microcontrollers. It provides clear instructions on programming Electron., vol. 1, pp. 445–455, 2020, doi: 10.1109/OJPEL.2020.3026775.
the microcontrollers using MATLAB Simulink Embedded [6] A. E. Toubal Maamar, M. Helaimi, R. Taleb, M. Kermadi, and S. Mekhilef,
Coder and shows fundamental functions like ADC, PI “A neural network‐based selective harmonic elimination scheme for five‐
controller, PWM, etc. The closed-loop control application on level inverter,” Circuit Theory & Apps, vol. 50, no. 1, pp. 298–316, Jan.
2022, doi: 10.1002/cta.3130.
the buck converter shows how the switching signal can be [7] V. K. Awaar, N. Anjali, M. S. Rani, S. Bannuru, S. Tangallapally, and A.
generated easily using the MCU without manual coding and Siri, “Parameter Estimation and Speed Control of FOC Based PMSM
how its parallel processing power can be used to ensure faster Drive Using F28379D,” in 2022 IEEE 2nd International Conference on
system response. This seamless integration proves highly Sustainable Energy and Future Electric Transportation (SeFeT), IEEE,
2022, pp. 1–6.
effective for real-time control applications, such as artificial [8] J. Qiu, C. Zhu, and Y. Wang, “Automatic Fast Experiment System Design
intelligence-based control, PI control of power converters, Based on Matlab Embedded Code,” in 2021 China Automation Congress
renewable energy systems, electric vehicle systems, etc. The (CAC), IEEE, 2021, pp. 7360–7363.
Embedded Coder support package makes generating code [9] J. Aruni, J. Titus, and K. Hatua, “Design of a DSP-based Control Platform
for Real-Time Simulation of Power Electronic Systems,” in 2021 IEEE
easier and faster than writing it manually. This paper 2nd International Conference on Smart Technologies for Power, Energy
highlighted how this integration can speed up work processes and Control (STPEC), IEEE, 2021, pp. 1–6.
in DSP-based solutions, making them more efficient. [10] J. C. Molina Fraticelli, “Simulink Code Generation: Tutorial for
Generating C Code from Simulink Models using Simulink Coder,” 2012.
REFERENCES [11] “Getting Started with Texas Instruments C2000 Microcontroller Blockset
- MATLAB & Simulink.” Accessed: Feb. 28, 2024. [Online]. Available:
[1] Texas Instruments Inc., “The Essential Guide for Developing with C2000 https://www.mathworks.com/help/ti-c2000/ug/getting-started-with-
Real-Time Microcontrollers (Rev. F)”. C2000-example.html
[2] N. Rigogiannis, D. Voglitsis, and N. Papanikolaou, “Microcontroller Based [12] “Serial Communication Using SCI Blocks - MATLAB & Simulink.”
Implementation of Peak Current Control Method in a Bidirectional Buck- Accessed: Jan. 29, 2024. [Online]. Available:
Boost DC-DC Converter,” in 2018 20th International Symposium on https://www.mathworks.com/help/ti-c2000/ug/serial-communication-
Electrical Apparatus and Technologies (SIELA), Bourgas: IEEE, Jun. example.html
2018, pp. 1–4. doi: 10.1109/SIELA.2018.8447148. [13] Texas Instruments Inc., “C2000 Digital Power Buck Converter
[3] A. Elrajoubi, S. S. Ang, and A. Abushaiba, “TMS320F28335 DSP BoosterPack Design Guide (Rev. A)”.
programming using MATLAB Simulink embedded coder: Techniques [14] “Closed Loop Control of a DC-DC Buck Converter - MATLAB &
and advancements,” in 2017 IEEE 18th Workshop on Control and Simulink.”https://www.mathworks.com/help/ti-c2000/ug/dc-dc-buck-
Modeling for Power Electronics (COMPEL), IEEE, 2017, pp. 1–7. converter.html
136
Authorized licensed use limited to: National Chung Hsing Univ.. Downloaded on March 11,2025 at 15:56:20 UTC from IEEE Xplore. Restrictions apply.