4m Active Primary Mirror Control System (obsolete)

  1.0 Primary Mirror control Program description
  2.0 Command description
  3.0 Program Databases
  4.0 Program Maintanance
  5.0 Position Angle conventions
  6.0 Amplitude conventions

This page is very old and much work has been done on the active optics system, including a major upgrade in 2014.  The value of the information here is uncertain.


G.Schumacher, 14 December 1995

FOR MORE INFO: Hard-copy manual "4M Active Primary Mirror Support System Operating Manual", by G.Perez et al.
Also: Calibration Positions for 4MAP Lookup Tables.


Controlling the primary mirror consists of applying a calculated pressure to the support pads. There are 33 pads distributed uniformly in two concentric rings: one called the outer ring, having 21 pads and the other called the inner ring, having 12 pads. In the outer ring there are also three hard points, separated at 120 degrees each, where the mirror sits when there is no pressure applied.

Associated to each pad, there is a pressure controller named MAMAC CONTROLLER, that outputs a pressure proportional to a voltage applied to it. The output pressure in turn is sensed and converted back to a voltage that is read by an analog to digital converter. Therefore, in order to control each MAMAC there is a DAC and an ADC device connected to it.

A control cycle consists then on calculating the pressure to apply to each pad, convert that pressure to a voltage, instruct the DAC to generate that voltage, and read back the voltage proportional to the output pressure sensed by the ADC. In between control cycles, the program constantly monitors each device and takes several actions on error conditions.

The control program is designed to operate in one of two modes. The first mode is called EMULATION MODE, and consists of emulating the behaviour of the old "passive" mechanical controllers. That behaviour is based on applying an equal pressure to every pad in each ring, proportional to the cosine of the zenith distance of the telescope. This pressure is called the Nominal Pressure and can be defined independently for the outer and inner ring. The second mode is called ACTIVE MODE and consists of adding different pressures to the basic Nominal ones, calculated based on known aberrations, parameterized in terms of tables of coefficients for each term of the distortion model. Switching between modes is done with the ACTIVE coefficients command.

The control program runs in one of five states: The START state, the HALT state, the ERROR state, the ADJUST state and the CHECK state.

  • The START state is entered by the GO command. The program checks that the previous state is HALT or otherwise rejects the command. Upon entering the START state, the DAC's and ADC's are tested by reading the status from each device. Then, the program checks the state of the air switch and of the zenith switch. If all conditions are met, the state is changed to ADJUST and the emulation mode is selected.
  • The HALT state is the initial state of the program, and is also entered by the HALT command or the RESET command after an error condition. The HALT command causes the pressure to be dropped by sending a zero voltage to all the MAMACS.
  • The ERROR state is entered by one or more of the following conditions:
  •  air switch off

    • lift off switches activation
    • DGH modules failures
    • MAMAC modules failures
    • TCS communications broken

An error condition causes the pressure to be dropped abruptly by activating the safety valves. A zero voltage is also written to the DAC's. In order to activate the control again, it is necessary to change to the HALT state by issuing the RESET command, followed by the GO command.

The ADJUST state is entered from the START state or from the CHECK state by an ADJ command. In this state, the pressures are calculated and then converted to voltages that are applied to the MAMACS. Before applying the new voltages a check is made to lower first all pressures that will be lower than the present ones and then raising all pressures that will be higher than the present ones. This is to avoid an intermediate situation in that the mirror might be lifted due to the total sum of pressures might be larger than the mirror weight.

The CHECK state is entered after a successfull adjust process. In this state the program continuously monitors the condition of the DGH modules and the MAMAC modules. In particular, the pressure is read back and checked against the requested one. If a pressure changes, no attempt is made to correct it, but the ERROR state is entered if the change is greater than a certain limit (presently 2 psi). The TCS link is also monitored. If no TCS command is received after 1 second has elapsed from the last one, it is assumed that the RS485 link or the TCS is broken and the pressure gets dropped by openning the safety valves.

back to top


The user interacts with the program by giving commands in a Command Window at the PC terminal. Several of the commands could also be issued from the TCP user interface. In that case, all commands should be preceded by the "box id". The id for the 4M Active Primary control PC is "4map".


This command turns on or off the calculation of active corrections for a given mirror position. By default, the program starts in the off state. Format:

act [on / off]


This command causes the program to calculate a new set of pressures and apply them to the MAMAC controllers. This command takes as its arguments the present telescope hour angle (hours) and declination (degrees).

adj hour_angle declination
adj -1.23 -47.35


c0, c2, c3, c4

Specify new values for the individula active corrections. c0 specifies spherical, c2 astigmatism, c3 trefoil and c4 quadrafoil.
These commands set the total value of the corresponding correction.

c0 amplitude(nm)
c0 2000
c2 amplitude(nm) PA(deg)
c2 1000 45
c3, c4 have same format as c2.


Specify values which will be added vectorially to the existing amplitude and PA of the corresponding correction. "twk" refers to the "tweak" command in the TCP. Format same as c0,c2,c3,c4.


This command reads the digital input port of a DGH module. The result is returned as an hex number.

din module_address
din Q


This command writes to the digital output port of a DGH module. The value should be given as an hex number.

dout module_address value
dout x 2


This command activates the control cycle. The telescope must be at zenith with air on and the program must be in the HALT state. A test is made of all modules, and if satisfactory, the mirror gets supported with the proper pressures.


This command halts the control cycle by sending a zero voltage to all the MAMACS. In this state, all periodical TCS communications ceases.


Lists help info on screen.


This command defines the DGH addresses for the inner ring pads. See the Nomenclature Diagram for the numbering scheme.

i pad_number DAC_address ADC_address
i 8 2 Y


This command defines the DGH addresses for the outer ring pads. See the Nomenclature Diagram for the numbering scheme.

