Constructing the controller

To implement the integral term, you use the fixed-point limitedIntegrator block, which expands to:

fixedpointPIDcontroller3

The integral term of the PID controller can be implemented as:

fixedpointPIDcontroller4

Compared to the floating-point implementation, the only differences are the fixed-point const and mul blocks used to define the integral gain and to perform multiplication, respectively. This set of blocks is encapsulated the Integral Term compound block.

The Proportional Term compound block contains the fixed-point equivalent.

The arithmetic operations of the derivative term are replaced with fixed-point equivalents, const, mul, sum, and gain, as shown below.

These blocks are encapsulated in the Derivative Term compound block.

Combining the three control terms, the fixed-point PID control can be implemented as:

fixedpointPIDcontroller5

This set of blocks is encapsulated in the PID Control (FIXED POINT CONTROLLER) compound block. The complete system becomes:

Three convert blocks are used to ensure that the inputs to the Controller and the Volts to Degrees converter are the correct data type. Furthermore, the 0o and 90o calibration voltages are defined using fixed-point const blocks. The simulation parameters remain unchanged from the floating-point implementation.

It is important to note that in the simulation depicted above, the PID Control and Volts to Degrees Converter are simulated by Embed in scaled fixed-point while the Fan-Paddle-Sensor is simulated in floating-point. This means that you can simulate how a given control or logic prototype would execute on a fixed-point embedded system target, such as a DSP or a microcontroller. This lets you answer in a single design and simulation iteration, crucial questions, such as:

      Is it feasible?

      Will it work?

      Will it work on the embedded target that I have chosen or have in mind?

      Am I getting the most dynamic range for each of my variables?

      Can I guarantee that none of the variables will suffer numerical overflow for the entire range of inputs and outputs that I am designing for?

      Does my control system exceed or at least meet the design specifications?