This example shows how to use the CAN Calibration Protocol (CCP) block to monitor model signals and tune parameter values in the application code running on the target hardware. You can use either use Monitor and Tune or a third-party calibration tool to interact with the application. The parameters can be loaded in the hardware flash memory and copied to the RAM during initialization.
Vector-Informatik CAN hardware and drivers must be installed on your host computer, and the baud rate must be set to 1 MBd to match the processor CAN configurations. For more information, see Set Up CAN Communication with Target Hardware.
Spectrum Digital F2812/F2808/F28335 eZdsp board or F2808/F28035/F28044/F28069/F28335 controlCARD with Peripheral Explorer kit.
These are the Simulink models available for different C2000 processors:
The example model c28x_ccp_ert.slx can be used for Texas Instruments™ Piccolo F2803x/F2806x, F28x3x, F280x, F281x, F2807x, F2837x, and F28004x target hardware. By default, the F28335 target hardware is selected.
To change the target hardware, browse to Configuration Parameters > Hardware Implementation > Hardware board.
During code generation, an
ASAP2 file is generated. The
ASAP2 file contains symbol and memory address information. Either External mode or a third-party calibration tool can use the generated ASAP2 file to log the signals and update the parameters on the real-time application generated for the model.
ASAP2 file generation, browse to Configuration Parameters > Code Generation > Interface and select the ASAP2 interface option.
While opening the model c28x_ccp_ert.slx, a script is processed as a pre-load function callback. This callback can be viewed by selecting File > Model Properties > Callbacks > PreLoadFcn.
c2000_ccp_data.m callback sets the Simulink® signals and parameters, thereby resolving the Simulink objects needed for the CCP DAQ lists and Simulink tunable parameters. Now, you can monitor the model signals and tune parameter values in real-time using CCP.
Browse to Configuration Parameters > Hardware Implementation > Hardware board, and select the required hardware board.
Ensure that Communication interface is set to CAN. The selection can be made at Configuration Parameters > Hardware Implementation > Target hardware resources > External Mode > Communication interface.
Open Hardware tab and click Monitor & Tune.
Use the diagnostic viewer to follow the build progress, and wait until the code loads and runs on the target hardware.
Observe the logged data on the scope.
The model c28x_ccp_ert.slx contains a variety of signals and parameters that can be logged or changed in real-time on the target hardware. Parameter tuning and signal logging are enabled by the CCP block included in the model. Additionally, when the model is built, it must be configured to generate an ASAP2 file. The ASAP2 file contains information about the signals and parameters that are available for logging or tuning in the real-time application.
The model contains a simple counter with parameterized step size,
STEP_PARAM takes advantage of a custom storage class package labeled
tic2000demospkg to load the parameters on the flash memory and run them from the RAM for calibration using the
ramfuncs section available in the memory map.
For this example, a custom storage class package labeled
tic2000demospkg has been created. Run cscdesigner -advanced tic2000demospkg to view the definition of the
This model can be run from the flash memory (standalone) and also from the RAM. In both cases,
STEP_PARAM is stored in the ramfuncs section. You can update the parameter
STEP_PARAM and log the output of the counter, COUNTER_SIGNAL. Additional signals available for logging are SINE_SIGNAL, PULSE_SIGNAL, and the RANDOMx signals.
To change the parameter
STEP_PARAM in the real-time application:
Change its value,
STEP_PARAM.Value, in the MATLAB workspace.
Update the model to apply this new value to the real-time application by selecting Simulation > Update Diagram or pressing Ctrl+D.
As an alternative to Monitor and Tune, you can use a third-party calibration tool for signal logging and parameter tuning. The same signals and parameters that are available with External mode may be logged or updated using the third-party calibration tool. While using a third-party calibration tool, ensure that the tool is set in compliance with the word addressable nature of the Texas Instruments C2000 processors (16-bit addressable).