User`s guide
10 Targeting Custom Hardware
10-14
This list describes the function of each macro in mdlInitializeSizes:
• ssSetNumSFcnParams — The number of input parameters is equal to the
number of parameters in the block’s dialog box.
•
ssSetNumInputPorts — The ADC block has no inputs because it reads data
from the I/O board. An ADC is a source block (i.e., the block has only output
ports).
•
ssSetNumOutputPorts — The number of outputs equals the number of I/O
channels. The code above obtains the number of channels from the dialog
box, which is the first argument passed to the S-function (i.e., the first item
in the dialog box).
•
ssSetInputPortDirectFeedThrough — It is important to note that the ADC
has no direct feedthrough. The ADC’s output is calculated based on values
obtained external to the Simulink model, not from the input of another block.
In fact, the ADC has no inputs; it calculates its output based on values
obtained from the I/O board. This information affects the organization of the
generated code.
•
ssSetNumSampleTimes — Assuming that all channels run at the same rate,
there is only one sample time (the board’s sample time specified in its dialog
box).
Initializing Sizes — Output Devices
Initializing size information for an output device, such as a DAC (digital to
analog converter) has two important differences from the ADC:
• Since the DAC obtains its inputs from other blocks, the number of channels
is equal to the number of inputs (instead of number of outputs as is the case
with the ADC). This is because the DAC is a sink block (i.e., the block has
only input ports and it writes data to something that is external to the
Simulink model — the I/O device).
• Also notice that this block has direct feedthrough (i.e., the DAC cannot
execute until the block feeding it updates its outputs). This information
affects the organization of the generated code.