| Simulink® Fixed Point™ | ![]() |
| On this page… |
|---|
Open the Simulink model of the feedback design by starting the Help browser, clicking the Demos tab, and selecting "Scaling a Fixed-Point Control Design" from the list of Simulink Fixed Point demos. Alternatively, you can access the model directly by typing its name at the MATLAB command line:
fxpdemo_feedback
The feedback design model is shown here.

The Simulink model of the feedback design consists of the following blocks and subsystems:
Reference
This Signal Generator block generates a continuous-time reference signal. It is configured to output a square wave.
Sum
This Sum block subtracts the plant output from the reference signal.
ZOH
The Zero-Order Hold block samples and holds the continuous signal. This block is configured so that it quantizes the signal in time by 0.01 seconds.
Analog to Digital Interface
The analog to digital (A/D) interface consists of a Data Type Conversion block that converts a double to a fixed-point data type. It represents any hardware that digitizes the amplitude of the analog input signal. In the real world, its characteristics are fixed.
Controller
The digital controller is a subsystem that represents the software running on the hardware target. Refer to Digital Controller Realization.
Digital to Analog Interface
The digital to analog (D/A) interface consists of a Data Type Conversion block that converts a fixed-point data type into a double. It represents any hardware that converts a digitized signal into an analog signal. In the real world, its characteristics are fixed.
Analog Plant
The analog plant is described by a transfer function, and is controlled by the digital controller. In the real world, its characteristics are fixed.
Scope
The model includes a Scope block that displays the plant output signal.
To set up this kind of fixed-point feedback controller simulation, typically you perform the following steps:
Identify all design components.
In the real world, there are design components with fixed characteristics (the hardware) and design components with characteristics that you can change (the software). In this feedback design, the main hardware components are the A/D hardware, the D/A hardware, and the analog plant. The main software component is the digital controller.
Develop a theoretical model of the plant and controller.
For the feedback design used in this tutorial, the plant is characterized by a transfer function. The characteristics of the plant are unimportant for this tutorial, and are not discussed.
The digital controller model used in this tutorial is described by a z-domain transfer function and is implemented using a direct-form realization.
Evaluate the behavior of the plant and controller.
You evaluate the behavior of the plant and the controller with a Bode plot. This evaluation is idealized, because all numbers, operations, and states are double-precision.
You simulate the feedback controller design using Simulink and Simulink Fixed Point software. Of course, in a simulation environment, you can treat all components (software and hardware) as though their characteristics are not fixed.
Open loop (controller and plant) and plant-only Bode plots for the "Scaling a Fixed-Point Control Design" demo are shown in the following figure. The open loop Bode plot results from a digital controller described in the idealized world of continuous time, double-precision coefficients, storage of states, and math operations.

The plant and controller design criteria are not important for the purposes of this tutorial. The Bode plots were created using workspace variables produced by an M-file script named preload_feedback.m.
In this simulation, the digital controller is implemented using the fixed-point direct form realization shown in the following diagram. The hardware target is a 16-bit processor. Variables and coefficients are generally represented using 16 bits, especially if these quantities are stored in ROM or global RAM. Use of 32-bit numbers is limited to temporary variables that exist briefly in CPU registers or in a stack.

The realization consists of these blocks:
Up Cast
Up Cast is a Data Type Conversion block that connects the A/D hardware with the digital controller. It pads the output word of the A/D hardware with trailing zeros to a 16-bit number (the base data type).
Numerator Terms and Denominator Terms
Each of these Discrete FIR Filter blocks represents a weighted sum carried out in the CPU target. The word size and precision used in the calculations reflect those of the accumulator. Numerator Terms multiplies and accumulates the most recent inputs with the FIR numerator coefficients. Denominator Terms multiples and accumulates the most recent delayed outputs with the FIR denominator coefficients. The coefficients are stored in ROM using the base data type. The most recent inputs are stored in global RAM using the base data type.
Combine Terms
Combine Terms is a Sum block that represents the accumulator in the CPU. Its word size and precision are twice that of the RAM (double bits).
Down Cast
Down Cast is a Data Type Conversion block that represents taking the number from the CPU and storing it in RAM. The word size and precision are reduced to half that of the accumulator when converted back to the base data type.
Prev Out
Prev Out is a Unit Delay block that delays the feedback signal in memory by one sample period. The signals are stored in global RAM using the base data type.
The controller directly implements this equation,

where
u(k - 1) represents the input from the previous time step.
y(k) represents the current output, and y(k - 1) represents the output from the previous time step.
bi represents the FIR numerator coefficients.
ai represents the FIR denominator coefficients.
The first summation in y(k) represents multiplication and accumulation of the most recent inputs and numerator coefficients in the accumulator. The second summation in y(k) represents multiplication and accumulation of the most recent outputs and denominator coefficients in the accumulator. Because the FIR coefficients, inputs, and outputs are all represented by 16-bit numbers (the base data type), any multiplication involving these numbers produces a 32-bit output (the accumulator data type).
![]() | Working with the Fixed-Point Tool | Tutorial: Feedback Controller | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |