Homing header
This page contains the complete code of the header file in this chapter.
These settings should be changed according to your hardware environment.
In Homing.h
, your Homing code should be as follows:
#pragma once
//High velocity used for homing.
//The meaning of this value depends on the homing mode.
#define HOMING_HIGH_VELOCITY 360
//Low velocity used for homing.
//The meaning of this value depends on the homing mode.
#define HOMING_LOW_VELOCITY 36
//Acceleration used while homing.
#define HOMING_ACCELERATION 3600
//Deceleration used while homing.
#define HOMING_DECELERATION 3600
//Direction in which the axis searches for the home.
//Only positive and negative directions are acceptable.
#define HOMING_DIRECTION mcPositiveDirection
//Type of module containing the home sensor.
//TRUE for Axis, FALSE for I/O module.
#define HOME_SENSOR_TYPE FALSE
//Index of the axis/IO module containing the sensor.
#define HOME_SENSOR_INDEX 1
//Offset of the sensor in the module input data.
#define HOME_SENSOR_OFFSET 13
//Invert the home sensor value.
#define HOME_SENSOR_INVERT FALSE
//Home an axis using a probe.
VOID HomingLatch(int Index);
//Home an axis using a sensor.
VOID HomingSoft(int Index);
//Home an axis using a limit switch.
VOID HomingSensor(int Index);
//Home an axis using the CANopen DS402 homing modes in the drive.
VOID HomingSlave(int Index);
//Home an axis using the current position.
VOID HomingOnPosition(int Index);
The touch probe variable is defined in SystemInitialization.h
.
In SystemInitialization.h
, your code should be as follows:
#pragma once
//Using instances other than zero requires a special license.
#define INSTANCE 0
//Base cycle time for the EtherCAT network.
//Require the High Speed Timer license if the cycle time is less than 1 millisecond.
#define CYCLE_TIME cycle500
//Available contol modes for the axes.
#define ACCESS_MODE accessPos
//Print logs to the RtxServer.
#define VERBOSITY FALSE
//Map the axes digital inputs to the PDO.
#define SERVO_INPUT TRUE
//Map the axes digital outputs to the PDO.
#define SERVO_OUTPUT FALSE
//Map the axes internal position to the PDO.
//It works only when two encoders are connected to the axis.
#define SECOND_ENCODER FALSE
//Map the actual velocity variable to the PDO.
#define ACTUAL_VELOCITY TRUE
//Map the actual torque variable to the PDO.
#define ACTUAL_TORQUE TRUE
//Map the actual current variable to the PDO.
#define ACTUAL_CURRENT TRUE
//Map the following error variable to the PDO.
#define FOLLOWING_ERROR TRUE
//Map the max torque variable to the PDO.
/*If your drive has the Max Torque object and you set this value
to TRUE, you must use WriteAxisMaxTorque to set its value, or
the axis won't move.*/
#define MAX_TORQUE FALSE
//Map the max current variable to the PDO.
/*If your drive has the Max Current object and you set this value
to TRUE, you must use WriteAxisMaxCurrent to set its value, or
the axis won't move.*/
#define MAX_CURRENT FALSE
//Map the Modes of Operation to the PDO.
//It works only when the control mode is changed while the axis is enabled.
#define SYNCHORNIZED_CONTROL_MODE TRUE
//Automatically restart the master when the EtherCAT cable is reconnected.
#define AUTO_RESTART TRUE
//Automatically restart individual slaves when they are powered back on.
#define AUTO_REPAIR TRUE
//Use the automatic EtherCAT configuration feature.
//If this is disabled, most of KINGSTAR feature are disabled.
#define AUTO_CONFIG TRUE
//Use distributed clocks (DC) to synchronize the slaves.
#define ENABLE_DC TRUE
//Wait for the slaves to be synchronized before going to OP.
#define DC_CHECK TRUE
//Use Master shift instead of Bus shift for DC.
//The slave synchronization jitter will be reduced but the master may be less stable.
#define DC_MASTER_SHIFT FALSE
//Allow slaves to be added while in OP.
//Require the Hot Connect license.
#define HOT_CONNECT TRUE
//Connect the last slave back to the computer for cable redundancy.
//Require the Cable Redundancy license.
#define REDUNDANCY TRUE
//Map the TouchProbeControl and TouchProbeStatus variables to the PDO.
#define TOUCHPROBE TRUE
//Minimum number of axes in the system.
//Simulated axes will be added if there is not enough hardware connected.
#define AXES_COUNT 2
//Minimum number of I/O modules in the system.
//Simulated modules will be added if there is not enough hardware connected.
#define IO_COUNT 3
//Length in Bits of the input buffer of simulated modules.
#define IO_INPUT_LENGTH 16
//Length in Bits of the output buffer of simulated modules.
#define IO_OUTPUT_LENGTH 16
BOOL StartKingstar();
BOOL StopKingstar();