CODESYS 枕式機(jī)應(yīng)用

9Y 其他CODESYS 枕式機(jī)應(yīng)用已關(guān)閉評(píng)論340字?jǐn)?shù) 1322閱讀4分24秒閱讀模式

//----色標(biāo)中斷信號(hào)響應(yīng)處理:將傳送帶軸當(dāng)前位置存放到位置緩存
IF SensorTriger=1 THEN
IF (BufDeep<0) THEN
BufDeep:=0; //防止出錯(cuò)
END_IF
IF BufDeep>=2 THEN
BufDeep:=2; //最多只支持2個(gè)緩存,多于2個(gè),丟棄,防止出錯(cuò)
END_IF

CASE BufDeep OF //--緩存指針,最多記住3個(gè)標(biāo)志
0:
TargetPointArry0:=Axis_CONVERY.fActPosition;
1:
TargetPointArry1:=Axis_CONVERY.fActPosition;
2:
TargetPointArry2:=Axis_CONVERY.fActPosition;
END_CASE

BufDeep:=BufDeep+1;
SensorTriger:=0;

END_IF

//-----自由計(jì)時(shí)器刷新,可用于判斷超時(shí)錯(cuò)誤-------->>--
IF PowerupTimerS < 32700 THEN
PowerupTimerS:=PowerupTimerS+2; //EtherCAT Period is 2ms
END_IF

//----按系統(tǒng)運(yùn)行狀態(tài)0~5分別處理---------------->>
IF Sysstatus<0 OR Sysstatus>5 THEN //萬(wàn)一狀態(tài)指針錯(cuò)誤,糾正為重新開(kāi)始運(yùn)行
Sysstatus:=0;
END_IF

CASE Sysstatus OF
// System status: 0=Selfchecking; 1=Error; 2=Stopped; 3=Man-Jogging; 4=SlaveAxis Origining;
// 5=MasterAxis firstrun;
0: //上電自診斷,伺服使能 Self checking
IF NOT Inited THEN
//-----使能兩個(gè)伺服驅(qū)動(dòng)器----->>------
MC_Power2(Enable:=TRUE, bRegulatorOn:=TRUE, bDriveStart:=TRUE, Axis:=Axis_FlyCut,);
MC_Power1(Enable:=TRUE, bRegulatorOn:=TRUE, bDriveStart:=TRUE, Axis:=Axis_CONVERY,);

MC_Power3(Enable:=TRUE, bRegulatorOn:=TRUE, bDriveStart:=TRUE, Axis:=Axis_ZJ,);

Inited:= MC_Power1.Status AND MC_Power2.Status AND MC_Power3.Status;

//-----超時(shí)錯(cuò)誤判斷------>>-----
IF (PowerupTimerS> 10000) AND (Ethercat.xConfigFinished = FALSE) THEN
SysStatuMark:=1; //EtherCAT Network/Cable Error
Sysstatus:=1; //Error State
END_IF

IF (PowerupTimerS> 12000) AND (Ethercat.xError = TRUE) THEN
SysStatuMark:=2; //EtherCAT Network/Cable Error
Sysstatus:=1; //Error State
END_IF

ELSE
Sysstatus :=2; //If two servo can be ENABLED, Switch to statu 2;
SysStatuMark:=0; //OK
END_IF

1: //停機(jī)告警狀態(tài) Stopped,Error Alarming

AxisConvy_RUN:=0;

IF Reset_key=TRUE THEN //----如果手動(dòng)復(fù)位按鈕,
Sysstatus:=0; //--退回到起始狀態(tài)
PowerupTimerS:=0; //--重新計(jì)時(shí)
SysStatuMark:=0; //--清除告警

IF EtherCAT.xConfigFinished=FALSE THEN
EtherCAT.xRestart :=Reset_key; //---如果EtherCAT網(wǎng)絡(luò)有問(wèn)題,重啟網(wǎng)絡(luò)
END_IF

