Model-Based Design is a process which is involved during system modeling, plant modeling, controller modeling etc. Let’s say, you have to design a plant or any system in the real world. Before designing your system, you require some testing like MIL, SIL, PIL and HIL. These multiple testing are required to assure that our system is ready to deploy in the real world. All these processes are involved in the Model-Based Design. The following things are going to be discussed as given below.
- Model in the loop
- Software in the loop
- Processor in the loop
- Hardware in the loop
- V-shape model
- Coder modules in MATLAB for Model-based Design
- Advantages of Model-Based Design
As you see in the figure below (steps are from left to right), in every next step we compare output from the first step. If we get a desired output in every step then we go for hardware implementation.
Let’s discuss all the processes for the testing of controller with an example. We will use Simulink which is a strongest tool for system modeling as compared to other softwares.
Model in the Loop
This is the first step in which we design a plant and a controller virtually on Simulink. We give a desired reference output to a model and we use a controller to control the plant. We optimize the parameters of the controller until we get the desired output from the simulated model. When we get the desired output from the simulated model, then we go for the next step that is SIL.
To optimize parameters of a controller in Simulink, there are special modules like Simulink Design Optimization and Simulink Control Design. Additionally, you can use rapid prototyping as well.
As you see in the figure above after optimizing parameter values of the controller, the desired output and the simulated output remain equal after some time. These all processes are called Model in the Loop.
Software in the Loop
This is the second step to test the controller. In this case we generate C/C++ code for the controller, and we execute the code on the host machine to control the virtual plant. In this case a simulated output will be generated. We will match this output with the first step. If it is not matched then we optimize parameters of the model. For SIL we can use Simulink Coder and Embedded Coder modules which are available in MATLAB/Simulink. When we get the desired output from the simulated model then we go for PIL.
- For SIL with SImulink, you can go in the app and search for SIL, as given in the figure below.
- You will have two options to choose from: Top model SIL and Model Blocks in SIL/PIL Mode.
- If you want to test the whole plant then you can go for the first option Top Model, for controller testing you have to choose Model Blocks in SIL/PIL Mode.
- Further create a reference model of your controller. Before creating a reference model be sure that your whole plant is set to discrete (because a continuous step is not supported in SIL and PIL).
- A reference controller will run on Simulink and a SIL controller will run on the host machine. If an error of both the controllers is zero or almost zero then you can go for PIL.
- Before converting the controller in a reference model, first make the controller as a subsystem, then right click-Block Parameters (subsystem)- treat as atomic unit.
- After the above mentioned steps right click on the controller subsystem then follow the image below.
- Right-click your Model block, for example, Referenced Model. Select Block Parameters (ModelReference), which opens the Function Block Parameters dialog box. From the Simulation Mode drop-down list, select Software-in-the-loop (SIL).
- On the Apps tab, click SIL/PIL Manager.
In the Mode section, select SIL/PIL Simulation Only.
In System Under Test select Model blocks in SIL/PIL mode.
Processor in the Loop
In PIL we deploy the controller in a hardware, and the hardware will control the virtual plant. In this case two controllers will run simultaneously, one – in the hardware, and the other – in Simulink. And both will control the virtual plant. Check the output of both. If you are satisfied then go for the Hardware in the Loop.
The process is same as SIL for testing in Sumulink. Only you have to choose PIL instead of SIL. Remember, while running PIL your hardware has to be connected with your machine.
Summary of SIL and PIL
With SIL and PIL simulations, you can:
– Test whether your model and generated code are numerically equivalent.
– Observe code coverage.
– Perform code execution profiling
How SIL and PIL Simulations Work
– In a SIL or PIL simulation, code is generated for either the top model or part of the model.
– With SIL, this code is compiled for and executed on your development computer.
– With PIL, the code is cross-compiled for the target hardware and runs on the target processor.
Hardware in the Loop
In this case we test the controller with the real-time plant. C-code will be in the engine control unit or electronic control unit, the control unit is used to control the real-time plant. For this testing you can use Simulink Real Time and Simulink Desktop Realtime modules in Sumulink.
A V-shape model is widely used in automation and automotive industries. MIL, SIL, PIL, and HIL are part of it.
Specific Coder Modules in MATLAB For Model-Based-Design
Apart from the above, there are other coders in MATLAB like MATLAB Coder, PLC Coder etc.
Advantages of MBD
- Early test and verification
- High accuracy
- High product quality
- Time gain
- It is a core of development of any system in real-time
Model Based Design Using Simulink
The example is based on the movement of solar panel according to the Sun movement, to increase the solar efficiency. Click here to learn
Please, comment below if you want an article on some specific topic.
Thank you for the auspicious writeup. It in fact was a amusement account it.
Look advanced to more added agreeable from you!
However, how can we communicate?