o pad_number DAC_address ADC_address
o 8 J q


This command changes the default Nominal Pressure for the inner ring. The pressure is given in units of psi.

pin [pressure]
pin 9.0


This command changes the default Nominal Pressure for the outer ring. The pressure is given in units of psi.

pout [pressure]
pout 8.5


This command calculates and prints the pressures on the screen. The command arguments are an hour angle and a declination. This command doesn't interfere with the normal calculations done with the adj command, so it's useful for debugging the active corrections.

pp hour_angle declination


This command resets an error condition and place the program in the HALT state. This command must be given prior to go, after an error condition.status This command returns a textual description of the program status. Possible responses include:


This message indicates that the system is active and no errors are present.


This message indicates that the system is in the HALT state. To activate it, a go command must be given.

ERROR 5: MAMAC 12 BAD 2.351 0.000

This message indicates that when checking the MAMAC voltage (number 12 in this case), a difference of more than 0.5 volts was detected. This might be due to a bad DAC, a bad ADC or a bad MAMAC. To determine the offender, a specific test should be run for each module associated with that MAMAC unit (see the Nomenclature Diagram).


This message indicates that the specific module (2 in this case) is not responding to commands issued to it.


This command orders the execution of test for the DGH modules or MAMAC units. The tests are run on all modules or units. If you want to test a specific module, use the vin or vout commands. The responses are similar to the ones described under the status command.

test dgh/mamac


This command reads the voltage of one DGH module or all ADC modules. The argument is the module address. If the address is '*' then read all ADC modules.

vin module_address (or *)


This command outputs a voltage to one or all DAC modules. Be aware that this is an active command so if air is on, a pressure will be applied to the pads. Use with care and only if you know what you are doing. As a rule of thumb, the relation of voltage to pressure is close to 1 to 4 (i.e. 1 volt 4 psi).

vout module_address (or *) voltage
vout * 0.0


This command defines the DGH addresses for modules not related with the pads. This are the ones that act on the solenoid valves or receive information on the various switches.

x module_number module_address


This command sets all voltages to zero. This is equivalent to vout * 0.0.


Lists help info on screen.

back to top


The program uses two databases for its proper functioning: a Parameters Database, called "4map.par" and a Coefficients Database, called "4map.cof". These are currently located on ctiot0, on the /ut02 disk, in the 4map directory.(8Jul04).

The Parameters Database is a collection of commands that defines the starting values for the program. Any valid command could be placed in this file, that gets executed at startup. In particular, the DGH addresses are to be found here so, if a module is changed the new address should be modified accordingly. A '*' character at the beggining of the line indicates a comment; therefore, the file is self documented.

The Coefficients Database contains the parameter values for the different aberrations, mapped around the sky. The map is made in terms of zenith distance and azimuth positions. Each line contains the values for a certain azimuth. Normally, there are 10 values per line, corresponding to zenith distances of 0°, 15°, 30°, 45° and 60°. The first 5 values corresponds to the amplitude parameter and the next 5 values corresponds to the angle parameter. The azimuth values span the range of 0° to 360°, in steps of 30°. Again, an '*' character at the beginning of the line indicates a comment. The hour angles and declinations at which the IMAN measurements for this table should be made are listed in "Calibration Positions for 4MAP Lookup Tables".

back to top


All the source code resides in directory \AP\SOURCE on drive C: of the control PC. The program is entirely written in C and the MICROSOFT C/C++ compiler rev 8.0 is used to produce the object modules.

The process of making a new executable is automated by using the NMAKE utility. There is a MAKEFILE that declares all the files and libraries needed. The procedure then consist of editting the necessary files and then typing the command 'NMAKE'.

back to top


The active force patterns are generated by using the Mamac controllers to increase or decrease the air pressure in specific air bags, as compared to the nominal air pressure required to support the mirror at a given telescope position. A positive correction to the air pressure moves the corresponding part of the mirror upwards, while a negative correction lowers the corresponding part of the mirror.
4MAP can correct abberations with the azimuthal position cos(m*phi - phi0), for the following values of m:

m abberation
0 spherical
2 astigmatism
3 triangular (trefoil)
4 quadrafoil


The corresponding cos(m*phi-phi0) force patterns are then superimposed on the mirror. The sinusoidal force pattern is repeated m times going around the mirror. An amplitude and a position angle must be specified in order to generate this pattern.
The position angle convention for phi0, when a positive amplitude is requested, is:

  • For phi0 = 0, the peak additional (upwards) force is always at the pad on the NORTH side of the mirror.
  • For other values of phi0, the peak is moved through an angle phi0/m, which increases from north through west for positive values of phi0.
  • For m=0 (spherical abberation), positive amplitudes cause an increased upwards force on the inner ring of supports, and a decreased force on theouter ring

back to top


When TWEAK commands are entered through the TCP menu system, the requested amplitudes are accepted in the units measured by IMAN, and are then scaled by calibration factors before being passed on to 4MAP. The current calibration factors are:

Abberation m Calibration factor
Spherical 0 0.00288
Astigmatism 2 0.00101
Trefoil 3 0.00117
Qaudrafoil 4 0.00123

where the values entered through the menu commands are DIVIDED by the calibration factor before being passed on to 4MAP.

However, when force patterns requests are entered directly into the 4MAP PC using the commands c0,c2,c3 or c4, the amplitudes must be specified without the scale factors. The units then correspond to the deflections predicted by a simplified analysis of the mirror performed by Lothar Noethe at ESO.

The calibration factors also convert the micron units used by IMAN into the nanometer units used by 4MAP, and would be 0.001 if the calculations by Noethe had been perfect. So Lothar's analysis came really close on every abberation except spherical.

back to top