MCV_CamSwitch
The MCV_CamSwitch function block realises the output of a cam-controlled switch that is assigned to an axis. The cam's range can be defined freely.
The function blocks internal calculations are based on a modulo coordinate system with the value range [0, 3600000] 0,1 µm or 10-4°.
The prerequisite that no more than half the modulo value range is covered by the axis in each PLC cycle must also be fulfilled.
Block diagram
Parameters of the function block
VAR_IN_OUT | |||
| Axis | AXIS_REF | Axis reference. |
VAR_INPUT | |||
| Enable | BOOL | Activates the cam-driven switch. |
| FirstOnPosition | DINT | Position of the axis at which the output of the cam-driven switch changes from FALSE to TRUE, if the axis is rotating in a positive direction. Default unit [0,1µm or 10-4 °] |
| LastOnPosition | DINT | Position of the axis at which the output of the cam-driven switch changes from TRUE to FALSE, if the axis is rotating in a positive direction. Default unit [0,1µm or 10-4 °] |
| CompTime | DINT | Compensation time by which the switch-on phase of the cam-driven switch is advanced or delayed. Unit [1ms] |
| PosType | INT | Selection whether command position or actual position of the axis should be used for comparison with the input variables and for calculation of the switch-on position / switch-off position that is changed by the compensation time. 0: Actual position of the axis (ACTIVE_POS) 1: Command position of the axis |
VAR_OUTPUT | |||
| Active | BOOL | Indicates the current state of the cam-driven switch. |
| State | BOOL | Output of the cam-driven switch. The output is TRUE, if: Case 1: Case 2: |
| Error | BOOL | Indicates if an error has occurred. |
| ErrorID | WORD | Error identification. |
| Pulsed | BOOL | For visualization purposes. If "State" = TRUE, "Pulsed" is assigned TRUE for one second. |
Behavior of the function block
- Input values for ‘FirstOnPosition’ and ‘LastOnPosition’ that are less than the low limit of the modulo coordinate system are set to the low limit and input values that are more than the high limit are set to the high limit. This is done internally in the function block without acknowledgement.
- Specification of a compensation time leads in the function block to modification of the switching positioned defined by ‘ FirstOnPosition’ and ‘LastOnPosition’. If values should result for the modified switching positions that are outside the value range of the modulo coordinate system, these are converted to values within the range. This is done internally in the function block without acknowledgement.
- Modification of the switching positions by specification of a compensation time is done directly in the PLC cycle by they are passed on at the "CompTime" input and fully take effect immediately.
- Specification of the compensation time "CompTime" acts equally on the ‘FirstOnPosition’ and ‘LastOnPosition’. Positive values for "CompTime" lead to a situation in which the "State" output changes after a delay to reach a switching position. Negative values lead to a situation in which the "State" output changes before the switching position are reached.
- Behavior of the ‘State’ output of the cam-controlled switch and the positions that are passed on to the ‘FirstOnPosition’ and ‘LastOnPosition’ inputs. The axis moves in positive direction from the low limit of the modulo coordinate system to the high limit.
Case 1: ‘FirstOnPosition’<‘LastOnPosition’
Case 2: ‘FirstOnPosition’>‘LastOnPosition’
- The function block takes two special cases into account, which result from the fact that the PLC system is a discreet system. These are:
- The axis position at the time tn is before the switch-on position and the axis position at the time tn+1 is after the switch-off position. Therefore, the switching range is less than the distance covered by the axis in one PLC cycle.
- If the axis position is before the switch-on position at the time tn, specification of a compensation time may result in a situation in which the axis position at the time tn+1 is after the switch-off position due to modification of the switch-on points.
- In these special cases, the "State" output becomes TRUE for at least one PLC cycle although it was not detected within one revolution of the axis that the axis position was between the switching positions.