How do I read the values from signals using Link for Code Composer Studio 1.3.1 (R14)?

3 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
To bring the signals into MATLAB for further analysis, you can make signal lines in the model visible to Code Composer Studio. Once the signal is visible (or accessible) via CCS, you can import the data into MATLAB and analyze the results.
For example, consider the attached modellook at the model c6713dskANC_mod.mdl. The model is modified from the Time Domain Acoustic Noise Canceler demo from the Embedded TI C6000 demo section. Please observe the following:
1. Double-click the Noise Canceling Algorithm block.
2. In the signal from the blue Line In C6713 DSK ADC block to Sum block, I have named the signal 'sig1'.
3. Right-click on sig1 and select Properties to open up the Signal Properties dialog box.
3. Click on the 'Real-Time Workshop' pane.
4. Notice that the 'RTW Storage Class' field has been changed from the default 'Auto' to 'ExportedGlobal'.
5. The above 4 steps are the same for the signal from the Sum block to the LMS Filter block. This signal is named 'sig2'.
The key is that the signal is given a name and the 'RTW Storage Class' field is changed to 'ExportedGlobal'. With these changes, CCS can access the value of the signal.
You can then import the signal into MATLAB by following these steps:
1. Start the simulation as you normal do to execute the demo.
2. Once the demo is running on the TI board, execute the following code:
%
cc = ccsdsp; % create a link to CCS
data_size = 100; % the number of samples we want to obtain
data1 = zeros(data_size,2); % pre-allocate the data array to be collected
data2 = zeros(data_size,2); % pre-allocate the data array to be collected
% Use a FOR-loop to collect 1 data at a time
for i = 1:data_size
halt(cc); % pause the TI chip so we can read the data
data1(i,:) = read(cc,address(cc,'sig1'),'uint16',2); % read the data from sig1 at this point in time
data2(i,:) = read(cc,address(cc,'sig2'),'uint16',2); % read the data from sig2 at this point in time
run(cc); % resume the TI chip
end
% plot your data from data1 and dat2
The general idea of the above code is to create a link to CCS with CCSDSP. Once the connection is made, you can use READ and ADDRESS to read the contents of the sig1 and sig2 signals. Once you collect the data, you can use MATLAB's PLOT to visualize the data.

More Answers (0)

Categories

Find more on System Composer in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!