Hello,
I ran into an issue trying to use my Stabilizer with dual-iir application in PID mode to do side of fringe locking of a cavity. I would like to lock such that my photodiode output voltage is 1.5 V when cavity piezos have 5 V DC at the input. So this seems to require me to have an input offset of -1.5 V and output offset of 5 V. The issue is I do not seem to understand how the offsets work in Stabilizer, specifically when Ki is nonzero.
I connect a DC voltage generator to the input of channel 0 of my stabilizer via a BNC T, the other end of the T going to my oscilloscope (Picoscope 5444). I first use the following command to see that the stabilizer is alive and responsive to changes in the error signal:
python -m stabilizer.iir_coefficients --verbose --broker 10.34.16.99 --prefix dt/sinara/dual-iir/04-91-62-d2-84-57 --channel 0 --sample-period 1e-05 --x-offset 0.0 --y-min -10 --y-max 10 --y-offset 0.0 pid --Kp 1.0 --Ki 0.0
In this case, the output (blue) follows the input (red) exactly, which is expected. Then I check that the input offset works as expected by setting it to 2 V. Now what I expect to see is 0 output when I set the input to 2 V. This is true with Kp = 1 and Ki = 0, suggesting that the error signal fed to the PID is indeed 0. However, when I now set Ki = 0.01, the output increases linearly in time (screen below).
![integral-gain-0p1.png](https://forum.m-labs.hk/assets/files/2023-08-25/1692967503-225104-integral-gain-0p1.png)
The code I use to obtain the screenshot above:
python -m stabilizer.iir_coefficients --verbose --broker 10.34.16.99 --prefix dt/sinara/dual-iir/04-91-62-d2-84-57 --channel 0 --sample-period 1e-05 --x-offset -2.0 --y-min -10 --y-max 10 --y-offset 0.000 pid --Kp 1.0 --Ki 0.1
My question here is what exactly is fed into the integrator, if the error signal is supposed to be 0?
Now I want to check what the y-offset does:
python -m stabilizer.iir_coefficients --verbose --broker 10.34.16.99 --prefix dt/sinara/dual-iir/04-91-62-d2-84-57 --channel 0 --sample-period 1e-05 --x-offset -2.0 --y-min -10 --y-max 10 --y-offset 1.000 pid --Kp 1.0 --Ki 0.0
In this case, Stabilizer outputs 1 V, which is expected. However, when I now set Ki=0.001, the output rails to +10 V.
![y-offset-1.png](https://forum.m-labs.hk/assets/files/2023-08-25/1692968331-717044-y-offset-1.png)
I use the following code here:
python -m stabilizer.iir_coefficients --verbose --broker 10.34.16.99 --prefix dt/sinara/dual-iir/04-91-62-d2-84-57 --channel 0 --sample-period 1e-05 --x-offset -2.0 --y-min -10 --y-max 10 --y-offset 1.000 pid --Kp 1.0 --Ki 0.001
With smaller values of Ki-s railing still occurs equally fast.
I guess what I do not ultimately understand is the internal diagram of the PID, i.e. at which points the offsets are added, and I completely do not understand why the output rails like this with a nonzero y-offset and Ki. Any help would be appreciated, thanks.