TMS320F28335 DSP Programming Using MATLAB Simulink Embedded Coder: Techniques and Advancements
TMS320F28335 DSP Programming Using MATLAB Simulink Embedded Coder: Techniques and Advancements
TMS320F28335 DSP Programming Using MATLAB Simulink Embedded Coder: Techniques and Advancements
net/publication/319219169
CITATIONS READS
5 5,685
3 authors:
Ali A. Abushaiba
University of Kansas
4 PUBLICATIONS 15 CITATIONS
SEE PROFILE
All content following this page was uploaded by Akrem Mohamed Elrajoubi on 28 February 2019.
Abstract—This paper provides a tutorial on how to program entering the “ver” command into the command window.
Texas Instruments™ (TI) TMS320F28335 Digital Signal Using Simulink code generation is more effective than
Processor (DSP) through Code Composer Studio (CCS) writing line by line any code by CCS which takes a long
version 6 and MATLAB Simulink Embedded Coder. First it time for users to program the DSP [6]. Section II presents
shows how to setup Simulink and Embedded Coder and the required settings for the DSP target configuration, while
produce code to program TMS320F28335 and variant of TI’s section III demonstrates the fundamental blocks used in
C2000 DSPs. It describes how to interact between MATLAB power electronics and motor drives applications from
2015b and CCS V6 and provides an explanation of the vital
steps and settings needed to program the DSP. Basic functions
Simulink and their main parameters. Serial Communication
such as Pulse Width Modulation, Analog Digital Conversion, Interface (SCI) transmit and receive blocks are shown in
and Proportional-Integral controllers are explained. Finally, section IV, and then closed loop control model is developed
closed loop control model for a micro-inverter topology is for the micro-inverter topology in section V.
developed.
II. CCSV6 TARGET CONFIGURATION
Keywords— TMS320F28335 DSP, CCS V6, MATLAB
Simulink. First make sure that Code Composer Studio (CCS)
version 6 or 5 is installed. If you have an older version of
I. INTRODUCTION CCS installed, you should upgrade to version 5 or CCS
Designing closed loop feedback multi PWM control version 6 which is now supported in Simulink for code
schemes is much harder and more time consuming in CCS generation. Embedded Coder (EC) works for previous
than in MATLAB Simulink Embedded Coder for Texas versions but they are no longer supported by Texas
Instruments™ TMS320F28335 Digital Signal Processor Instruments. For setting up xMakefile in Simulink which
(DSP). TMS320F28335 DSP is a cheaper controller which tells EC where the CCS 6 compiler is installed among other
proved excellent convergence, and real time control for programs. So MATLAB can call the command lines
significant reduction of output ripple [1]. The code is provided by CCS 6, and where MATLAB can find the
automatically generated using the embedded coder, and so compiler needed to create the makefile code. However,
time for programming and control implementation is “xmakefilesetup” command in MATLAB is no longer
reduced. TI DSPs present effective and simple control needed because of the Embedded Coder Support package
design for DC motors [2]. MATLAB Simulink for DSP for TI C2000 Processors which permits the settings for
controller is highly valuable as model design, simulation, model configuration parameters easily. Type
code generation, debugging and running can be “supportPackageInstaller” command to launch the Support
accomplished for control algorithm [3]. MATLAB Simulink Package Installer Graphical User Interface in MATLAB.
environment is especially recommended for control Then type this command
algorithm implementation into micro controller [4, 5]. The “checkEnvSetup('ccsv5','f28335','check')” in MATLAB, as
goal of this paper is to provide a simple and clear procedure shown in Fig. 1 the tools must be installed properly. For
to begin learning how to program the TMS320F28335 DSP F28335 we do not need header files but we need to install
from Texas Instruments™ (TI) through Code Composer Flash APIs from TI ControlSUITE webpage. In case you
Studio (CCS) and MATLAB Simulink Embedded Coder. need to check the compiler just type in the command
To begin, you need to make sure that you have the window: mex –setup , or mex.getCompilerConfigurations.
Embedded Coder, MATLAB Coder, and Simulink Coder For Matlab 2015a you will need to install the Embedded
toolboxes installed on your PC. Embedded coder sits on top Coder Support package for TI C2000 Processors. But for
of MATLAB and Simulink coder; it allows you to add Matlab 2011b and 2013a versions the library already exists.
device specific code (ADC’s, DAC’s, CAN, etc.) to what it Then we choose C2833x processor for our DSP control
produces by the respective coders. An easy way to check the card.
toolboxes installed on your version of MATLAB is by
Fig.1. MATLAB checkEnvSetup command for F28335 DSP.
A TMS320F28335DSP board is shown in Fig. 4 with the Fig. 7 shows ePWM Block Parameters to generate
blinking GPIO34 LED after running the program. Since this two complementary PWM signals with a frequency of 20
programming was done on the flash memory of the DSP, KHz and duty cycle of 0.5. For frequency of 40 KHz, the
you can turn on and off the USB switch to see that the Timer period would be 1875. But for up counting mode it
program is still working and has not been erased from the would be 3750. The duty cycle is depending on the CMPA
RAM by turning off the power. value and the counting mode specified in Fig.7. Here it is up
counting mode so D= 0.5 since 1875/3750 = 0.5. As can be
III. PWM, ADC, GPIO, AND PI BLOCKS noticed, the frequency and duty cycle can be specified as
TMS320F28335DSP has up to 18 PWM outputs which input ports or via dialog. Under the General tap, the Timer
is adequate to control many three phase power converters. period can be specified and it is calculated as in (1). Every
12 of these outputs are ePWM modules which are shown in action can be chosen from the available choices (Do
Table 1. SYSCLK is set to 150 MHz, which is the nothing, Clear, Set, and Toggle). As can be seen, Action
maximum clock speed of the TMS320F28335 as specified when counter=CMPA on up-count (CAU) is Set, and Action
in the CPU clock. Fig. 5 shows two synchronized enhanced when counter=CMPA on down-count (CAD) is Clear. Also
Pulse Width Modulator (ePWM) blocks together to use the counting mode can be chosen (Up, Down, or Up-Down).
frequency and duty cycle as inputs. Timer period = (150 MHz )/(2 * 20 KHz)=3750 (1)
The pulses shown in Fig. 6 are for the two ePWM
outputs shown in Fig. 5 while they are synchronized with a
phase shift of TBPHS = 1500 (number of cycles for the time
period). Notice that these two ePWM outputs are 180 degree
shifted, the switching frequency is 50 KHz, and each ePWM
has two complementary signals. The duty cycles are 0.33
(=1000/(2*1500)) and 0.23 (=700/(2*1500)) for channel 1
(ePWM1A) and channel 3 (ePWM2A), respectively.
rejection [9]. The reference values for the PI controllers are ePWM1A S1 ePWM1B S2
for the comparison with the ADC output to obtain the
targeted time period for ePWM blocks. Fig.15 shows the ePWM2A S3 ePWM2B S4
IBSRC was designed and developed in reference [10] with ePWM3A S5 ePWM3B S6
the F28335 DSP Card on the prototype.
ePWM4A S7 ePWM4B S8
VI. CONCLUSION
Using MATLAB Simulink embedded coder tools with
no hand writing code is time and money saving, more
efficient, faster execution time, and great for research and
industrial control design. This tutorial gives the instructions
on how to program the TMS320F28335 micro-controller
using make file approach with embedded coder in
MATLAB Simulink 2015b, and then debugging the
program in CCS V6. In this paper, the main steps for the
interaction between MATLAB 2015b and CCS V6 are
investigated and explained. Different versions of MATLAB
have some differences to interact with CCS, F28335 DSP
could be programmed using MATLAB 2011b and 2013a,
but there are some errors for flash programming mode.
IBSRC system was controlled by F28335 DSP through
Fig.15. Interleaved Isolated Boost Series Resonant Converter Prototype
MATLAB Simulink Embedded Coder. The Embedded
[10]. Coder Support package for TI C2833x Processor provides
the fundamental blocks needed for any power electronic,
smart grid or motor drives applications.
REFERENCES
[1]. L. Katzir, Y. Loewenstern, B. Bishara and D. Shmilovitz,
"Implementation of a high voltage power supply with the
MATLAB/Simulink embedded coder," 2014 IEEE 28th Convention of
Electrical & Electronics Engineers in Israel (IEEEI), Eilat, 2014, pp. 1-4.
[2]. R. Duma, P. Dobra, M. Abrudean and M. Dobra, "Rapid prototyping of
control systems using embedded target for TI C2000 DSP," 2007
Mediterranean Conference on Control & Automation, Athens, 2007, pp. 1-
5.
[3]. S. Yuan and Z. Shen, "The Design of Matlab-DSP Development
Environment for Control System," 2012 Third International Conference on
Digital Manufacturing & Automation, GuiLin, 2012, pp. 903-906.
[4]. R. Grepl, "Real-Time Control Prototyping in MATLAB/Simulink:
Review of tools for research and education in mechatronics," 2011 IEEE
International Conference on Mechatronics, Istanbul, 2011, pp. 881-886.
[5]. B. dos Santos, R. E. Araújo, D. Varajão and C. Pinto, "Rapid
Prototyping Framework for real-time control of power electronic converters
using simulink," IECON 2013 - 39th Annual Conference of the IEEE
Industrial Electronics Society, Vienna, 2013, pp. 2303-2308.
[6]. J. C. Molina Fraticelli, “Simulink Code Generation Tutorial for
generating C code from Simulink Models using Simulink Coder” NASA
MARSHALL SPACE FLIGHT CENTER 2012. Available at:
https://www.mathworks.com/matlabcentral/answers/uploaded_files/56491/
Simulink%20Code%20Generation.pdf
[7].http://www.mathworks.com/help/ecoder/ug/tutorial-using-xmakefile-
with-code-composer-studio-4-x-
1.html?searchHighlight=code+composer+studio.
[8]. http://www.ti.com/tool/tmdscncd28335
[9]. http://www.mathworks.com/products/embedded-coder/webinars.html#.
[10]. L. A. Garcia-Rodriguez, C. Deng, J. C. Balda and A. Escobar-Mejía,
"Analysis, modeling and control of an interleaved isolated boost series
resonant converter for microinverter applications," 2016 IEEE Applied
Power Electronics Conference and Exposition (APEC), Long Beach, CA,
2016, pp. 362-369.