Download Fixed-Point Blockset User`s Guide

Transcript
Digital Controller Realization
Digital Controller Realization
The digital controller is implemented using a fixed-point direct form
realization. The 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 is shown below.
1
In1
Convert
Up Cast
Numerator Terms
Convert from
A2D Type
to BaseType
Multiply and accumulate
most recent inputs and
numerator coefficients
in the accumulator
1
Convert
Combine Terms
Combine numerator
and denominator
contributions to TF
in accumulator
1
z
Prev Out
Store most
recent output
in memory for
one sample time
Out1
Down Cast
Reduce output from
accumulator size to
base memory size
Denominator Terms
Multiply and accumulate
most recent outputs and
denominator coefficients
in accumulator
The realization consists of these blocks:
• FixPt Conversion
The Up Cast block 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). The Down Cast block 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.
• FixPt FIR
These blocks represent a weighted sum carried out in the CPU target. The
word size and precision used in the calculations reflect those of the
accumulator. The Numerator Terms block multiplies and accumulates the
6-7