Implementing a PID position controller

Floating-Point Diagram: position_control_regular

Fixed-Point Diagram: position_control_fixpoint

Location: Examples > Fixed Point

In most real-world cases, a scaled fixed-point-based embedded controller controls a real system, such as automotive brake systems, machine tools, aerospace control surfaces, and other similar systems. In each case, the best way to prototype an embedded controller is to realize the controller in scaled fixed-point implementation that is native to the target platform. The rest of the simulation — such as sensors, plant model components, and actuators — are best simulated in double-precision floating-point to most accurately reflect the real-world application scenario.

This tutorial examines the implementation of a PID controller for a position control application. The plant, controller, and other arithmetic operations are first implemented in double-precision floating point.

The system comprises an electrical motor connected to a small propeller that blows air on a paddle. The paddle is moved at an angle from the vertical. The control problem is to adjust the speed of the motor by varying its input voltage to maintain the paddle at a user-defined angle from the vertical. The system can be schematically represented as shown below.

For the prototyping process, the fan-paddle-sensor subsystem can be collapsed into a single model, as shown below.