Guide to Tuning the HF2LI-PID Controllers

On the Zurich Instruments website, there are a few advanced examples of using HF2LI-PID controllers in different feedback control applications. However, I often get questions from first time users on how to properly tune the PID gain parameters. I am no expert in feedback control systems or the PID loop optimization. However, I do believe tuning the HF2LI-PID parameters should not be an intimidating task for anybody who needs to use the HF2LI-PID controllers.

Case Study: Automatic Gain Control

Let us take a very simple case study of controlling the output amplitude of a simple oscillator. This is sometimes called automatic gain control, or AGC. For best signal-to-noise ratio, we will assume that we are working in the resonance frequency peak region of the oscillator as shown below. Note that due to the change in the environment, the peak resonance frequency can drift which also causes the measured amplitude to vary. Therefore, the objective here is to maintain a constant measured amplitude using the HF2LI-PID.

resonance_amplitude

We observe from the above screenshot that the amplitude reading is about 6 mV.  Again, we assume that we are already driving the oscillator near its peak resonance frequency. We need to set up now the PID tab in the ziControl graphical user interface. First, we need to select the PID input. This is done by choosing ‘Demodulator: R’ and ‘1′ in two list items of the Input section. The reason is that we want to control the amplitude (i.e. R) that is measured using the demodulator 1. For the PID output, we need to select ‘Sig Out 1: Amplitude’ and ‘7′ in the Output section. This corresponds to the fact that we want to adjust the amplitude of the oscillator 7 to control the amplitude of the oscillator output. Note that the Input and Output sections are color highlighted yellow and orange, respectively, in the screenshot below.

PID_io_setup

It is worth noting that if your device-under-test can have an abrupt behavior of shifting 180o during oscillation, it may be better to use X as the PID input in order not to soft limit the amplitude to only positive values. Remember to automatically zero out the Y value by using the ‘Auto Zero Phaseshift‘ function of the demodulator in the Lock-in tab.

Hint: if you are using one of the auxiliary outputs as the PID feedback (i.e. PID Output), then you need to set the Signal to ‘Manual‘ in the Auxiliary I/O tab.

auxiliary_io_setup

PID Tuning Method

There are in fact many PID tuning methods. They can be classified in two categories:

  • open loop methods
  • closed loop methods

The open loop methods mean that the tuning is done while the feedback path is not closed. This allows one to observe the open loop response according to the PID parameters setting. The close loop methods, on the other hand, means that the PID parameters are adjusted on-the-fly while the loop is in the feedback operation. The method that I am suggesting to use in this blog is the closed loop method, in particular, the Good Gain tuning method. In theory, the Good Gain method can be performed on the HF2LI-PID with the loop closed by following the steps below:

  1. Initially, try to manually adjust the Setpoint in open loop such that the controlled signal is close to its final value.

    Hint: You probably want to open up the demodulator filter bandwidth to at least 5.0 kHz and the demodulator readout to 14.4 kSa/s in order not to interfere with the PID bandwidth tuning

  2. Set all P, I and D values to zero. Increase P gradually until you get a slight overshoot in the step response. (Be careful with the polarity such that you do not have a positive feedback.) The step response can be observed by manually adjusting the Setpoint and observe the controlled signal response in the Spectroscope. You should now observe the error between the measured R and the set point value getting smaller and smaller as P values is increases. Note that with the P-controller, one can get close, but might never exactly, to the final set point value. It depends on the characteristics of the device-under-test as well as the setup delay. Make sure that the HF2LI-PID input and output are not unintentionally soft limited in value (e.g. limited in amplitude, frequency etc.).

    P_tuning

    P-tuning: circled spot indicates the on-set of instability in step response when P gets too large

    Hint: You can actually use the Toggle function in the PID tab and observe the step response in Spectroscope

  3. Once the above condition is met, the rule is usually to set I to an initial value of 1.5Tou. Tou is the delta time between the overshoot and the undershoot of the step response. Increase the I gain parameter gradually until the error value Err gets very close to zero. One can slight decrease the P value by 50% to 80% if the step response becomes slightly unstable.

    I_tuning2

    I-tuning: determine an initial value for I from Tou

  4. One can potentially set D to 1/4 of I although it is not necessarily and sometimes might not even bring any improvement.
  5. Check loop response again by applying a step response as in Step 2. Adjust mainly the P and I gain parameters accordingly for fine tuning.

PI_tuning

 PI-fine tuning: final peak-to-peak noise should be as small as possible

In this case study, I only adjusted the gain parameters P and I without having to set the D gain parameter. I used the Spectroscope to help with the fine tuning by looking at the peak-to-peak noise of the HF2LI-PID output. If this peak-to-peak value gets bigger in the spectroscope during the fine tuning process, then you are probably getting away from the optimal value. Below is a step response from 5 mV to 35 mV of the resonator output under the final tuned HF2LI-PID setting.

step_response

Step response of 4 ms under fine tuned PID

I would say that this is very close to the maximum step response speed that we can get with this oscillator. To do a sanity check, I used the modeling tool included in each HF2LI-PID controller to check the simulated response. The simulation showed a step response of about 1.5 ms, not very far from the 4 ms that we have achieved through the Good Gain tuning method.

PID_simulation

Summary

In this blog, I demonstrated an example of automatic gain control using the HF2LI-PID controllers. The Good Gain tuning method was used to do the closed loop tuning in real time. The toggle function and the Spectroscope are both very practical tools in ziControl when doing this type of tuning. Of course, one can always do a numerical simulation first in order to tune the PID values. But the advantage of this type of manual tuning is that one can directly perform a trial-and-error operation without the need to figure out exactly the transfer function of the complete closed loop feedback. The method might not be the most accurate, but it is certainly very practical in my opinion. Hopefully this blog can be useful to get you started with the HF2LI-PID .

External Reference

Haugen, Finn, 2010, The Good Gain method for PI(D) controller tuning, July 19, 2010