SetAxisHomeSwitch

Sets a digital sensor to be used as a homing switch.

Syntax

KsError SetAxisHomeSwitch(
     int Index,
     BOOL AxisSwitch,
     int ModuleIndex,
     int BitOffset,
     BOOL Invert
);

Parameters

Index: the index of an axis. Indexes are zero based. Aliases affect this parameter.

AxisSwitch: set to TRUE if the sensor is connected to an axis input, or set to FALSE if it is connected to an I/O module.

ModuleIndex: identifies which I/O module or axis contains the sensor. Aliases affect this parameter.

BitOffset: the offset in bit of the sensor digital input in the module input variables.

Invert: inverts the sensor value.

Return value

If the function succeeds, it returns errNoError, otherwise an error code. For more information about the error code, see the KsError list.

Remarks

Used to set which digital input to use as a sensor before starting homing.

Example

Copy
KsError nRet = SetAxisHomeSwitch(0, TRUE, 0, 1, FALSE);

KsCommandStatus homeCommand =
WaitForCommand(30, TRUE,
               HomeAxis(0, 0, 360, 36, 3600, 3600, 3600000, McDirection::mcPositiveDirection, McHomingMode::homingSensor)
              );

double homePosition = 1;
GetAxisPosition(0, mcActualValue, &homePosition);
RtPrintf("Home position: %d\n", (int)homePosition);

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header ksmotion.h ksmotion.h
Library KsApi_Rtss.lib KsApi.lib

See also

SetAxisNegativeLimitSwitch

SetAxisPositiveLimitSwitch