Deciphering Malcolm's real-time code

5 July 2001
M. Chun

1. LOOP PROCESSOR (lp)

The guts of the real-time servo loop are in the routine feedback() (in feedback.c). This routine does the three loop processes (high-order DM loop, secondary off-loading to the tip/tilt mount, and the tertiary off-loading to the telescope mount loop).

Procedure:

1. Check control that a valid matrix is loaded
2. Check that the membrane stroke is not equal to zero
3. Calculate the high order error signal from the sensors and store the resulting error signal (-> delta_drive). Presummably the appropriate memory has already been loaded with the new wavefront sensor signals as there isn't a line in the code which seems to do this. I guess whatever loads the signals into memory prompts the call to feedback().
4. Do the control servo loop. For Hokupa'a this is a simple integrator
new_voltages = old_voltages + gain * delta_drive
5. Check the range of the actuators. The code for Hokupaa-36 simply pins any actuator values greater than the specified maximum/minimum (+/-1). It could try to find an overall offset for the DM to use as much dynamic range as possible
6. Output the voltages to the DM drive electronics.
7. Do tip/tilt loop
a. Calculate the two T/T signals from the DM drive signals
b. Do control servo loop for T/T actuators with TTgain
c. Check range
d. Output voltages to T/T actuators
8. Calculate the miror modes from the drive signals
9. Subtract from the DM drive signals any contribution from any mode which has a near-zero eigenvalue.

Note on subtracting out the null modes from the DM drive signals

The modes with near-zero eigenvalues are normally excluded from the wavefront reconstruction however, saturation of actuators and hysterisis can cause some of these modes to creep into the mirror figure. Malcolm includes as part of the basic servo (but after the DM has been updated), code to project out any contribution from null modes in the DM voltages. You can easily decompose the voltages accumulated and sent to the DM into the mirror modes with the matrix multiplication:

mode_coefficients = [U] [act]
The contribution from the null modes is then simply the sum over all the null modes of the mode_coefficients times the mirror modes.

null_contribution += null_contribution + mode_coef(i)*mirror_mode(i)
This null contribution should be subtracted from the DM actuators voltages.

Note: There is a version of the Hokupa'a code to do this that seems to have a problem in it. (This is to be confirmed). Malcolm uses the second matrix [V] instead of the eigenfunctions array [U].