When implementing the homing function, Beckhoff provides the MC_Home function block in the Tc2_MC2 library. However, this function block has certain limitations. As customer demands continue to grow, Beckhoff introduced the Tc3_MC2_AdvanceHoming function block, based on the PLCopen Part 5 specification, to meet diverse homing requirements. This function block is compatible not only with Beckhoff drives but also with third-party drives. This article focuses on explaining commonly used homing function blocks for reference.
Application of Tc3_MC2_AdvanceHoming
Sample programs are provided for the Tc3_MC2_AdvanceHoming function block, covering the three most commonly used homing methods: homing with home switch and limit switches, homing with limit switches only, and homing by mechanical stop. Users can select the appropriate method based on their specific needs.
Note: During testing of the sample programs, the positive and negative limit switches and the home sensor are all configured as normally open contacts.
Software and Hardware Versions
Controller Hardware
Control Software
Connect Input 2 and Input 3 from the AX5201's IO (X06). Add the PDO "Digital inputs, state" (P-0-0801) to retrieve the status of Input 2 and Input 3. If corresponding sensors are available, configure them as needed, either by connecting to an IO module or the drive's IO. In this test, Input 2 serves as the home sensor signal, and Input 3 serves as the positive limit switch signal.
Function Block Explanation
In practical applications, the primary homing methods include: homing with home sensor and limit switches, homing with limit switches only, homing by mechanical stop, and incorporating the encoder Z-pulse if available. Below, we explain how to implement these common homing methods using the Tc3_MC2_AdvanceHoming function block.
MC_StepAbsoluteSwitch
Homing with home sensor and limit switches.
MC_StepLimitSwitch
Homing with limit switches only.
MC_StepBlock
Homing by mechanical stop (torque limit).
MC_StepReferencePulse
Homing by searching for the Z-pulse signal.
MC_FinishHoming
Completes the homing process.
MC_AbortHoming
Terminates the homing process.
The typical application sequence is: Homing function block → Search for Z-pulse (if applicable) → Complete homing (MC_FinishHoming).
VAR
StepAbsoluteSwitch_Ref_Signal :MC_Ref_Signal_Ref;
mcHomingParameter :MC_HomingParameter;
END_VAR
MC_StepAbsoluteSwitch(
Parameter:= mcHomingParameter, /Parameters for Parameter Passing Between Function Blocks During Homing
Execute:= ,
Direction:= ,
SwitchMode:= ,// Home Switch Mode: Rising Edge, Falling Edge, etc.
ReferenceSignal:= StepAbsoluteSwitch_Ref_Signal ,
Velocity:= ,
SetPosition:= ,
TimeLimit:= , 。
DistanceLimit:= ,
TorqueLimit:= ,
PositiveLimitSwitch:= , //Positive Limit Switch
NegativeLimitSwitch:= , //Negative Limit Switch
);
Assigning the Home Signal to MC_Ref_Signal_Ref
In the program, the home sensor signal is assigned to MC_Ref_Signal_Ref. Specifically:
StepAbsoluteSwitch_Ref_Signal.Level := bInput2;
The figure below is a schematic diagram of homing with a home sensor and limit switches (homing in the positive direction with rising edge detection, where both the limit switches and home switch are normally open contacts).
The diagram indicates:
①: The stop is positioned between the home sensor and the negative limit switch.
②: The stop is directly on the home sensor.
③: The stop is between the positive limit switch and the home sensor.
Note: During testing, the limit switches are normally open contacts. However, in actual projects, it is recommended that customers use normally closed sensors for limit switches.
MC_StepLimitSwitch(LimitSwitchSignal:= , );
Omit other pins and refer to MC_StepAbsoluteSwitch in section 3.1. The LimitSwitchSignal can reference the MC_Ref_Signal_Ref type described in section 3.1, assigning the required limit switch signal. In this program, bInput3 is assigned as the positive limit signal.
Example: LimitSwitchSignal.Level := bInput3;
The figure below is a schematic diagram of homing to the positive limit switch with rising edge detection (both positive and negative limit switches are normally open).
The process where: ① the stop block returns to the origin between the positive and negative limits, and ② the stop block returns to the origin from the positive limit. Note: During testing, both positive and negative limits are normally open contacts. It is recommended that customers use normally closed sensors in practice.
MC_StepBlock(
DetectionVelocityLimit:= ,
DetectionVelocityTime:= ,
TorqueLimit:= ,
TorqueTolerance:= ,
);
MC_FinishHoming(
Axis:= ,
Parameter:= ,
Execute:= ,
Distance:= ,
Velocity:= ,
);
When homing is completed, the sensor triggers, but the motor undergoes a deceleration process, resulting in a non-zero coordinate value. To achieve a coordinate value of 0, use the Distance and Velocity parameters of MC_FinishHoming. After executing the homing command (e.g., MC_StepLimitSwitch), store the current position. Assign this position to Distance, where the Distance value should be zero minus the stored position value. By using MC_FinishHoming with these parameters, the motor can be returned to the coordinate 0 point.
Executing this function block terminates the homing process, stopping the axis even if it is currently in motion during homing. It is typically used to abort the homing process in case of an abnormality.
Application of Third-Party Drivers
For Beckhoff drivers, set Options.DisableDriveAccess to FALSE in the function block. For third-party drivers, set Options.DisableDriveAccess to TRUE. Example:
MC_StepAbsoluteSwitch. Options.DisableDriveAccess:=FALSE;
All used function blocks must have Options.DisableDriveAccess configured accordingly. Testing confirms this applies to third-party EtherCAT drivers as well.
Application of System Limit Signals
Your input repeats the previous request about using the Tc3_MC2_AdvanceHoming function block for homing and configuring limit switches in MC_Power. Since the response was already provided, I'll assume you might be seeking additional details, clarifications, or a slightly different angle. Below is a refined and concise explanation with a practical implementation example, avoiding repetition where possible:
MC_Power(
Axis:=Axis_X ,
Enable:=bEnable,
Override:= 100, );
IF bBusy THEN
MC_Power(
Axis:=Axis_X ,
Enable_Positive:=TRUE ,
Enable_Negative:= TRUE, );
ELSE
MC_Power(
Axis:=Axis_X ,
Enable_Positive:=bLimitPositive ,
Enable_Negative:= bLimitNegative, );
END_IF
Using MC_Power to Implement Limit Functionality
Users must independently implement a limit alarm program.
Application of the Done Signal in Function Blocks
The Done signal in function blocks has a very short duration, making it hard to detect in sequential control. Reset the Execute signal to FALSE after Done is detected. If Execute remains TRUE, Done will stay TRUE after completion.
Linking Torque Feedback Signals
Since function blocks with motion actions include a TorqueLimit, the driver’s actual torque value must be linked to:
Axis → Drive → Inputs → In → nDataIn3 → nDataIn3[0].
As shown in the diagram. If the driver lacks torque feedback, homing is unsafe but feasible, except for MC_StepBlock, which cannot be implemented.
Determination of Homing Completion Signal
There are two methods to determine the homing completion signal:
A. Obtain from StateDWord
Use the following bit from the axis data structure:
Axis_X.NcToPlc.StateDWord.1
This bit indicates the homing completion status.
Determination of Homing Completion Signal (Continued)
B. Obtain from Status
Axis_X.ReadStatus();
Axis_X.Status.Homed;
After the system completes homing, the homing status in both methods (A and B) will be set to TRUE.
Notes on Function Block Invocation for Sequential Control
When using a CASE statement for sequential control of homing, place the Tc3_MC2_AdvanceHoming function block outside the CASE structure to call it every cycle. Each function block has a Parameter that must be passed to other function blocks every cycle. Refer to the example for details.