Overview of Example
This example shows how stochastic network traffic causes timing latency and uncertainty in an anti-lock braking system (ABS) that uses Control Area Network (CAN) communications. The model is representative of a real-world heavily-loaded network and also illustrates a domain-specific model of a distributed system. By including real-world timing effects in a model, you gain confidence about the behavior and robustness of your design before you test it in hardware.
We begin with the ideal scenario of an anti-lock braking system using CAN communications with no background traffic. In this model, we simulate a CAN with no background traffic by manually setting the output of the Manual Switch that is contained in the Background Traffic subsystem block to the "OFF" position, before running the simulation. In this ideal scenario, the software simulates a communication system with a steady rate of network utilization over time and with no delays in message delivery. These ideal conditions result in excellent slip response from the ABS system relative to decreasing wheel speed.
modelname = 'sedemo_absbrake_can'; open_system(modelname); set_param('sedemo_absbrake_can/Background Traffic/Manual Switch', 'sw', '0'); sim(modelname);
Next, we simulate the more realistic scenario of a CAN with some stochastic network traffic. This background traffic results in message delivery delays on the network. To simulate this, we manually set the Manual Switch contained in the Background Traffic subsystem block to the "ON" position. By setting the Manual Switch to this position, we allow the Step Function block that is also contained in the Background Traffic subsystem block to introduce traffic to the network. In this model, the Step Function block is configured to output a value at simulation time, T=6 seconds. If we contrast the updated simulation results with those of our previous ideal scenario, we see that the introduction of message delivery delays to the network results in much poorer slip response from the ABS system relative to the wheel speed.
set_param('sedemo_absbrake_can/Background Traffic/Manual Switch', 'sw', '1'); sim(modelname);
Re-prioritization of the CAN Messages
A CAN processes messages from distributed nodes on the network based on the message priority of each node. In our model, each subsystem is a CAN node. We define a message priority of 5 for the ABS Controller subsystem, 6 for Vehicle Dynamics subsystem, and 4 for Background Traffic subsystem. This means that the CAN processes messages from the Background Traffic subsystem first. We saw previously that the introduction of background traffic on the network resulted in much poorer slip response from the ABS system. To reduce the negative impact of background traffic, we adjust the CAN message priority of the ABS Controller subsystem and Vehicle Dynamics subsystem to have a higher priority than the Background Traffic subsystem. This change results in a reduced message delivery delay on the network and an improved slip response from the ABS system relative to the wheel speed.
set_param('sedemo_absbrake_can/CAN Node 1', 'MsgID', '2', ... 'IDSubscription', '[0,0,0,1,0,0,0,0,0,0]'); set_param('sedemo_absbrake_can/CAN Node 2', 'MsgID', '3', ... 'IDSubscription', '[0,0,1,0,0,0,0,0,0,0]'); sim(modelname);
This example shows an anti-lock braking system using CAN communications and highlights the negative effect that increased network utilization can produce on latency and response times.
bdclose all; clear modelname