After a negative rail was added to the PZT driver and a new Beckhoff scanning tool became available (thanks Daniel!), I was able to simplify the SHG auto locker and modified it such that the positive and negative rails are taken into account. SHG guardian no longer toggles the offset slide bar to look for resonance but instead sends in a scan to look for resonance. Once the resonance is found, the PZT is offset by that X amount of voltage and the loop is engaged. The code currently looks at Trans PD output power. At some point I'd like to make it look at the reflected green power and make it dependent of the input power (which can be done with the LASER IR PD). If SHG is locked with too much or negative voltage being sent to the PZT, it will drop lock to find another sweet spot. The low limit is currently set to 0V, and high limit is set to 85V.
More warning messages and fault conditions will be added in the future. For now it is relatively robust (I think).