Integrating manual function into an axis
A manual function can be created in several places in the application. The following sample explains how a manual function for moving and switching on the axis can be integrated into it.
- 1. Extend an existing class by inheritance. In this sample, the
FB_Carriage
class is used for this purpose.
FUNCTION_BLOCK FB_CustomCarriage EXTENDS FB_Carriage
- 2. Instantiate the
FB_ManualXyz
manual function in the class of the axis. This is not necessary for the manual function of the forward/backward movement, since this is already instantiated by theFB_Carriage
class.
FUNCTION_BLOCK FB_CustomCarriage EXTENDS FB_Carriage
VAR
fbManualPower: FB_ManualPower;
END_VAR
- 3. The
FB_CarriageHmi
class used here already provides an HMI interface for both manual functions. For more manual functions, you need to extend the class with respective instances of theFB_ManualFunctionHmi
class. - 4. Afterwards, the newly instantiated manual function must be initialized. For convenience, you can use the
F_SucceededHr()
function to check the return value of the initialization function for success and copy it to a local variable.
METHOD Init : HRESULT
IF NOT F_SucceededHr(fbManualPower.Init(THIS^, iCarriageHmi), Init) THEN
RETURN;
END_IF
Init := SUPER^.Init();
- 5. To process the inner algorithms of the manual functions, you must call the respective cycle methods in
Cyclic()
.
METHOD Cyclic
fbManualPower.Cyclic();
fbManualForBack.Cyclic();
- 6. In the same method you can additionally define when the manual function should be activated for use and/or which method is called by the manual function.
fbManualPower.Enable := bManualMode OR bSetupMode OR bAutomaticMode;
fbManualPower.Cyclic();
fbManualForBack.Enable := bManualMode OR bSetupMode;
fbManualForBack.Cyclic();
IF bSetupMode THEN
IF fbManualForBack.TrigCmdWorkPos.RQ THEN
JogNegative(TRUE);
ELSIF fbManualForBack.TrigCmdWorkPos.FQ THEN
JogNegative(FALSE);
ELSIF fbManualForBack.TrigCmdBasePos.Q THEN
JogPositive(fbManualForBack.TrigCmdBasePos.Q);
END_IF
ELSIF bManualMode THEN
IF fbManualForBack.TrigCmdWorkPos.Q THEN
MovePtp(1, fbManualForBack.TrigCmdWorkPos.Q, 8);
ELSIF fbManualForBack.TrigCmdBasePos.Q THEN
MovePtp(2, fbManualForBack.TrigCmdBasePos.Q, 8);
END_IF
END_IF