Reset_key:=FALSE;
END_IF

IF Setup_key=TRUE AND SysStatuMark=0 THEN //----系統(tǒng)正常的情況下,如果手動(dòng)調(diào)試按鈕,轉(zhuǎn)到調(diào)試狀態(tài)
Sysstatus:=3;

END_IF
//Setup_key:=TRUE;
IF Setup_key=FALSE AND SysStatuMark=0 THEN //----系統(tǒng)正常的情況下,如果手動(dòng)調(diào)試按鈕,轉(zhuǎn)到調(diào)試狀態(tài)
Sysstatus:=2;

END_IF

2: //正常停機(jī) Stopped, Normal

AxisConvy_RUN:=0;

IF Axis_CONVERY.nAxisState=4 OR Axis_CONVERY.nAxisState=5 THEN
AxisConvery_Stop:=1; //此處給出停機(jī)標(biāo)志
END_IF

IF Axis_FlyCut.nAxisState=4 OR Axis_FlyCut.nAxisState=5 THEN
AxisFlyCut_Stop:=1; //此處給出停機(jī)標(biāo)志
END_IF

IF Setup_key= TRUE THEN
Sysstatus:= 3; //goto JOG and Setting

END_IF

IF Run_key= TRUE THEN
Sysstatus:= 4; //Proparing to run
Run_key:=0;
Run1Cmd:=1;
END_IF

3: // Manual Jogging and setting, Omitted because of no Set_Key here
MC_Jog1( Axis:= Axis_Convery, JogForward:= JOG_AxisConvery_for, JogBackward:=JOG_AxisConvery_bak, Velocity:= 100,Acceleration:= 1000, Deceleration:= 1000, );

MC_Jog2( Axis:= Axis_FlyCut, JogBackward:= JOG_AxisFlyCut_for,JogBackward:=JOG_AxisFlyCut_bak, Velocity:= 100,Acceleration:= 1000, Deceleration:= 1000, );

IF FlyZero_key= TRUE THEN
MC_SetPosition1(Axis:= Axis_FlyCut,Execute:=TRUE,Mode:=FALSE,);
FlyZero_key:= FALSE;
END_IF

IF Setup_key= FALSE AND JOG_AxisConvery_for= FALSE AND JOG_AxisFlyCut_for=FALSE AND JOG_AxisConvery_bak= FALSE AND JOG_AxisFlyCut_bak=FALSE THEN
Sysstatus:= 2;
END_IF

4: //SlaveAxis Adjusting, 若飛剪軸不在等待位置,先回到原點(diǎn)
MC_MoveAbsolute2(Axis:= Axis_FlyCut ,Execute:=Run1Cmd ,Position:=0 ,Velocity:=360 ,Acceleration:=3600 ,Deceleration:=3600 , );
Run1Cmd :=0;
//MC_Home1(Axis:= Axis_FlyCut, Execute:= Run1Cmd, Position:= 0, );

IF MC_MoveAbsolute2.done=TRUE THEN
MC_MoveAbsolute2(Axis:= Axis_FlyCut ,Execute:=FALSE ,);
CAM_TabEnable:=TRUE;//凸輪表使能
Sysstatus:=5; //goto runing

//初始化用于同步起始點(diǎn)的比較寄存器緩沖,這里設(shè)計(jì)了2級(jí)緩沖,Clear CMR buffer------>>--
CMR0:=0;
CMR1:=0;
CMR_Pointer:=0;

//讓自由計(jì)時(shí)器從新計(jì)時(shí),便于檢查色標(biāo)信號(hào)超時(shí)判斷--------->>-----
PowerupTimerS:=0;

END_IF

5: //MasterAxis firstRun
//傳送帶開(kāi)始以速度方式運(yùn)動(dòng),運(yùn)行速度Vspeed為按時(shí)間變化----------------->>--
AxisConvy_RUN:=TRUE;

CAM_InEnable:=TRUE;//凸輪同步使能,由CMR+Offset比對(duì)匹配時(shí),觸發(fā)同步

