After performing unit tests of the single components in our system, we may
want to perform some closed-loop testing, which means testing the whole BMS ECU
against the plant model. So we can create the harness for the closed-loop system,
and in this harness you can simulate the component under test in different
ways. For instance, we can use some blocks from Simulink Test. Like the Test
Sequence block, which is a kind of simplified version of Stateflow. And in
this test sequence you can inject some state requests for driving, balancing,
charging. And then there may be some transition between the different steps
that could be logical, temporal, or a combination.
Okay then we can use some dashboards to visualize the signals and to check
whether there are some faults raised by our ECU. So we run the simulation in
closed loop, and then we can take a look at some of the signals - like the
temperature of cells, state of charge, the pack current, the voltages, and
so on. And then here by taking a look at lamps we can see whether everything is
running fine or not. Well, so that's a way to test your closed-loop system. But
maybe there may be some occasions where you really want to check some conditions
on signals which are really deep down the hierarchy. And maybe you don't want
to modify the interface of your models. So to show this, let me open a different
harness. So in this harness I'm using a signal builder to excite the closed-loop
system and I give some state requests. And now I want to check some conditions
on signals, which are really deep down the hierarchy. In particular I want to
check some conditions on these two signals: the discharge current limit and
the charge current limit. But I don't want to modify the interface of my model,
so to do this I can use an observer. So I just right click on the canvas, observers,
and then I add an observer here. So with this observer I can essentially
go and pick signals deep down the hierarchy without modifying the
interfaces. And then I can check some conditions on them. So to do this I click
on this little badge on the bottom left, and here I can explore the whole
hierarchy of my model. And I can select any signals that I want without changing
the interfaces of my system. So just go to the BMS ECU, current power
limits, and then I select the first output which is the charge current limit.
And then with this little Wi-Fi signal I can add them to my observer. Just do the
same for the discharge current limit, I add again, and now as you can see I have
access to these two signals. Well now I can define some conditions on these two
signals, and I can use a block from the Simulink test library, and in particular I
will use a test assessment block. So I just open the block and then here I can
add my conditions. So I have added some conditions and in particular
I use the verify statement to make sure that the charge current limit is below a
certain threshold, and the discharge current limit is above a certain
threshold that I can define as constants here. Okay so now this is inside the
observer, and as you can see I haven't changed anything in the main model. So
now when I run the simulation also the observer will run. So if some
conditions are not respected, I will see this in the diagnostic viewer. And here
you can see that some of those conditions are not respected and I have
a nice description in the diagnostic viewer.