12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264 |
- #include "global.h"
- #if HAI_HUA_MACHINE ==1
- void QueDuan_AlarmProtect(void);
- void QueDuan_ManualAction(void);
- void QueDuan_AutoAction(void);
- void QueDuan_StepCheckStart(void);
- void QueDuan_XiaQue(void);
- void QueDuan_Motor(void);
- void QueDuan_YuanDianAction(void);
- void QueDuan_TuiLianAction(void);
- void QueDuan_ExtiActionX31(void);
- void QueDuan_BingLian(void);
- void QD_TuiDaiAction(void);
- static unsigned long cZipCnt = 0,cTableCnt = 0,cTuiFangKuaiCnt = 0;
- static long save_limit_pos,cRealPos;
- static long dwSaveLength;
-
- unsigned char cCheckLianFlg = 0;
- unsigned char cCheckLianFlgEN = 0;
- unsigned char cGoLimitEn = 0;
- short *length_buffer;
- void QueDuan_ExtiActionX31(void)
- {
- cCheckLianFlg = 1;
- }
- void QD_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(QD_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void QueDuan_InitAction(void)
- {
- float length_buff,pulse_buff;
-
- length_buff = QD_PARAM_CYCLE_LENGTH;
- pulse_buff = QD_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
- QD_SZ_OUT = 1;
- }
- void QueDuan_Action(void)
- {
- QueDuan_AlarmProtect();
- QueDuan_Motor();
- QueDuan_XiaQue();
- QueDuan_ManualAction();
- QueDuan_TuiLianAction();
- QueDuan_BingLian();
- QueDuan_AutoAction();
- QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
- }
- //手动动作
- void QueDuan_ManualAction(void)
- {
- if(bRunning == 0)
- {
- cGoLimitEn = 0;
- if(QD_bClearTotal) //切断计数清零
- {
- QD_bClearTotal = 0;
- ClrcToTal(QD_TOTAL_ADDR);
- }
-
- if(QD_bClearNowTotal)
- {
- QD_bClearNowTotal = 0;
- QD_PARAM_NOW_CNT = 0;
- }
-
- if(QD_bXiaQie)
- {
- QD_bXiaQie = 0;
- if((QD_XiaQieStep == 0) && !QD_TL_VAVLE)
- {
- QD_XiaQieStep = 1;
- }
- }
-
- if(QD_bQianDianDW)
- {
- QD_bQianDianDW = 0;
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 61;
- cZipCnt = 0;
- }
- }
-
- if(QD_bTL)
- {
- QD_bTL = 0;
- if(QD_TL_VAVLE)
- {
- QD_TL_VAVLE = 0;
- }
- else if(!QD_GZ_VAVLE && !QD_SM_VAVLE)
- {
- QD_TL_VAVLE = ~QD_TL_VAVLE;
- }
- }
-
- // if(!Y_DRV)QD_bTL = 0;
-
- if(QD_bYD)
- {
- QD_bYD = 0;
- QD_YD_VAVLE = ~QD_YD_VAVLE;
- }
-
- if(QD_bGZ)
- {
- QD_bGZ = 0;
- QD_GZ_VAVLE = ~QD_GZ_VAVLE;
- }
-
- if(QD_bJD)
- {
- QD_bJD = 0;
- QD_JD_VAVLE = ~QD_JD_VAVLE;
- }
-
- if(QD_bXM)
- {
- QD_bXM = 0;
- QD_XM_VAVLE = ~QD_XM_VAVLE;
- if(!QD_XM_VAVLE)QD_GZ_VAVLE = 0;
- }
-
- if(QD_bSM)
- {
- QD_bSM = 0;
- if(QD_SM_VAVLE)
- QD_SM_VAVLE = 0;
- else if(!QD_TL_VAVLE)
- QD_SM_VAVLE = 1;
- }
- //推方块
- if(QD_bTFK)
- {
- QD_bTFK = 0;
- QD_TFK_VAVLE = ~QD_TFK_VAVLE;
- }
- //台面电机
- if(QD_bTB)
- {
- QD_bTB = 0;
- QD_TABLE_VAVLE = ~QD_TABLE_VAVLE;
- }
-
- // if(QD_bYBD)
- // / {
- // QD_bYBD = 0;
- // QD_YBD_VAVLE = ~QD_YBD_VAVLE;
- // }
-
- if(QD_bTestCS)
- {
- QD_bTestCS = 0;
- QD_CS_OUT = 1;
- QD_CSDelay = dwTickCount + QD_PARAM_CS_TIME;
- }
-
- if(QD_bBL)//合链
- {
- QD_bBL = 0;
- QD_BL_VAVLE = ~QD_BL_VAVLE;
- }
-
- if(QD_bHL) //护链,双开用
- {
- QD_bHL = 0;
- QD_HL_VAVLE = ~QD_HL_VAVLE;
- }
-
- if(QD_bYX)
- {
- QD_bYX = 0;
- QD_YX_VAVLE = ~QD_YX_VAVLE;
- }
- if(QD_XiaQieStep == 0)
- {
- if(dwTickCount >= QD_CSDelay)QD_CS_OUT = 0;
- }
- //电机控制
- if(QD_bGoMotor && !QD_QIAN_LIMIT_IN)
- {
- QD_SZ_OUT = 0;
- QD_JZ_DIR = QD_YDIR_N;
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED/3,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
- }
-
- if(QD_bBackMotor) //后退限位已经取消
- {
- QD_SZ_OUT = 0;
- QD_JZ_DIR = QD_YDIR_P;
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED/3,QD_DIR_P,QD_PARAM_GO_LOW_SPEED/3,15,15);
- }
-
- if(!QD_bGoMotor && !QD_bBackMotor && (QD_MotorStep == 0))
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
-
- if(QD_QIAN_LIMIT_IN && (QD_MotorStep == 0) && !QD_bBackMotor &&(QD_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
- }
- }
- void QueDuan_AlarmProtect(void)
- {
- cRealPos = GetPos(X_AXIS);
- if(!bRunning)
- {
- ;
- //
- #if 0
- if(QD_BACK_LIMIT_IN_UP)
- {
- if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
- {
- QD_bBackMotor = 0;
-
- AxisDecStop(X_AXIS);
- QD_JD_VAVLE = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
-
- }
- }
- #endif
- }
- else
- {
- if((cRealPos > QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH > 3000)
- && (cGoLimitEn != 0))
- {
- AxisEgmStop(X_AXIS);
- QD_JD_VAVLE = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
- }
- }
- }
- void QueDuan_AutoAction(void)
- {
- //台面电机定时关掉
-
- if(bRunning)
- {
- if(dwTickCount >= QD_TBDelay)
- QD_TABLE_VAVLE = 0;
- switch(QD_AutoStep)
- {
- case 1:
- if(dwTickCount >= QD_AutoDelay)
- {
- QD_AutoStep = 2;
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 61; //前点定位
- }
- cGoLimitEn = 0;
- }
- break;
- case 2:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 30;
- QD_AutoStep = 3;
- cGoLimitEn = 1;
- }
- break;
- case 3:
- if(QD_MotorStep == 0)
- {
- if(QD_SAFE_IN)
- {
- bStop = 1;
- }
- else
- {
-
- if(QD_XiaQieStep == 0)
- QD_XiaQieStep = 1;
- QD_AutoStep = 4;
- }
- }
- break;
- case 4:
-
- // if((QD_MACHINE_TYPE == QD_NO_GL_TUIFANGKUAI) || (QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI))
- // {
- // 闭口
- if((QD_XiaQieStep == 0) || ((QD_XiaQieStep == 6) && QD_KB_MODE)|| ((QD_XiaQieStep == 13) && (QD_KB_MODE == 0)))// && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- cGoLimitEn=0;
- QD_MotorStep = 40; //切完后退
-
- }
- QD_AutoStep = 5;
- }
- /*
- // }
- // else
- // {
- if(((QD_XiaQieStep == 0) || (QD_XiaQieStep == 13)) && !QD_SHANG_MU_LIMIT_IN && !QD_XIA_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 40; //切完后退
- QD_AutoStep = 5;
- }
- }
- }
- */
- break;
- case 5:
-
- if(QD_MotorStep == 0)
- {
- cZipCnt++;
- QD_PARAM_NOW_CNT++;
- cTableCnt++;
- AddToTal(QD_TOTAL_ADDR);
- AddToTal(CT_WORKTOTAL_ADDR);
- CalProSP(QD_PROSPEED_ADDR);
-
- if(cTableCnt >= QD_PARAM_TABLE_NUM)
- {
- cTableCnt = 0;
- QD_TABLE_VAVLE = 1;
- QD_TBDelay = dwTickCount + QD_PARAM_TB_TIME;
- }
-
- if(/*(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) ||*/ SingOneFlg)
- {
- /*
- if((QD_PARAM_SET_TOTAL == 0) && !SingOneFlg)
- {
- QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY;
- QD_AutoStep = 1;
- }
- else
- */
- {
- bRunning = 0;
- QD_AutoStep = 0;
- SingOneFlg = 0;
-
- }
-
- // if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
- }
- else
- {
- QD_AutoStep = 1;
-
- if((QD_PARAM_NOW_CNT >= QD_PARAM_ZHA_SHU) && (QD_PARAM_ZHA_SHU > 0))
- {
- QD_AutoDelay = dwTickCount + QD_PARAM_ZS_STOP_TIME;
- QD_PARAM_NOW_CNT = 0;
- if(QD_PARAM_ZS_STOP_TIME == 0)
- {
- bRunning = 0;
- QD_AutoStep = 0;
- SingOneFlg = 0;
- QD_SetAlarmCode(QD_TOTAL_ALARM);
- }
- }
- else
- QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY;
- }
- }
- break;
- }
- }
- }
- void QueDuan_StepCheckStart(void)
- {
- // 启动
- if((START_IN_UP) || bStart || QD_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (QD_AutoStep == 0))
- {
- if(QD_XIA_MU_LIMIT_IN && !QD_PARAM_XM_ENABLE)QD_SetAlarmCode(QD_XM_DAOWEI);
- // else if(GetAlarmCode(QD_ALARM_ADDR) != 0);
- //else if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
- // else if(QD_BL_VAVLE)QD_SetAlarmCode(QD_BL_ALARM);
- else if(QD_SM_VAVLE)QD_SetAlarmCode(QD_SM_ALARM);
- else
- {
- bRunning = 1;
- QD_AutoStep = 1;
- if(QD_bSingle)
- SingOneFlg= 1;
- cZipCnt = 0;
- cTuiFangKuaiCnt = 0;
- QD_BL_VAVLE = 0; //并链关
- QD_DGLG_VAVLE = 0; //顶过链杆关
- SetAlarmCode(QD_ALARM_ADDR,0);
- }
- }
- QD_bSingle = 0;
- }
- //停止
- if(STOP_IN_UP || bStop)
- {
- bStop = 0;
- if(bRunning)
- {
-
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- dwTickCount = QD_TBDelay;
- SingOneFlg = 0;
- QD_JD_VAVLE = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_TFK_VAVLE= 0;
- QD_TL_VAVLE = 0;
- QD_HL_VAVLE = 0;
- QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- //QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- QD_DGLG_VAVLE = 0; //顶过链杆关
- AxisDecStop(X_AXIS);
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- user_datas[121] = 0;
- user_datas[122] = 0;
- SetAlarmCode(QD_ALARM_ADDR,0);
- }
- else
- {
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- dwTickCount = QD_TBDelay;
- SingOneFlg = 0;
- QD_JD_VAVLE = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_TFK_VAVLE= 0;
- QD_YX_VAVLE = 0;
- QD_HL_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_DGLG_VAVLE = 0; //顶过链杆关
- QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- AxisDecStop(X_AXIS);
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- SetAlarmCode(QD_ALARM_ADDR,0);
- }
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- }
-
- if(bAlarmStop)
- {
- bAlarmStop = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
-
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- SingOneFlg = 0;
- bRunning = 0;
- AxisDecStop(X_AXIS);
- dwTickCount = QD_TBDelay;
- QD_TABLE_VAVLE = 0;
- QD_JD_VAVLE=0;
- QD_GZ_VAVLE=0;
- }
-
- }
- //记忆长度模式误差检测
- void QueDuan_CheckLength(long zip_length)
- {
- static long start_dist;
- switch(QD_CheckLengthStep)
- {
- case 0:break;
- case 1:
- start_dist = cRealPos;
- dwSaveLength = 0;
- QD_CheckLengthStep = 2;
- break;
- case 2:
- if(QD_GUO_LIAN_IN_DW){
- dwSaveLength = cRealPos - start_dist;
- // user_datas[127] = cRealPos;
- }
- break;
- }
- }
- #if !QD_KB_MODE //开口
- //开口切专用
- //30步开始后拉开始,分解4种工作模式
- //40步开始用切断后拉动作
- //60步开始为前方向,开闭口一样
- void QueDuan_Motor_KK(void)
- {
- static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
- unsigned short ch;
- user_datas[121]= QD_MotorStep;
- user_datas[122]= length_buff;
- user_datas[123] = cRealPos;
- user_datas[124] = GetCurSpeed(X_AXIS);
- user_datas[125] = QD_AutoStep;
- user_datas[126] = QD_XiaQieStep;
- // user_datas[127] = QD_XiaQieStep;
- QueDuan_CheckLength(length_buff);
-
- switch(QD_MotorStep)
- {
- case 30:
- switch(QD_PARAM_BACK_MODE) //开口分四种模式
- {
- case 0: //单数控模式
- QD_MotorStep = 310; //每种模式留20步
- QD_DGLG_VAVLE = 1; //顶过链杆关
- break;
- case 1://单感应模式
- QD_MotorStep = 330; //每种模式留20步
-
- break;
- case 2: //先感应后数控模式+检测
- QD_MotorStep = 350; //每种模式留20步
- break;
- default: //数控模式+过链检测长度
- QD_MotorStep = 370; //每种模式留20步
- break;
- }
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- break;
- //310步到315步为数控模式
- case 310:
- QD_MotorStep = 311;
- QD_JZ_DIR = QD_YDIR_P;
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 1; //并链起动
- break;
- case 311:
- if(dwTickCount >= QD_MotorDelay)
- {
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
-
-
-
-
- //李永庆代码
- SetDir(X_AXIS, QD_DIR_N);
- //两段速度移动距离 拉链长度+慢速长度停止
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
-
- SetDir(X_AXIS,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 312;
- }
- break;
- case 312:
- //勾针提前输出 ,争取时间推方块
- if (!QD_GZ_VAVLE && (cRealPos >= (QD_PARAM_ZIPPER_LENGTH- 230)))
- QD_GZ_VAVLE = 1;
-
- if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
- {
- QD_MotorStep = 313;
-
- }
- else if(cRealPos >= (QD_PARAM_ZIPPER_LENGTH + (*length_buffer) + QD_PARAM_ERROR_LENGTH))
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 313:
- if(!QD_GZ_VAVLE && ((cRealPos) > (QD_PARAM_ZIPPER_LENGTH - 230)))
- QD_GZ_VAVLE = 1;
-
- if(!X_DRV)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_MotorStep = 314;
- QD_BL_VAVLE = 0; //停止时并链一定要打开
-
- if((QD_PARAM_BACK_MODE == 2) && !QD_DGLG_VAVLE) //模式2,先检测长度后数控
- {//对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
- if(cZipCnt > 1) //长度检测
- {
- if(QD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
- {
- if(((dwSaveLength + QD_PARAM_MOTOR_DELAY_LENGTH) > (length_buff + QD_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);//拉链变长,对比警告
- }
- else if((dwSaveLength + QD_PARAM_MOTOR_DELAY_LENGTH+ QD_PARAM_ERROR_LENGTH) < length_buff)
- {
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM); ////拉链变短
- }
-
- QD_CheckLengthStep = 0;
- }
- }
- }
- }
- break;
- case 314:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay)) //数控到停止
- {
- QD_MotorStep = 0;
- QD_TFK_VAVLE = 1; //推方块输出
- }
- break;
- //330步到349步单感应模式
- case 330:
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 331;
- QD_JZ_DIR = QD_YDIR_P;
-
-
- user_datas[127] = 0;
- break;
- case 331:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 332;
- if(cZipCnt < 2)
- {
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 10; //并链起动
- //第一条都是过链感应,后拉速度减半//原来QD_PARAM_CHECK_BACK_HSPEED/2
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,9000,QD_DIR_P,QD_PARAM_START_SPEED,8,13);
-
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
-
- }
- else
- {
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 1; //并链起动
- //因为每条都是过链感应,所以直接运行检测模式后拉速度
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_CHECK_BACK_HSPEED,QD_DIR_P,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
-
- }
- }
- break;
- case 332:
- if(cZipCnt > 1) //第二条开始数控降速
- {
- if((cRealPos + QD_PARAM_BACK_LOW_SPEED_LENGTH + 600)>= length_buff)
- {
- CancelPmoveState(X_AXIS); //长度模式去掉
- AxisChangeSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- user_datas[127] = cRealPos;
- QD_MotorStep = 334; //到检测定位
- }
- if(QD_GUO_LIAN_IN_DW) //重新到链上
- {
- CancelPmoveState(X_AXIS);
- AxisChangeSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 335; //到检测定位
- }
- //
- // if((cRealPos >= (QD_PARAM_BACK_LOW_SPEED_LENGTH + 60)) && QD_GUO_LIAN_IN)
- // {
-
- // }
- }
- else //第一条工作
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorDelay = dwTickCount + 0;//QD_PARAM_DELAY_XM;
- QD_MotorStep = 333;
- }
- else if((cRealPos >= QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
- {
- // QD_SetAlarmCode(QD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
- }
- }
- break;
- case 333:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 334;
- }
- break;
- case 334:
- if(QD_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- //滤波有待调试
- // if((((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) && (QD_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QD_PARAM_NO_LT_DELAY_CHECK) && (QD_PARAM_LT_ENABLE == 0)))
- // {
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 335;
- }
- // }
- }
- break;
- case 335:
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
-
- }
- //在空们都把延时清零
- if(QD_GUO_LIAN_IN)
- {
- gou_zhen_buff = cRealPos;
- }
- //定位停止
- if(((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH) && !QD_GUO_LIAN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 336;
- QD_GZ_VAVLE = 1;
- }
- break;
- case 336:
- if(!X_DRV)
- {
- QD_GZ_VAVLE = 1;
-
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- // QD_XM_VAVLE = 1;
- QD_MotorStep = 337;
- }
- break;
- case 337:
- if(1)
- {
- QD_MotorStep = 338;
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- }
- // else if(dwTickCount >= QD_MotorDelay) QD_SetAlarmCode(QD_XM_DAOWEI);
- break;
- case 338:
- if((dwTickCount >= QD_MotorDelay))
- {
- QD_TFK_VAVLE = 1; //推方块输出
- QD_MotorStep = 339;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- break;
- case 339:
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(QD_PARAM_ZIPPER_LENGTH_ADDR,length_buff);
- }
- else if(cZipCnt > 1) //长度检测
- {
- if(QD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
- {
- if(cRealPos >= length_buff) //拉链变长,对比警告
- {
- if((cRealPos - save_buff) > (length_buff+QD_PARAM_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- else //拉链变短
- {
- if((cRealPos - save_buff + QD_PARAM_ERROR_LENGTH) < (length_buff))
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM);
- }
- }
- }
- QD_MotorStep = 0;
- break;
- //350步到369步单感应模式
- case 350:
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
-
- QD_MotorStep = 351;
- QD_JZ_DIR = QD_YDIR_P;
-
-
- break;
- case 351:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 352;
- //第一,二条都是过链感应,测量长度
- if(cZipCnt < 2)
- {
- if(QD_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
- QD_BinLianStep = 10; //并链起动
- QD_DGLG_VAVLE = 0; //顶过链杆关
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,9000,QD_DIR_P,QD_PARAM_START_SPEED,8,12);
-
- }
- else
- {
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 1; //并链起动
- QD_DGLG_VAVLE = 1; //顶过链杆关
- QD_CheckLengthStep = 1; //长度检测,第3条才有对比
- //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
- QD_MotorStep = 311;
- }
- }
- break;
- case 352:
- //前两条都按最低速度工作
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorDelay = dwTickCount + 2;//因慢速,加8MS滤波
- QD_MotorStep = 353;
- }
- else if((cRealPos >= QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
- {
- // QD_SetAlarmCode(QD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
- }
- break;
- case 353:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 354;
- }
- break;
- case 354:
- if(QD_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- //滤波有待调试
- // if((((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) && (QD_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QD_PARAM_NO_LT_DELAY_CHECK) && (QD_PARAM_LT_ENABLE == 0)))
- // {
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 355;
- }
- // }
- }
- break;
- case 355:
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
-
- }
- //在空们都把延时清零
- if(QD_GUO_LIAN_IN)
- {
- gou_zhen_buff = cRealPos;
- }
- //定位停止
- if(((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH) && !QD_GUO_LIAN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 356;
- QD_GZ_VAVLE = 1;
- }
- break;
- case 356:
- if(!X_DRV)
- {
- QD_GZ_VAVLE = 1;
-
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- // QD_XM_VAVLE = 1;
- QD_MotorStep = 357;
- }
- break;
- case 357:
- if(1)
- {
- QD_MotorStep = 358;
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- }
- break;
- case 358:
- if((dwTickCount >= QD_MotorDelay))
- {
- QD_TFK_VAVLE = 1; //推方块输出
- QD_MotorStep = 359;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- break;
- case 359:
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- //测量出来长度
- SetData32bits(QD_PARAM_ZIPPER_LENGTH_ADDR,length_buff);
- }
- QD_MotorStep = 0;
- break;
- //370步到389步为数控模式
- case 370:
- QD_MotorStep = 371;
- QD_JZ_DIR = QD_YDIR_P;
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 1; //并链起动
-
- QD_CheckLengthStep = 1; //长度检测开始
-
- break;
- case 371:
- if(dwTickCount >= QD_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- //李永庆代码
- SetDir(X_AXIS, QD_DIR_N);
- //两段速度移动距离 拉链长度+慢速长度停止
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
-
-
- SetDir(X_AXIS,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 372;
- }
- break;
- case 372:
- //勾针提前输出 ,争取时间推方块
- if (!QD_GZ_VAVLE && (cRealPos >= (QD_PARAM_ZIPPER_LENGTH - 230)))
- QD_GZ_VAVLE = 1;
- if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
- {
- QD_MotorStep = 373;
-
- }
- break;
- case 373:
- if(!QD_GZ_VAVLE && ((cRealPos) > (QD_PARAM_ZIPPER_LENGTH - 230)))
- QD_GZ_VAVLE = 1;
-
- if(!X_DRV)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_MotorStep = 374;
- QD_BL_VAVLE = 0; //停止时并链一定要打开
- //对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
- if(cZipCnt > 1) //长度检测
- {
- if((QD_PARAM_ERROR_LENGTH != 0) && length_buff) //长度误差值不能为0
- {
- if((dwSaveLength > (length_buff + QD_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);//拉链变长,对比警告
- }
- //上升沿的长度
- else if((dwSaveLength + QD_PARAM_ERROR_LENGTH) < length_buff)
- {
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM); ////拉链变短
- }
-
- QD_CheckLengthStep = 0;
- }
- }
- else if(cZipCnt == 1) //长度检测
- {
- if(dwSaveLength)
- length_buff = dwSaveLength;
- }
- }
- break;
- case 374:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay)) //数控到停止
- {
- QD_MotorStep = 0;
- QD_TFK_VAVLE = 1; //推方块输出
- }
- break;
- //切完延时后拉带松夹子
- case 40:
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVLE = 0;
- }
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- SetDir(X_AXIS, QD_DIR_P);
- QD_JZ_DIR = QD_YDIR_P;
- SetDir(X_AXIS, QD_DIR_N);
- QD_MotorStep = 41;
- break;
- case 41:
-
- if((dwTickCount >= QD_MotorDelay))
- {
- jz_buff = cRealPos;
- if(QD_JD_VAVLE)
- //两段速度移动距离
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,QD_PARAM_SJZ_LENGTH,5000,QD_PARAM_BACK_LENGTH,QD_DIR_P);
- else
- //夹子已经张开
- AxisMovePosAccDec(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH),QD_PARAM_START_SPEED,10,10);
- // AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 42;
- }
- break;
- case 42:
-
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- {
- QD_JD_VAVLE = 0;
- QD_MotorStep = 43;
- }
- if(!X_DRV)
- {
- QD_JD_VAVLE = 0;
- QD_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 150;
- SetPos(X_AXIS, 0);
- }
- else
- QD_MotorDelay = dwTickCount;
-
- QD_BL_VAVLE = 0;//并链也要打开
- QD_JZ_DIR = QD_YDIR_N;
- if(!QD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
- {
- if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
- {
- QD_TuiLianStep = 1;
- QD_MotorStep = 62;
- }
- }
- else
- QD_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN)
- {
- SetPos(X_AXIS, 0);//在前点,直接置零点
- QD_JZ_DIR = QD_YDIR_P;
- //前点亮的情况下先退出
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,1000);
- QD_MotorDelay = dwTickCount + 300;
- }
- QD_MotorStep = 63;
- QD_JD_VAVLE = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))// && !QD_SHANG_MU_LIMIT_IN)
- {
- SetDir(X_AXIS, QD_DIR_N);
- QD_JZ_DIR = QD_YDIR_N;
- SetDir(X_AXIS, QD_DIR_P);
- go_buff = cRealPos;
- QD_YD_VAVLE = 1;
- QD_HL_VAVLE = 1;
- QD_YX_VAVLE = 1;
- //李永庆代码,当位置在慢速之外,走数控到慢速点
- if(cZipCnt > 0)
- {
-
- if(cRealPos>(QD_PARAM_GO_LOW_SPEED_LENGTH))
- {
-
- // AxisMovePosAccDecNotStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- // SetStartSpeed(X_AXIS,QD_PARAM_START_SPEED);
- // SetAccTime(X_AXIS,QD_PARAM_ACC);
- // SetDecTime(X_AXIS,QD_PARAM_DCC);
- //两段速度移动距离
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH+ 100,QD_DIR_N);
- //跑三段速度
- AxisMoveThreePosNoStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos -QD_PARAM_GO_LOW_SPEED_LENGTH-300,
- QD_PARAM_GO_HIGH_SPEED*2/3,350,
- QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_DIR_N) ;
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
-
- // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- }
-
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
- // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
- }
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =64;
- }
-
- break;
- case 64:
- if(cZipCnt > 1)
- {
- //李永庆代码
- if(((cRealPos) < (QD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QD_QIAN_DEC_IN))
- {
- user_datas[126]= GetCurSpeed(X_AXIS);
- // MoveChangSpeedDec(X_AXIS,QD_PARAM_GO_HIGH_SPEED*2/3,6,8);
- // AxisChangeSpeed(X_AXIS,40);
- QD_MotorStep =65;
- }
- if(QD_QIAN_LIMIT_IN) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- else
- {
- if(QD_QIAN_LIMIT_IN) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- else if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
-
- break;
- case 66:
- if(!X_DRV)
- {
- SetPos(X_AXIS, 0);
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 67;
- }
- break;
- case 67: //等推链完成后,
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QD_JD_VAVLE = 1;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- }
- QD_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_HL_VAVLE = 0;
- QD_YX_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- #endif
- void QueDuan_BingLian(void)
- {
- static long bl_pos_buff,HL_delay;
-
- switch(QD_BinLianStep)
- {
- case 0:break;
- case 1:
- bl_pos_buff = cRealPos;
- QD_BinLianStep = 2;
- break;
- case 2:
- if((cRealPos - bl_pos_buff) >= QD_PARAM_DELAY_HL_LENGTH)
- {
- QD_BL_VAVLE = 1;
- QD_BinLianStep = 3;
- }
- break;
- case 3://有过链检测
- if(QD_GUO_LIAN_IN_DW || ((cRealPos - bl_pos_buff) >= (QD_PARAM_ZIPPER_LENGTH - QD_PARAM_HL_DELAY_BACK)))
- {
- QD_BL_VAVLE = 0;
- QD_BinLianStep = 0;
- }
- break;
- case 10:
- bl_pos_buff = cRealPos;
- QD_BinLianStep = 11;
- break;
- case 11:
- if((cRealPos - bl_pos_buff) >= QD_PARAM_DELAY_HL_LENGTH)
- {
- QD_BL_VAVLE = 1;
- QD_BinLianStep = 12;
- }
- break;
- case 12://有过链检测
- if(QD_GUO_LIAN_IN_DW)
- {
- QD_BL_VAVLE = 0;
- QD_BinLianStep = 0;
- }
- break;
- default:;
- }
-
- }
- #if QD_KB_MODE==1 //闭口
- //作闭口专用程序
- //不带过链感应长度输入电机长度 闭口有勾针到位
- void QueDuan_Motor_NoGL(void)
- {
- static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
- long pulse_buff;
- unsigned short ch,kk;
- user_datas[124]= cRealPos;
- user_datas[125]= bRunning;
- // user_datas[123] = length_buff - (*length_buffer);
- // user_datas[127] = cRealPos;
- // user_datas[126] = go_buff - cRealPos;
- user_datas[122] = QD_AutoStep;
- user_datas[121] = QD_MotorStep;
-
- if((QD_MotorStep >= 101) && (QD_MotorStep <= 103))
- {
- if(QD_QIAN_LIMIT_IN_DW)QD_HL_VAVLE = 0;
- }
- switch(QD_MotorStep)
- {
- case 30:
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
- if(QD_PARAM_BL_ENABLE) //
- QD_BinLianStep = 1;
- QD_JZ_DIR = QD_YDIR_P; //电机方向
- if(QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI) //双开带过链感应
- {
- if(QD_PARAM_DEC_MODE == QD_BACK_NOMAL_DEC_MODE)//测长数控
- QD_MotorStep = 101;
- else
- QD_MotorStep = 31;
- }
- else //闭口走长度
- QD_MotorStep = 31;
- break;
- case 31:
- if(dwTickCount >= QD_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
- //李永庆代码
- SetDir(X_AXIS, QD_DIR_N);
- //两段速度移动距离
- // 轴 第一段速度 第一段长度要减去送链长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH-200,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH + (*length_buffer),QD_DIR_P);
-
- //AxisMovePosAccDecNotStop(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_START_SPEED,QD_PARAM_BACK_LOW_SPEED,4,QD_PARAM_DCC+8);
-
- SetDir(X_AXIS,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- break;
- case 32:
- //勾针提前输出
- if (!QD_GZ_VAVLE && ((cRealPos + QD_PARAM_GOUZHEN_LENGTH + 200) >= (QD_PARAM_ZIPPER_LENGTH )))
- QD_GZ_VAVLE = 1;
- if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
- {
- QD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- QD_MotorStep = 33;
- }
- else if(cRealPos >= (QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))//QD_PARAM_ERROR_LENGTH))
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 33:
- if(!QD_GZ_VAVLE && (cRealPos + QD_PARAM_GOUZHEN_LENGTH + 200) > (QD_PARAM_ZIPPER_LENGTH ))
- {
- QD_GZ_VAVLE = 1;
- QD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- }
- //提前12MM取消数控模式,进入连续运动
- if((cRealPos + 100 + 200) > (QD_PARAM_ZIPPER_LENGTH ))
- {
- CancelPmoveState(X_AXIS);
- SetStartSpeed(X_AXIS,1500);
- AxisChangeSpeed(X_AXIS,1500);
- }
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + 10;
- QD_YD_VAVLE = 1;
- QD_MotorStep = 34;
- QD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else if(((cRealPos + 200) >= (QD_PARAM_ZIPPER_LENGTH + (*length_buffer) + QD_PARAM_ERROR_LENGTH)))// && dwTickCount >= QD_MotorDelay)
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 34:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay))
- {
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_YD_VAVLE = 1;
- QD_MotorStep = 35;
- }
- break;
- case 35:
- if(cZipCnt == 0)
- {
- ch = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-20-QD_PARAM_ERROR_LENGTH;
- kk = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+20+QD_PARAM_ERROR_LENGTH;
- }
- else
- {
- ch = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-QD_PARAM_ERROR_LENGTH;
- kk = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+QD_PARAM_ERROR_LENGTH;
- }user_datas[128] = ch;
- user_datas[127] = kk;
- if(((cRealPos) < (ch)) && QD_PARAM_ERROR_LENGTH)
- {
- SetAlarmCode(QD_ALARM_ADDR,QD_LENGTH_LONG_ALARM);
- if(dwTickCount >= QD_MotorDelay)
- bAlarmStop = 1;
- }
- else if((cRealPos > kk) && QD_PARAM_ERROR_LENGTH)//(QD_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
- {
- SetAlarmCode(QD_ALARM_ADDR,QD_LENGTH_LONG_ALARM);
- if(dwTickCount >= QD_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
- SetDir(X_AXIS, QD_DIR_N);
- QD_JZ_DIR = QD_YDIR_N;
- SetDir(X_AXIS, QD_DIR_P);
- AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_LOW_SPEED,-QD_PARAM_FZ_LENGTH,3000,QD_PARAM_ACC,QD_PARAM_DCC);
- SetDir(X_AXIS, QD_DIR_P);
- QD_MotorStep = 0;
- }
-
- break;
- case 101:
- if(dwTickCount >= QD_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
-
- if(cZipCnt <= 2)
- {
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_FIRST_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- QD_MotorStep = 102;
- }
- else
- {
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- QD_MotorStep = 102;
- }
- }
- break;
- case 102:
- if(cZipCnt <= 2)
- {
- //拉链上升沿,就是到空位
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- if(X_DRV)
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED); //降速
- QD_MotorStep = 103;
- }
- }
- else
- {
- //1为双开
- if((QD_SK_MODE) && (((cRealPos + QD_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH))))
- {
- QD_YX_VAVLE = 1;
- QD_HL_VAVLE = 1;
- }
- if(((cRealPos - gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
- {
- QD_GZ_VAVLE = 1;
- QD_YX_VAVLE = 1;
- }
- if((cRealPos - back_buff) > (length_buff - QD_PARAM_BACK_LOW_SPEED_LENGTH-PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC))))
- {
- if(X_DRV)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
- QD_MotorStep = 103;
- }
- }
- break;
- case 103:
- if(cZipCnt <= 2)
- {//双开暂不用,先保留
- #if QD_SK_MODE
- if((QD_SK_MODE) && ((dwTickCount + QD_PARAM_GZ_DELAY/2) >= QD_MotorDelay))
- {
- QD_YX_VAVLE = 1;
- QD_HL_VAVLE = 1;
- }
- #endif
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_GZ_VAVLE = 1;
- QD_YX_VAVLE = 1;
- #if QD_SK_MODE //双开暂不用,先保留
- if(QD_SK_MODE)
- QD_MotorStep = 154;
- else
- #endif
- QD_MotorStep = 160;
- }
- }
- else
- {
- #if QD_SK_MODE //双开暂不用,先保留
- if((QD_SK_MODE) && (((cRealPos + QD_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH))))
- {
- QD_YX_VAVLE = 1;
- QD_HL_VAVLE = 1;
- }
- #endif
- if(((cRealPos - gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH)))
- {
- QD_GZ_VAVLE = 1;
- QD_YX_VAVLE = 1;
- #if QD_SK_MODE //双开暂不用,先保留
- if(QD_SK_MODE)
- QD_MotorStep = 154;
- else
- #endif
- QD_MotorStep = 160;
- }
-
-
- if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + length_buff)) && QD_GZ_VAVLE)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- }
- break;
- case 154:
- #if QD_SK_MODE //双开暂不用,先保留
- if(QD_GZ_UP_IN)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_CHECK_GZ;
- QD_MotorStep = 104;
- }
- #endif
- break;
- case 160:
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_YD_VAVLE = 1;
- QD_MotorStep = 105;
- }
- else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + length_buff)) && QD_GZ_VAVLE && (cZipCnt > 2))
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- break;
- case 104:
- #if QD_SK_MODE //双开暂不用,先保留
- if(dwTickCount >= QD_MotorDelay)
- {
- //勾针离开就是到位
- if(!QD_GOUZHEN_IN && QD_GZ_UP_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 105;
- }
- }
- #endif
- break;
- case 105:
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_HL_VAVLE = 1;
- QD_YD_VAVLE = 1;
-
- if(cZipCnt == 1)
- {
- go_length_buff = cRealPos - back_buff;
- }
- else if(cZipCnt == 2)
- {
- length_buff = cRealPos - back_buff;
- }
- else if(cZipCnt > 2)
- {
- if(((cRealPos - save_buff) < (length_buff - QD_PARAM_ERROR_LENGTH- (*length_buffer))))QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else if(((cRealPos - save_buff) > (QD_PARAM_ERROR_LENGTH + length_buff - (*length_buffer))))QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else
- {
- }
- }
- AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_FZ_LENGTH,1,QD_PARAM_ACC,QD_PARAM_DCC);
-
- }
- break;
- case 106:
- if(!X_DRV)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- else
- {
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_YD_VAVLE = 1;
- QD_MotorStep = 0;
- }
- }
-
- break;
- case 40:
- QD_JD_VAVLE = 0;
- SetDir(X_AXIS, QD_DIR_P);
- QD_JZ_DIR = QD_YDIR_P;
- SetDir(X_AXIS, QD_DIR_N);
-
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
-
- QD_MotorStep = 41;
- break;
- case 41:
-
- if((dwTickCount >= QD_MotorDelay))
- {
- //夹子已经张开
- AxisMovePosAccDec(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH),QD_PARAM_START_SPEED,10,10);
- // AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 42;
- }
- break;
- case 42:
-
- // if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- // {
- // QD_JD_VAVLE = 0;
- // QD_MotorStep = 43;
- // }
- // else
- if(!X_DRV)
- {
- QD_JD_VAVLE = 0;
- QD_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 150;
- SetPos(X_AXIS, 0);
- }
- else
- QD_MotorDelay = dwTickCount;
-
- QD_BL_VAVLE = 0;//并链也要打开
- QD_JZ_DIR = QD_YDIR_N;
- if(!QD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
- {
- if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
- {
- QD_TuiLianStep = 1;
- QD_MotorStep = 62;
- }
- }
- else
- QD_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN)
- {
- SetPos(X_AXIS, 0);//在前点,直接置零点
- QD_JZ_DIR = QD_YDIR_P;
- //前点亮的情况下先退出
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,1000);
- QD_MotorDelay = dwTickCount + 300;
- }
- QD_MotorStep = 63;
- QD_JD_VAVLE = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))// && !QD_SHANG_MU_LIMIT_IN)
- {
- SetDir(X_AXIS, QD_DIR_N);
- QD_JZ_DIR = QD_YDIR_N;
- SetDir(X_AXIS, QD_DIR_P);
- go_buff = cRealPos;
- QD_YD_VAVLE = 1;
- QD_HL_VAVLE = 1;
- QD_YX_VAVLE = 1;
- //李永庆代码,当位置在慢速之外,走数控到慢速点
- if(cZipCnt > 0)
- {
-
- if(cRealPos>(QD_PARAM_GO_LOW_SPEED_LENGTH))
- {
-
- // AxisMovePosAccDecNotStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- // SetStartSpeed(X_AXIS,QD_PARAM_START_SPEED);
- // SetAccTime(X_AXIS,QD_PARAM_ACC);
- // SetDecTime(X_AXIS,QD_PARAM_DCC);
- //两段速度移动距离
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH+ 100,QD_DIR_N);
- //跑三段速度
- AxisMoveThreePosNoStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos -QD_PARAM_GO_LOW_SPEED_LENGTH-300,
- QD_PARAM_GO_HIGH_SPEED*2/3,350,
- QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_DIR_N) ;
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
-
- // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- }
-
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
- // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
- }
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =64;
- }
-
- break;
- case 64:
- if(cZipCnt > 1)
- {
- //李永庆代码
- if(((cRealPos) < (QD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QD_QIAN_DEC_IN))
- {
- user_datas[126]= GetCurSpeed(X_AXIS);
- // MoveChangSpeedDec(X_AXIS,QD_PARAM_GO_HIGH_SPEED*2/3,6,8);
- // AxisChangeSpeed(X_AXIS,40);
- QD_MotorStep =65;
- }
- if(QD_QIAN_LIMIT_IN) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- else
- {
- if(QD_QIAN_LIMIT_IN) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN)
- {
-
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
-
- }
- else if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
-
- break;
- case 66:
- if(!X_DRV)
- {
- SetPos(X_AXIS, 0);
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 67;
- }
- break;
- case 67: //等推链完成后,
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QD_JD_VAVLE = 1;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- }
- QD_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_HL_VAVLE = 0;
- QD_YX_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- #endif
- //电机动作
- void QueDuan_Motor(void)
- {
- if(QD_KB_MODE) //闭口
- {
- #if QD_KB_MODE //闭口
- QueDuan_Motor_NoGL();
- #endif
- }
- else //开口
- {
- #if !QD_KB_MODE //开口
- QueDuan_Motor_KK(); //
- #endif
- }
- // switch(QD_MACHINE_TYPE)
- // {
- // case QD_NO_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
- // case QD_NO_GL_TUIFANGKUAI: QueDuan_Motor_NoGL();break;
- // case QD_CS_TUIFANGKUAI:break;
- // default:;
- // }
- }
- //超声方式下切,开口专用
- void QueDuan_XiaQue_KK(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- /*
- if(bRunning)
- {
- QD_XiaQieStep = 6;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- if(QD_SAFE_IN)
- {
- bStop = 1;
- QD_XM_VAVLE = 0;
- }
- }
- else
- */
- QD_XiaQieStep = 2;
- break;
- case 2:
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 3;
- break;
- case 3:
- if(1)
- {
- QD_XiaQieDelay = dwTickCount + 0;//QD_PARAM_GZ_DELAY;
- QD_XiaQieStep = 4;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 4:
- if(QD_GZ_VAVLE) //勾针已经有输出就不需要延时
- {
- QD_XiaQieDelay = dwTickCount + 0;
- }
- else
- QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_GZ_VAVLE = 1;
- cTuiFangKuaiCnt=0;
- QD_XiaQieStep = 5;
-
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_TFK_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(1)
- {
- QD_XiaQieStep = 7;
- QD_XiaQieDelay = dwTickCount + 1000;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 7:
- if(QD_GOUZHEN_IN)
- {
- cTuiFangKuaiCnt = 0;
- QD_YD_VAVLE = 1;
- if(!bRunning)
- QD_XiaQieDelay = dwTickCount + 200;
- else
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
-
- if(!QD_QIAN_LIMIT_IN)
- QD_XiaQieStep = 8;
- else
- QD_SetAlarmCode(QD_QIAN_LIMIT_ALARM);
- }
- else if((dwTickCount >= QD_XiaQieDelay))
- {
- if(cTuiFangKuaiCnt < QD_PARAM_TFK_NUMBER)
- {
- QD_TFK_VAVLE = 0;
- cTuiFangKuaiCnt++;
- QD_XiaQieDelay = dwTickCount + 500;
- QD_XiaQieStep = 100;
- }
- else
-
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 100:
- if((dwTickCount >= QD_XiaQieDelay))
- {
- QD_XiaQieStep = 5;
- }
- break;
- case 8://上下模同时输出
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 1;
- if(QD_PARAM_XM_ENABLE == 0) //配置下模动
- QD_XM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 9;
- }
- break;
- case 9://上下模到位,调试模下的话,等按下一步按键 下模不动
- if(QD_SHANG_MU_LIMIT_IN && (QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(QD_PARAM_CS_MODE) //无超声配置
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
- QD_XiaQieStep = 12;
- }
- else
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 10;
- }
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- if(!QD_SHANG_MU_LIMIT_IN)QD_SetAlarmCode(QD_SM_DAOWEI);
- else QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 10:
- if(dwTickCount >= QD_XiaQieDelay)
- {
-
- QD_CS_OUT = 1;
- //
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
- QD_XiaQieStep = 11;
- }
- break;
- case 11:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_CS_OUT = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
- QD_XiaQieStep = 12;
- }
- break;
- case 12:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 0;
- if(QD_PARAM_XM_ENABLE == 0) //配置下模动
- QD_XM_VAVLE = 0;
- QD_TFK_VAVLE = 0;
- QD_GZ_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 13;
- }//
- break;
- case 13:
- if(!QD_SHANG_MU_LIMIT_IN)
- {
- //启动推链(送链)
- if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)
- QD_TuiLianStep = 1;
- }
- if(!QD_SHANG_MU_LIMIT_IN && (!QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE))
- {
- QD_XiaQieStep = 0;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
- break;
- }
- }
- void QueDuan_TuiLianAction(void)
- {
- if(QD_PARAM_XM_ENABLE == 0)
- {
- QD_TuiLianStep = 0;
- }
- else
- {
- switch(QD_TuiLianStep)
- {
- case 1:
- QD_TuiLianStep = 2;
- break;
- case 2:
- QD_TLDelay = dwTickCount + QD_PARAM_YD_DELAY;
- QD_TuiLianStep = 3;
- break;
- case 3:
- if(!QD_SM_VAVLE && !QD_SHANG_MU_LIMIT_IN)//dwTickCount >= QD_TLDelay)
- {
- QD_TL_VAVLE = 1;
- if(!bRunning)QD_TFK_VAVLE = 0;
- QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
- QD_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TuiLianStep = 0;
- }
- break;
- case 10:
-
- QD_TuiLianStep = 11;
- break;
- case 11:
- if(!Y_DRV)
- {
- {
- QD_TuiLianStep = 0;
- }
- }
- break;
- }
- }
- }
- //闭口专用
- void QueDuan_XiaQue_NO_GL(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- if(!bRunning)
- {
- if((QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI) && QD_SK_MODE)
- {
- //跳到双开
- // QD_YD_VAVLE = 1;
- QD_HL_VAVLE = 1; //护链
- QD_YX_VAVLE = 1; //压带
- QD_GZ_VAVLE = 1; //勾针
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 100;
- }
- else
- {
- // QD_GZ_VAVLE = 1; //勾针
-
- // QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- // QD_XiaQieStep = 100;
- QD_YD_VAVLE = 1;
- QD_XiaQieStep = 2;
- QD_XiaQieDelay = dwTickCount + 30;
- }
- }
- else
- {
- QD_YD_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 2;
- }
- break;
- case 2:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_XiaQieStep = 3;
- QD_XiaQieDelay = dwTickCount;
- }
- break;
- case 3:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))
- {
- QD_SM_VAVLE = 1;
- QD_XM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 4;
- }
- }
- break;
- case 4://永兴为下模固定
- if(QD_SHANG_MU_LIMIT_IN && (QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE))
- {
- QD_GZ_VAVLE = 0;
- if(!QD_PARAM_CS_MODE) //气切
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
- QD_XiaQieStep = 5;
- }
- else
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 10;
- } //
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
-
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(!QD_SHANG_MU_LIMIT_IN && (!QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE)) //下模不动就不用判断
- {
- if(QD_TuiLianStep == 0)
- QD_TuiLianStep = 1;
- if(!bRunning)
- QD_JD_VAVLE = 0;
- QD_XiaQieStep = 0;
-
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
-
- break;
- //10~11步为超声
- case 10:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
- QD_XiaQieStep = 11;
- }
- break;
- case 11:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_CS_OUT = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
- QD_XiaQieStep = 5;
- }
- break;
- case 100:
- if(dwTickCount >= QD_XiaQieDelay)
- {
-
- //这是双开程序,暂时不考虑
- #if 1
- if(QD_GOUZHEN_IN)
- {
- QD_YD_VAVLE = 1;
- QD_XiaQieStep = 3;
- }
- #endif
- }
- break;
- }
- }
- //切断动作
- void QueDuan_XiaQue(void)
- {
-
- if(QD_KB_MODE) //闭口
- {
- QueDuan_XiaQue_NO_GL(); //
- }
- else //开口
- {
- QueDuan_XiaQue_KK();
- }
- #if 0
- switch(QD_MACHINE_TYPE)
- {
- case QD_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- case QD_CS_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- default:;
- }
- #endif
- }
- #endif
|