END_CASE

//---以下為所有狀態(tài)都需要的處理---------------->>
//-----前面作了MC的執(zhí)行觸發(fā)、使能標(biāo)志的處理,下面統(tǒng)一放在這里------>>
MC_CAMTableSelect1(
Master:= Axis_CONVERY,
Slave:= Axis_FlyCut,
CamTable:= Cam1,
Execute:= CAM_TabEnable,
Periodic:= FALSE,
MasterAbsolute:= FALSE,
SlaveAbsolute:= 1,
Done=> Tbldn,
Busy=> ,
Error=> ,
ErrorID=> ,
CamTableID=> Cam1_ID);

//---比較目標(biāo)緩沖區(qū)的長(zhǎng)度,觸發(fā)CAM同步的判斷、CamIn的觸發(fā)-----
IF CAM_InEnable=TRUE THEN
IF BufDeep >0 THEN
tmp1:=Axis_CONVERY.fActPosition-(TargetPointArry0+SensorCut_Length);
IF tmp1>-0.1 THEN
CamIn_trig:=1;

TargetPointArry0:=TargetPointArry1;
TargetPointArry1:=TargetPointArry2;
BufDeep:=BufDeep-1;
END_IF
//---防錯(cuò)處理:若傳送帶的當(dāng)前位置比比較點(diǎn)的位置大,清掉無(wú)用的比較點(diǎn)----->>
(* (tmp1>0.1) THEN
TargetPointArry0:=TargetPointArry1;
TargetPointArry1:=TargetPointArry2;
IF BufDeep>0 THEN
BufDeep:=BufDeep-1;
END_IF

END_IF *)

END_IF
END_IF

pp:=Run_key;

MC_CamIn1(
Master:= Axis_CONVERY,
Slave:= Axis_FlyCut,
Execute:= CamIn_trig,
MasterOffset:= 0,
SlaveOffset:= 0,
MasterScaling:= 1,
SlaveScaling:= -1,
StartMode:=0 ,
CamTableID:= Cam1_ID,
VelocityDiff:= 0,
Acceleration:= 30,
Deceleration:= 30, );

CamIn_trig:=FALSE; //

MC_CamOut1(
Slave:= Axis_FlyCut,
Execute:= Stop_key,
Done=> ,
Busy=> ,
Error=> ,
ErrorID=> );

MC_MoveVelocity1(Axis:= Axis_CONVERY , Execute:=AxisConvy_RUN , Velocity:= Vspeed , Acceleration:= 60, Deceleration:=60 , );

//如果2個(gè)軸都已停穩(wěn)3=standstill,返回停機(jī)狀態(tài)
(*IF Sysstatus=5 AND Axis_CONVERY.nAxisState=3 AND Axis_FlyCut.nAxisState =3 THEN
Sysstatus:=2;
END_IF
*)
//只要有1個(gè)軸故障停機(jī)1=errorstop,就返回故障停機(jī)狀態(tài)
IF Axis_CONVERY.nAxisState=1 OR Axis_FlyCut.nAxisState =1 THEN
AxisFlyCut_Stop:=1;
AxisConvery_Stop:=1;
Sysstatus:=1;
END_IF

IF Stop_key=1 THEN
AxisFlyCut_Stop:=1;
AxisConvery_Stop:=1;
AxisConvy_RUN:=0;
Stop_key:=0;
END_IF

//----測(cè)試位移----->>
MC_MoveRelative1(
Axis:= Axis_CONVERY,
Execute:= test1,
Distance:=120 ,
Velocity:= Vspeed,
Acceleration:=60 ,
Deceleration:= 60,
);

//----測(cè)試位移------>>
MC_MoveRelative2(
Axis:= Axis_FlyCut,
Execute:= test2,
Distance:=360 ,
Velocity:= Vspeed,
Acceleration:=60 ,
Deceleration:= 60,
);

