MATLAB: What are some Modeling techniques when developing a Simulink Application for TI C2000

applicationfaqmodellingsimulinktechniquestic2000

What are some Modeling techniques when developing a Simulink Application for TI C2000? 

Best Answer

1. The following links provide a quick reference to setting up and getting started with Modeling your application using the Embedded Coder TI C2000 Hardware Support Package:
2. The following links provide examples for the TI C2000 Hardware Support Package that can help to quickly get started with designing:
3. When you set the Fixed-step size for your application (fundamental sample time) to "auto", the solver will determine the correct sample time for the model to run using sample time settings you've chosen on the blocks in the model. You can also force the model to execute at a specific sample time by assigning it to the Fixed-step size (fundamental sample time), (i.e. a value of 0.1 means 100ms sample time) as long as the block sample times are integer multiples of this value. 
4. Function-Call Split block is a great way to control the execution order of the subsystems. This scenario is specifically applicable for TI C2000 applications that deal with SPI or I2C based peripherals as one needs to follow a specific sequence of commands to initialize them. Please refer to the "Initialization" subsystem in the shipping example "c28x_i2c_sensor" to get more details on the usage. 
5. Within the subsystem, the execution order of the blocks can be controlled using the block priority. Right-click on the given block and select properties to assign the priority number. A lower value translates to a higher priority. Please refer subsystem "c28x_spi_eeprom_interrupt/Write EEPROM Data/Write Enable" in the shipping example "c28x_spi_eeprom_interrupt". Notice here that SPI Transmit block with priority 1 executes first followed by SPI Recieve block with a priority of 2. 
6. Simulink executes all blocks within an atomic subsystem before moving on to the next block. Conditionally executed subsystems are atomic. Unconditionally executed subsystems are virtual by default. You can, however, designate an unconditionally executed subsystem as atomic (see "c28069pmsmfoc_cla/FOC Alogrithm/Torque Control Algorithm/Atomic Hall Reading" from TI C2000 Support package shipping example). This is useful if you need to ensure that a subsystem is executed completely before any other block is executed.
7. For atomic Subsystems that are having performance-sensitive code, using the "ramfuncs" compiler attribute, one can make the given subsystem execute from RAM  than from ROM(Flash). Under the Block Parameters, one can select this option as captured below. Right-click on the block "c28379Dpmsmfocdual_cpu1_ert/FOC Alogrithm Motor" (from TI C2000 Support package shipping example) and select the block parameters. See the below image for the selection. 
8. External source files/libraries can be added to the model build using the "Configuration Parameters->Code Generation->Custom Code" option. Using this option one can also selectively place external C or C++ code into sections of code that the code generator produces. Additionally "C Caller" block can be used to call external C functions from within the model that are part of external source code and libraries. Here is the documentation link for the complete workflow: 
9. An alternative to point 8 is to selectively place external C or C++ code into sections of code that the code generator produces by adding blocks from the Custom Code library. Please refer to the below FAQ for an idea on the same: 
10. For handling multi-byte data using "Byte Pack" and "Byte Unpack", refer to the shipping example "c28x_spi_eeprom_interrupt". In the subsystem "c28x_spi_eeprom_interrupt/Write EEPROM Data", the Byte Pack block would create packets of uint8 (customizable for the given data type) data that can be sent over SPI bus. Similarly under the subsystem "c28x_spi_eeprom_interrupt/Data Realignment", the Byte Unpack block would unpack the uint8’s to the intended type.