Pulse I/O Interface Extension (-21,-22,-24) Digital Loopback
This example shows how to perform a loopback test using an Pulse I/O interface extension, such as -21, -22 or -24. You can test the basic I/O interface extension by running this example, which is also used to demonstrate how the Speedgoat I/O Blockset informs you in case something is wrong in your configuration.
Setup
Prerequisites
You will require the following to run this example:
- A Pulse I/O with one or two I/O interface extensions installed that contain digital channels
- A Speedgoat configuration file that supports an I/O interface extension
- A connector cable from the I/O modules to the terminal board
- A terminal board with jumper wires
Initialize and Open the Simulink model
The installed Speedgoat I/O Blockset includes configuration files for all possible hardware configurations with up to two I/O interface extensions. The configuration files implement the DIO functionality on every available pin. Before the Simulink model can be built, the correct configuration file must be specified in Setup block of the example file.
modelName = 'sgMdl_PulseIO_2x_DigitalLoopback';
First, open the mask of the Pulse I/O Setup block and select the configuration file that supports your hardware from the drop-down. For this example also make sure the I/O interface extension is enabled.
The information of your implemented I/O interface extension functionality is contained in the configuration file. If the selected configuration file doesn't support an I/O interface extension, the checkbox won't be visible.
Test Setup
Use the Pin Mapping button in the Setup block to locate the functionalities specified in the table below and then locate the corresponding pins on the terminal board. Connect these pins with jumper wires. Note that this example will be suitable for all combinations with any of the supported digital I/O interface extensions.
Model Description
In this model, digital outputs ch1–4 values are received by digital inputs ch9–12. These channels are located on the I/O interface extension.
Note that in case you did not enable the I/O interface extension in the Pulse I/O Setup block, all I/O functionalities located on the I/O interface extension are turned off. If this is the case when using this example model, a warning will be shown in the MATLAB command window while modifying the Simulink model: - Warning: Following DI are located on disabled I/O interface extension:
- - 9
- - 10
- - 11
- - 12
- Warning: Following DO are located on disabled I/O interface extension:
- - 1
- - 2
- - 3
- - 4
If you do a manual update of the Simulink model (using Ctrl+D), these warnings will be changed to an error message. If so, make sure to select the correct I/O interface extension in the Pulse I/O Setup driver block (see here). The scope displays received digital values on the I/O interface extension.
Build, Download, and Run the Example
To run the example, either run the following code section or click the Run on Target button in the REAL-TIME tab in the Simulink model:
% Build the Simulink model
slbuild(modelName); % this will create the real-time application file (.mldatx)
% Create and connect to the Speedgoat real-time target machine
% Download and install the real-time application on the target machine
% Connect the Simulink model with external mode to the real-time application on the target machine
set_param(modelName,'SimulationMode','external') % put model into External Mode
set_param(modelName,'SimulationCommand','connect') % connect with External Mode
% Start the real-time application
% Wait a few seconds and then stop the real-time application on the target machine
Check the Results
To check the loopback is working as expected, open the Simulink scope that is connected to the Digital Input and Digital Output driver blocks. The scope must display the signals as shown below:
Additional References