PSO Distance Functions

You can use the PSO Distance module to generate events based on the distance traveled by one or more axes. Using three counters to track up to three position feedback sources, the module calculates the distance traveled in real time. Upon reaching the desired distance, the module generates an event to be used by other modules, most often to trigger the generation of a waveform.

In one dimensional mode, the PSO Distance module tracks a single feedback source. The PSO distance counters change in real time in response to the tracked feedback source. When the counters reach the specified distance, the module generates a distance event. The PSO distance module will generate events when the distance is reached in either the positive or negative direction. Upon generating an event, the PSO Distance module resets the distance counters to prepare for the next event.

In two or three dimensional mode, the distance counters independently track each individual feedback source. In real time, the PSO feature calculates the vector distance of the combined inputs, using the sum of squares of each PSO counter. When the vector distance meets or exceeds the desired distance, the PSO distance module generates an event and resets the counters to prepare for the next event.

In addition to generating events at a fixed distance, the PSO Distance module also supports the use of the drive array to specify a sequence of distances (array mode). The module contains a variety of advanced features, such as allowing you to specify additional reset conditions for the PSO counters.

Configuring the Tracking Inputs

Use the PsoDistanceConfigureInputs() function to specify the number and source of the position feedback signals you want the PSO distance counters to track. The number of elements that you specify in the $inputs array argument determines the operating dimensions of the PSO distance module. If you specify a single element in the $inputs argument, the module operates in one dimensional mode. If you specify two or three elements in the $inputs array argument, the module operates in two or three dimensional mode. The PSO distance module can track input speeds up to 100 MHz (100,000,000 counts/second).

Optional Purchase Necessary: On some Aerotech drives, two and three dimensional PSO distance tracking is a paid option. Review your ordering information to see the number of dimensions that your drive supports.

function PsoDistanceConfigureInputs($axis as axis, $inputs[] as PsoDistanceInput)

Selects the source of each PSO distance counter.

Arguments

$axis  The axis on which to configure the distance counter sources.

$inputs  An array of one to three input sources, one for each distance counter.

Use the PsoDistanceInput enumeration to select the PSO distance tracking inputs for your drive. You must also configure the correct feedback parameters for the input you are using. These can include PrimaryFeedbackType Parameter, AuxiliaryFeedbackType Parameter, and the Primary Multiplier and Auxiliary Multiplier parameters.

If you want to divide each input by an integer scale factor, you can use the PsoDistanceConfigureScaling() function. This can be useful if the resolution of the feedback signals is not the same for all configured tracking inputs. You must specify a number of elements for the $scaleFactors array argument equal to the operating dimensions of the PSO Distance module. If a divider is not necessary, use a scale factor of 1.

function PsoDistanceConfigureScaling($axis as axis, $scaleFactors[] as integer)

Configures the PSO distance counters to apply an integer scale factor for each tracking input.

Arguments

$axis  The axis on which to configure the scale factors.

$scaleFactors  An array of one to three integer scale factors, one per tracking input.

Configuring the Event Distance

The PSO distance module generates an event after the counters detect that a specified distance has been traveled. You can configure the module to generate events using a fixed distance value or using an array of distance values from the drive array. To specify a fixed event distance, use the PsoDistanceConfigureFixedDistance() function. When you use a fixed event distance, the PSO Distance module uses the value you specify in the $distance argument as the event distance. After the counters reach the event distance, the module resets the counters and continues using this value for the next event distance. The specified distance must be a positive integer number of counts. If you try to specify a non-integer number of counts, Automation1 Studio will report an error. You can use the Trunc() function to ensure that you specify a valid integer distance, but this can change your expected event distance.

The PSO Distance module requires a fixed quantity of time to respond to changes at the tracking inputs. As a result, a small latency occurs before the PSO Distance module generates an event. When the PSO Distance module is configured to track a single input, the latency is 40 nanoseconds. When the PSO Distance module is configured to track two or three inputs, the latency is 50 nanoseconds. Additional latency can occur because of the feedback type of the tracking input. Refer to the PrimaryEmulatedQuadratureDivider Parameter and AuxiliaryEmulatedQuadratureDivider Parameter topics for more information.

function PsoDistanceConfigureFixedDistance($axis as axis, $distance as integer)

Configures the distance in counts that the PSO counter or counters must travel for an event to occur.

