MC_CyclicSwitch
| Function block | MC_CyclicSwitch | ||
|---|---|---|---|
| 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. | |||
| VAR_IN_OUT | |||
| V | AxisIn | AXIS_REF | Reference to an axis. |
| V | OutputIn | MC_OUTPUT_REF | Selects which digital output will be controlled by the corresponding track. |
| V | CyclicSwitchIn | MC_CAMSWITCH_REF |
Controls the switching actions.
|
| VAR_INPUT | |||
| V | Enable | BOOL |
Enables a cyclical track. |
| V | StartPosition | LREAL | The position from which the switch is on. |
| V | IntervalType | MC_LengthType | The type of Interval. mcDistance and mcTime can be used. |
| V | Interval | LREAL | The length of a cycle. It depends on the IntervalType you select. This value must be positive. |
| V | DurationType | MC_LengthType | The type of Duration. mcDistance and mcCount can be used. |
| V | Duration | LREAL |
the duration over which the cycle repeats. It depends on the DurationType you select. This value must be positive. |
| V | ValueSource | MC_Source |
Defines the source for axis values. For example, positions:
|
| VAR_OUTPUT | |||
| V | Done | BOOL | The cyclical task is completed. |
| V | Busy | BOOL | The function block is not finished and new output values are to be expected. |
| V | Active | BOOL | The function block is controlling the axis. |
| V | CommandAborted | BOOL | The command is aborted by another command. |
| V | Error | BOOL | Signals that an error has occurred within the function block. |
| V | ErrorID | MC_Error | Error identification. |
|
|||
| MC_CyclicSwitch | ||||||
|---|---|---|---|---|---|---|
| AXIS_REF | AxisIn | Axis | AXIS_REF | |||
| MC_OUTPUT_REF | OutputIn | Output | MC_OUTPUT_REF | |||
| MC_CAMSWITCH_REF | CyclicSwitchIn | CyclicSwitch | MC_CAMSWITCH_REF | |||
| BOOL | Enable | Done | BOOL | |||
| LREAL | StartPosition | Busy | BOOL | |||
| MC_LengthType | IntervalType | Active | BOOL | |||
| LREAL | Interval | CommandAborted | BOOL | |||
| MC_LengthType | DurationType | Error | BOOL | |||
| LREAL | Duration | ErrorID | MC_Error | |||
| MC_Source | ValueSource | |||||
Use cases:
The following cases are in the RT/Win32 interface, but they help you understand how a cyclic switch work.
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
);