-

Y_AX_DigitalCamSwitch

Image

This function block commands a group of discrete output bits analogous to a set of mechanical cam controlled switches driven by a rotating shaft. Forward and backward movements are allowed. A maximum of 32 outputs and 256 switches are supported.

Parameters:

* Parameter Data Type Description Default
VAR_IN_OUT
B Axis AXIS_REF Logical axis reference.
B Switches Yt_AX_CamSwitchRef Reference to the switching actions. 256 maximum switches.
E TrackOptions Yt_AX_TrackRef Reference to the track related properties. 32 maximum tracks.
VAR_INPUT
B Enable BOOL The function will continue to execute while enable is held high. FALSE
E EnableMask DWORD Individually enables the tracks [0..31] per the bit pattern. Value of 1 means Enabled, 0 means disabled. Least significant bit corresponds to Track [0]. Default if not connected is All Tracks Enabled. DWORD#FFFFFFFF
VAR_OUTPUT
B Busy BOOL Function Block Enable is ON but no tracks are enabled (EnableMask = 0).
B Error BOOL Set high if an error has occurred during the execution of the function block. This output is cleared when 'Execute' or 'Enable' goes low.
E ErrorID UINT If Error is true, this output provides the Error ID. This output is reset when 'Execute' or 'Enable' goes low.
B InOperation BOOL Function Block Enable is ON and at least 1 track is enabled (EnableMask is <> 0).
E Output DWORD Resulting CamSwitch output for each track per the bit pattern. Least significant bit corresponds to Track [0]. This Output will need to be tied to physical outputs outside of the DigitalCamSwitch FB.
E SWErrorCode Yt_AX_SwErrorStruct Switch Error Code Structure that identifies particular warnings with switch settings. The user can monitor this ErrorCode if Warning output comes on.
E Warning BOOL Signals that a non-critical error has occurred within the function block. In this case, the block will continue to function.

Notes:

• This functionality is sometimes called PLS – Phase or Position or Programmable Limit Switch.

• Switches will be evaluated for both forward and reverse travel of the axis.

• OnCompensation and OffCompensation will only be applied when the axis is moving in the Positive Direction.

• Track Hysteresis is not supported.

Restrictions

If the output specified in the PLS is also controlled somewhere else in the project then the last instruction wins. This would also be the case when a single output is used in two PLS blocks.

The PLS block will support a maximum of 256 switches and 32 outputs. This means that the block will react to a maximum of 512 positions (two for each switch).

If the cam-like lobes of multiple switches intersect with each other for a single track the net effect would be an OR-ing of the switches.

Example1 SW1: on at 10, off at 50, SW2: on at 20, off at 30; net effect on at 10 off at 50.

Example2 SW1: on at 10, off at 50, SW2: on at 40, off at 60; net effect on at 10 off at 60.

Operation

On the rising edge of Enable, the input data will be checked against restrictions. The busy output will remain on until at least 1 track is enabled and the FB is controlling the outputs, then the InOperation bit will be set and the busy bit reset.

While the Enable is on, the EnableMask value will be read each scan and effect the output control.

On the falling edge of Enable, all outputs will be reset (turn off), and the InOperation, Busy, and Error bits will be reset. ErrorID output will be set to 0.

Input Data that is read only on rising edge of Enable:

CAMSWITCH_STRUCT[].TrackNumber

CAMSWITCH_STRUCT[].AxisDirection

CAMSWITCH_STRUCT[].CamSwitchMode

AXIS_REF

CAMSWITCH_REF.MasterType

CAMSWITCH_REF.MachineCycle

CAMSWITCH_REF.LastSwitch

Input Data that is read continuously while Enabled:

CAMSWITCH_STRUCT[].FirstOnPosition

CAMSWITCH_STRUCT[].LastOnPosition

CAMSWITCH_STRUCT[].Duration

CAMSWITCH_STRUCT[].FirstOnPosition

TRACK_STRUCT[].OnCompensationScaler

TRACK_STRUCT[].OffCompensationScaler

Enable

EnableMask

Output Bits: Boolean Outputs are exclusive


AxisDirection must be 0, any other number will default to 0. (values 1 and 2 not supported.)

CamSwitchMode must be 0 or 1, any other number will default to 0.

Error Description:

See theFunction Block ErrorID List.

Example 1:

Consider the PLS requirement shown in the figure below. There are 4 tracks (0, 1, 2, 3) in the set up and a total of 5 switches (0, 1, 2, 3, 4).


Track 0 has 2 switches associated with is:

Track 1 has 1 switch associated with it:

Track 2 has 1 switch associated with it:

Track 3 has 1 switch associated with it:



Image

The switches can be defined and initialized as follows:


undefined

Enable the Y_AX_DigitalCamSwitch FB and set Axis1 in motion using MC_MoveVelocity. Setting the EnableMask = 16#0000000F will enable Tracks 1-4. Alternatively, The EnableMask can enable each track by setting EnableMask.X0 through EnableMask.X3 = TRUE.


Y_AX_DigitalCamSwitch-FBStart.png


Once the Y_AX_DigitalCamSwitch FB is enabled and is in operation, the track output states will be as shown in the logic analyzer plot given below. Note that the outputs will correspond to the position of the axis.


Y_AX_DigitalCamSwitch-LogicAnalyzer.png




Example 2:

If speed compensation needs to be applied to individual tracks, it can be accomplished by specifying either OnCompensationScaler or OffCompensationScaler in the TRACK_REF data type (TrackOptions in Y_AX_DigitalCamSwitch). An example of applying a -0.06 OffCompensation on track 1 and 0.05 OnCompensation on track 3 is shown below.



Y_AX_DigitalCamSwitch-InitCOmp.png

Y_AX_DigitalCamSwitch-LogicAnalyzer-OffScaler.png




 


This help information is valid for iCube Engineer Online Help 2025.6

Copyright © 2025 YASKAWA EUROPE GmbH and © 2025 YASKAWA America, Inc.