PID Design Using Frequency Domain Methods

PID Design Using Frequency Domain Methods

Tom Radigan
Advanced Motion Concepts, Inc.
41 Walker Road Atkinson, NH USA 

With motion control applications, a PID or Proportional plus Integral plus Derivative controller is often implemented using tuning rules or by a trial and error process on the shop floor. If modeling of the motion control system can be performed then it is possible to analytically derive the three terms of the PID controller.

The process of modeling a motion control system begins with a block diagram. As shown in Figure 1 the model is compromised of a number of different elements. The elements comprise a motion control system that is closed loop; meaning the output position, C(s) is constantly monitored using feedback, in this case a linear encoder. At the summing junction the feedback is subtracted from the desired position, R(s) and the result is an error, E(s), which is sent to the PID controller. In motion control applications the PID controller operates in discrete time with a sampling period. Every sampling period the digital controller takes the error signal and produces an output within the range of +/-10 volts. It does this using a Zero Order hold and a DAC or digital to analog converter. The Zero Order Hold refers to the process of sampling the signal and then holding between intervals which introduces a delay into the system. The digital to analog converter takes the output of the PID controller and converts it to an analog voltage. The amplifier takes the voltage signal and produces an output current to the motor. The linear actuator takes the output current and produces a linear force which translates into output position. The linear encoder provides position feedback to the controller typically using a quadrature signal measured in counts. While the model is a mixture of discrete and continuous time elements this analysis will be done in continuous time to simplify the model.

pid design

Figure 1: Block Diagram for Closed Loop Motion Control System

The modeling of the motion control system takes place in the s domain using Laplace transforms to derive the transfer functions. The s-domain transfer function for the PID controller in ideal form is:

\displaystyle {{G}_{{pid}}}={{K}_{p}}\left( {1+\frac{1}{{{{T}_{i}}s}}+{{T}_{d}}s} \right)

Where~{{K}_{p}} is the proportional gain, {{T}_{i}} is the integral time constant and {{T}_{d}} is the derivative time constant. Letting ~{{K}_{i}} be the integral gain and ~{{K}_{d}} be the derivative gain in the terms below:

\displaystyle {{K}_{i}}=\frac{{{{K}_{P}}}}{{{{T}_{i}}}}~~~~~~{{K}_{d}}={{K}_{p}}{{T}_{d}}

Using these terms the parallel form of the PID controller can be implemented:

\displaystyle {{G}_{{pid}}}={{K}_{p}}+\frac{{{{K}_{i}}}}{s}+{{K}_{d}}s=~\frac{{{{K}_{d}}{{s}^{2}}+{{K}_{p}}s+{{K}_{i}}}}{s}

The Zero Order Hold transfer function is a first-order low-pass filter with sampling period tsh/2:

\displaystyle {{G}_{{sh}}}=~\frac{1}{{1+\frac{{{{\tau }_{{sh}}}}}{2}s}}

Letting tsh=.001 sec,

\displaystyle {{G}_{{sh}}}=~\frac{1}{{1+.0005s}}

The DAC is modeled as a constant gain with n bit resolution:

\displaystyle ~{{K}_{{dac}}}=\frac{{20}}{{{{2}^{n}}}}

Letting n= 14 bit,

~{{K}_{{dac}}}=.0012~volts/count

The amplifier is modeled as a constant gain, Kam, and to account for its limited bandwidth, fb, a first-order low-pass filter is added. The time constant of the filter is tam:

\displaystyle {{G}_{{am}}}=~\frac{{{{K}_{{am}}}}}{{1+{{\tau }_{{am}}}s}}~~~~{{\tau }_{{am}}}=\frac{1}{{2\pi {{f}_{b}}}}

Letting Kam = 2 amps/volt and fb = 2000Hz,

\displaystyle {{G}_{{am}}}=~\frac{2}{{1+.0000798s}}

The linear actuator is modeled as a gain, Kf, which is the linear motor force constant plus the Laplace transform of F = ma, where a is the acceleration and m is the mass of the actuator and the payload. The model assumes no friction as the system will be using an air bearing. The actuator transfer function with output in position (meters) and input in current (amps):

\displaystyle {{G}_{{act}}}=~\frac{{{{K}_{f}}}}{{m{{s}^{2}}}}

Letting Kf = 8.9 Newton/Amp and m=0.5kg,

\displaystyle {{G}_{{act}}}=~\frac{{8.9}}{{0.5{{s}^{2}}}}

The linear encoder is modeled as a gain, Ke. If the resolution of the linear encoder is 0.1 micron/count then the gain of the linear encoder is:

~{{K}_{e}}=10,000,000~counts/meter

The multiplication of all elements from the Zero Order Hold to the Linear Encoder is known as the Open Loop Function, {{G}_{p}}\left( s \right)H\left( s \right). The Open Loop Function used in this frequency domain analysis is:

