MC_DigitalCamSwitch

Function block MC_DigitalCamSwitch
Uses an axis' position to control a switch that triggers a digital output. 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
B AxisIn AXIS_REF Reference to an axis.
B SwitchesIn ARRAY [0..255] OF MC_CAMSWITCH_REF Controls the switching actions. The track numbers need to be in order.
E OutputsIn ARRAY [0..31] OF MC_OUTPUT_REF Selects which digital output will be controlled by the corresponding track.
E TracksIn ARRAY [0..31] OF MC_TRACK_REF Adds the compensation time and hysteresis to the switches on a track. The TrackNumber is defined in Switches.
VAR_INPUT
B Enable BOOL

Enables the tracks. If this value is FALSE, all tracks are disabled; if this is TRUE, see EnableMask to check if the specified tracks are enabled.

E EnableMask DWORD Enables the different tracks. This parameter is 32 bits of BOOL. The corresponding track in the track array is enabled when its BOOL value is set to one.
E ValueSource MC_Source

Defines the source for axis values. For example, positions:

  • mcCommandedValue, mcSetValue – synchronization on set value. We suggest you use these settings.
  • mcActualValue – synchronization on actual value. This setting may not be stable.
VAR_OUTPUT
B InOperation BOOL Checks whether the commanded tracks are enabled.
E Busy BOOL The function block is not finished and new output values are to be expected.
B Error BOOL Signals that an error has occurred within the function block.
E ErrorID MC_Error Error identification.
  • MC_CAMSWITCH_REF is a vendor specific structure that defines switches for digital cam.
  • MC_OUTPUT_REF is a vendor specific structure linked to the (physical) outputs.
  • MC_TRACK_REF is vendor specific structure containing the track properties. For example, the compensation per track (A track is a set of switches related to one output). It can also contain the reference to the output.
  • This functionality is sometimes called PLS – Phase or Position or Programmable Limit Switch.

 

  MC_DigitalCamSwitch  
AXIS_REF   AxisIn   Axis   AXIS_REF
ARRAY [0..255] OF MC_CAMSWITCH_REF   SwitchesIn   Switches   ARRAY [0..255] OF MC_CAMSWITCH_REF
ARRAY [0..31] OF MC_OUTPUT_REF   OutputsIn   Outputs   ARRAY [0..31] OF MC_OUTPUT_REF
ARRAY [0..31] OF MC_TRACK_REF   TracksIn   Tracks   ARRAY [0..31] OF MC_TRACK_REF
BOOL   Enable   InOperation   BOOL
DWORD   EnableMask   Busy   BOOL
MC_Source   ValueSource   Error   BOOL
        ErrorID   MC_Error
             

 

Elements within the MC_CAMSWITCH_REF structure

B/E Parameter Type Description
B TrackNumber INT The index of a track. Indexes are zero-based.
B FirstOnPosition [user unit] LREAL The position from which the switch is on.
B LastOnPosition [user unit] LREAL The position from which the switch is off.
E AxisDirection INT

The direction of an axis. The default value is zero. If you select one or two, the switch is active only when the axis is moving in the specified direction.

Both: 0, Positive: 1, Negative: 2.

E CamSwitchMode INT

The cam switch is controlled by axis' positions or time. The default value is zero. If choosing Position, you need to set FirstOnPosition and LastOnPosition; if choosing Time, you need to set FirstOnPosition and Duration.

Position: 0, Time: 1.

E Duration TIME How long the switch is on. This property is available when CamSwitchMode is Time. The unit is second.

 

Elements within the MC_TRACK_REF structure

B/E Parameter Type Description
E OnCompensation TIME The length of time with which a switch is turned on (rising edge) before or after a switching point per track. If the value is positive, the switch-on will be delayed; if the value is negative, the switch-on will be advanced.
E OffCompensation TIME The length of time with which a switch is turned off (falling edge) before or after a switching point per track. If the value is positive, the switch-off will be delayed; if the value is negative, the switch-off will be advanced.
E Hysteresis [unit] LREAL The distance from a switching point (in positive and negative direction) in which a switch is not turned on or off until the axis has left this area. This can avoid frequent switching around a switching point.

 

This definition of a cam has a start and an end position, so the user can define each single cam, which has a FirstOnPosition and a LastOnPosition (or time). This function or function block is similar to a mechanical cam but has the additional advantages that the outputs can be set for a certain time, and to give it a time-compensation and a hysteresis.

CamSwitchMode: it can be position or time.

