User's Manual
PMAC User Manual
108 Closing the Servo Loop
Actual PID Algorithm
The actual equation used in the PID algorithm to compute the commanded output for motor x is as
follows:
⋅⋅
−
⋅
+
⋅+⋅
+⋅⋅
−
=
128
)(0931
}
23
2
)(33
128
)(35)(32
)({0830
19
2)(
nAVIxIxnIEIxnCAIxnCVIx
nFEIxIxnDACout
where:
• DACout(n) is the 16-bit output command (-32768 to +32767) in servo cycle n. It is converted to a -
10V to +10V output. DACout(n) is limited by Ix69.
• Ix08 is an internal position scaling term for motor x (usually set to 96).
• Ix09 is an internal scaling term for the velocity loop for motor x.
• FE(n) is the following error in counts in servo cycle n, which is the difference between the
commanded position and the actual position for the cycle [CP(n) - AP(n)].
• AV(n) is the actual velocity in servo cycle n, which is the difference between the last two actual
positions [AP(n) - AP(n-1)] in counts per servo cycle.
• CV(n) is the commanded velocity in servo cycle n: the difference between the last two commanded
positions CP(n) - CP(n-1)] in counts per servo cycle.
• CA(n) is the commanded acceleration in servo cycle n, which is the difference between the last two
commanded velocities [CV(n) - CV(n-1)] in counts per servo cycle
IE(n) is the integrated following error in servo cycle n, which is:
n-1
∑
[FE(j)]
j=0
(For all servo cycles for which the integration is active. Ix34=1 turns off the input to, but not the output
from the integrator when CV does not equal zero.)
Notch Filters
The PMAC can be used to set up notch filters. A notch filter is an anti-resonance (band-reject) filter used
to counteract a physical resonance. While there are many different philosophies as to how to set up a
notch filter, we recommend setting up a lightly damped band-reject filter at about 90% of the resonant
frequency, and a heavily damped band-pass filter somewhat greater than the resonant frequency (to
reduce the high-frequency gain of the filter itself).
For those familiar with control theory (not necessary to use the notch), the form of the PMAC notch filter
system is:
2
D2z
1
D1z1
2
N2z
1
N1z1
D(z)
N(z)
−
+
−
+
−
+
−
+
=
where the numerator – N(z) – is the band-reject filter, and the denominator – D(z) – is the band-pass
filter. The notch filter acts on the output of the PID filter itself.
PMAC uses four I-variables to specify the full notch filtering system: two (Ix36 [N1] and Ix37 [N2]) for
the band-reject filter, and two (Ix38 [D1] and Ix39 [D2]) for the band-pass filter. These I-variables
represent the actual coefficients used in the difference equations for the notch. These I-variables have a
range of -2.0 to +2.0; they are 24-bit values, with one sign bit, two integer bits, and 21 fractional bits.
Before implementing a notch filter in the PID-Plus algorithm, tune the PID parameters somewhat to get at
least minimal performance, even if control of oscillations is poor.