<< 点击显示目录 >> 主页
ACOPOS 6D使用手册 > mapp 6D > 入门指南 > 开始使用 ACOPOS 6D Programming |
推荐 → 6D最简Demo案例 可从此链接中直接下载Demo例程
为了控制 ACOPOS 6D 系统的移动,这里提供了代码示例,可直接或通过 "打开为文本 "转入 AS 软件项目(逻辑视图)。
由于 mapp 6D 自动在任务类 #1 中执行,因此可以将任务分配到任何任务类中。
全局变量 "gMain "稍后可用于测试。
图在逻辑视图中添加源代码
(*Main control datatype*)
TYPE
gMainType : STRUCT (*Main control variable datatype*)
Cmd : gMainCmdType; (*Main commands*)
Par : gMainParType; (*Main parameter*)
Status : gMainStatusType; (*Main status*)
END_STRUCT;
gMainCmdType : STRUCT (*Main commands type*)
Power : BOOL; (*Power on the system*)
Start : BOOL; (*Start a plane movement for the selected shuttle*)
Stop : BOOL; (*Stop all shuttles in the system*)
ErrorReset : BOOL; (*Reset any active error*)
END_STRUCT;
gMainParType : STRUCT (*Main parameter type*)
SelectedShuttleIndex : UINT; (*Selected index in the global array of shuttle references*)
Velocity : REAL; (*InPlane (X,Y) Velocity*)
Acceleration : REAL; (*InPlane (X,Y) Acceleration*)
InPlanePosition : McAcp6DInPlaneAxesType; (*InPlane (X,Y) Position*)
END_STRUCT;
gMainStatusType : STRUCT (*Main status type*)
AsmState : McAcp6dPLCopenStateEnum; (*Assembly state*)
ShuttlesPresent : UINT; (*Number of shuttles present on the assembly*)
SelectedShuttleID : UINT; (*ID of the shuttle which was selected in the array*)
END_STRUCT;
END_TYPE
(*Global shuttle array datatype*)
TYPE
gShuttleListType : STRUCT (*Global shuttle list datatype*)
ID : UINT; (*ID of the shuttle*)
Ref : Mc6DShuttleType; (*Reference to the shuttle*)
END_STRUCT;
END_TYPE
(*Communication Variables*)
VAR
gCommInput : Mc6DControllerFBIOType; (*Communication variable INPUT*)
gCommOutput : Mc6DControllerFBIOType; (*Communication variable OUTPUT*)
END_VAR
(*CONSTANTS*)
VAR CONSTANT
MAX_NUM_SHUTTLE : UINT := 50; (*Maximum numer of shuttles on the system (50 Shuttles)*)
END_VAR
(*Derived CONSTANTS*)
VAR CONSTANT
MAX_INDEX_SHUTTLE : UINT := MAX_NUM_SHUTTLE - 1; (*Maximum index for a shuttles on the system (0 to MAX_NUM_SHUTTLE - 1)*)
END_VAR
(*Global Control Variable*)
VAR
gMain : gMainType; (*Global control variable*)
gShuttleList : ARRAY[0..MAX_INDEX_SHUTTLE] OF gShuttleListType; (*Global shuttle list*)
END_VAR
TYPE
MainStepEnum :
( (*States for the main state machine*)
MAIN_STARTUP,
MAIN_POWER_OFF,
MAIN_DISABLED,
MAIN_POWER_ON,
MAIN_GET_SHUTTLE,
MAIN_GET_SHUTTLE_WAIT,
MAIN_READY,
MAIN_START_MOVEMENT,
MAIN_STOP_MOVEMENT,
MAIN_ERROR
);
END_TYPE
(*Function Blocks*)
VAR
fbAsmReadInfo : MC_BR_AsmReadInfo_Acp6D;
fbAsmPowerOn : MC_BR_AsmPowerOn_Acp6D;
fbAsmPowerOff : MC_BR_AsmPowerOff_Acp6D;
fbAsmGetShuttle : MC_BR_AsmGetShuttle_Acp6D;
fbAsmStop : MC_BR_AsmStop_Acp6D;
fbMoveInPlane : MC_BR_MoveInPlane_Acp6D;
fbAsmReset : MC_BR_AsmReset_Acp6D;
END_VAR
(*Local Vars*)
VAR
MainStep : MainStepEnum; (*Variable for the state machine*)
i : UINT;
END_VAR
PROGRAM _INIT
(* Call communication variables once to ensure they are created *)
gCommInput;
gCommOutput;
(* Assign assembly reference to function blocks *)
fbAsmReadInfo.Assembly := ADR(gAssembly6D_1);
fbAsmPowerOn.Assembly := ADR(gAssembly6D_1);
fbAsmPowerOff.Assembly := ADR(gAssembly6D_1);
fbAsmGetShuttle.Assembly := ADR(gAssembly6D_1);
fbAsmStop.Assembly := ADR(gAssembly6D_1);
(* Set parameters for function block "fbMoveInPlane" *)
fbMoveInPlane.Parameters.Mode := mcACP6D_MOVE_ABSOLUTE;
fbMoveInPlane.Parameters.Path := mcACP6D_PATH_X_THEN_Y;
fbMoveInPlane.Parameters.EndVelocity := 0.0;
(* Initialize main control parameters *)
gMain.Par.Velocity := 1.0; //[m/s]
gMain.Par.Acceleration := 10.0; //[m/s²]
gMain.Par.InPlanePosition.X := 0.36; //[m]
gMain.Par.InPlanePosition.Y := 0.12; //[m]
(* Enable diagnostic function block *)
fbAsmReadInfo.Enable := TRUE;
END_PROGRAM
PROGRAM _CYCLIC
(* Check for current assembly state *)
IF (gMain.Status.AsmState = mcACP6D_ERRORSTOP) THEN
(* If an error occurs, go to the error state *)
MainStep := MAIN_ERROR;
ELSIF (gMain.Status.AsmState = mcACP6D_STARTUP) THEN
(* As long, as the 6D - controller is in startup, stay in startup state *)
MainStep := MAIN_STARTUP;
END_IF
(* Limit the selected index for the shuttle list *)
gMain.Par.SelectedShuttleIndex := LIMIT(0, gMain.Par.SelectedShuttleIndex, MAX_INDEX_SHUTTLE);
(* State machine *)
CASE MainStep OF
MAIN_STARTUP:
(* Wait for the 6D controller to be started *)
IF (gMain.Status.AsmState = mcACP6D_DISABLED) THEN
(* If assembly is disabled *)
MainStep := MAIN_DISABLED;
ELSIF NOT(gMain.Status.AsmState = mcACP6D_STARTUP) THEN
(* If assembly is in any other state, disable it *)
MainStep := MAIN_POWER_OFF;
END_IF
MAIN_POWER_OFF:
(* Activate Function block *)
fbAsmPowerOff.Execute := TRUE;
(* Wait for the command to be done OR if the assembly state is already correct *)
IF (fbAsmPowerOff.Done) OR (gMain.Status.AsmState = mcACP6D_DISABLED) THEN
(* Reset the function block *)
fbAsmPowerOff.Execute := FALSE;
(* Next step *)
MainStep := MAIN_DISABLED;
ELSIF (fbAsmPowerOff.Error) THEN
(* Next step *)
MainStep := MAIN_ERROR;
END_IF
MAIN_DISABLED:
(* Wait for the power on command *)
IF (gMain.Cmd.Power) THEN
(* Next step *)
MainStep := MAIN_POWER_ON;
END_IF
MAIN_POWER_ON:
(* Activate Function block *)
fbAsmPowerOn.Execute := TRUE;
(* Wait for the command to be done OR if the assembly state is already correct *)
IF (fbAsmPowerOn.Done) OR (gMain.Status.AsmState = mcACP6D_READY) THEN
(* Reset the function block *)
fbAsmPowerOn.Execute := FALSE;
(* Delete data from global shuttle array *)
brsmemset(ADR(gShuttleList),0,SIZEOF(gShuttleList));
(* Init index *)
i := 0;
(* Next step *)
MainStep := MAIN_GET_SHUTTLE;
ELSIF (fbAsmPowerOn.Error) THEN
(* Next step *)
MainStep := MAIN_ERROR;
END_IF
MAIN_GET_SHUTTLE:
(* Enable the function block *)
fbAsmGetShuttle.Enable := TRUE;
(* Wait until the data is valid *)
IF (fbAsmGetShuttle.Valid) THEN
(* Check any shuttle is present *)
IF (fbAsmGetShuttle.TotalCount > 0) THEN
(* Reset the "next" command *)
fbAsmGetShuttle.Next := FALSE;
(* Save the number of shuttles *)
gMain.Status.ShuttlesPresent := fbAsmGetShuttle.TotalCount;
(* Save the shuttle data *)
gShuttleList[i].ID := fbAsmGetShuttle.AdditionalInfo.ShuttleID;
gShuttleList[i].Ref := fbAsmGetShuttle.Shuttle;
(* Next step *)
MainStep := MAIN_GET_SHUTTLE_WAIT;
ELSE
(* No shuttles present *)
gMain.Status.ShuttlesPresent := 0;
(* Disable the function block *)
fbAsmGetShuttle.Enable := FALSE;
(* Next step *)
MainStep := MAIN_READY;
END_IF
END_IF
MAIN_GET_SHUTTLE_WAIT:
(* Check if there are more shuttles to read out *)
IF (fbAsmGetShuttle.RemainingCount > 0) THEN
(* Get next shuttle *)
fbAsmGetShuttle.Next := TRUE;
(* Increase index *)
i := i + 1;
(* Next step *)
MainStep := MAIN_GET_SHUTTLE;
ELSE
(* Reset the function block *)
fbAsmGetShuttle.Enable := FALSE;
(* Next step *)
MainStep := MAIN_READY;
END_IF
MAIN_READY:
IF NOT(gMain.Cmd.Power) THEN
(* Reset command *)
gMain.Cmd.Power := FALSE;
(* Next step *)
MainStep := MAIN_POWER_OFF;
ELSIF (gMain.Cmd.Start) THEN
(* Reset command *)
gMain.Cmd.Start := FALSE;
(* Next step *)
MainStep := MAIN_START_MOVEMENT;
ELSIF (gMain.Cmd.Stop) THEN
(* Reset command *)
gMain.Cmd.Stop := FALSE;
(* Next step *)
MainStep := MAIN_STOP_MOVEMENT;
END_IF
MAIN_START_MOVEMENT:
(* Activate the function block *)
fbMoveInPlane.Shuttle := ADR(gShuttleList[gMain.Par.SelectedShuttleIndex].Ref);
fbMoveInPlane.Parameters.Velocity := gMain.Par.Velocity; //Parameter set in INIT, can be modified in Watch
fbMoveInPlane.Parameters.Acceleration := gMain.Par.Acceleration; //Parameter set in INIT, can be modified in Watch
fbMoveInPlane.Parameters.Position := gMain.Par.InPlanePosition; //Parameter set in INIT, can be modified in Watch
fbMoveInPlane.Execute := TRUE;
(* Wait for the command to be accepted *)
IF (fbMoveInPlane.Acknowledge OR fbMoveInPlane.Done) THEN
(* Reset the function block *)
fbMoveInPlane.Execute := FALSE;
(* Next step *)
MainStep := MAIN_READY;
ELSIF (fbMoveInPlane.Error) THEN
(* Reset the function block *)
fbMoveInPlane.Execute := FALSE;
(* Next step *)
MainStep := MAIN_READY;
END_IF
MAIN_STOP_MOVEMENT:
(* Activate Function block *)
fbAsmStop.Execute := TRUE;
(* Wait for the command to be done *)
IF (fbAsmStop.Done) THEN
(* Reset the function block *)
fbAsmStop.Execute := FALSE;
(* Next step *)
MainStep := MAIN_READY;
ELSIF (fbAsmStop.Error) THEN
(* Next step *)
MainStep := MAIN_ERROR;
END_IF
MAIN_ERROR:
(* Reset assembly with user command *)
fbAsmReset.Execute := gMain.Cmd.ErrorReset;
(* Reset the assembly after diagnosis *)
IF (fbAsmReset.Done) THEN
(* Reset command *)
gMain.Cmd.ErrorReset := FALSE;
gMain.Cmd.Power := FALSE;
gMain.Cmd.Start := FALSE;
gMain.Cmd.Stop := FALSE;
(* Reset function blocks *)
fbAsmReset.Execute := FALSE;
fbAsmPowerOff.Execute := FALSE;
fbAsmPowerOn.Execute := FALSE;
fbAsmGetShuttle.Enable := FALSE;
fbAsmGetShuttle.Next := FALSE;
fbMoveInPlane.Execute := FALSE;
fbMoveInPlane.Execute := FALSE;
(* Next step *)
IF (gMain.Status.AsmState = mcACP6D_DISABLED) THEN
MainStep := MAIN_DISABLED;
ELSE
MainStep := MAIN_POWER_OFF;
END_IF
END_IF
END_CASE
(* 调用功能块 *)
fbAsmReadInfo();
fbAsmPowerOff();
fbAsmPowerOn();
fbAsmGetShuttle();
fbAsmStop();
fbMoveInPlane();
fbAsmReset();
(* 分配组件和当前所选托盘的信息 *)
gMain.Status.AsmState := fbAsmReadInfo.AssemblyInfo.AssemblyState;
gMain.Status.SelectedShuttleID := gShuttleList[gMain.Par.SelectedShuttleIndex].ID;
END_PROGRAM
PROGRAM _EXIT
(* 禁用 FUB *)
fbAsmReadInfo.Enable := FALSE;
(* 调用功能块 *)
fbAsmReadInfo();
END_PROGRAM
To control the movement of an ACOPOS 6D system, code examples are available here that can be transferred to the Automation Studio project (Logical View) directly or by with "Open as text".
The task can be assigned to any task class since mapp 6D is automatically executed in task class #1.
Global variable "gMain" can be used later for testing.
Fig.: Adding the source code in the Logical View
(*Main control datatype*)
TYPE
gMainType : STRUCT (*Main control variable datatype*)
Cmd : gMainCmdType; (*Main commands*)
Par : gMainParType; (*Main parameter*)
Status : gMainStatusType; (*Main status*)
END_STRUCT;
gMainCmdType : STRUCT (*Main commands type*)
Power : BOOL; (*Power on the system*)
Start : BOOL; (*Start a plane movement for the selected shuttle*)
Stop : BOOL; (*Stop all shuttles in the system*)
ErrorReset : BOOL; (*Reset any active error*)
END_STRUCT;
gMainParType : STRUCT (*Main parameter type*)
SelectedShuttleIndex : UINT; (*Selected index in the global array of shuttle references*)
Velocity : REAL; (*InPlane (X,Y) Velocity*)
Acceleration : REAL; (*InPlane (X,Y) Acceleration*)
InPlanePosition : McAcp6DInPlaneAxesType; (*InPlane (X,Y) Position*)
END_STRUCT;
gMainStatusType : STRUCT (*Main status type*)
AsmState : McAcp6dPLCopenStateEnum; (*Assembly state*)
ShuttlesPresent : UINT; (*Number of shuttles present on the assembly*)
SelectedShuttleID : UINT; (*ID of the shuttle which was selected in the array*)
END_STRUCT;
END_TYPE
(*Global shuttle array datatype*)
TYPE
gShuttleListType : STRUCT (*Global shuttle list datatype*)
ID : UINT; (*ID of the shuttle*)
Ref : Mc6DShuttleType; (*Reference to the shuttle*)
END_STRUCT;
END_TYPE
(*Communication Variables*)
VAR
gCommInput : Mc6DControllerFBIOType; (*Communication variable INPUT*)
gCommOutput : Mc6DControllerFBIOType; (*Communication variable OUTPUT*)
END_VAR
(*CONSTANTS*)
VAR CONSTANT
MAX_NUM_SHUTTLE : UINT := 50; (*Maximum numer of shuttles on the system (50 Shuttles)*)
END_VAR
(*Derived CONSTANTS*)
VAR CONSTANT
MAX_INDEX_SHUTTLE : UINT := MAX_NUM_SHUTTLE - 1; (*Maximum index for a shuttles on the system (0 to MAX_NUM_SHUTTLE - 1)*)
END_VAR
(*Global Control Variable*)
VAR
gMain : gMainType; (*Global control variable*)
gShuttleList : ARRAY[0..MAX_INDEX_SHUTTLE] OF gShuttleListType; (*Global shuttle list*)
END_VAR
TYPE
MainStepEnum :
( (*States for the main state machine*)
MAIN_STARTUP,
MAIN_POWER_OFF,
MAIN_DISABLED,
MAIN_POWER_ON,
MAIN_GET_SHUTTLE,
MAIN_GET_SHUTTLE_WAIT,
MAIN_READY,
MAIN_START_MOVEMENT,
MAIN_STOP_MOVEMENT,
MAIN_ERROR
);
END_TYPE
(*Function Blocks*)
VAR
fbAsmReadInfo : MC_BR_AsmReadInfo_Acp6D;
fbAsmPowerOn : MC_BR_AsmPowerOn_Acp6D;
fbAsmPowerOff : MC_BR_AsmPowerOff_Acp6D;
fbAsmGetShuttle : MC_BR_AsmGetShuttle_Acp6D;
fbAsmStop : MC_BR_AsmStop_Acp6D;
fbMoveInPlane : MC_BR_MoveInPlane_Acp6D;
fbAsmReset : MC_BR_AsmReset_Acp6D;
END_VAR
(*Local Vars*)
VAR
MainStep : MainStepEnum; (*Variable for the state machine*)
i : UINT;
END_VAR
PROGRAM _INIT
(* Call communication variables once to ensure they are created *)
gCommInput;
gCommOutput;
(* Assign assembly reference to function blocks *)
fbAsmReadInfo.Assembly := ADR(gAssembly6D_1);
fbAsmPowerOn.Assembly := ADR(gAssembly6D_1);
fbAsmPowerOff.Assembly := ADR(gAssembly6D_1);
fbAsmGetShuttle.Assembly := ADR(gAssembly6D_1);
fbAsmStop.Assembly := ADR(gAssembly6D_1);
(* Set parameters for function block "fbMoveInPlane" *)
fbMoveInPlane.Parameters.Mode := mcACP6D_MOVE_ABSOLUTE;
fbMoveInPlane.Parameters.Path := mcACP6D_PATH_X_THEN_Y;
fbMoveInPlane.Parameters.EndVelocity := 0.0;
(* Initialize main control parameters *)
gMain.Par.Velocity := 1.0; //[m/s]
gMain.Par.Acceleration := 10.0; //[m/s²]
gMain.Par.InPlanePosition.X := 0.36; //[m]
gMain.Par.InPlanePosition.Y := 0.12; //[m]
(* Enable diagnostic function block *)
fbAsmReadInfo.Enable := TRUE;
END_PROGRAM
PROGRAM _CYCLIC
(* Check for current assembly state *)
IF (gMain.Status.AsmState = mcACP6D_ERRORSTOP) THEN
(* If an error occurs, go to the error state *)
MainStep := MAIN_ERROR;
ELSIF (gMain.Status.AsmState = mcACP6D_STARTUP) THEN
(* As long, as the 6D - controller is in startup, stay in startup state *)
MainStep := MAIN_STARTUP;
END_IF
(* Limit the selected index for the shuttle list *)
gMain.Par.SelectedShuttleIndex := LIMIT(0, gMain.Par.SelectedShuttleIndex, MAX_INDEX_SHUTTLE);
(* State machine *)
CASE MainStep OF
MAIN_STARTUP:
(* Wait for the 6D controller to be started *)
IF (gMain.Status.AsmState = mcACP6D_DISABLED) THEN
(* If assembly is disabled *)
MainStep := MAIN_DISABLED;
ELSIF NOT(gMain.Status.AsmState = mcACP6D_STARTUP) THEN
(* If assembly is in any other state, disable it *)
MainStep := MAIN_POWER_OFF;
END_IF
MAIN_POWER_OFF:
(* Activate Function block *)
fbAsmPowerOff.Execute := TRUE;
(* Wait for the command to be done OR if the assembly state is already correct *)
IF (fbAsmPowerOff.Done) OR (gMain.Status.AsmState = mcACP6D_DISABLED) THEN
(* Reset the function block *)
fbAsmPowerOff.Execute := FALSE;
(* Next step *)
MainStep := MAIN_DISABLED;
ELSIF (fbAsmPowerOff.Error) THEN
(* Next step *)
MainStep := MAIN_ERROR;
END_IF
MAIN_DISABLED:
(* Wait for the power on command *)
IF (gMain.Cmd.Power) THEN
(* Next step *)
MainStep := MAIN_POWER_ON;
END_IF
MAIN_POWER_ON:
(* Activate Function block *)
fbAsmPowerOn.Execute := TRUE;
(* Wait for the command to be done OR if the assembly state is already correct *)
IF (fbAsmPowerOn.Done) OR (gMain.Status.AsmState = mcACP6D_READY) THEN
(* Reset the function block *)
fbAsmPowerOn.Execute := FALSE;
(* Delete data from global shuttle array *)
brsmemset(ADR(gShuttleList),0,SIZEOF(gShuttleList));
(* Init index *)
i := 0;
(* Next step *)
MainStep := MAIN_GET_SHUTTLE;
ELSIF (fbAsmPowerOn.Error) THEN
(* Next step *)
MainStep := MAIN_ERROR;
END_IF
MAIN_GET_SHUTTLE:
(* Enable the function block *)
fbAsmGetShuttle.Enable := TRUE;
(* Wait until the data is valid *)
IF (fbAsmGetShuttle.Valid) THEN
(* Check any shuttle is present *)
IF (fbAsmGetShuttle.TotalCount > 0) THEN
(* Reset the "next" command *)
fbAsmGetShuttle.Next := FALSE;
(* Save the number of shuttles *)
gMain.Status.ShuttlesPresent := fbAsmGetShuttle.TotalCount;
(* Save the shuttle data *)
gShuttleList[i].ID := fbAsmGetShuttle.AdditionalInfo.ShuttleID;
gShuttleList[i].Ref := fbAsmGetShuttle.Shuttle;
(* Next step *)
MainStep := MAIN_GET_SHUTTLE_WAIT;
ELSE
(* No shuttles present *)
gMain.Status.ShuttlesPresent := 0;
(* Disable the function block *)
fbAsmGetShuttle.Enable := FALSE;
(* Next step *)
MainStep := MAIN_READY;
END_IF
END_IF
MAIN_GET_SHUTTLE_WAIT:
(* Check if there are more shuttles to read out *)
IF (fbAsmGetShuttle.RemainingCount > 0) THEN
(* Get next shuttle *)
fbAsmGetShuttle.Next := TRUE;
(* Increase index *)
i := i + 1;
(* Next step *)
MainStep := MAIN_GET_SHUTTLE;
ELSE
(* Reset the function block *)
fbAsmGetShuttle.Enable := FALSE;
(* Next step *)
MainStep := MAIN_READY;
END_IF
MAIN_READY:
IF NOT(gMain.Cmd.Power) THEN
(* Reset command *)
gMain.Cmd.Power := FALSE;
(* Next step *)
MainStep := MAIN_POWER_OFF;
ELSIF (gMain.Cmd.Start) THEN
(* Reset command *)
gMain.Cmd.Start := FALSE;
(* Next step *)
MainStep := MAIN_START_MOVEMENT;
ELSIF (gMain.Cmd.Stop) THEN
(* Reset command *)
gMain.Cmd.Stop := FALSE;
(* Next step *)
MainStep := MAIN_STOP_MOVEMENT;
END_IF
MAIN_START_MOVEMENT:
(* Activate the function block *)
fbMoveInPlane.Shuttle := ADR(gShuttleList[gMain.Par.SelectedShuttleIndex].Ref);
fbMoveInPlane.Parameters.Velocity := gMain.Par.Velocity; //Parameter set in INIT, can be modified in Watch
fbMoveInPlane.Parameters.Acceleration := gMain.Par.Acceleration; //Parameter set in INIT, can be modified in Watch
fbMoveInPlane.Parameters.Position := gMain.Par.InPlanePosition; //Parameter set in INIT, can be modified in Watch
fbMoveInPlane.Execute := TRUE;
(* Wait for the command to be accepted *)
IF (fbMoveInPlane.Acknowledge OR fbMoveInPlane.Done) THEN
(* Reset the function block *)
fbMoveInPlane.Execute := FALSE;
(* Next step *)
MainStep := MAIN_READY;
ELSIF (fbMoveInPlane.Error) THEN
(* Reset the function block *)
fbMoveInPlane.Execute := FALSE;
(* Next step *)
MainStep := MAIN_READY;
END_IF
MAIN_STOP_MOVEMENT:
(* Activate Function block *)
fbAsmStop.Execute := TRUE;
(* Wait for the command to be done *)
IF (fbAsmStop.Done) THEN
(* Reset the function block *)
fbAsmStop.Execute := FALSE;
(* Next step *)
MainStep := MAIN_READY;
ELSIF (fbAsmStop.Error) THEN
(* Next step *)
MainStep := MAIN_ERROR;
END_IF
MAIN_ERROR:
(* Reset assembly with user command *)
fbAsmReset.Execute := gMain.Cmd.ErrorReset;
(* Reset the assembly after diagnosis *)
IF (fbAsmReset.Done) THEN
(* Reset command *)
gMain.Cmd.ErrorReset := FALSE;
gMain.Cmd.Power := FALSE;
gMain.Cmd.Start := FALSE;
gMain.Cmd.Stop := FALSE;
(* Reset function blocks *)
fbAsmReset.Execute := FALSE;
fbAsmPowerOff.Execute := FALSE;
fbAsmPowerOn.Execute := FALSE;
fbAsmGetShuttle.Enable := FALSE;
fbAsmGetShuttle.Next := FALSE;
fbMoveInPlane.Execute := FALSE;
fbMoveInPlane.Execute := FALSE;
(* Next step *)
IF (gMain.Status.AsmState = mcACP6D_DISABLED) THEN
MainStep := MAIN_DISABLED;
ELSE
MainStep := MAIN_POWER_OFF;
END_IF
END_IF
END_CASE
(* 调用功能块 *)
fbAsmReadInfo();
fbAsmPowerOff();
fbAsmPowerOn();
fbAsmGetShuttle();
fbAsmStop();
fbMoveInPlane();
fbAsmReset();
(* 分配组件和当前所选托盘的信息 *)
gMain.Status.AsmState := fbAsmReadInfo.AssemblyInfo.AssemblyState;
gMain.Status.SelectedShuttleID := gShuttleList[gMain.Par.SelectedShuttleIndex].ID;
END_PROGRAM
PROGRAM _EXIT
(* 禁用 FUB *)
fbAsmReadInfo.Enable := FALSE;
(* 调用功能块 *)
fbAsmReadInfo();
END_PROGRAM