MC_Stop1(Axis:= Axis_CONVERY,Execute:=AxisConvery_Stop,);
MC_Stop2(Axis:= Axis_FlyCut,Execute:=AxisFlyCut_Stop,);
AxisFlyCut_Stop:=0;
AxisConvery_Stop:=0;

MC_Reset1(Axis:= Axis_CONVERY, Execute:= r1, );
MC_Reset2(Axis:= Axis_FlyCut, Execute:= r2, );
MC_Reset3(Axis:= Axis_ZJ, Execute:= r3, );

IF Sysstatus >0 AND ( 飛剪伺服.wstate <>8) THEN
b:=b+1;
SysStatuMark:=2; //第二個(gè)伺服網(wǎng)絡(luò)斷線
END_IF

IF Sysstatus >0 AND ( 追剪伺服.wstate <>8) THEN
a:=a+1;
SysStatuMark:=3; //第一個(gè)伺服網(wǎng)絡(luò)斷線
END_IF

//---下面的語(yǔ)句是為了讓MC指令能得到下一次的上升沿------------>>---
MC_MoveAbsolute2(Axis:= Axis_FlyCut ,Execute:=FALSE , );
MC_MoveVelocity1(Axis:= Axis_CONVERY , Execute:=FALSE,);
MC_SetPosition1(Axis:= Axis_FlyCut,Execute:=FALSE,Mode:=FALSE,);

繼續(xù)閱讀
我的微信
這是我的微信掃一掃
weinxin
我的微信
微信號(hào)已復(fù)制
我的微信公眾號(hào)
我的微信公眾號(hào)掃一掃
weinxin
我的公眾號(hào)
公眾號(hào)已復(fù)制
 
如何選擇合適的裝袋機(jī) 其他

如何選擇合適的裝袋機(jī)

選擇合適的裝袋機(jī) 裝袋機(jī)可以包裝液體、液體或固體產(chǎn)品。它們用于食品、醫(yī)療和制藥行業(yè)等各個(gè)領(lǐng)域。 裝袋包括產(chǎn)品(稱重、計(jì)數(shù)、計(jì)量等),然后是灌裝階段,然后是包裝的切斷和密封。 查看裝袋機(jī) 如何選擇裝袋機(jī)...
自動(dòng)裝袋機(jī) 其他

自動(dòng)裝袋機(jī)

在包裝過(guò)程中使用裝袋機(jī)的好處 靈活性 您可以使用同一臺(tái)機(jī)器創(chuàng)建從 100mm-300mm的可變袋子長(zhǎng)度,并在袋子寬度方面找到靈活性。您還可以在機(jī)器上添加真空,以消除行李中的空氣。 標(biāo)簽 您可以使用熱轉(zhuǎn)...
視覺(jué)計(jì)數(shù)設(shè)備在工業(yè)應(yīng)用 其他

視覺(jué)計(jì)數(shù)設(shè)備在工業(yè)應(yīng)用

計(jì)數(shù)設(shè)備應(yīng)用簡(jiǎn)介 顧名思義,計(jì)數(shù)是一種對(duì)任何行業(yè)中數(shù)千個(gè)零件進(jìn)行計(jì)數(shù)的方法。影響計(jì)數(shù)的最重要因素是秤、零件重量及其偏差。平均重量偏差通常趨于 0.5%。此外,環(huán)境以及正確設(shè)備的選擇和安裝也是必不可少的...
塑料袋印刷包裝機(jī) 其他

塑料袋印刷包裝機(jī)

  帶打印機(jī)裝袋機(jī) |小袋包裝印刷機(jī) 袋裝包裝機(jī),包括打印機(jī),讓您的生活更輕松。使用這些機(jī)器,您可以處理日常業(yè)務(wù)流程并為下一個(gè)訂單準(zhǔn)備所有產(chǎn)品。 包裝印刷機(jī)的優(yōu)勢(shì) 包裝是產(chǎn)品營(yíng)銷和保存最重要...