\displaystyle {{G}_{p}}\left( s \right)H\left( s \right)=~\frac{{213600}}{{0.5{{s}^{2}}\left( {1+.0005s} \right)\left( {1+.0000798s} \right)}}

The response of the Open Loop Function to a sinusoidal input is called its frequency response. The frequency response can be calculated by substituting s by jw in the Open Loop Function. The steady state response is then given by:

{{G}_{p}}\left( {j\omega } \right)H\left( {j\omega } \right)=~\left| {{{G}_{p}}\left( {j\omega } \right)H\left( {j\omega } \right)} \right|{{e}^{{j\phi \left( \omega \right)}}}=\left| {{{G}_{p}}\left( {j\omega } \right)H\left( {j\omega } \right)} \right|\angle \phi \left( \omega \right)=M\angle \phi

Where the difference between the output and input sine waves can be described by two parameters: Magnitude, M and phase, Φ. Magnitude measures the amplitude ratio and phase measures the phase shift. The magnitude and phase can be determined by calculator for low order systems. For higher order systems the magnitude and phase can be determined using technical computing software such as Matlab or GNU Octave.

First, we need to calculate the phase of {{G}_{p}}\left( {j{{\omega }_{1}}} \right)H\left( {j{{\omega }_{1}}} \right)~or~arg{{G}_{p}}\left( {j{{\omega }_{1}}} \right)H\left( {j{{\omega }_{1}}} \right). This is the addition of the phase shift for each element of the Open Loop Function at the specified frequency,~{{\omega }_{{1.}}} The specified frequency needs to be chosen and is selected as 487 radians/sec.

arg{{G}_{p}}\left( {j{{\omega }_{1}}} \right)H\left( {j{{\omega }_{1}}} \right)=arg{{G}_{{sh}}}\left( {j487} \right)+arg{{G}_{{am~}}}\left( {j487} \right)+arg{{G}_{{act}}}\left( {j487} \right)

arg{{G}_{p}}\left( {j{{\omega }_{1}}} \right)H\left( {j{{\omega }_{1}}} \right)=~-13.69{}^\circ -2.22{}^\circ -180.000{}^\circ =-195.91{}^\circ

Second, the magnitude \left| {{{G}_{p}}\left( {j{{\omega }_{1}}} \right)H\left( {j{{\omega }_{1}}} \right)} \right|~ is calculated as 1.749.

Third, we need to specify the phase margin, {{\phi }_{m}} or stability of the system. The phase margin is the difference between the actual phase and -180° at the frequency,~{{\omega }_{1}}~,where the gain equals 0dB. We choose the phase margin as 62°.

Fourth, the argument or phase shift contribution of the PID controller can then be found:

\theta =arg{{G}_{{pid}}}\left( {j{{\omega }_{1}}} \right)=-{{180}^{{}^\circ }}+{{\phi }_{m}}-arg{{G}_{p}}\left( {j{{\omega }_{1}}} \right)H\left( {j{{\omega }_{1}}} \right)

\theta =arg{{G}_{{pid}}}\left( {j{{\omega }_{1}}} \right)=-{{180}^{{}^\circ }}+62{}^\circ +195.91{}^\circ =77.91{}^\circ

The magnitude of θ must be less than 90 degrees.

Now we can solve for the PID proportional gain:

\displaystyle {{K}_{p}}=\frac{{Cos\theta ~}}{{\left| {{{G}_{p}}\left( {j{{\omega }_{1}}} \right)H\left( {j{{\omega }_{1}}} \right)} \right|}}=\frac{{Cos~77.91{}^\circ }}{{1.749}}=~0.120

Solving for the derivative time constant:

\displaystyle {{T}_{d}}=\frac{{Tan\theta ~}}{{{{\omega }_{1}}}}=~\frac{{Tan~77.91{}^\circ }}{{487}}=0.00959

Solving for the PID derivative gain:

{{K}_{d}}={{K}_{p}}{{T}_{d}}=\left( {0.120} \right)\left( {0.00959} \right)=~.00115

Lastly, solving for the PID integral gain:

\displaystyle {{K}_{i}}={{K}_{d}}\omega _{1}^{2}-\frac{{{{\omega }_{1}}Sin\theta ~}}{{\left| {{{G}_{p}}\left( {j{{\omega }_{1}}} \right)H\left( {j{{\omega }_{1}}} \right)} \right|}}

\displaystyle {{K}_{i}}=\left( {.00115} \right)\left( {{{{487}}^{2}}} \right)-~\frac{{487~Sin77.91{}^\circ }}{{1.749}}=0.475

It’s important to note these calculations are not a guarantee of system stability. It is necessary to check the response of the system to a step input using the closed loop transfer function and also to check the system stability using the Nyquist plot. Finally, to match the PID gains to your controller the form of the PID must be the same. For example the motion controller PID must take the ideal or parallel form otherwise the gains will not calculate to appropriate values.

References:

Charles L. Phillips and John M. Parr. Feedback Control Systems, Fifth Edition, Pearson Education, 2011.

Should you have any questions about this article please contact us