Experiment #3 – Introduction to TI C2000 microcontroller, Code Composer

Studio (CCS) and Matlab Graphic User Interface (GUI)

Objectives – The objective of Experiment #3 is to familiarize the students with the TI C2000
microcontroller, Code Composer Studio, and Matlab Graphic User Interface (GUI). Students will design a
power electronics control module which can plot the data from the target board through the Integrated
Development Environment (IDE). The analog PWM signal data is to be injected from Function
Generator.

Integrated Development Environment (IDE)
The concepts of rapid prototyping and digital control techniques in power electronics in the developed
laboratory are realized based on using the TI C2000 micro-controller [13] in conjunction with the
Matlab/Simulink software based on an integrated development environment. The integrated development
environment is a combination of software tools which allows implementation and experimentation
processes to be carried out conveniently and interactively both under one single roof. As depicted in Fig.
2, Matlab/Simulink environment is used for the design, optimization, and off-line simulations of the
models and power electronic circuits. The Real Time Workshop converts the Simulink model to C
programming code [14]. Subsequently, the C code is automatically compiled to the assembly language for
the TI C2000 micro-controller, assembled, link-edited, and downloaded. Finally, Matlab Graphical User
Interface (GUI) is used to run, tune, and monitor the running process.




Lab equipment
1) Matlab/Simulink
2) Matlab GUI(Graphical User Interface)
3) Code Composer Studio
4) C2000 Microcontroller(TMS320F28035)
5) Blackhawk USB2000 emulator

Lab procedure

A. Building a simulation model in Matlab/Simulink

1. Create a new Simulink model



2. Initializing the Simulink model by deploying the Target Preference Board block to
your Simulink model




If you get this warning window, click “YES”.

3. Configuration of the Target Preference Board

If you double click the Target Preference Board block, you will be able to open the
configuration window like below. And then, click the Get from IDE button. The Target
Preference Board will automatically configure your Simulink model by linking to Code
Composer Studio.


IDE Support will show the information of TI C2000 micro-controller, and confirm the
micro controller setting by clicking OK button.


4. Save your Simulink model in temporary folder under C drive

You should save your Simulink in the temporary folder under C drive to link to Code
Composer Studio.



Ex) C:\TEMP\exp2\exp2mdl


5. Designing a power electronics control Simulink model

Add the ADC, Rate Transition, Constant, IQN x int32, Data Type Conversion, and
To RTDX in your Simulink model.











6. Configuration of the ADC block
Open the configuration window of ADC block by double clicking the block, and then
configure the ADC block by following the below settings.



7. Configuration of the Rate Transition block
Handle transfer of data between ports operating at different rates. Configuration
parameters are shown in the below figures.


8. Configuration of the scale factor for the ADC and Constant block
Piccolo F 28035 has a built-in 12-bit ADC(Analog to Digital Converter), input of ADC
should be regulated between 0 to 3.3 V. And, a division of 0.83 is added to the lower
side. According to the input, ADC will convert the analog signals to the 12 bit digital
signal. That is, when 3.3 V input is applied to the ADC, it will convert to the maximum
digital value, 4095(2^12). When the 0 V is applied to the ADC, it will convert to the
minimum digital value, 0. Therefore, converted analog signal should be re-scaled by the
scaling factor, 3.3/4086/0.83 = 0.000971.

DSP based power electronic control system is run on the fixed-data calculation method,
thus, the constant source block should be configured as the fixed 32 bit integer. The
configuration of the constant block is depicted in the below figure.


9. Configuration of the Data Type Conversion block
Convert the input to the data type and scaling of the output. Since the RTDX requires the
int32 data type, input must be converted to the data type of int32.


10. Configuration of To RTDX block

11. Configuration of simulation parameter
Set the fixed step size at 1e-5 sec and build action as build only.






B. Designing a control interface by using the Matlab Graphic User Interface(GUI)
1. Starting GUI


Or type GUIDE in the command window, and GUIDE Quick Start dialog will pop up
in your MATLAB.

2. Creating a new project
Selecting the ‘Blank GUI(default)’, and then click the ‘ok’ button, the GUIDE layout
editor will appear in your MATLAB like below.

