SRI RAMAKRISHNA ENGINEERING COLLEGE
VATTAMALAIPALAYAM, N.G.G.O. COLONY POST, COIMBATORE – 641 022.
CONTROL AND TESTING METHODS
Presented by
[Link]
Assistant Professor,
Department of ECE,
Sri Ramakrishna Engineering College Coimbatore- 641022
1
CONTROL AND TESTING METHODS
• Controller on target
• Plant on target
• Processor in the Loop real-time simulations (PIL)
• Model In Loop test (MIL)
• Code verification using Software In Loop (SIL) test
• Hardware In loop Test (HIL) - HIL implementation using raspberry pi: coupled tanks
model, quarter car model – FPGA based Hardware in Loop simulation (HIL) for Power
Electronics.
* 2
Plant and Controller
• Plant → System controlled by a control system
• Controller → Controlling plant so as to refrain it from current state to the desired state
• Ex. DC Motor Speed Control
• Motor → Plant
• PID Controller → Controller
* 3
Host & Target
Embedded Systems
• Host → General Purpose Computer where software is developed
• Target → Embedded system that runs the software
• Ex. Automatic Cooling System
• Host → Computer
• Target → Board (Raspberry pi / Texas C3200)
* 4
On Target Verification
• Verification activities performed on the target
• On-target testing means testing the application in its target environment. (aka Host-
Target testing / Cross testing)
• The key principle behind testing an application on-target is that code is executed in the
environment for which it was designed.
• Rather than in an environment where it was never intended to be executed.
• On-host testing means testing the application on a host computer (such as the
development system used to build the application) (aka Host-Host Testing)
* 5
On Target Verification
On Target Verification of Embedded Systems
• Many different processor families having different configurations
• Real time OS
• Much slower devices
• Devices with a real-time requirement can’t do single step debugging, because the plant connected
to the device will break
• Much less memory is available
• Communication to the outside world is limited.
• PCs/phones have nice big graphical displays - an embedded system might only have a few IO pins
and a couple of LEDs
• Real-time embedded systems are fixed applications. Unlike a PC, it’s often not possible to run a
verification tool on an embedded system – so any data collected must be transferred to a separate PC for
analysis
* 6
CONTROL AND TESTING METHODS
• Controller on target
• Plant on target
• Processor in the Loop real-time simulations (PIL)
• Model In Loop test (MIL)
• Code verification using Software In Loop (SIL) test
• Hardware In loop Test (HIL) - HIL implementation using raspberry pi: coupled tanks
model, quarter car model – FPGA based Hardware in Loop simulation (HIL) for Power
Electronics.
* 7
Controller on target
- Control algorithm runs on actual embedded hardware/target device
- To evaluate and validate control algorithm, when executed on real target hardware
Ex. Robotic position control
8
Plant on target
- Plant model runs on embedded HW / Target device
- Control algorithm runs on host computer
- This can be done when physical system needs to be tested in real time (To validate the
behavior of plant model)
Ex. Physical system development of Robots of specific application
9
Plant on target
• This refers to deploying a model of the plant (the system being controlled) on
hardware (the target).
• The plant model simulates the behavior of the physical system on which the
control system will eventually be applied.
• This can be done to validate the controller's performance under various
operating conditions before deploying the system on the real plant.
Purpose: To simulate the plant's dynamics using real-time hardware to test how the
controller performs with a realistic model before applying it to the actual physical
system.
Example: In process control, before applying a controller to a real chemical plant,
a model of the plant is simulated on a real-time hardware system to test the
controller’s effectiveness and robustness.
1
0
Model Based Testing
Design Workflow
• Creating a model of system requirements for testing
• Generating test data from this requirements model representation
• Verifying your design algorithm with generated test cases
1
1
CONTROL AND TESTING METHODS
• Controller on target
• Plant on target
• Processor in the Loop real-time simulations (PIL)
• Model In Loop test (MIL)
• Code verification using Software In Loop (SIL) test
• Hardware In loop Test (HIL) - HIL implementation using raspberry pi: coupled
tanks model, quarter car model
• FPGA based Hardware in Loop simulation (HIL) for Power Electronics.
* 1
2
Testing methods in Model Based Design
• After recognizing the requirement of the component/system and modeling at the
simulation level (e.g. Simulink platform), testing comes in the verification part
of Model Based Design approach
• Before the model is deployed to the hardware for production, a few verification
steps take place
• Testing methods
Model In Loop Testing (MIL)
Software In Loop Testing (SIL)
Processor In Loop Testing (PIL)
Hardware in Loop Testing (HIL)
1
3
Testing methods in Model Based Design
1
4
Testing methods in Model Based Design
Model-in-the-Loop (MIL) simulation or Model-Based Testing:
• Simulation is a technique used to abstract the behavior of a system or sub-
system in a way that this model can be used to test, simulate and verify that
model.
1
5
Testing methods in Model Based Design
• Process,
• Testing the controller logic on the simulated model of the plant
• If your controller works as desired
• Should record the input and output of the controller which will be used in the
later stage of verification
1
6
Testing methods in Model Based Design
• Software-in-the-Loop (SIL) simulation:
• Once model verified in MIL simulation, next stage is SIL
• We generate code only from controller model and replace the controller block
with this code
• Then run the simulation with controller block (Containing Code) & Plant (Still a
software model)
• This step will give idea of whether control logic (Controller model be converted
to Code) and if it is hardware implementable
• Comparing outputs of Previous step and SIL, if there is any huge deviations,
then changes has to done in MIL accordingly and Repeat the process
• From this we can get to know, execution time in metrics
1
7
Testing methods in Model Based Design
Software-in-the-Loop (SIL) simulation:
1
8
Testing methods in Model Based Design
• Processor-in-the-Loop (PIL) / FPGA-in-the-Loop (FIL) simulation:
• Next step to SIL
• Controller model is dumped onto an embedded processor and run a closed loop
simulation with a simulated plant
• Replacing the controller subsystem with PIL block (which will have controller code
running on HW)
• This step will identify if the processor is capable of running developed control logic
• PIL simulation cross compiles generated source code and then downloads and runs
the object code on the target hardware
• If there are any glitches, SIL/MIL is performed again
• FIL → In case of running the simulations on FPGA instead of embedded processor
1
9
PIL (Processor In Loop Test Simulation)
• This refers to deploying a model of the plant (the system being controlled) on
hardware (the target).
• The plant model simulates the behavior of the physical system on which the
control system will eventually be applied.
• This can be done to validate the controller's performance under various
operating conditions before deploying the system on the real plant.
Purpose: To simulate the plant's dynamics using real-time hardware to test how the
controller performs with a realistic model before applying it to the actual physical
system.
Example: In process control, before applying a controller to a real chemical plant,
a model of the plant is simulated on a real-time hardware system to test the
controller’s effectiveness and robustness.
2
0
Testing methods in Model Based Design
• Processor-in-the-Loop (PIL) / FPGA-in-the-Loop (FIL) simulation:
2
1
SIL AND PIL
• 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.
Module I-20EI253 [Link]
AP(O.G)/EIE
Testing Methods
Hardware-in-the-Loop (HIL) simulation:
- Next step to PIL
- Hardware-in-the-loop (HIL) simulation is a technique for validating your control
algorithm, running on an intended target controller, by creating a virtual real-time
environment that represents your physical system to control.
- HIL helps to test the behavior of your control algorithms without physical prototypes.
- Before connecting embedded processor to the actual HW, the plant model can be run on
any real time system (Speedgoat)
- Real time system performs deterministic simulations and have physical real connections to
the embedded processor
- Ex. Communication interfaces such as CAN, UDP
Analog I/P, O/P
- This identifies issues related to communication channels and I/O interfaces
- Ex. Attenuation and delay, introduced by analog channel
- These behaviors cannot be captured in simulation
Testing Methods
Hardware-in-the-Loop (HIL) simulation:
Working
1. You create and simulate a virtual real-time implementation of physical components such as
a plant, sensors, and actuators on a real-time target computer.
2. You run the control algorithm on an embedded controller and run the plant or environment
model in real time on a target computer connected to the controller. The embedded
controller interacts with the plant model simulation through various I/O channels.
3. You refine software representations of your components and gradually replace parts of the
system environment with the actual hardware components.
With this approach, HIL simulation can eliminate costly iterations in hardware fabrication.
Testing Methods
Hardware-in-the-Loop (HIL) simulation:
• HIL testing typically performed for safety critical applications
• HIL simulation is especially useful when testing your control algorithm on the real physical
system is costly or dangerous.
• HIL simulation is widely used in
• Automotive - Vehicle dynamics and controls
• Aerospace and defense - Flight simulators and flight dynamic control
• Industrial automation and machinery industries to test embedded designs - Controller-
plant testing
• Also being adopted in medical devices, communications, semiconductors, and other
industries.
• It is required by Automotive and Aerospace standards
• HIL → Full controller → Hardware (Including I/O connectivity)
• PIL → Only uses controller processor (No I/O connectivity)
Testing Methods
After all the testing methods done,
- We can replace plant model with original hardware and run the test
Ex. DC motor speed controller
- Controller → FPGA/Processor
- Interfaced to DC motor connecting the inputs and outputs of sensors and
transducers
Testing Methods
Hardware-in-the-Loop (HIL) simulation:
Testing Methods
Hardware-in-the-Loop (HIL) simulation:
Testing Methods
Hardware-in-the-Loop (HIL) simulation:
Testing Methods
• Using Simulator for Hardware:
• Mathematical model of the system is developed and same is programmed into the
microcontroller.
• Now, the microcontroller now act like that system.
• In this example, a two Tank system is modelled and programmed in Arduino nano
• Now Arduino act as Two Tank System
• From this simulation they found,
• Liquid levels to rised from 2.7 meters to 3.3 meters when the flow rate was increased
from 1 cubic meter per sec to 1.11 cubic meter per sec
CONTROL AND TESTING METHODS
• Controller on target
• Plant on target
• Processor in the Loop real-time simulations (PIL)
• Model In Loop test (MIL)
• Code verification using Software In Loop (SIL) test
• Hardware In loop Test (HIL) - HIL implementation using raspberry pi: coupled
tanks model, quarter car model
• FPGA based Hardware in Loop simulation (HIL) for Power Electronics.
* 3
1
HIL Implementation using raspberry pi:
coupled tanks model, quarter car model
Coupled Tank Parameters
State space model of the system
Discrete Model of the System
Block diagram of HIL Implementation
Response of the plant with step change
Quarter Car Model
State Space Model
Discrete Model
HIL Setup
Response of the system
CONTROL AND TESTING METHODS
• Controller on target
• Plant on target
• Processor in the Loop real-time simulations (PIL)
• Model In Loop test (MIL)
• Code verification using Software In Loop (SIL) test
• Hardware In loop Test (HIL) - HIL implementation using raspberry pi: coupled
tanks model, quarter car model
• FPGA based Hardware in Loop simulation (HIL) for Power Electronics.
* 4
3
Need for FPGA for design of Power
Electronics
Real time simulation of Power electronics - Challenging because
- The computational burden imposed on the simulator hardware due to the
- Inherent switching characteristics
- Win increase in switching events per simulation time step, multiple
switching events are usually imposed by the controller in-between two
simulation instances
- Simulator, unlike an actual system
- Cannot instantaneously respond to the PWM outputs of the controller
- It only accounts for it at the end of the simulation time-step
- Thus, errors are introduced to the simulation results
- The percentage error due to the Inter-simulation Time-Step (ITS) in the
functions of the simulation time-step of the simulator and the switching
frequency of the controller
Need for FPGA for design of Power
Electronics
- Certain issues make running a model real-time challenging
- Minimum time step
- Model complexity
- Specialized solvers
- It is all about time step
- Thermal – seconds
- Mechanical – milliseconds
- Power Systems – sub-milliseconds
- Power Electronics – microseconds
- Radar – nanoseconds
- Typical real-time CPU based solutions run in the sub-millisecond range
- FPGA based solutions run in the microsecond range
Need for FPGA for design of Power
Electronics
Need for small step solutions
- High sample rates (small time steps) are required to capture fast transients in
systems like power electronics
Path to FPGA Accelerated Real-time:
Simscape
1. Create a model of the system
– Often called ‘Desktop Simulation’
– Can combine Simscape with Simulink
2. Convert model to HDL
– Allows model to run on an FPGA
– Utilize Simscape to HDL Advisor
3. Program real-time machine with custom bitstream
– Bitstream is the program on the FPGA
– Combine with standard Simulink model on a CPU
Application
Solar Inverter for Real Time testing
Application
Step 1: To create a model (Desktop Simulation)
Application
Inverter and Boost Converter Model
This subsystem needs to be converted from continuous model to discrete model
appropriate to FPGA
Application
Step 2: Convert to HDL - Simscape HDL workflow advisor
Application
Extract State space parameters
Application
Choose smaller number of solver iterations
Application
HDL Subsystem
Application
Replaces Simscape with HDL
Application
Compare generated model to original
Application
Step 3: Create Custom bitstream for real time FPGA
Application
Application
Combine with the simulink model
Application
Scope Screenshot
Thank You
* 61