PSO Example 2
The following example demonstrates the difference between the Equal, PositiveDirection, and NegativeDirection comparison types. In this example, three channels are used, each with identical parameter settings except for the comparison type.
The parameters are set as follows.
All three channels
Point 0 = 2000
Point 1 = 4000
Point 2 = 6000
Channel 1
ComparisonType = Equal
Channel 2
ComparisonType = PositiveDirection
Channel 3
ComparisonType = NegativeDirection
After setting the above parameters, the axis is moved from position 0 to position 8000 using a position command. The output and active index for each channel during this motion are shown in the following figure.

The channel 3 output is never active. For channel 1 and channel 2, the output is active for only when the axis position equals one of the data points. The duration that the output is active is exactly one cycle.
If the axis is moved from position 8000 to position 0 instead, the output and active index for each channel during this motion will be as follows.

The channel 2 output is never active.
The following is the code for this example.
EventControl::ComparatorSource src;
EventControl::PSOOutput out;
double point[3];
Motion::PosCommand pos;
src.axis = 0;
src.sourceType = EventControl::ComparatorSourceType::PosCommand;
out.outputType = EventControl::PSOOutputType::IOOutput;
out.byteAddress = 0;
out.bitAddress = 0;
out.invert = 0;
point[0] = 2000;
point[1] = 4000;
point[2] = 6000;
pos.axis = 0;
pos.profile.type = ProfileType::Trapezoidal;
pos.profile.velocity = 1000;
pos.profile.acc = 1000;
pos.profile.dec = 1000;
pos.target = 8000;
wmxlib_EventControl->SetPSOConfig(1, EventControl::ComparisonType::Equal, &src, &out, 0);
out.bitAddress = 1;
wmxlib_EventControl->SetPSOConfig(2, EventControl::ComparisonType::PositiveDirection, &src, &out, 0);
out.bitAddress = 2;
wmxlib_EventControl->SetPSOConfig(3, EventControl::ComparisonType::NegativeDirection, &src, &out, 0);
wmxlib_EventControl->SetPSOMultipleData(1, 3, point);
wmxlib_EventControl->SetPSOMultipleData(2, 3, point);
wmxlib_EventControl->SetPSOMultipleData(3, 3, point);
wmxlib_EventControl->StartPSO(1);
wmxlib_EventControl->StartPSO(2);
wmxlib_EventControl->StartPSO(3);
wmxlib_CoreMotion->motion->StartPos(&pos);