HIL setup for a quadrocopter
An autonomic quadrocopter prototype needs to be developed using a newly developed trajectory control. The motor controls are capable of detecting a range of engine issues and report their current state. The quadrocopter must be able to get into a safe state (e.g. landed), even if a motor is disabled during flight.
Continuous integration is required for feedback on the projects progress and quality. Since there are different microcontrollers and low level hardware involved (e.g. pulse width modulation), it would be costly to develop a full emulation.
Since the quadrocopter is to be used in public space, functional safety requirements are high. Among them are back to back tests and tests for many failure scenarios.
In addition, the costs for prototypes should be kept as low as possible.
Several teams are involved in the development, including algorithm development, embedded device driver development, integration, test, functional safety and more. Since there is a limit in available hardware, a setup must be developed, which can be easily switched between a hardware in the loop and a pure software simulation mode.
The hardware in the loop setup connects the localisation and trajectory control microcontroller and the four motor control microcontrollers using two CAN busses,
The PC can listen and create all required CAN packets. The individual microcontrollers can be individually disabled.
For simulation of motor load, the libraries for PWM and reading of the EMF (ADC) are replaced by simulations. Alternatively an extension by external load simulators is possible.
In all cases, the software has to provide simulations for the environment, the rigid body of the quadrocopter and the translate this to a sensor simulation. While the environment simulation and the rigid body simulation may be idealized, the sensor simulation has to provide realistic values. This can be archived by applying Gaussian processes, drift, additional frequencies to the signals.
A logical schematic shows how hardware and software setup work in a loop,
The hardware or the software simulation of the microcontrollers can be switched off for either pure hardware in the loop or pure PC simulation.
If both are active, the comparator must decide whose signals are fed into the rigid body simulation. This is also one possible spot to define a maximum difference between the hardware and the software results.