PSO Fixed Distance Pulse Output (GL4)
Demonstrates generating a sequence of pulses each time the vector sum of the tracked GL4 axes moves a fixed distance.
// PSO Fixed Distance Pulse Output (GL4) Example: // Demonstrates generating a sequence of pulses each time the vector sum of the tracked GL4 axes moves a fixed distance. // It also demonstrates configuring the PSO Transformation module so that the PSO Distance module tracks the average of // both encoders of each GL4 axis. To help you visualize the behavior of the PSO output generated by this configuration, // the pulse times used in this program are longer than would be typical and this program triggers data collection. You // can use the Data Visualizer to collect the "OutputActive" bit of the "Pso Status" signal (for $psoAxis) and the // Position Feedback signal (for $motionAxes). To see the complete output from this program, you must collect data at a // period of 1 msec and a time to collect of at least 4000 msec. program var $psoAxis as axis var $motionAxes[] as axis = [X, Y] // Set the PSO axis to the first motion axis. $psoAxis = $motionAxes[0] // Set incremental mode. SetupTaskTargetMode(TargetMode.Incremental) // Enable and home the axis. Enable($motionAxes) Home($motionAxes) // Reset all PSO configuration. PsoReset($psoAxis) // Configure PSO Transformation channel 0 to average the two primary encoders on the X axis. PsoTransformationConfigure(X, 0, PsoTransformationInput.GL4PrimaryFeedbackAxis1Encoder0, PsoTransformationInput.GL4PrimaryFeedbackAxis1Encoder1, PsoTransformationFunction.Average) PsoTransformationOn(X, 0) // Configure PSO Transformation channel 1 to average the two primary encoders on the Y axis. PsoTransformationConfigure(X, 1, PsoTransformationInput.GL4PrimaryFeedbackAxis2Encoder0, PsoTransformationInput.GL4PrimaryFeedbackAxis2Encoder1, PsoTransformationFunction.Average) PsoTransformationOn(X, 1) // Configure the distance module to track: // PSO Transformation channel 0 // PSO Transformation channel 1 PsoDistanceConfigureInputs($psoAxis, [PsoDistanceInput.PsoTransformationChannel0Output, PsoDistanceInput.PsoTransformationChannel1Output]) // Configure the distance module to generate an event every 10 units. This assumes that the counts per unit of both motion axes is the same. // To account for differences between position feedback and emulated quadrature resolution caused by the EmulatedQuadratureDivider parameter, divide the distance by the value of this parameter on the first axis. PsoDistanceConfigureFixedDistance($psoAxis, Round(UnitsToCounts($motionAxes[0], 10) / ParameterGetAxisValue($motionAxes[0], AxisParameter.PrimaryEmulatedQuadratureDivider))) // Enable the distance counter. PsoDistanceCounterOn($psoAxis) // Enable distance events. PsoDistanceEventsOn($psoAxis) // Configure waveform module in pulse mode: 20 ms total time, 10 ms on time (50% duty cycle), 3 periods per event. PsoWaveformConfigureMode($psoAxis, PsoWaveformMode.Pulse) PsoWaveformConfigurePulseFixedTotalTime($psoAxis, 20000) PsoWaveformConfigurePulseFixedOnTime($psoAxis, 10000) PsoWaveformConfigurePulseFixedCount($psoAxis, 3) PsoWaveformApplyPulseConfiguration($psoAxis) PsoWaveformOn($psoAxis) // Select the waveform module output as the PSO output source. PsoOutputConfigureSource($psoAxis, PsoOutputSource.Waveform) // Trigger Data Collection. AppDataCollectionSnapshot() // Move the axes a vector distance of approximately 44 units, expecting 4 events. MoveLinear($motionAxes, [20, 40]) // Disable the axes. Disable($motionAxes) // Stop Data Collection. AppDataCollectionStop() end