SetAxisCyclicSwitch

Uses an axis' position to control a switch that triggers a digital output repeatedly. When an axis reaches a certain position, a switch is turned on or off. A switch can be controlled by a forward and backward movement of an axis.

Syntax

KsCommandStatus SetAxisCyclicSwitch(
     int Index,
     McOutput Output,
     double StartPosition,
     McCamSwitch CyclicSwitch,
     McLengthType IntervalType,
     double Interval,
     McLengthType DurationType,
     double Duration,
     McSource ValueSource
);

Parameters

Index [in]: the index of an axis. Indexes are zero based. Aliases affect this parameter.

Output [in]: selects which digital output will be controlled by the corresponding track. See the McOutput structure.

StartPosition [in]: the position from which the cycle starts.

CyclicSwitch [in]: controls the switching actions. See the McCamSwitch structure.

IntervalType [in]: the type of Interval. mcDistance and mcTime can be used. See the McLengthType type.

Interval [in]: the length of a cycle. It depends on the IntervalType you select. This value must be positive.

DurationType [in]: the type of Duration. mcDistance and mcCount can be used. See the McLengthType type.

Duration [in]: the duration over which the cycle repeats. It depends on the DurationType you select. This value must be positive.

ValueSource [in]: defines the source for axis values. For example, positions. See the McSource type.

Return value

Returns the KsCommandStatus structure.

Remarks

Example

Case 1

A cyclic switch completes its task for the duration.

McOutput outputBit = {
   FALSE,   //Axis or IO module. FALSE = I/O.
   0,       //Index
   0        //Offset
}

McCamSwitch cyclicSwitch = {
   0,    //TrackNumber
   40,   //FirstOnPosition 
   60,   //LastOnPosition
   1,    //AxisDirection. 1 = Positive.
   0,    //CamSwitchMode. 0 = Position.
   0     //Duration. It is not used in this case.
);

Command = SetAxisCyclicSwitch(
   TargetAxis,    //Index
   outputBit,     //Output
   100,           //StartPosition
   cyclicSwitch,  //CyclicSwitch
   mcDistance,    //IntervalType
   100,           //Interval
   mcDistance,    //DurationType
   250,           //Duration
   mcSetValue     //ValueSource
);

Case 2

A cyclic switch is aborted before it completes the task.

McOutput outputBit = {
   FALSE,   //Axis or IO module. FALSE = I/O.
   0,       //Index
   0        //Offset
}

McCamSwitch cyclicSwitch = {
   0,        //TrackNumber
   0,        //FirstOnPosition
   0,        //LastOnPosition
   1,        //AxisDirection. 1 = Positive.
   1,        //CamSwitchMode. 1 = Time.
   0.003     //Duration
);

Command = SetAxisCyclicSwitch(
   TargetAxis,    //Index
   outputBit,     //Output
   100,           //StartPosition
   cyclicSwitch,  //CyclicSwitch
   mcTime,        //IntervalType
   0.005,         //Interval
   mcCount,       //DurationType
   3,             //Duration
   mcSetValue     //ValueSource
);

Requirements

  RT Win32
Minimum supported version 4.1 4.1
Header ksmotion.h ksmotion.h
Library KsApi_Rtss.lib KsApi.lib

See also

AbortCommand

PowerAxis

ResetAxis

SetAxisCamSwitch