exp4

.pdf

School

University of Colorado, Boulder *

*We aren’t endorsed by this school

Course

4517

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

pdf

Pages

13

Uploaded by BailiffAntelope7746

Report
1 Experiment 4 Introduction to TI C2000 microcontroller, Code Composer Studio (CCS) and Matlab Graphic User Interface (GUI) 4.1 Objective This experiment is in continuation of Experiments 2 and 3. In Experiment 2, the students learned how to generate a PWM signal on one of the I/O ports of the target board (microcontroller) by using Matlab/Simulink. In Experiment 3, the students learned how to read and import a square-wave signal from one of the I/O ports of the microcontroller and plot it in Matlab/Simulink. In this experiment, the students learn how to (i) generate two complementary PWM signals on two I/O ports of the microcontroller and (ii) read and import the two generated PWM signals from the other two I/O ports of the microcontroller and plot them in Matlab/Simulink. 4.2 Building the Power Electronic Simulink Model 1. Simulink Program Create a new Simulink model to generate two PWM signals and also to read two square wave signals. For component configurations, use your knowledge/background from Experiments 2 and 3. A typical Simulink model developed for this purpose is shown in the following figure. Target Preference Board block
2 2. Configuration of the Blocks, Parameters, and Components a) Configure your Target preference board as you did in Experiments 2 and 3. b) Go to S imulation---- >Configuration Parameters Change the solver to fixed step and leave the fixed step-size as ‘ auto ’ only. c) Setting a Sampling Time for Simulink Blocks You must choose ‘-1’(inherited) instead of specific numbers(ex. 1e-5sec) for all the blocks. d) ADC Block parameters: Make sure to choose correct SOC trigger number and input channel. Ex: use if you use SOC0 then use input channel ADCINA0, for SOC1 use ADCINA1 etc. e) PWM Block Configurations Period and duty cycle must be controlled by “input ports”. You can use either a pair of a PWM block or two different PWMs for your design. Ex) PWM1A / PWM1B or PWM2A / PWM2B…, etc. f) PWM Time Period and Duty Cycle Setting Duty cycle must be controlled in a percentage format. For time period, using clock cycles is recommended. Ex: For clock cycle calculation use the following equation: Clock cycles (pts.) = desired time period (sec) * Target board frequency (60 MHz) 2400 pts = 40e-6s*60Mhz .
3 The ePWM block parameters which have to be changed are marked in the figures below:
4 4.3 GUI Program 1. Development of the GUI Develop a GUI program to control the duty cycle and period of the generated PWM waveforms and plot the imported square waveforms. For this purpose, you need to use the following components in your GUI program. Specify the Tag names for the components and change/edit the m-code associated with the GUI accordingly. 2. Editing the exp4cntrGUI m-file Edit the m-code associated with your GUI program to include the following features/functionalities. a) Plot/Adjust the Axis Write this code from line 64 % Initial setting for two axes% set(handles.figure1, 'visible' , 'off' ) axes(handles.axes1); set(handles.axes1, 'xlim' ,[0 200]); set(handles.axes1, 'ylim' ,[-1 5]); set(handles.axes1, 'xlimmode' , 'manual' ); set(handles.axes1, 'ylimmode' , 'manual' ); set(handles.axes1, 'layer' , 'bottom' ); set(handles.axes1, 'nextplot' , 'add' ); xlabel( 'fixed steps' ); ylabel( 'pwm1' );
5 % Plot some dummy data first to get axes handle % allNaN = NaN*ones(1,200); plot(allNaN); handles.h1 = line( 'parent' , handles.axes1); set(handles.figure1, 'visible' , 'off' ) axes(handles.axes2); set(handles.axes2, 'xlim' ,[0 200]); set(handles.axes2, 'ylim' ,[-1 5]); set(handles.axes2, 'xlimmode' , 'manual' ); set(handles.axes2, 'ylimmode' , 'manual' ); set(handles.axes2, 'layer' , 'bottom' ); set(handles.axes2, 'nextplot' , 'add' ); xlabel( 'fixed steps' ); ylabel( 'pwm2' ); % Plot some dummy data first to get axes handle % allNaN = NaN*ones(1,200); plot(allNaN); handles.h2 = line( 'parent' , handles.axes2); b) Initialize the Code Composer Studio settings (Continuation) %intializing CCS settings global cc; cc=ticcs; configure(cc.rtdx,1024,4); %setting buffer memories for RTDX open(cc.rtdx, 'ichan1' , 'w' ); %open RTDX channel for ichan1 open(cc.rtdx, 'ichan2' , 'w' ); %open RTDX channel for ichan2 open(cc.rtdx, 'ochan1' , 'r' ); %open RTDX channel for ochan1 open(cc.rtdx, 'ochan2' , 'r' ); %open RTDX channel for ochan2 enable(cc.rtdx, 'ichan1' ); %enable ichan1 RTDX channel enable(cc.rtdx, 'ichan2' ); %enable ichan2 RTDX channel enable(cc.rtdx, 'ochan1' ); %enable ochan1 RTDX channel enable(cc.rtdx, 'ochan2' ); %enable ochan2 RTDX channel enable(cc.rtdx); %enable RTDX cc.rtdx; %link to CCS c) Plot data on the Axes of GUI and show instantaneous value of the Ydata in the Edit box (Continuation) % Plotting datas in your GUI% frameSize = 1; xlimit = 200; NumOfFrames = xlimit/frameSize; yLines = handles.h1; yLines2 = handles.h2; set(handles.figure1, 'visible' , 'on' ); r = cc.rtdx;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help