The design of a controller requires a mathematic modeling followed by the adjusting of some model parameters. However to overcome the controller to a single piece of hardware, involves the codification of this mathematical based model into an appropriate firmware description suited to work correctly in a specific platform. Recently a model driven development approach, firstly defined by system engineers, has been frequently used as way to reduce the time of development of embedded systems, producing rapid and reliable product in a short time development cycle. This model driven approach is basically used for test and is known as X-In-The-Loop. These tests provide four levels of testing configurations: MIL (Model-In-The-Loop), SIL (Software-In-The-Loop), PIL (Processor-In-The-Loop) and HIL (Hardware-In-The-Loop). Each of the configuration levels provides some advances and reduces the gap in the development process that initiate with the mathematical model and ends at the firmware running in a stand-alone microprocessor platform .
A model-driven system approach starts from the MIL configuration, where basic simulation is performed to analyze the controller model along with the simulated plant model. The basic idea behind MIL is to generate and validate some test cases of your model in a computing high precision float pointing arithmetic platform, providing the behavior and the quality of your model under a certain computer platform. The proposal of this step is to generate the reference output test results of your controller to the following steps. Any problem with the mathematical controller model can be rapidly found and corrected, taking the MIL step a first step of development.
In Software-In-The-Loop (SIL) the model used in the MIL test is replaced by an executable code running at the same computer platform in a fixed-point arithmetic manner. This step helps the system developer to find fast some wrong memory sizing choices. Normally these two steps are made using a single integrated platform in a PC. The SIL step can be bypassed if your controller system will run in a piece of hardware that has a floating point dedicated unit in its CPU datapath.
The following test consists in the PIL (Processor-In-The-Loop) that goes beyond the PC platform. This step introduces some hardware features that permit to achieve more realistic situations where the control algorithm will run. In PIL the target processor is a non-real time environment and the communication with the external processors is given by using specific functions installed in a simulation integrated environment installed in the host PC.
PIL requires drivers to communicate the computer platform with the aimed hardware. The resulting object code generated in the PC links with other test-management functionality and is then downloaded, typically to an off-the-shelf evaluation board with the target processor. The simulation tool, running on the PC machine, then communicates with the downloaded software, typically via a serial communication link.
The PIL simulation follows the simulation tool installed in the computer send test values to the firmware installed in the processor of the evaluation board, through a serial link and waits for the processor response through the same or another communication channel.
The software real time operation cannot be tested in the PIL, this step is done by the HIL test. Although at first sight, this can be seen as a limitation, in fact this permits to break the simulation problem in two parts that can be verified before we have the certainty that the controller firmware will run correctly in the standalone processor platform. PIL permits to test if the compile optimizations effects in a non-real time execution platform with the presence of an off-the-shelf processor platform where the firmware will finally run.
As the last step of an embedded controller system development HIL is presented. HIL simulation must include electrical emulation of sensors and actuators in a real time target platform before the controller be validated with real sensors and actuators of the plant. These electrical emulations act as the interface between the plant simulation and the embedded system under test all of them in the same platform. The value of each electrically emulated sensor is controlled by the plant simulation and is read by the embedded system under test bringing a real time feedback next to the real situation that the controller will face before to be installed to control a physical plant.
Nowadays there are some model-driven platforms that allows the engineer develop the above simulation step of the controller. Latelly, Mathworks© and National Instruments© are the most known platforms. This work concentrates in presenting the development steps of an attitude control model in the MATLAB – Simulink tool from Mathworks©.
2. The processor in the loop (PIL) and hardware in the loop (HIL) simulation approach
In the PIL application example described in section 3, we use MATLAB/Simulink environment both for a design procedure, code generation and for perform a PIL co-simulation together with a device. In the following paragraphs we describe some works that has some relationship with our work regarding the use of a development environment, code generation and co-simulation. The focus was in works with aerospace application where we presented their proposition, the hardware and tools used as well as the co-simulation scheme done.
In , simulations SIL and PIL were performed to obtain an attitude determination and control system (ADCS) for the microsatellite CKUTEX from Cheng Kung University. The SIL simulation is made using the MATLAB software and after, the PIL simulation is implemented using a PIC microcontroller to the implantation of the ADCS algorithm while the satellite dynamics is implemented in NI-PXI platform and coded by Labview software. According to the authors, the attitude determination and control system that was obtained and tested, provided good results once the plant dynamic response obeyed the project specifications. In , the MATLAB software is used with the purpose of generate the code of an entire control system and the dynamics of two satellites (represented by two robots). In this work a physical simulator using two industrial robots is assembled for a simulation of proximity operations between satellites as
In , a true co-simulation approach is studied for control application running on a Field Programmable Gate Array processor (FPGA). The proposed approach adopts the LABVIEW Real-Time environment (from National Instruments©) to perform the simulation of an artificial satellite' dynamic model. This study simulates a reaction wheel and its control in Simulink exclusively for the controller design. Subsequently, the generated code is implemented on the FPGA. The entire system model attitude control is previously built and simulated in Simulink. The RTW generates the code that represents the satellite dynamics' mathematical model inside LABVIEW environment. In the case of the reaction wheel and its control, RTW generates the C code to simulate the dynamic model that must be adapted to the LABVIEW rules for FPGA programming.
In , the Simulink is used together with another MATLAB toolbox called xPC Target. This toolbox allows to perform prototyping, testing and development of real-time systems for running in general-purpose computers. The MATLAB/Simulink tools were used to generate executable code for the target computer from the model built in Simulink. The goal is to achieve simulation and real-time implementation of an algorithm integrating inertial navigation and GPS, using the validation and testing of the proposed algorithm in the FlightGear flight simulator (inside MATLAB), running on the host computer.
In order to exemplify the possibility of use of different development environment to perform SIL and PIL simulations of a satellite control system; in the work of , a SIL simulation is made in MATRIXx environment where is obtained and tested the control algorithm, simulated the space environment and the satellite dynamics. This same software is used to generate the controller code, that after is downloaded in the satellite processor while its model is ported to a DSP that is controlled by a computer. This computer runs the real-time simulation together with the satellite processor, controlling the actuators and sensors signals too, in a PIL simulation. An interface allows the user to interact with the simulation, monitoring and changing simulation parameters in real-time.
In the cited works, is observed as the simulations SIL, PIL and HIL can be useful in controllers project and test to aerospace applications and as this simulations can be implemented in different ways, different virtual development environments and together with several hardware platforms. The results are not only obtained much more quickly but come from tests very cheap that those made in a real platform, which is often not accessible to the researchers. Furthermore, the interaction with the user in real-time and the analysis instruments, available by co-simulation tools, make the tests much more dynamic and enables the analysis of the system response in situations more realistic.
Today there are many co-simulation tools and many are the possibilities of combination between these tools and the several processors hardware platforms. Such tools are in continuous development and making possible the coupling with several hardware platforms from different manufacturers, including additional functional facilities to become easier the task of development.
In these studies, the Simulink is used as a friendly graphical tool for systems development, design and generation of executable code for various devices and applications. The following section presents more details of a control system design procedure using the PIL approach, Simulink tools and a DSP processor.
3. Example of PIL simulation application
As an example of PIL simulation scheme, we present the application of this strategy on the attitude control problem of an artificial satellite. This case study consists of an embedded digital attitude control system (ACS) design for three axis stabilization . The information obtained by the sensors is processed by a Digital Signal Processor (DSP). The controller design is based on Linear-quadratic Gaussian (LQG) optimal control approach, a well known control theory in terms of space technology applications.
3.1. The satellite attitude control problem
The mathematical model of the satellite attitude considers two reference systems: the orbital frame and the satellite body frame. The orbital frame moves jointly with the satellite. Its origin coincides with the satellite's center of the mass. The axis of the orbital frame is defined by the satellite radius vector, the axis by the orbital normal, and the axis completes a right handed coordinate frame.
The body frame () has its origin in the center of mass of the satellite. Their axes coincide with the satellite's principal axes of inertia. We consider the case where the nominal attitude has axes of the body frame aligned with the axes of the orbital frame . The Euler angles are adopted as parameters of attitude, considering the sequence of rotations 3-2-1. In this case, the rotation matrix is given by .
The kinematics equation is obtained by the time derivative of the rotation matrix equation , then:
The kinematics equation can be simplified if one considers small angle maneuvers, in this case we can approximate: , , , , and . Moreover, the non-linear terms () are very small compared to the linear ones. The velocities are also small compared to the orbital velocity . Considering those approximations the kinematic equation is given by:
In this work the satellite is modeled as a rigid body. Therefore the dynamic model can be obtained with the Euler equation that describes the rotation of a rigid body [9, 11]. The dynamic equation is given by:
3.1.1. The LQG control approach
The Linear Quadratic Regulator is designed upon the linearization of the dynamic model. The theory is developed for linear systems. However, the system simulation takes into consideration the complete non-linear model of the satellite. This optimal control approach consists of minimizing a quadratic cost function and computing a feedback gain matrix . The optimization problem aims to obtain a control law expressed by a linear relationship between the state variable
where and are the weight matrices of state and control vectors, respectively. The value of
Due to the presence of noises in sensors measurements and uncertainties in models, a filter is needed to obtain more reliable information about the states. For the inclusion of signals filtering, we adopted the controller design based on the theory of Linear Quadratic Gaussian control . We consider in this work the presence of white noise in the observations, and that the system is observable. In the LQG problem, we want to minimize the cost function:
where is the covariance matrix of the measurements noise, and is the covariance matrix of the dynamics noise (or model uncertainties). The LQG control law determination will be given by solving two problems: setting the controller for the linear quadratic deterministic problem, and setting a Kalman-Bucy filter for optimum estimation of state . The formulation of the Kalman-Bucy filter is given by:
The gain of the optimal filter is given by . After obtaining
where is the transfer function of the attitude dynamics.
The linear quadratic controller action can be implemented using actuators such as reaction wheels and magnetic actuators for a continuous control command. However, during orbital operations, such as rapid detumbling maneuvers, the required torqueses are usually too high for reaction wheels. Therefore, on-off propulsion strategies are used for such operations . The choice of cold gas jets actuation in the present study aims to test the control in a most critical situation in terms of the small attitude adjustments difficulties.
The firing of the gas jets is controlled by a pulse-width pulse-frequency modulator (PWPF) . The PWPF is an interesting option for the thrusters control system due to its advantages over other types of pulse modulators. PWPF is designed to provide propulsion output proportional to the input command. The modulator optimizes the use of propellants; it provides a smoother control and increases the equipment life. The PWPF structure is shown in Fig. 1 .
When the positive input in the Schmitt trigger is greater than , the trigger output is . If the input falls below , the trigger output becomes null. This response is also reflected for negative inputs. The error signal
3.1.2. The digital LQG controller
The LQG controller, originally designed for continuous time systems, must be adapted to discrete time application. The appropriate selection of the sampling period
Very large sampling periods may result in violation of the rule established by the sampling theorem, which says that the sampling frequency must be twice greater than the highest signal component frequency . If the condition of the theorem is not satisfied, there are information losses in the signal reconstruction. A reasonable choice for the sampling rate is 10 to 30 times the bandwidth of the system in closed loop . A suggestion of  is to adopt a sampling frequency greater than 20 , in order to have a fairly smooth control response. In , the indication is to adopt the sampling period , where and is the bandwidth of the closed loop continuous system. System dynamics frequencies' analysis and recursive tuning adjustments led to the value of 10ms as a quite satisfactory value, considering the desired pointing accuracy. Furthermore, since the maximum speed of the adopted DSP core is 600MHz, a sampling period of 10ms allows the processing of the received signal and computing the control signal in the co-simulation in the interval between samples.
The design of control systems in the continuous domain is mathematically simpler and allows the use of a large set of tools. In the case of control system design in discrete domain, the mathematical problem is quite more complicated. In addition, in the continuous time domain, the visualization of the relationship between physical reality and mathematical representation of a control system is more evident. Therefore, the usual starting point for a discrete time control design is the continuous time control system study, followed by discretization procedures.
There are several methods of discretization of a given continuous time system, and they are basically divided into open loop methods and closed loop methods. In the open-loop methods the discretization essentially consists of turning the transfer function
Several methods of discretization have been proposed and evaluated . We adopted the open loop method of transformation of Tustin, also called bilinear transformation, giving satisfactory results even when compared to closed loop methods (which often have better results by taking into account the whole system), when applied to systems of low order. This method is based on the approximation of the integral represented by the factor
The dynamics of the satellite plant in the case of discrete control remains the same as in the continuous time case. Figure 2 illustrates the LQG controller scheme after its discretization. The main change observed in this scheme is the addition of a zero-order holder in the output signal which is sent to the satellite's block, as indicated by the output named “torque”. The sensors signals are received by the “measured states” gateway. Finally, the controller subsystem was changed by the discretization in terms of its integration function.
3.2. Numerical simulations
The validation of the digital attitude controller was carried through a scheme of co-simulation, where a computer performs the simulation of the satellite's motion, in MATLAB/Simulink, using models of attitude kinematics and dynamics, and a Blackfin 537 DSP device (installed on ADSP-BF537 kit, Analog Devices) plays the digital LQG controller processing, and also the PWPF modulator .
The interface with the computer uses the Real-Time Workshop tool, through the Embedded IDE link, as shown in the Fig. 3.
The validation tests comprise two distinct scenarios. In the first one, the tests consider the same case studied in the precedent sections, i.e. the three axes attitude stabilization. In the second scenario, the attitude control is aimed to perform a maneuver to achieve a new orientation, i.e. a task of attitude tracking.
The co-simulation scheme is based on the computer communication with the DSP (cf. Fig. 4), which is facilitated by Simulink tool, which allows integration of several external processors, including the BF537, by creating a block
The block PIL is inserted in the block diagram developed in the Simulink environment. It is responsible for the communication with the DSP, i.e. in charge of sending the information of the satellite attitude and of receiving the commands related to the control action, i.e. the gas jets driving from the PWPF modulator.
Figure 6 shows the results for the three Euler angles, of the validation tests for the case of three-axis stabilization scheme using co-simulation. The considered initial deviation is 10 degrees for each one of the three Euler angles, as in the case of the previous simulations.
A comparative analysis of the obtained results in the case of continuous LQG controller (in a simulation made only in MATLAB/ Simulink environment), and those obtained in the scheme of co-simulation (Fig. 6), can be made from a plot of the results differences. This differences plot is shown in Fig. 7.
The differences are smaller than 0.1 degree for the three angles. However, we cannot conclude about the better precision scenario. Both simulations met the accuracy specifications, nevertheless the simulation of continuous-time system lacks of realism for an experimental application. In fact, the small difference between the two cases shows only that the co-simulation scheme works very similarly to the idealized case, which may suggest an optimistic outcome in relation to the expectations of an experimental application.
In a second test case, the satellite is commanded to change its attitude, initially with three angles (roll, pitch, and yaw) at the same value of 10°, for a new attitude defined by the values 50, 60 and 45°, respectively. The results are shown in Fig. 8. It was observed that the controller performs satisfactorily its task, with tracking maneuver time of about 45 seconds. An important remark: the gap angles between initial and final attitudes are relatively large for the considered approximations in the synthesis of LQG control law. In the controller design, we adopted a linearized model for small angle values, whereas in the simulation of the motion of the satellite attitude we used nonlinear models of kinematics and dynamics. These models, in the case of large angles, exhibit very different behaviors of the linearized model, especially for higher angular velocities. It shows that the adopted controller achieves adequate performance even with this difference between models, and it presents interesting features of robustness.
In terms of adopted sampling time, it was observed that the simulation in MATLAB/ Simulink waits the DSP processing to continue the calculations, preventing it from some problem related to the interval between two controller processing and actuation. However, there is a DSP development platform tool that allows the measurement of processing time and data traffic. Consequently, it is possible to verify if the DSP processing time remains inferior to the maximum time period provided for sampling (10ms in this study). This tool is the
The development of applications for embedded systems, as well the design of controllers to be performed by dedicate processors, can be immensely facilitated using the co-simulation approaches such as the Processor-In-The-Loop and Hardware-In-The-Loop. This validation scheme has been used as a way to move beyond on strictly computer simulations, opening the studies to realistic problems related to communication and exchange of data between embedded processor and controlled system, e.g. time delays, reliability of transmitted and received data, and processing time of the controller. These features are particularly useful for the design of artificial satellite embedded systems. That is the case of the example discussed here, a module function for the attitude control to be performed by an embedded digital processor.
The authors acknowledge the support of the Federal University of ABC - UFABC (Brazil), and of the