186 lines
4.9 KiB
XML
186 lines
4.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<TcPlcObject Version="1.1.0.1">
|
|
<POU Name="FB_Aligner" Id="{5be6cab7-2294-48e5-869c-33773329143e}" SpecialFunc="None">
|
|
<Declaration><![CDATA[FUNCTION_BLOCK FB_Aligner EXTENDS FB_PackMLGeneric
|
|
VAR_INPUT
|
|
xEnableVacuum : BOOL;
|
|
xExecute : BOOL;
|
|
|
|
xConfirmAlarms : BOOL;
|
|
END_VAR
|
|
VAR_OUTPUT
|
|
xVacuumEnabled : BOOL;
|
|
END_VAR
|
|
VAR_IN_OUT
|
|
stHMIInterface : ST_HMI_Aligner;
|
|
END_VAR
|
|
VAR
|
|
xActivateVacuum AT %Q* : BOOL := FALSE;
|
|
xDeactivateVacuum AT %Q* : BOOL := TRUE;
|
|
xVacuumOk AT %I* : BOOL;
|
|
|
|
diXOffset AT %I* : DINT;
|
|
diYOffset AT %I* : DINT;
|
|
|
|
_fbXAxis : FB_AxisPTP;
|
|
_fbYAxis : FB_AxisPTP;
|
|
|
|
_rtExecute : R_TRIG;
|
|
_xStartAlign : BOOL;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[_fbXAxis(
|
|
xInvertCalibrationCam:= FALSE,
|
|
xEnablePositive:= TRUE,
|
|
xEnableNegative:= TRUE,
|
|
rOverride:= 100.0,
|
|
lrVelocity:= 2.5,
|
|
lrAcceleration:= 0,
|
|
lrDecelleration:= 0,
|
|
lrJerk:= 0,
|
|
xConfirmAlarms:= xConfirmAlarms);
|
|
|
|
_fbYAxis(
|
|
xInvertCalibrationCam:= FALSE,
|
|
xEnablePositive:= TRUE,
|
|
xEnableNegative:= TRUE,
|
|
rOverride:= 100.0,
|
|
lrVelocity:= 2.5,
|
|
lrAcceleration:= 0,
|
|
lrDecelleration:= 0,
|
|
lrJerk:= 0,
|
|
xConfirmAlarms:= xConfirmAlarms);
|
|
|
|
|
|
// =============================
|
|
// Call isa88 base state machine
|
|
// =============================
|
|
SUPER^(stPackMLHMIInterface := stHMIInterface.stStationCmds);
|
|
|
|
_rtExecute(CLK:= xExecute, Q=> _xStartAlign);
|
|
|
|
// Handle enable disable vacuum command
|
|
xActivateVacuum := xEnableVacuum;
|
|
xDeactivateVacuum := (NOT xEnableVacuum);
|
|
xVacuumEnabled := xVacuumOk;]]></ST>
|
|
</Implementation>
|
|
<Method Name="FB_init" Id="{5048e086-25a4-4fbb-bf29-7a016bcf2277}">
|
|
<Declaration><![CDATA[//FB_Init is always available implicitly and it is used primarily for initialization.
|
|
//The return value is not evaluated. For a specific influence, you can also declare the
|
|
//methods explicitly and provide additional code there with the standard initialization
|
|
//code. You can evaluate the return value.
|
|
METHOD FB_Init: BOOL
|
|
VAR_INPUT
|
|
bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold)
|
|
bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change)
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[_stSMConfig.xClearingDisabled := TRUE;
|
|
_stSMConfig.xStartingDisabled := TRUE;
|
|
_stSMConfig.xHeldDisabled := TRUE;
|
|
_stSMConfig.xSuspededDisabled := TRUE;
|
|
_stSMConfig.xCompletedDisabled := FALSE;]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Clearing" Id="{0b5b5108-3886-40a3-876f-a3460b5d5089}">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Clearing
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[CASE _iSSM OF
|
|
0:
|
|
// TODO: Reset axes
|
|
M_StateComplete();
|
|
END_CASE]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Execute" Id="{d508050c-8f62-4fb2-be6c-88cfee1bab3b}">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Execute
|
|
VAR_INST
|
|
_deltaX : REAL;
|
|
_deltaY : REAL;
|
|
|
|
_uiRuns : UINT;
|
|
_tonWait : TON;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[CASE _iSSM OF
|
|
// Start first alignment
|
|
0:
|
|
_deltaX := DINT_TO_REAL(diXOffset) * -0.001;
|
|
_deltaY := ((DINT_TO_REAL(diYOffset) * 0.001) - 37.5) * -1;
|
|
|
|
IF (ABS(_deltaX) < 10.0) AND (ABS(_deltaY) < 10.0) AND (NOT _fbXAxis.xError) AND (NOT _fbYAxis.xError) THEN
|
|
_fbXAxis.M_MoveRel(lrRelDist := _deltaX);
|
|
_fbYAxis.M_MoveRel(lrRelDist := _deltaY);
|
|
_iSSM := 10;
|
|
END_IF
|
|
|
|
// Wait for axis movements to be done
|
|
10:
|
|
IF (NOT _fbXAxis.xBusy) AND (NOT _fbYAxis.xBusy) THEN
|
|
_uiRuns := _uiRuns + 1;
|
|
|
|
// Do alignment twice because of backlash in aligner station
|
|
IF _uiRuns > 1 THEN
|
|
_iSSM := 30;
|
|
ELSE
|
|
_iSSM := 20;
|
|
END_IF
|
|
END_IF
|
|
|
|
// Wait 1 second to stabelise reading
|
|
20:
|
|
_tonWait(IN := TRUE, PT := T#2S);
|
|
IF _tonWait.Q THEN
|
|
_tonWait(IN := FALSE);
|
|
_iSSM := 0;
|
|
END_IF
|
|
|
|
30:
|
|
_uiRuns := 0;
|
|
_eCmd := E_PackMLCmd.COMPLETE;
|
|
END_CASE]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Resetting" Id="{015c2bf3-1e45-46dd-93fe-a1f154bfd906}">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Resetting
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[CASE _iSSM OF
|
|
0:
|
|
// Enable axes
|
|
_fbXAxis.xEnable := TRUE;
|
|
_fbYAxis.xEnable := TRUE;
|
|
|
|
IF _fbXAxis.xEnabled AND _fbYAxis.xEnabled THEN
|
|
IF (NOT _fbXAxis.xHomed) THEN
|
|
_fbXAxis.M_Homing(lrHomingPosition := BC.Tc2_MC2.DEFAULT_HOME_POSITION);
|
|
END_IF
|
|
|
|
IF (NOT _fbYAxis.xHomed) THEN
|
|
_fbYAxis.M_Homing(lrHomingPosition := BC.Tc2_MC2.DEFAULT_HOME_POSITION);
|
|
END_IF
|
|
|
|
_iSSM := 10;
|
|
END_IF
|
|
|
|
10:
|
|
// Home axes
|
|
IF (NOT _fbXAxis.xBusy) AND (NOT _fbYAxis.xBusy) THEN
|
|
_fbXAxis.M_MoveAbs(0.0);
|
|
_fbYAxis.M_MoveAbs(0.0);
|
|
_iSSM := 20;
|
|
END_IF
|
|
|
|
20:
|
|
// Move to 0 position
|
|
IF (NOT _fbXAxis.xBusy) AND (NOT _fbYAxis.xBusy) THEN
|
|
M_StateComplete();
|
|
END_IF
|
|
END_CASE]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
</POU>
|
|
</TcPlcObject> |