Documentation search search close
CONTENTS

    Open this example in MATLAB

v10.0.1.x for R2026a
View other versions

BMTS - Fault Insertion with FIU

This example shows you how to configure a Speedgoat Fault Insertion Unit (FIU), set different fault states, and read back status information.
One FIU offers up to 36 independent and isolated channels for fault insertion, each with an input and an output socket. The stackable design allows the combination of one or multiple FIUs, Speedgoat Battery Cell Emulators (BCE) and Temperature Sensor Emulators (TSE) to emulate and test large-scale battery packs and battery management systems (BMS) with fault insertion capability.
The Simulink model features the BMTS Setup, BMTS Read, BMTS Write, and BMTS Bus Pack blocks.

Setup

Prerequisites

You will require the following to run this example:
  • Speedgoat real-time target machine with a free Ethernet port
  • Speedgoat Fault Insertion Unit
  • Ethernet cable from the target machine to the FIU

Test Setup

In this example, a FIU12-1 with 12 channels is used. For devices with more channels, the configuration can be changed by following these steps:
  • Open the BMTS Setup block, click the device type of device 1 in the table (FIU12-1) to open a drop-down menu, and select a different device
  • Click Save and Close
  • Open the BMTS Read and BMTS Write block masks, select the new device from the drop-down menu, and click OK
  • Open the BMTS Bus Pack block and set the Device Type on the Device Selection tab to the correct device, then click OK

Configuration

The Speedgoat real-time target machine communicates with the Speedgoat Fault Insertion Unit over EtherCAT. For this purpose, the Ethernet port of the target machine must be configured for EtherCAT.
Use a CAT5 cable or newer to connect the target machine and the FIU. On the target machine, choose an unused RJ45 Ethernet connector, an onboard interface or an IO71x/IO791 I/O module. Plug the other end of the cable into the upper RJ45 connector of the FIU, labeled with ETH1.
To activate EtherCAT support for the respective interface, enter the following in the MATLAB command window to open the Ethernet Configuration Tool:
speedgoat.configureEthernet
Select EtherCAT in the Configuration column for the chosen interface, as shown below for the ETH1 interface:
Click the Store button to store the configuration on the target machine, then close the Ethernet Configuration Tool when the process has finished.

Open Simulink Model

modelName = 'sgMdl_BMTS_FaultInsertionWithFIU';
open_system(modelName); % Open Simulink model

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
tg = slrealtime;
tg.connect;
 
% Download and install the real-time application on the target machine
tg.load(modelName);
 
% 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
 
% Open the Simulation Data Inspector
Simulink.sdi.view;
 
% Start the real-time application
tg.setStopTime(60);
tg.start;
 
% Wait for the application to stop
while(strcmp(tg.status, 'running'))
pause(1);
end
 
% Select the signals for plotting, set the axis limits and line colors
sdiRunIDs = Simulink.sdi.getAllRunIDs;
sdiLatestRun = Simulink.sdi.Run.getLatest;
s = sdiLatestRun.getSignalsByName('Ch1_Status'); s=s(1);
plotOnSubPlot(s,1,1,true);
s.LineColor = [0.6350 0.0780 0.1840];
s = sdiLatestRun.getSignalsByName('Ch2_Status'); s=s(1);
plotOnSubPlot(s,1,1,true);
s.LineColor = [0.8500 0.3250 0.0980];
Simulink.sdi.setSubplotLimits(1,1,'AllRange',[0,60,-1,32]);

Check the Results

Open the Simulink scope connected to the BMTS Read block and compare the signals to check if the fault insertion is working as expected. On the scope, the status signal of channels 1 and 2 are displayed. The status signal is a uint8 value with the lower 6 bits indicating the switch state of the 6 relays used to create different fault scenarios. For each relay, a value of 0 indicates that the relay is either in its default switch state ("no fault"), while a value of 1 indicates that the relay is in the switched state ("fault").
The displays in the Simulink model also show the individual status bits while the model is running in external mode.
For more information about the available fault states and corresponding relay switch states, please refer to the FIU Usage Notes.

Additional References