HolyLab / Imagine

A graphical interface for recording with OCPI microscopes.
1 stars 1 forks source link

Improve fast scanning #67

Open Cody-G opened 5 years ago

Cody-G commented 5 years ago

Currently in fast scanning experiments I use the piezo in closed-loop mode. This has the advantage of addressing the troublesome piezo control issues of hysteresis and drift. It has the drawback that all of our command are interpreted/transformed by a PID controller, making it difficult to optimize the control waveform to generate a desired response. It turns out that when the piezo command waveform is periodic (as is the case for my experiments) hysteresis is not a problem in open loop mode because the piezo quickly stabilizes into a consistent trajectory. The "drift" however is still a problem: In open-loop mode the mean value of the piezo position slowly drifts up or down over a period of minutes during a dynamic recording. This drift is corrected by the "I" (Integral) term of the "PID" controller. That term effectively adjusts the gain of the controller so that the mean of the command equals the mean of the response signal.

Recently I realized that we can have the best of both worlds if we run in open loop mode and handle the job of the "I" term on our own in software (Since drift is a slow process, the latency of software is not a problem). This would be easy to implement using https://github.com/HolyLab/Imagine.jl to adaptively update the control signal based on drift. I expect that this will allow us to better tune the piezo command to make the response more triangular without worrying about sending the PID into an unstable regime that could cause damage. Before this can work I'll need to make some changes to Imagine.jl and we'll need the ability to operate Imagine in a camera-only mode; see https://github.com/HolyLab/Imagine/issues/66.

kdw503 commented 5 years ago

Ok, I understood. This is why you need camera-only mode.

timholy commented 5 years ago

This sounds like a great idea. Given how much control you already do, going to open loop mode just feels right---otherwise you'll forever be trying to outsmart the PID.