Real-Time Workshop | ![]() ![]() |
Adding Device Driver Blocks to the Model
Add device driver blocks to the Simulink block diagram as you would any other block -- simply drag the block from the block library and insert it into the model. Connect the ADC or Digital Input block to the model's inputs and connect the DAC or Digital Output block to the model's outputs.
Including Device Driver Code
Device driver blocks are implemented as S-functions written in C. The C code for a device driver block is compiled as a MEX-file so that it can be called by Simulink. See External Interfaces/API in the MATLAB online documentation for information on MEX-files.
The same C code can also be compiled and linked to the generated code just like any other C-coded, S-function. However, by using the target (.tlc
) file that corresponds to each of the C file S-functions, the device driver code is inlined in the generated code.
The matlabroot
\rtw\c\dos\devices
directory contains the MEX-files, C files, and target files (.tlc
) for the device driver blocks included in doslib
. This directory is automatically added to your MATLAB path when you include any of the blocks from doslib
in your model.
![]() | Configuring Device Driver Blocks | Building the Program | ![]() |