GUIDE layout has below components in component palette:
: Push Button
: Slider
: Radio Button
: Check Box
: Edit Text
: Static Text
: Pop-up Menu
: List box
: Toggle Button
: Table
: Axes
: Panel
: Button Group
: ActiveX control

3. Designing the control interface of plotting data from the target board
This control interface consists of one Axes, one Edit box, two Push Buttons, and two
Static Text. The axes box will plot obtained data from the DSP as well as showing its
numerical value on the edit box. Two Push Buttons will be used as Run and Halt
respectively. Two Static Texts will be used to label each component. The sample
control interface is shown in the below figure.





4. Save the designed control interface, model and m-file under C:\TEMP


5. Editing m-file code of GUI
Initializing output plot settings (You may type the below code after line 64)
% Initializing output plot settings %
set(handles.figure1,'visible','off')
axes(handles.axes1);
set(handles.axes1,'xlim',[0 100]);
set(handles.axes1,'ylim',[-1 5]);
set(handles.axes1,'xlimmode','manual');
set(handles.axes1,'ylimmode','manual');
set(handles.axes1,'zlimmode','manual');
set(handles.axes1,'climmode','manual');
set(handles.axes1,'alimmode','manual');
set(handles.axes1,'layer','bottom');
set(handles.axes1,'nextplot','add');
xlabel('Fixed steps');
ylabel('Analog output(V)');
% Plot some dummny data first to get axis handles %
allNaN = NaN*ones(1,100);
plot(allNaN);
handles.h1 = line('parent',handles.axes1);



Initializing CCS settings
% Initializing CCS settings %
global cc;
cc=ticcs;
configure(cc.rtdx,1024,4);
open(cc.rtdx,'ochan1','r');
enable(cc.rtdx,'ochan1');
enable(cc.rtdx);
cc.rtdx



Plotting data on the Axes of GUI and showing numerical Ydata values on the
Edit box.
% Read data from Target Board, and plot them on the axes1 %
frameSize = 1;
xlimit = 100;
NumOfFrames = xlimit/frameSize;
yLines = handles.h1;
set(handles.figure1,'visible','on');
r = cc.rtdx;

while(isenabled(cc.rtdx))
set(yLines, 'ydata', allNaN, 'xdata', [1:xlimit]);
pause(1e-5);
for k = 1:NumOfFrames
if ~ishandle(yLines)
return;
end

yAll = get(yLines,'ydata');
x = (k-1)*frameSize+1;
y = (k-1)*frameSize+frameSize;

% Read Data from the Target through RTDX %
numMsgs = r.msgcount('ochan1');

if (numMsgs > 0),
if (numMsgs > 1),
r.flush('ochan1',numMsgs-1);
end
yAll(x:y) = readmsg(cc.rtdx,'ochan1', 'int32');
set(handles.dataedit,'String',num2str(yAll(y)));
end
set(yLines,'ydata',yAll,'xdata',[1:xlimit]);
pause(1e-5);
end
end


Coding for “Run” and “Halt” button
% --- Executes on button press in Run.
function Run_Callback(hObject, eventdata, handles)
% hObject handle to Run (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see
GUIDATA)
global cc;
run(cc);

% --- Executes on button press in Halt.
function Halt_Callback(hObject, eventdata, handles)
% hObject handle to Halt (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles structure with handles and user data (see
GUIDATA)
global cc;
halt(cc);


C. Implementation

1. Turn on the TI C2000 micro-controller
You must turn on the TI C2000 micro-controller by selecting the USB side of toggle
switch.

2. Check the connection between the Matlab and TI C2000 micro-controller
Type “ticcs” in the Matlab command window, and you can check the
connection of TI C2000 micro-controller with Matlab.

3. Build C code language from simulation model
Users can build the simulation model by clicking the build button in the simulation
toolbar.

And then, IDE link links to Code Composer Studio to generate C code. If build is
completed, Code Composer Studio must be linked like below.

4. Loading C code on the target board
Since the build action is selected as ‘build’, use must load the C code on the target
board manually by selecting ‘load program’ command in the ‘File’ option.



5. Run the m-file
You can run the control interface by clicking RUN button of toolbar of m-
file.


6. Plotting the PWM waveform in GUI


Note : Analog signal is connected to ADC A0 port for this lab manual

Sign up to vote on this title
UsefulNot useful