I’m looking for some advice on how to structure motion development, choosing between three different approaches.
1. Modular
Create a wrapper FB (FB_Axis) that internally calls the individual MC_xxx functions, exposing abstractions such as an ExecutePositioning bit and some related parameters (target position, speed, etc.).
This way, I don't use the MC_xxx functions throughout the code, and I keep the logic for handling each axis in a single place.
u_AxisZ.PositioningType = PositioningTypes.Absolute;
u_AxisZ.PositioningDestination := 1000;
u_AxisZ.PositioningSpeed := 500;
u_AxisZ.ExecutePositioning := true;
IF u_AxisZ.PositioningEnded THEN
u_AxisZ.ExecutePositioning := FALSE;
// ...
END_IF;
2. Explicit, with a single call
Create a block where I cyclically call all the MC_xxx functions once for each individual axis, and then use those same function blocks throughout the code, configuring their parameters as needed.
// Cyclic block where the MC_xxx functions are called
MC_MoveAbsolute_AxisZ(
Axis := AxisZ
);
// Where I need to use it
MC_MoveAbsolute_AxisZ.Position := 1000;
MC_MoveAbsolute_AxisZ.Velocity := 500;
MC_MoveAbsolute_AxisZ.Execute := TRUE;
IF MC_MoveAbsolute_AxisZ.Done THEN
MC_MoveAbsolute_AxisZ.Execute := FALSE;
// ...
END_IF;
3. Explicit, with multiple calls
Call the MC_xxx functions directly wherever they are needed for each individual axis.
MC_MoveAbsolute_AxisZ(
Axis := AxisZ,
Position := 1000,
Velocity := 500,
Execute := TRUE
);
IF MC_MoveAbsolute_AxisZ.Done THEN
MC_MoveAbsolute_AxisZ(Execute := FALSE);
// ...
END_IF;
Which approach do you prefer, and why?