<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.0.20">
  <POU Name="PRG_HomingAllAxes" Id="{b7e1f7ae-3cc9-4075-bb39-f88e67560fec}">
    <Declaration><![CDATA[PROGRAM PRG_HomingAllAxes
VAR
	i: 			INT;
	cam: 			BOOL;
	fbMC_Home: 	ARRAY [1..nMaxNumberOfAxis] OF MC_Home;

	Blinker1: 	FB_Blinker;
	nHandle: 	UINT;
	Done: 		BOOL;
	fbRtrig: 	R_TRIG;
	nState: 		UINT;
	tmpPos: LREAL;
END_VAR
VAR_OUTPUT
	bErr: 		BOOL;
	nErrid: 		UDINT;
	bBusy: 		BOOL;
END_VAR
VAR_INPUT
	bExec: 		BOOL;
END_VAR
VAR CONSTANT
	STATE_INIT:				UINT := 0;
	STATE_START_HOMING:		UINT := 1;
	STATE_WAIT_HOMING_DONE:	UINT := 2;
END_VAR]]></Declaration>
    <Implementation>
      <ST><![CDATA[(* ========================================================================	*)
(*   PRG: PRG_HomingAllAxis			        		            	 	   	*)
(* ------------------------------------------------------------------------	*)
(*   Desc: 																 	*)
(*   Auth: MiB / TV                                          				*)
(*   Date: 02.09.2005                                        				*)
(*   Last: 02.04.2013               			                            *)
(*   Rev.: 1.2																*)
(*         1.1 12.06.06: if an error occurs: Stop all axis in PTP channel  	*)
(*         1.2 08.11.06: reference cam is no longer set in this prg. 		*)
(*						 it now is done in PtpFunctions (because of G74)    *)
(* ======================================================================== *)


fbRtrig(Clk := bExec);
IF fbRtrig.Q THEN
	nState := STATE_INIT;
END_IF


CASE nState OF

STATE_INIT:
	bBusy := FALSE;
	IF fbRtrig.Q THEN
		bErr := FALSE;
		nErrid := 0;
		nState := STATE_START_HOMING;
		bBusy := TRUE;
		FOR i:=1 TO nMaxNumberOfAxis DO
		fbMC_Home[i](
			Execute:= FALSE ,
			Axis:= arrAxis_Ref[i]);
		END_FOR
END_IF

STATE_START_HOMING:
	FOR i:=1 TO nMaxNumberOfAxis DO
		fbMC_Home[i](
			Execute:= TRUE ,
			Position:= DEFAULT_HOME_POSITION ,
			Axis:= arrAxis_Ref[i]);
			
	END_FOR
	nState := STATE_WAIT_HOMING_DONE;

STATE_WAIT_HOMING_DONE:
	Done := TRUE;
	FOR i:=1 TO nMaxNumberOfAxis DO
		fbMC_Home[i](
			Position:= DEFAULT_HOME_POSITION ,
			Axis:= arrAxis_Ref[i]);			
		Done := fbMC_Home[i].Done AND Done;
		IF fbMC_HOME[i].Error THEN
				bErr := TRUE;
				nErrid := fbMC_HOME[i].ErrorId;
				nState := STATE_INIT;
		END_IF
	END_FOR;
	IF Done THEN
		nState := STATE_INIT;
	END_IF
END_CASE
]]></ST>
    </Implementation>
    <ObjectProperties />
  </POU>
</TcPlcObject>