User`s guide
Using Proc essor in the Loop
PIL Algorithm
The algorithmic code, such as the control algorithm, to be tested d uring the
PIL cosimulation. The PIL algorithm resides in compiled object form to allow
verification at the obje ct lev el.
PIL A pplication
The executable application to run on the processor platform. The PIL
application is created by linking the PIL algorithm object code with some
wrapper code (or test harness) that provides an executio n framework that
interfaces to the PIL algorithm.
Thewrappercodeincludesthe
string.h header file so that the memcpy
function is available to the PIL application. The PIL application uses memcpy
to facilitate data exchange between Simulink software and the cosimulation
processor.
Note Whether the PIL algorithm code under test uses string.h is
independe nt of the use of
string.h by the wrapper code. It depends entirely
on the implementation of the algorithm in the generated code.
How Cosimulation Works
In a P IL cosimulation, Real-Time Workshop software generates an executable
application for the PIL algorithm . Th is code runs (in simulated time) on a
processor platform. The plant model remains in Simulink software without
the use of code generation.
During PIL cosimulation, Simulink software simulates the plant model for
one sample interval and exports the output signals (
ontn of the plant) to the
processor platform via Code Composer Studio software. When the processor
platform receives signals from the plant model, it executes the PIL algorithm
for one sample step. The PIL algorithm returns its output signals (
ontn of
the algorithm) computed during this step to Simulink software in
inn,viathe
CCS interface. At this point, one sample cycle of the simulation is complete
and the plant model proceeds to the ne xt sample interval. The process repeats
and the sim ulation pro gres ses.
4-5