Duration: time, the output of a time cam is ON. The time compensation (OnCompensation and OffCompensation) can be positive or negative. Negative means the output changes before the switching position is reached.

Hysteresis: this parameter avoids the phenomenon where the output continually switches if the axis is near the switching point and the actual position is jittering around the switching position. Hysteresis is part of MC_TRACK_REF, which means that a different hysteresis is possible for each track.

 

Example of MC_CAMSWITCH_REF

Parameter Type Switch01 Switch02 Switch03 Switch04 ... SwitchN
TrackNumber INTEGER 1 1 1 2    
FirstOnPosition [unit] LREAL 2000 2500 4000 3000    
LastOnPosition [unit] LREAL 3000 3000 6000 --    
AxisDirection INTEGER 1=Pos 2=Neg 0=Both 0=Both    
CamSwitchMode INTEGER 0=Position 0=Position 0=Position 1=Time    
Duration LREAL -- -- -- 1.35 seconds    

 

Example of MC_OUTPUT_REF

Parameter MC_OUTPUT_REF[0] MC_OUTPUT_REF[1] MC_OUTPUT_REF[2] - - - MC_OUTPUT_REF[31]
IsAxis FALSE FALSE FALSE - - - FALSE
Index 0 0 0 - - - 0
BitOffset 0 1 2 - - - 31

 

Example of an I/O module

 

The figure below uses the values from the example of MC_CAMSWITCH_REF above. It uses neither On/OffCompensation nor Hysteresis. This is the behavior of the outputs, when the axis is moving continuously in the positive direction.

MC_DigitalCamSwitch – Positive Direction

 

Positive Direction: Behavior of the Outputs

TrackNumber 1 (Switch01, 02, 03) is mapped to MC_OUTPUT_REF[1] and TrackNumber 2 (Switch04) is mapped to MC_OUTPUT_REF[2]. When Switch01, Switch02, and Switch03 are triggered, the second output (Output 1) on the first I/O module (Index 0) is turned on. When Switch04 is triggered, the third output is turned on (Output 2).

 

Example of On/Off Compensation

This example uses OnCompensation -125ms and OffCompensation +250ms.

 

The figure below shows the behavior of the outputs, when the axis is moving continuously in the negative direction without On/OffCompensation and Hysteresis.

 

MC_DigitalCamSwitch – Negative Direction

 

Negative Direction: Behavior of the Outputs

 

EnableMask

EnableMask is a DWORD parameter that contains 32 bits. Each bit is a BOOL value that controls an output. An output is enabled or disabled by setting its corresponding bit TRUE or FALSE. For example, bit 0 controls MC_OUTPUT_REF[0] and bit 1 controls MC_OUTPUT_REF[1]. If bit 0 and 1 are TRUE, their outputs are enabled, which means their outputs will be turned on when their corresponding switches are triggered; if they are FALSE, their outputs are disabled, which means their outputs won't be turned on even if their corresponding switches are triggered.

Bits Bit 0 Bit 1 Bit 2 Bit 3 - - - - Bit 31
Value TRUE/FALSE TRUE/FALSE TRUE/FALSE TRUE/FALSE - - - - TRUE/FALSE

 

Example of MC_OUTPUT_REF

Parameter MC_OUTPUT_REF[0] MC_OUTPUT_REF[1] MC_OUTPUT_REF[2] - - - MC_OUTPUT_REF[31]
IsAxis FALSE FALSE FALSE - - - FALSE
Index 0 0 0 - - - 0
BitOffset 0 1 2 - - - 31

 

Example 1 of EnableMask Bits

Bit 0, 1, and 2 are TRUE, which means Output 0, 1, and 2 are enabled. The outputs are turned on when their corresponding switches are triggered.

Bits Bit 0 Bit 1 Bit 2 Bit 3 - - - - Bit 31
Value TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE

 

Positive Direction: Behavior of the Outputs

 

Example 2 of EnableMask Bits

Bit 0 and 2 are TRUE, which means Output 0 and 2 are enabled. Only these two outputs are turned on when their corresponding switches are triggered.

Bits Bit 0 Bit 1 Bit 2 Bit 3 - - - - Bit 31
Value TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE

 

Positive Direction: Behavior of the Outputs

 

Example 3 of EnableMask Bits

All bits are FALSE, which means all outputs are disabled. No outputs are turned on even if their corresponding switches are triggered.

Bits Bit 0 Bit 1 Bit 2 Bit 3 - - - - Bit 31
Value FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

 

Positive Direction: Behavior of the Outputs