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

VOID HomeSensor(INT Index) {
   //Configure the switch to use for homing
   KsError nRet = SetAxisHomeSwitch(Index, TRUE, 0, 1, FALSE);

   //The axis will move in the preset homing direction when the sensor is low
   //The axis will move in the reverse direction when the sensor is high
   //The axis starts moving at the high velocity
   /*The velocity will be divided by 10 every time the direction is reversed
     until it finds the sensor in the preset direction at the low velocity*/
   KsCommandStatus home = WaitForCommand(30, TRUE, HomeAxis(Index, 0, 360, 36, 
	3600, 3600, 3600000, mcPositiveDirection, homingSensor));

   double homePosition = 1;
   GetAxisPosition(Index, 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