MC_DigitalCamSwitch (FB)¶
FUNCTION_BLOCK MC_DigitalCamSwitch
This function block is analogous to switching on a motor shaft: The function block commands a group of discrete output bits to switch in analogy to a set of mechanical cam controlled switches connected to an axis. Forward and backward movements are allowed.
Note
Changing the VAR_IN_OUT-parameters requires a new rising edge of the Enable input.
Hint
This functionality is sometimes called PLS – Phase or Position or Programmable Limit Switch.
Example
Assume the following parameter values set:
Parameter
Type
Switch01
Switch02
Switch03
Switch04
TrackNumber
INT
1
1
1
2
FirstOnPosition [u]
REAL
2000
2500
4000
3000
LastOnPosition [u]
REAL
3000
3000
1000
-
AxisDirection
INT
1=Pos
2=Neg
0=Both
0=Both
CamSwitchMode
INT
0=Position
0=Position
0=Position
1=TIME
Duration
TIME
-
-
-
1350
Assume further, that no on/off compensation nor hysteresis is employed. The figure demonstrates the behavior of the outputs, when the axis is moving continuously in positive direction. The axis is a modulo axis with a modulo length of 5000 u.
![]()
Example of DigitalCamSwitch¶
Now assume that on compensation (-125ms) and off compensation (+250ms) are employed.
![]()
Detailed description of Switch01¶
The resulting behavior of the outputs, when the axis is moving continuously in negative direction without on/off compensation and without hysteresis.
![]()
Example in negative direction¶
- InOut:
Scope
Name
Type
Initial
Comment
Inout
AxisReference to axis the switches are connected to
SwitchesReference to switching actions
OutputsReference to signal outputs that are directly related to the referenced tracks
TrackOptionsReference to structure containing track related properties, e.g. the on/off compensations per output/track.
Input
EnableBOOLFALSE
TRUE: Enables execution of function block.EnableMaskDWORD16#FFFFFFFF
32 bits of
BOOLenabling the different tracks. Least significant data is related to the lowestTrackNumber.TappetModetp_mode_auto
Mode for position outputs
Output
InOperationBOOLFALSE
TRUE: Commanded tracks have been enabled.BusyBOOLFALSE
TRUE: Execution of function block has not been finished yet.ErrorBOOLFALSE
TRUE: Error has occurred within the function block.ErrorIDSMC_ERROR0
Error identification
SwitchCorruptedINTSignalizes potential problems that arise from compensation times: Compensation times may lead to the case that the extrapolated position passes one switching point several times before passing the other switching point again. As a consequence, a non-inverted switch may become inverted (and the other way around). In this case, this variable indicates the switch in concern. There are two possible reasons:
noisy velocity-values,
“big” difference between on- and off-compensation.
-1 means that such behaviour hasn’t occured.
Structure: