//程序代码
PROGRAM PLC_PRG
VAR
iStatus: INT;
MC_Power_0: MC_Power;
MC_Power_1: MC_Power;
MC_Power_2: MC_Power;
MC_Power_3: MC_Power;
MC_MoveAbsolute_0: MC_MoveAbsolute;
MC_MoveAbsolute_1: MC_MoveAbsolute;
MC_MoveAbsolute_2: MC_MoveAbsolute;
MC_MoveAbsolute_3: MC_MoveAbsolute;
END_VAR
//变量以及功能块定义
CASE iStatus OF
0:
MC_Power_0(Axis:= J1, Enable:= TRUE, bRegulatorOn:= TRUE, bDriveStart:=TRUE , );
MC_Power_1(Axis:= J2, Enable:= TRUE, bRegulatorOn:= TRUE, bDriveStart:=TRUE , );
MC_Power_2(Axis:= J3, Enable:= TRUE, bRegulatorOn:= TRUE, bDriveStart:=TRUE , );
MC_Power_3(Axis:= J4, Enable:= TRUE, bRegulatorOn:= TRUE, bDriveStart:=TRUE , );
IF MC_Power_0.Status AND MC_Power_1.Status AND MC_Power_2.Status AND MC_Power_3.Status THEN
iStatus:=iStatus+1;
END_IF
1:
MC_MoveAbsolute_0(Axis:=J1, Execute:= TRUE, Position:=50 ,  Velocity:=3 , Acceleration:= 2, Deceleration:=100,);
MC_MoveAbsolute_1(Axis:=J2, Execute:= TRUE, Position:=50 ,  Velocity:=3 , Acceleration:= 2, Deceleration:=100,); 
MC_MoveAbsolute_2(Axis:=J3, Execute:= TRUE, Position:=50 ,  Velocity:=3 , Acceleration:= 2, Deceleration:=100,); 
MC_MoveAbsolute_3(Axis:=J4, Execute:= TRUE, Position:=50 ,  Velocity:=3 , Acceleration:= 2, Deceleration:=100,); 
IF MC_MoveAbsolute_0.Done AND MC_MoveAbsolute_1.Done AND MC_MoveAbsolute_2.Done AND MC_MoveAbsolute_3.Done THEN
MC_MoveAbsolute_0(Axis:=J1 , Execute:= FALSE,);
MC_MoveAbsolute_1(Axis:=J2 , Execute:= FALSE,);
MC_MoveAbsolute_2(Axis:=J3 , Execute:= FALSE,);
MC_MoveAbsolute_3(Axis:=J4 , Execute:= FALSE,);
iStatus:=iStatus+1; 
END_IF
2:
MC_MoveAbsolute_0(Axis:=J1, Execute:= TRUE, Position:=0 , Velocity:=3, Acceleration:= 2, Deceleration:=100,);
MC_MoveAbsolute_1(Axis:=J2, Execute:= TRUE, Position:=0 , Velocity:=3, Acceleration:= 2, Deceleration:=100,); 
MC_MoveAbsolute_2(Axis:=J3, Execute:= TRUE, Position:=0 , Velocity:=3, Acceleration:= 2, Deceleration:=100,); 
MC_MoveAbsolute_3(Axis:=J4, Execute:= TRUE, Position:=0 , Velocity:=3, Acceleration:= 2, Deceleration:=100,); 
IF MC_MoveAbsolute_0.Done AND MC_MoveAbsolute_1.Done AND MC_MoveAbsolute_2.Done AND MC_MoveAbsolute_3.Done THEN
MC_MoveAbsolute_0(Axis:=J1 , Execute:= FALSE,);
MC_MoveAbsolute_1(Axis:=J2 , Execute:= FALSE,);
MC_MoveAbsolute_2(Axis:=J3 , Execute:= FALSE,);
MC_MoveAbsolute_3(Axis:=J4 , Execute:= FALSE,);
iStatus:=1;
END_IF
END_CASE
