C Custom Block

Define this block with C commands and functions.

The CCustomBlock provides a generic interface for specifying the block's properties and defining its simulation function based on C commands and functions. The simulation function is specified in C code and stored as a block parameter. The C code is used during simulation.
  1. From the Palette Browser, select Activate > CustomBlocks > CCustomBlock. Drag and drop the block into your diagram and double-click it.
    The block dialog appears with tabs to define the Ports, States, Parameters, SimFunction and other advanced properties for the block.
  2. On the Ports tab, enter the number of input and output ports for the block, enter a name for each port, then click OK.
  3. On the States tab, enter the state of the block with respect to its initial continuous condition, initial state derivative, initial discrete state, and number of initial object states, then click OK.
  4. On the Parameters tab, enter the number of parameters for the block. For each parameter, enter a name, value, and type, then click OK.
  5. On the SimFunction tab, generate a code skeleton, enter the simulation function for your block, then click OK. The skeleton provides the essential framework for the C function that interfaces with inputs, outputs and events. Additional options:
    • Check the syntax of the C function with the check C code button.
    • Export a DLL with the generate dll and convert button.
  6. On the Advanced tab, enter the number of modes and zero-crossings for the block, select the activation mode: always active, initially active or standard, then click OK.