Autofocus uses an outer tracking loop to control motion using feedback from an analog input (or encoder channel, Automation1 only).
A target voltage is specified and the axis moves to the target analog input voltage. 

Automation1

Autofocus does not apply when used with the GI4, the GL4, or the XL4s.

Configuration

The parameters to configure the Autofocus loop are located under Axes > Autofocus on the Configure tab in Automation1 Studio.

  1. To start, set the AutofocusInput parameter (under Inputs) to the analog input channel that you are using with this axis.
    If you are using an encoder input instead, select the Auxiliary Encoder Feedback option. The encoder feedback is scaled to units of Volts as specified by the AutofocusEncoderScaleFactor parameter (under Tracking). The encoder counts are converted to Volts using the scale factor configured in this parameter.
  2. Set the AutofocusTarget parameter (under Tracking) to the target voltage of the analog input. This is the voltage that will be the target, or set-point, of the control loop.

These are technically the only parameters that are required to enable Autofocus. There are other features however that could still be helpful to configure depending on the system.

  • The Autofocus Limits section of the AutofocusSetup parameter (under Tracking) can be configured to enable limits on the Autofocus loop. If enabled, the loop will not command the axis past the limits configured in the AutofocusLimitHigh and AutofocusLimitLow parameters (under Thresholds).
    • The limits can be Enabled (relative), where the values specified in the above limit parameters are relative to the position of the axis when the Autofocus loop is enabled.
    • The limits can be Enabled (absolute), where the limit values are absolute positions on the axis relative to the axis home position.
  • The AutofocusSpeedClamp parameter (under Thresholds) can be configured to set the maximum speed that the Autofocus loop will command the axis to reach.
  • The AutofocusInitialRampTime parameter (under Tracking) can be configured to prevent an abrupt, instantaneous change in the Autofocus loop error if Autofocus is enabled at a voltage far away from the target voltage. Rather than introduce a large error into the Autofocus loop, this parameter will configure the loop to ramp the Autofocus target from the current voltage to the actual specified target voltage over a period of time.
    Note: this parameter can cause problems if the time interval is long enough that the target voltage is not finished ramping by the time the axis reaches the actual target voltage.
  • The AutofocusHoldInput parameter (under Inputs) can be configured to allow a digital input to essentially “pause” the Autofocus loop. When the digital input is active (either high or low depending on the Hold Input Polarity configured in the AutofocusSetup parameter), the axis stops moving but remains under the control of the Autofocus loop.
    When the digital input goes low, the axis continues moving as normal under Autofocus control.
  • Configure the AutofocusDeadband parameter (under Inputs) with a range in volts around the target voltage for which the Autofocus loop will turn off when the axis is within the deadband range.

If a range was specified in the AutofocusDeadband parameter, Autofocus can be enabled in AeroScript using the following command: AutofocusOn(AutofocusFocusMode.Single). This will disable the Autofocus Loop once the axis is within the range specified by the AutofocusDeadband parameter. 
Otherwise the Autofocus Loop can be enabled using AutofocusOn(AutofocusFocusMode.Continuous).

AutofocusOff() will disable the Autofocus Loop.

Tuning

The Loop Polarity setting of the AutofocusSetup parameter (under Tracking) must be correctly configured before tuning the Autofocus loop.
To verify the loop polarity, enable Autofocus and observe the axis. If it moves further away from the target position, the loop polarity must be reversed.

For the most commonly used sensors (position and force), the AutofocusGainK, AutofocusGainKi1, and AutofocusGainKi2 parameters are the only gains needed to tune the response of the loop.

To manually tune the loop, set the AutofocusGainKi1 parameter to a value greater than the servo loop bandwidth and all other AutofocusGainKi gains to zero. Then, adjust only the AutofocusGainK parameter. For low values of AutofocusGainK, the Autofocus Loop should always be stable.



A3200/Ensemble/Soloist

A3200 Only: Autofocus does not apply when used with the GL4, the Ndrive FCL or FLS, the Nmark CLS, GCL, or SSaM, or the XL4s.

Configuration

The parameters to configure the Autofocus loop are located under Axis > Autofocus Loop in the parameter file.

  1. To start, set the AutofocusInput parameter to the analog input channel that you are using with this axis.
  2. Set the AutofocusTarget parameter to the target voltage of the analog input. This is the voltage that will be the target, or set-point, of the control loop.

These are technically the only parameters that are required to enable Autofocus. There are other features however that could still be helpful to configure depending on the system.

  • Configure the AutofocusDeadband parameter with a range in volts around the set-point (target voltage) for which the Autofocus loop will turn off when the axis is within the deadband range.
    The Focus Mode of the AutofocusSetup parameter must be set to Single Focus for the Autofocus loop to turn off when the axis is in the deadband range.
  • The Autofocus Limits section of the AutofocusSetup parameter can be configured to enable limits on the Autofocus loop. If enabled, the loop will not command the axis past the limits configured in the AutofocusLimitHigh and AutofocusLimitLow parameters.
    • The limits can be Enabled (relative), where the values specified in the above limit parameters are relative to the position of the axis when the Autofocus loop is enabled.
    • Or the limits can be Enabled (absolute), where the limit values are absolute positions on the axis, relative to the axis home position.
  • The AutofocusSpeedClamp parameter can be configured to set the maximum speed the Autofocus loop will command the axis to reach.
  • The AutofocusHoldInput parameter can be configured to allow a digital input to essentially “pause” the Autofocus loop. When the digital input is active (either high or low depending on the Hold Input Polarity configured in the AutofocusSetup parameter), the axis stops moving but remains under the control of the Autofocus loop.
    When the digital input goes low, the axis continues moving as normal under Autofocus control.

On the A3200 and Ensemble platforms, Autofocus is enabled/disabled from an AeroBasic program using the AUTOFOCUS [axis] ON and AUTOFOCUS [axis] OFF commands respectively. For the Soloist, these commands are AUTOFOCUS ON and AUTOFOCUS OFF.


Tuning

The Loop Polarity setting of the AutofocusSetup parameter must be correctly configured before tuning the Autofocus loop.
To verify the loop polarity, enable Autofocus and observe the axis. If it moves further away from the target position, the loop polarity must be reversed.

The AutofocusGainKi, AutofocusGainKp, and AutofocusGainKi2 parameters are used to tune the response of the Autofocus loop. The Autofocus loop is a PI control loop where Kp is the proportional gain and Ki and Ki2 are the integral gains. In general Ki and Ki2 control the responsiveness of the loop and Kp controls the loop rigidity.

  • To tune the loop, start with Ki set to 1 and Ki2 and Kp set to 0. This should always be relatively stable and provides a good starting point. 
  • From there, adjust Ki. If the loop seems to be unstable (oscillating), decrease Ki. If it is not responding quickly enough (but is stable), slowly increase Ki.
    It is not uncommon to have a Ki value as low as 0.1. For low values of Ki, the loop should always be stable.
  • Once the loop is responding/converging quickly enough, slowly begin increasing Kp (0.1, 0.2, 0.3, etc.) to start introducing more rigidity into the response. As with any PI loop, too high of a gain will cause the loop to oscillate, or go unstable.

For reference, an example of some final gain values could be Ki = 0.4, Ki2 = 0, Kp = 4. The final gains you end up with will depend on your system.