Arguments

$axis  The axis on which to configure the distance.

$distance  The distance in counts.

To specify an array of distance values, use the PsoDistanceConfigureArrayDistances() function. Before you use this function, make sure that you have already written the desired distance values, in counts, to the drive array locations you specify with the $driveArrayStartIndex and $numberOfDistances arguments. To write values to the drive array to be used as distance values, use the DriveArrayWrite() function and specify DriveArrayType.PsoDistanceEventDistances as the $driveArrayType argument. For more information on writing values to the drive array, see the DriveArrayWrite() function in the Device Functions topic. When you use event distances from the drive array, the PSO Distance module uses the first specified drive array value as the first event distance. After the counters reach the first event distance, the module resets the counters and uses the next drive array value as the next event distance. The module continues using values in the drive array in this fashion until the configured number of event distances is reached. You can also use the $enableRepeat argument to instruct the module to use an infinite number of drive array values. In this mode, the module will return to the value at the $driveArrayStartIndex and use the same set of values again after the module uses the last event distance in the drive array.

function PsoDistanceConfigureArrayDistances($axis as axis, $driveArrayStartAddress as integer, $numberOfDistances as integer, $enableRepeat as integer)

Configures an array of distances in counts that the PSO counter or counters must travel for an event to occur.

Arguments

$axis  The axis on which to configure the distances.

$driveArrayStartAddress  The byte-addressable index of the drive array where the first distance is stored.

$numberOfDistances  The number of distances to be read from the drive array.

$enableRepeat  Configures PSO to continue to use distances after the last distance in the array is used, starting over at the first distance.

Controlling the Distance Counters

By default, the PSO Distance counters are disabled and will not track the configured inputs. In this default disabled state, the module holds the counters in reset. To enable the counters, use the PsoDistanceCounterOn() function. Once enabled, the counters will track the configured inputs and will generate an event upon reaching the specified event distance.

function PsoDistanceCounterOn($axis as axis)

Enables the PSO distance counters, allowing them to track their configured inputs.

Arguments

$axis  The axis on which to enable the PSO distance counters.

To return the counters to their default reset state, use the PsoDistanceCounterOff() function.

function PsoDistanceCounterOff($axis as axis)

Disables the PSO distance counters, causing them to retain their values and ignore their configured inputs.

Arguments

$axis  The axis on which to disable the PSO distance counters.

You can specify additional conditions under which the counters will reset by using the PsoDistanceConfigureCounterReset() function. You can specify multiple counter reset condition options simultaneously. To do this, set the $optionsMask argument to the bitwise OR of all desired option mask options, as defined in the PsoDistanceCounterResetMask enumeration.

function PsoDistanceConfigureCounterReset($axis as axis, $optionsMask as integer)

Configures the conditions which will reset the PSO distance counters.

Arguments

$axis  The axis on which to configure the distance counter reset conditions.

$optionsMask  A bitmask of PSO distance counter reset options. Use the values from the PsoDistanceCounterResetMask enum.

Controlling the Distance Events

By default, the PSO Distance module will not output any generated events to the PSO Event module. To allow events to leave the PSO Distance module, use the PsoDistanceEventsOn() command.

function PsoDistanceEventsOn($axis as axis)

Enables PSO distance events.

Arguments

$axis  The axis on which to enable distance events.

To prevent the PSO Distance module from outputting events to the PSO Event module, use the PsoDistanceEventsOff() command.

function PsoDistanceEventsOff($axis as axis)

Disables PSO distance events.

Arguments

$axis  The axis on which to disable distance events.

When PSO distance events are enabled and you are operating in one-dimensional mode, the PSO Distance module generates events when the counters travel the specified distance in either the positive or negative direction. If you want to allow only a specific direction to generate events, you can use the PsoDistanceConfigureAllowedEventDirection() function. Specify the option for the $eventDirection argument by using the PsoDistanceAllowedEventDirection enumeration. This function has no effect in two or three dimensional mode because the module uses the sum of squares to calculate the distance.

function PsoDistanceConfigureAllowedEventDirection($axis as axis, $eventDirection as PsoDistanceAllowedEventDirection)

Configures the distance counter tracking directions that will cause PSO distance events.

Arguments

$axis  The axis on which to configure the distance event directions.

$eventDirection  The distance event directions to set.