1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533 |
- #include "global.h"
- #if CHANG_SHENG_GEI_LI_MACHINE
- 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 QueDuan_ShenJiangAction(void);
- static unsigned long cZipCnt = 0,cTableCnt = 0,cTuiFangKuaiCnt = 0;
- static long save_limit_pos,cRealPos,cRealPosY;
- unsigned char cCheckLianFlg = 0;
- unsigned char cCheckLianFlgEN = 0;
- unsigned char cGoLimitEn = 0;
- unsigned char cLengthErrorFlg = 0;
- 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;
- save_limit_pos = QD_SAVE_POS;
-
- CalFreqTab_X_Free(20);
- length_buff = QD_PARAM_CYCLE_LENGTH;
- pulse_buff = QD_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
-
- axis_y->speed_unit = 300;
- length_buff = QD_PARAM_YL_CYCLE_LENGTH;
- pulse_buff = QD_PARAM_YL_CYCLE_PULSE;
- YGearRatio = pulse_buff/length_buff;
-
- QD_SZ_OUT = 1;
- MACHINE_BOOT_WIFI = 1;
- }
- void QueDuan_Action(void)
- {
- QueDuan_AlarmProtect();
- QueDuan_Motor();
- QueDuan_XiaQue();
- QueDuan_ManualAction();
- QueDuan_YuanDianAction();
- QueDuan_TuiLianAction();
- QueDuan_BingLian();
- QueDuan_ShenJiangAction();
- QueDuan_AutoAction();
- QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
- }
- long testFlg = 0;
- //手动动作
- void QueDuan_ManualAction(void)
- {
- static unsigned short button_cnt;
- if(bRunning == 0)
- {
- if(QD_bSetGZMode)
- {
- QD_bSetGZMode = 0;
- if(QD_PARAM_DC_MODE == 0)QD_GZ_VAVLE = 0;
- }
-
- if(dwTickCount >= QD_BUTTONDelay)
- {
- if(QD_bClearTotal) //计数清零
- {
- QD_BUTTONDelay = dwTickCount+1000;
- button_cnt++;
- if(button_cnt >= 3)
- {
- ClrcToTal(QD_TOTAL_ADDR);
- QD_bClearTotal = 0;
- }
- }
-
- if(QD_bClearNowTotal)
- {
- QD_BUTTONDelay = dwTickCount+1000;
- button_cnt++;
- if(button_cnt >= 3)
- {
- QD_bClearNowTotal = 0;
- QD_PARAM_NOW_CNT = 0;
- }
- }
-
- if(!QD_bClearNowTotal && !QD_bClearTotal)button_cnt = 0;
- }
-
- if(QD_bXiaQie)
- {
- QD_bXiaQie = 0;
- if(QD_XiaQieStep == 0)QD_XiaQieStep = 1;
- }
-
- if(QD_bQianDianDW)
- {
- QD_bQianDianDW = 0;
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 61;
- cZipCnt = 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_VAVEL = ~QD_JD_VAVEL;
- }
-
- if(QD_bR_UP)
- {
- QD_bR_UP = 0;
- QD_R_UP_VAVLE = ~QD_R_UP_VAVLE;
- }
-
- if(QD_bR_JD)
- {
- QD_bR_JD = 0;
- QD_R_JD = ~QD_R_JD;
- }
-
- if(QD_bXM)
- {
- QD_bXM = 0;
- QD_XM_VAVLE = ~QD_XM_VAVLE;
- }
-
- if(QD_bSM)
- {
- QD_bSM = 0;
- QD_SM_VAVLE = ~QD_SM_VAVLE;
- }
-
- if(QD_bTFK)
- {
- QD_bTFK = 0;
- QD_TFK_VAVEL = ~QD_TFK_VAVEL;
- }
-
- 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_bTL)
- {
- QD_bTL = 0;
- QD_TL_VAVLE = ~QD_TL_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_XiaQieStep == 0))
- {
- if(dwTickCount >= QD_CSDelay)QD_CS_OUT = 0;
- }
-
- if(QD_bYuanDianDW)
- {
- QD_bYuanDianDW = 0;
- if(QD_YuanDianStep == 0)QD_YuanDianStep = 1;
- }
-
- //电机控制
- if(QD_bYLBACK_MOTOR)
- {
- QD_YL_DIR = QD_YL_DIR_P;
- if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS,5, QD_YL_DIR_P,5,10,10);
- }
- if(QD_bYLGO_MOTOR)
- {
- QD_YL_DIR = QD_YL_DIR_N;
- if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS,5, QD_YL_DIR_N,5,10,10);
- }
-
- if(!QD_bYLBACK_MOTOR && !QD_bYLGO_MOTOR && (QD_MotorStep == 0))
- {
- if(Y_DRV)AxisDecStop(Y_AXIS);
- }
-
- if(QD_bYL)
- {
- QD_YL_VAVLE = ~QD_YL_VAVLE;
- }
-
- if(QD_bBackMotor && !QD_BACK_LIMIT_IN)
- {
- QD_SZ_OUT = 0;
-
- QD_JZ_DIR = QD_YDIR_P;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, QD_DIR_P, 5,5,10,10);
- }
-
- 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);
- }
-
- if(QD_bGoMotor && !QD_QIAN_LIMIT_IN)
- {
- QD_SZ_OUT = 0;
- QD_JZ_DIR = QD_YDIR_N;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, QD_DIR_N, 5,5,10,10);
- }
-
- if(QD_bCQ)
- {
- QD_bCQ = 0;
- QD_CQ_VAVLE = 1;
- QD_CQDelay = dwTickCount + QD_PARAM_CQ_TIME;
- }
- }
- if(QD_CQ_VAVLE && (dwTickCount >= QD_CQDelay) && (QD_MACHINE_TYPE == QD_NO_GL_TUIFANGKUAI))QD_CQ_VAVLE = 0;
- }
- void QueDuan_ShenJiangAction(void)
- {
-
- switch(QD_ShenJiangStep)
- {
- case 0:break;
- case 1:
- QD_R_UP_VAVLE = 1;
- QD_R_JD = 0;
- QD_ShenJiangDelay = dwTickCount + QD_PARAM_SJ_TIME;
- QD_ShenJiangStep = 2;
- break;
- case 2:
- if(dwTickCount >= QD_ShenJiangDelay)
- {
- QD_R_JD = 1;
- QD_ShenJiangDelay = dwTickCount + QD_PARAM_SJ_JZ_TIME;
- QD_ShenJiangStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= QD_ShenJiangDelay)
- {
- QD_JD_VAVEL = 0;
- QD_R_UP_VAVLE = 0;
- QD_ShenJiangStep = 4;
- QD_ShenJiangDelay = dwTickCount + QD_PARAM_DELAY_GO;
- }
- break;
- case 4:
- if(dwTickCount >= QD_ShenJiangDelay)
- {
- QD_JZ_DIR = QD_YDIR_N;
- if(QD_YL_ORIGIN_IN && (QD_MACHINE_TYPE == QD_NO_GL_TUIFANGKUAI))
- if(!X_DRV)MoveAction_Const_Stop_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);//
- else
- AxisMovePos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LENGTH);
- QD_ShenJiangStep = 5;
- }
- break;
- case 5:
- if(!X_DRV)
- {
- QD_R_JD = 0;
- QD_ShenJiangStep = 0;
- }
- break;
- case 6:
- {
- QD_R_JD = 0;
- QD_ShenJiangStep = 0;
- }
- break;
- }
- }
- void QueDuan_YuanDianAction(void)
- {
- switch(QD_YuanDianStep)
- {
- case 0:break;
- case 1:
- if(QD_MotorStep == 0)QD_MotorStep = 61;
- QD_YuanDianStep = 2;
- break;
- case 2:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 30;
- QD_YuanDianStep = 3;
- QD_JD_VAVEL = 1;
- }
- break;
- case 3:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 0;
- QD_YuanDianStep = 0;
- }
- break;
- }
- }
- void QueDuan_AlarmProtect(void)
- {
- cRealPos = GetPos(X_AXIS);
- cRealPosY = GetPos(Y_AXIS);
- if(QD_PARAM_BACK_ALARM_MODE)
- { //感应后限模式
- if(!bRunning)
- {
- if(QD_BACK_LIMIT_IN_UP)
- {
- if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
- {
- QD_bBackMotor = 0;
-
- AxisDecStop(X_AXIS);
- QD_JD_VAVEL = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
-
- }
- }
- }
- else
- {
- if(QD_BACK_LIMIT_IN_UP)
- {
- AxisDecStop(X_AXIS);
-
- QD_JD_VAVEL = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
- }
- }
- }
- else
- {
-
- if(QD_QIAN_LIMIT_IN_UP) //数控后限模式
- {
- save_limit_pos = cRealPos;
- SetData32bits(200,save_limit_pos);
- }
-
- if(QD_PARAM_MAX_BACK_LENGTH < (cRealPos - save_limit_pos))
- {
- if(!bRunning)
- {
- if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
- {
- QD_bBackMotor = 0;
- AxisDecStop(X_AXIS);
- QD_JD_VAVEL = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
- }
- }
- else
- {
- AxisDecStop(X_AXIS);
- QD_JD_VAVEL = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
- }
- }
-
- }
-
- // if(!QD_KADAI_IN)QD_KaDaiDelay = dwTickCount + 3000;
-
- /* if(bRunning)
- {
- if(dwTickCount >= QD_KaDaiDelay)QD_SetAlarmCode(QD_KA_DAI_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; //前点定位
- }
- }
- break;
- case 2:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 30;
- QD_AutoStep = 3;
- }
- break;
- case 3:
- if(QD_MotorStep == 0)
- {
- {
- if(QD_XiaQieStep == 0)QD_XiaQieStep = 1;
- QD_AutoStep = 4;
- }
- }
- break;
- case 4:
- if(QD_MACHINE_TYPE == QD_NO_GL_TUIFANGKUAI)
- {
- if(QD_PARAM_LONG_MODE)
- {
- if((QD_XiaQieStep == 0) && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 50;
- QD_AutoStep = 5;
- }
- }
-
- }
- else
- {
- if(((QD_XiaQieStep == 0) || (QD_XiaQieStep == 5)) && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 40; //切完后退
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- }
- QD_AutoStep = 5;
- }
- }
- }
- else
- {
- if(QD_PARAM_LONG_MODE)
- {
- if((QD_XiaQieStep == 0) && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 50;
- QD_AutoStep = 5;
- }
- }
-
- }
- else
- {
- if(((QD_XiaQieStep == 0) || (QD_XiaQieStep == 7)) && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 40; //切完后退
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- }
- QD_AutoStep = 5;
- }
- }
- }
- break;
- case 5:
- if(QD_MotorStep == 0)
- {
- cZipCnt++;
- cTableCnt++;
- AddToTal(QD_TOTAL_ADDR);
- CalProSP(QD_PROSPEED_ADDR);
- QD_PARAM_NOW_CNT++;
- if(cTableCnt >= QD_PARAM_TABLE_NUM)
- {
- cTableCnt = 0;
- QD_TABLE_VAVLE = 1;
- QD_TBDelay = dwTickCount + QD_PARAM_TB_TIME;
- }
-
- QD_AutoStep = 1;
-
- if(QD_PARAM_ZHA_SHU == 0)
- {
- if(QD_PARAM_LONG_MODE)
- QD_AutoDelay = dwTickCount + QD_PARAM_DELAY_LONG_GO;
- else
- QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY;
- }
- else
- {
- if(QD_PARAM_NOW_CNT >= QD_PARAM_ZHA_SHU)
- {
- QD_PARAM_NOW_CNT = 0;
- QD_AutoDelay = dwTickCount + QD_PARAM_ZS_STOP_TIME + QD_PARAM_CYCLE_DELAY;
- }
- }
- }
- break;
- }
- }
- }
- void QueDuan_StepCheckStart(void)
- {
-
- if(bRunning)
- QD_PARAM_RUN_STATE = 1;
- else
- QD_PARAM_RUN_STATE = 0;
-
- // 启动
- if((QD_START_IN_UP) || bStart || QD_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (QD_AutoStep == 0))
- {
- if((QD_XIA_MU_LIMIT_IN && (QD_PARAM_CS_MODE == 1)))QD_SetAlarmCode(QD_XM_DAOWEI);
- else if(GetAlarmCode(QD_ALARM_ADDR) != 0);
- else if(QD_BL_VAVLE)QD_SetAlarmCode(QD_BL_ALARM);
- else if(QD_SM_VAVLE)QD_SetAlarmCode(QD_SM_ALARM);
- else if(!QD_YL_ORIGIN_IN)QD_SetAlarmCode(QD_YL_LIMIT_ALARM);
- else if(QD_STOP_IN)QD_SetAlarmCode(QD_STOP_IN_ALARM);
- else if(QD_SHANG_MU_LIMIT_IN)QD_SetAlarmCode(QD_SM_DAOWEI);
- else if(!QD_SHANG_MU_ORIGIN_IN)QD_SetAlarmCode(QD_SM_YUANWEI);
- else
- {
- bRunning = 1;
- QD_AutoStep = 1;
- if(QD_bSingle) SingOneFlg= 1;
- else SingOneFlg= 0;
- cZipCnt = 0;
- cTuiFangKuaiCnt = 0;
- cLengthErrorFlg = 0;
- if(GetAlarmCode(QD_ALARM_ADDR) != QD_NO_ALARM)SetAlarmCode(QD_ALARM_ADDR,QD_NO_ALARM);
- }
- }
- QD_bSingle = 0;
- }
- //停止
- if(QD_STOP_IN_UP || bStop)
- {
- bStop = 0;
-
- if(bRunning)
- {
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_YuanDianStep = 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;
- QD_CheckDelay = dwTickCount;
- SingOneFlg = 0;
- QD_JD_VAVEL = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_TFK_VAVEL= 0;
- QD_TL_VAVLE = 0;
- QD_YBD_VAVLE = 0;
- QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_ShenJiangStep = 0;
- //QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- AxisDecStop(X_AXIS);
- QD_YuanDianStep = 0;
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- cLengthErrorFlg = 0;
- QD_R_JD = 0;
- QD_R_UP_VAVLE = 0;
- QD_YL_VAVLE = 0;
- if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
- }
- else
- {
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_YuanDianStep = 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;
- QD_CheckDelay = dwTickCount;
- SingOneFlg = 0;
- QD_JD_VAVEL = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_TFK_VAVEL= 0;
- QD_TL_VAVLE = 0;
- QD_YBD_VAVLE = 0;
- QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- AxisDecStop(X_AXIS);
- QD_YuanDianStep = 0;
- QD_BinLianStep = 0;
- QD_ShenJiangStep = 0;
- QD_BL_VAVLE = 0;
- cLengthErrorFlg = 0;
- QD_R_JD = 0;
- QD_R_UP_VAVLE = 0;
- QD_YL_VAVLE = 0;
- if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
- }
- }
-
- if(bAlarmStop)
- {
- bAlarmStop = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_YuanDianStep = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_ShenJiangStep = 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;
- QD_CheckDelay = dwTickCount;
- SingOneFlg = 0;
- bRunning = 0;
- AxisDecStop(X_AXIS);
- QD_TABLE_VAVLE = 0;
- }
-
- }
- void QueDuan_Motor_CS(void)
- {
- static long save_buff,gou_zhen_buff,go_buff,jz_buff,go_length_buff,guo_lian_buff,xhg_buff,fz_buff,length_buff;
-
- user_datas[121]= QD_MotorStep;
- user_datas[122] = QD_AutoStep;
- user_datas[123]= go_length_buff;
- user_datas[124] = QD_BinLianStep;
- user_datas[126] = cRealPosY;
- user_datas[127] = cRealPos;
- switch(QD_MotorStep)
- {
- case 30:
- QD_MotorStep = 31;
- if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
- break;
- case 31:
- if(dwTickCount >= QD_MotorDelay)
- {
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- QD_JZ_DIR = QD_YDIR_P;
- if(QD_PARAM_DEC_MODE == 1) // 记忆长度模式
- {
- if(cZipCnt < 2)
- {
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_FIRST_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- }
- else
- {
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff);
- MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,5)));
- }
- }
- else if(QD_PARAM_DEC_MODE == 2) // 纯感应模式
- {
- if(QD_PARAM_LONG_MODE)
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-(QD_PARAM_YL_TRANS_LENGTH));
- else
- MoveAction_Const_AccDec(X_AXIS, QD_DIR_P, QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- }
- else //长度输入
- {
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-(QD_PARAM_ZIPPER_LENGTH - QD_PARAM_OFFSET_LENGTH));
- MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,5)));
- }
-
- if(QD_PARAM_LONG_MODE)
- QD_MotorStep = 128;
- else
- QD_MotorStep = 32;
- }
- break;
- case 32:
- if(QD_PARAM_DEC_MODE == 1) // 记忆长度模式
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- fz_buff = cRealPos;
- QD_MotorStep = 33;
- }
- }
- else
- {
- if((cRealPos - gou_zhen_buff) >= (length_buff - QD_PARAM_DELAY_XM_LENGTH))QD_XM_VAVLE = 1;
-
- if(QD_PARAM_GOUZHEN_LENGTH != 0)
- {
- if((cRealPos - gou_zhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH))QD_GZ_VAVLE = 1;
- }
- if(!X_DRV)
- {
- QD_GZ_VAVLE = 1;
- QD_XM_VAVLE = 1;
- QD_MotorStep = 0;
- }
- }
- }
- else if(QD_PARAM_DEC_MODE == 2) // 纯感应模式
- {
- if(QD_PARAM_SPEED_MODE)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- fz_buff = cRealPos;
- QD_MotorStep = 33;
- }
- else if((cRealPos - save_buff) >= (length_buff - PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_ACC_SPEED))))
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
- else
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- fz_buff = cRealPos;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- }
- }
- else
- {
- if((cRealPos - gou_zhen_buff) >= ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_OFFSET_LENGTH) - QD_PARAM_DELAY_XM_LENGTH))QD_XM_VAVLE = 1;
- if(QD_PARAM_GOUZHEN_LENGTH != 0)
- {
- if((cRealPos - gou_zhen_buff) >= (QD_PARAM_ZIPPER_LENGTH - QD_PARAM_GOUZHEN_LENGTH))QD_GZ_VAVLE = 1;
- }
- if(!X_DRV)
- {
- QD_GZ_VAVLE = 1;
- QD_XM_VAVLE = 1;
- QD_MotorStep = 0;
- }
- }
- break;
- case 33:
- if(QD_PARAM_DEC_MODE==1)
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)fz_buff = cRealPos;
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
- if((cRealPos - fz_buff) >= QD_PARAM_DELAY_CHECK)
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- guo_lian_buff = cRealPos;
- QD_MotorStep = 34;
- }
- }
- }
- else
- {
-
- }
- }
- else if(QD_PARAM_DEC_MODE == 2) // 纯感应模式
- {
- if(QD_GUO_LIAN_IN_UP)fz_buff = cRealPos;
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
- if((fz_buff - cRealPos) >= QD_PARAM_DELAY_CHECK)
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- guo_lian_buff = cRealPos;
- QD_MotorStep = 34;
- }
- }
- }
- else
- {
- }
- break;
- case 34:
- if(QD_PARAM_DEC_MODE==1)
- {
- if(cZipCnt < 2)
- {
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
- if((cRealPos - guo_lian_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 35;
- }
- }
- else
- {
- if((cRealPos - guo_lian_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 35;
- }
- }
- }
- else if(QD_PARAM_DEC_MODE == 2) // 纯感应模式
- {
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
- if((guo_lian_buff - cRealPos) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 35;
- }
- }
- else
- {
- }
- break;
- case 35:
- if(!X_DRV)
- {
- if(QD_PARAM_DEC_MODE == 2) // 纯感应模式
- {
- if(!X_DRV)
- {
- if(cZipCnt == 0);
- else if(cZipCnt == 1)
- {
- length_buff = save_buff - cRealPos;
- SetData32bits(1,length_buff - QD_PARAM_OFFSET_LENGTH - QD_PARAM_TC_LENGTH);
- }
- else
- {
- if((save_buff - cRealPos) >(length_buff + QD_PARAM_MAX_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else if((save_buff - cRealPos)<(length_buff - QD_PARAM_MAX_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM);
- else;
- }
- QD_MotorStep = 0;
- }
-
- }
- else
- {
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(1,length_buff + QD_PARAM_OFFSET_LENGTH);
- }
- if(cZipCnt == 0)
- {
- go_length_buff = cRealPos - save_buff;
- }
- }
-
- QD_XM_VAVLE = 1;
- QD_GZ_VAVLE = 1;
- QD_MotorStep = 0;
- }
- break;
- case 40:
- if(dwTickCount >= QD_MotorDelay)
- {
- jz_buff = cRealPos;
-
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVEL = 0;
- }
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_SJ_TIME;
- QD_MotorStep = 41;
-
- }
- break;
-
- case 41: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
- {
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 42;
- }
- break;
- case 42:
- // 切断完成后拉电机动作
- if(dwTickCount >= QD_MotorDelay)
- {
- if(((QD_PARAM_SJZ_LENGTH) <= (jz_buff-cRealPos)))
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 43;
- }
- else if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 43;
- }
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
-
- break;
- case 50:
- if(!Y_DRV)
- {
- QD_MotorStep = 51;
- QD_YL_DIR = QD_YL_DIR_P;
- if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS, QD_PARAM_BACK_SPEED,QD_YL_DIR_P,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- QD_MotorDelay = dwTickCount + QD_PARAM_YL_SL_TIME;
- QD_YLBackDelay = dwTickCount + QD_PARAM_DELAY_YL_BACK;
- }
- break;
- case 51: if(dwTickCount >= QD_MotorDelay)
- {
- AxisEgmStop(Y_AXIS);
- QD_MotorStep = 52;
- }
- if(dwTickCount >= QD_YLBackDelay) QD_YL_VAVLE = 0;
- break;
- case 52: if(!Y_DRV)
- {
- QD_YL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
- case 61: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 50;
- }
-
- if(!QD_TL_VAVLE)
- {
- if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
- {
- QD_TuiLianStep = 1;
- }
- }
- QD_MotorStep = 62;
- break;
- case 62:
- if((QD_ShenJiangStep == 0) && QD_YL_ORIGIN_IN)
- {
- QD_MotorStep = 63;
- }
- case 63:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN || QD_QIAN_DEC_IN)
- {
- QD_JZ_DIR = QD_YDIR_P;
- AxisMovePos(X_AXIS,20,-2000);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 64;
- QD_JD_VAVEL = 0;
- }
- break;
- case 64:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay) && !QD_SHANG_MU_LIMIT_IN && !QD_JD_IN)
- {
- go_buff = cRealPos;
- QD_JZ_DIR = QD_YDIR_N;
-
- if((cZipCnt > 0) || (QD_PARAM_DEC_MODE == 2))
- {
- MoveAction_Const_Stop_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);//
- }
- else
- {
- MoveAction_Const_Stop_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- }
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =65;
- }
- break;
- case 65:
- if(cZipCnt > 0)
- {
- if(QD_PARAM_DEC_MODE == 1) // 长度输入模式
- {
- if(((go_buff - cRealPos) > ((QD_PARAM_ZIPPER_LENGTH + QD_PARAM_OFFSET_LENGTH - QD_PARAM_TC_LENGTH - QD_PARAM_FZ_LENGTH) - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC_SPEED))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
- else if(QD_PARAM_DEC_MODE == 2) //纯感应方式
- {
- if(QD_PARAM_LONG_MODE)
- {
- if(QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
- else
- {
- if((QD_QIAN_DEC_IN_UP && !QD_PARAM_SPEED_MODE)
- || ((QD_QIAN_DEC_IN_UP || ((go_buff - cRealPos) > (go_length_buff - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC_SPEED))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) ) && QD_PARAM_SPEED_MODE))
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
- }
- else
- {
- if(((go_buff - cRealPos) > ((go_length_buff - QD_PARAM_TC_LENGTH - QD_PARAM_FZ_LENGTH) - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC_SPEED))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
-
- }
- else
- {
- if(QD_PARAM_DEC_MODE == 2) //纯感应方式
- {
- if(QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
- else
- QD_MotorStep =66;
- }
-
- break;
- case 66:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + QD_PARAM_JD_DELAY;
- QD_MotorStep = 67;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
- break;
- case 67:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay))
- {
- QD_JD_VAVEL = 1;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 68;
-
- }
- break;
- case 68:
- if(1)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QD_MotorStep = 69;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_JD_IN_ALARM);
- }
- break;
- case 69:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_TFK_VAVEL = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
- case 128:
-
- if(!X_DRV)
- {
- if(QD_QIAN_DEC_IN || QD_QIAN_LIMIT_IN)
- {
- QD_SetAlarmCode(QD_DEC_ALARM);
- }
- else
- {
- QD_MotorStep = 129;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_YL_VAVLE = 1;
-
- if(!QD_PARAM_SJ_ENABLE)
- {
- QD_ShenJiangStep = 0;
- QD_R_UP_VAVLE = 0;
- QD_R_JD = 0;
- }
- else
- {
- if(QD_ShenJiangStep == 0)QD_ShenJiangStep = 1;
- }
- QD_YL_DIR = QD_YL_DIR_P;
- }
- }
- else
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- fz_buff = cRealPosY;
- QD_MotorStep = 150;
- }
- else
- {
- if(QD_GOUZHEN_IN)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- }
- }
- break;
- case 150:
- if(dwTickCount >= QD_GZDelay)
- {
- QD_GZ_VAVLE = 1;
- QD_MotorStep = 151;
- }
- break;
- case 151:
- if(QD_GUO_LIAN_IN_UP)fz_buff = cRealPos;
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
- if((cRealPosY - fz_buff) >= QD_PARAM_DELAY_CHECK)
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- guo_lian_buff = cRealPos;
- QD_MotorStep = 152;
- }
- }
- break;
- case 152:
- {
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
- if((cRealPosY - guo_lian_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(Y_AXIS);
- QD_MotorStep = 153;
- }
- }
- break;
- case 153:
- {
- if(!Y_DRV)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- }
- break;
- case 129:
- if(!QD_YL_ORIGIN_IN)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_YL;
- QD_MotorStep = 131;
- }
- else if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_YL_LIMIT_ALARM);
- break;
- case 131:
- if(dwTickCount >= QD_MotorDelay)
- {
- gou_zhen_buff = cRealPos;
- save_buff = cRealPosY;
-
- if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS, QD_PARAM_YL_HIGH_SPEED,QD_YL_DIR_P,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- QD_MotorStep = 132;
- }
- break;
- case 132:
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- AxisChangeSpeed(Y_AXIS,QD_PARAM_YL_LOW_SPEED);
- fz_buff = cRealPosY;
- QD_MotorStep = 133;
- }
- break;
- case 133:
- if(QD_GUO_LIAN_IN_UP)fz_buff = cRealPosY;
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
- if((fz_buff-cRealPosY) >= QD_PARAM_DELAY_CHECK)
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- guo_lian_buff = cRealPos;
- QD_MotorStep = 134;
- }
- }
- break;
- case 134:
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
-
- if((guo_lian_buff-cRealPosY) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(Y_AXIS);
- QD_XM_VAVLE = 1;
- QD_MotorStep = 135;
- }
- break;
- case 135:
- if(!Y_DRV)
- {
- QD_YL_DIR = QD_YL_DIR_N;
- AxisMovePos(Y_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 136;
- }
- break;
- case 136:
- if(cZipCnt == 0);
- else if(cZipCnt == 1)
- {
- length_buff = save_buff - cRealPosY;
- }
- else
- {
- }
- QD_MotorStep = 0;
- break;
- }
- }
- void QueDuan_BingLian(void)
- {
- static long bl_pos_buff;
- user_datas[125]= bl_pos_buff - cRealPos;
- switch(QD_BinLianStep)
- {
- case 0:break;
- case 1:
- bl_pos_buff = cRealPos;
- QD_BinLianStep = 2;
- break;
- case 2:
- if((bl_pos_buff - cRealPos) >= QD_PARAM_DELAY_HL_LENGTH)
- {
- QD_BL_VAVLE = 1;
- QD_BinLianStep = 3;
- }
-
- break;
- case 3:
- if(QD_GUO_LIAN_IN_DW)
- {
- QD_BLDelay = dwTickCount + QD_PARAM_DELAY_BL_BACK;
- QD_BinLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QD_BLDelay)
- {
- QD_BL_VAVLE = 0;
- QD_BinLianStep = 0;
- }
- break;
- default:;
- }
-
- }
- //不带过链感应长度输入电机长度
- void QueDuan_Motor_NoGL(void)
- {
- static long save_buff,gou_zhen_buff,go_buff,jz_buff,go_length_buff,guo_lian_buff,fz_buff,length_buff;
- static long save_pos_y;
- user_datas[121]= QD_MotorStep;
- user_datas[122] = QD_AutoStep;
- user_datas[123]= go_length_buff;
- user_datas[124] = QD_BinLianStep;
- user_datas[126] = cRealPosY;
- user_datas[127] = cRealPos;
-
-
- switch(QD_MotorStep)
- {
- case 30:
- QD_MotorStep = 31;
- if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
- break;
- case 31:
- if(dwTickCount >= QD_MotorDelay)
- {
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- QD_JZ_DIR = QD_YDIR_P;
- if(QD_PARAM_DC_MODE) // 带钩针模式
- {
- if(QD_PARAM_DEC_MODE == 1) // 长度输入模式
- MoveAction_Const_Back(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,PosToPulse(X_AXIS,((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH + QD_PARAM_OFFSET_LENGTH) - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,30))))));
- else if(QD_PARAM_DEC_MODE == 2) // 纯感应模式
- {
- if(QD_PARAM_LONG_MODE)
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-(QD_PARAM_YL_TRANS_LENGTH));
- else
- MoveAction_Const_AccDec(X_AXIS, QD_DIR_P, QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- }
- else //感应方式
- {
- if(cZipCnt < 2)
- {
- MoveAction_Const_AccDec(X_AXIS, QD_DIR_P, QD_PARAM_FIRST_SPEED,QD_PARAM_MIN_SPEED,10,30);
- }
- else
- {
- MoveAction_Const_Back(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,PosToPulse(X_AXIS,(length_buff - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,30))))));
- }
- }
- }
- else // 不带钩针
- {
- if(QD_PARAM_DEC_MODE==1) // 长度输入模式
- {
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-(QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH + QD_PARAM_OFFSET_LENGTH));
- MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,5)));
- }
- else if(QD_PARAM_DEC_MODE==2) // 纯感应模式
- {
- MoveAction_Const_AccDec(X_AXIS, QD_DIR_P, QD_PARAM_BACK_SPEED,1,10,30);
- }
- else // 感应方式
- {
- if(cZipCnt < 2)
- {
- MoveAction_Const_AccDec(X_AXIS, QD_DIR_P, QD_PARAM_FIRST_SPEED,1,10,30);
- }
- else
- {
- MoveAction_Const_Back(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,PosToPulse(X_AXIS,(length_buff - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,30))))));
- }
- }
- }
- if(QD_PARAM_LONG_MODE)
- QD_MotorStep = 128;
- else
- QD_MotorStep = 32;
- }
- break;
- case 32:
- if(QD_PARAM_DC_MODE) // 带钩针模式
- {
- if(QD_PARAM_DEC_MODE == 1) // 长度输入模式
- {
- if(((cRealPos - gou_zhen_buff) > ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH + QD_PARAM_OFFSET_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)))QD_GZ_VAVLE = 1;
- if((cRealPos - gou_zhen_buff) >= ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH + QD_PARAM_OFFSET_LENGTH) - (QD_PARAM_DELAY_XM_LENGTH)))QD_XM_VAVLE = 1;
-
- if(!X_DRV)
- {
- QD_YD_VAVLE = 1;
- QD_XM_VAVLE = 1;
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 33;
- }
- else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH + QD_PARAM_OFFSET_LENGTH)) && QD_GZ_VAVLE)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- }
- else if(QD_PARAM_DEC_MODE == 2)
- {
- if(QD_PARAM_SPEED_MODE)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if((cRealPos - save_buff) >= (length_buff - PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_ACC_SPEED))))
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
- else
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- }
-
- }
- else
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- }
- else
- {
- if(((cRealPos - gou_zhen_buff) > ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)))QD_GZ_VAVLE = 1;
- if((cRealPos - gou_zhen_buff) >= ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH) - (QD_PARAM_DELAY_XM_LENGTH)))QD_XM_VAVLE = 1;
-
- if(!X_DRV)
- {
- QD_YD_VAVLE = 1;
- QD_XM_VAVLE = 1;
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 33;
- }
- else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH + QD_PARAM_OFFSET_LENGTH)) && QD_GZ_VAVLE)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- }
- }
-
- }
- else
- {
- if(QD_PARAM_DEC_MODE==1) // 长度输入模式
- {
- if((cRealPos - gou_zhen_buff) >= ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH + QD_PARAM_OFFSET_LENGTH) - (QD_PARAM_DELAY_XM_LENGTH)))QD_XM_VAVLE = 1;
-
- if(!X_DRV)
- {
- QD_YD_VAVLE = 1;
- QD_XM_VAVLE = 1;
- QD_MotorStep = 0;
- }
- }
- else if(QD_PARAM_DEC_MODE==2) // 纯感应模式
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- fz_buff = cRealPos;
- QD_MotorStep = 33;
- }
- }
- else //感应方式
- {
-
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- fz_buff = cRealPos;
- QD_MotorStep = 33;
- }
- }
- }
-
- break;
- case 33:
- if(QD_PARAM_DC_MODE) // 带钩针模式
- {
- if(QD_PARAM_DEC_MODE==1) // 长度输入模式
- {
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- }
- }
- else if(QD_PARAM_DEC_MODE==2) // 纯感应模式
- {
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
-
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_XM_VAVLE = 1;
- QD_YD_VAVLE = 1;
- QD_MotorStep = 34;
- }
- }
- else
- {
- if(cZipCnt < 2)
- {
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
-
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_XM_VAVLE = 1;
- QD_MotorStep = 34;
- }
- }
- else
- {
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- }
- }
- }
-
- }
- else
- {
- if(QD_PARAM_DEC_MODE==1) // 长度输入模式
- {
- }
- else if(QD_PARAM_DEC_MODE==2) //纯感应模式
- {
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if((cRealPos - fz_buff) >= QD_PARAM_DELAY_CHECK)
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- guo_lian_buff = cRealPos;
- QD_MotorStep = 34;
- }
- }
- }
- else //感应方式
- {
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if((cRealPos - fz_buff) >= QD_PARAM_DELAY_CHECK)
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- guo_lian_buff = cRealPos;
- QD_MotorStep = 34;
- }
- }
- }
- }
- break;
- case 34:
- if(QD_PARAM_DC_MODE) // 带钩针模式
- {
- if(QD_PARAM_DEC_MODE==1) // 长度输入模式
- {
- }
- else if(QD_PARAM_DEC_MODE==2) // 纯感应模式
- {
- // if(!X_DRV)
- {
- {
- QD_YD_VAVLE = 1;
- QD_JZ_DIR = QD_YDIR_N;
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 35;
- }
- }
- }
- else
- {
- if(!X_DRV)
- {
- QD_YD_VAVLE = 1;
-
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(1,length_buff - QD_PARAM_OFFSET_LENGTH + QD_PARAM_TC_LENGTH);
- }
- else if(cZipCnt == 0)
- {
- go_length_buff = cRealPos - save_buff;
- }
- else
- {
- if((cRealPos - save_buff) >(length_buff + QD_PARAM_MAX_ERROR_LENGTH))
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- cLengthErrorFlg = 1;
- }
- else if((cRealPos - save_buff)<(length_buff - QD_PARAM_MAX_ERROR_LENGTH))
- {
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM);
- cLengthErrorFlg = 1;
- }
- else;
- }
-
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 35;
- }
- }
-
- }
- else
- {
- if(QD_PARAM_DEC_MODE==1) // 长度输入模式
- {
- }
- else if(QD_PARAM_DEC_MODE==2) // 纯感应模式
- {
- if((cRealPos - guo_lian_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 35;
- }
- }
- else //感应方式
- {
- if((cRealPos - guo_lian_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 35;
- }
- }
- }
- break;
- case 35:
- if(QD_PARAM_DC_MODE) // 带钩针模式
- {
- if(QD_PARAM_DEC_MODE == 1) // 长度输入模式
- {
- }
- else if(QD_PARAM_DEC_MODE == 2) // 纯感应模式
- {
- if(!X_DRV)
- {
- if(cZipCnt == 0);
- else if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(1,length_buff - QD_PARAM_OFFSET_LENGTH - QD_PARAM_TC_LENGTH);
- }
- else
- {
- if((cRealPos - save_buff) >(length_buff + QD_PARAM_MAX_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else if((cRealPos - save_buff)<(length_buff - QD_PARAM_MAX_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM);
- else;
- }
- QD_MotorStep = 0;
- }
- }
- else
- {
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- }
- }
- }
- else
- {
- if(QD_PARAM_DEC_MODE==1) // 长度输入模式
- {
- }
- else if(QD_PARAM_DEC_MODE==2) // 纯感应模式
- {
- if(!X_DRV)
- {
- if(cZipCnt == 0);
- else if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(1,length_buff - QD_PARAM_OFFSET_LENGTH - QD_PARAM_TC_LENGTH);
- }
- else
- {
- if((cRealPos - save_buff) >(length_buff + QD_PARAM_MAX_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else if((cRealPos - save_buff)<(length_buff - QD_PARAM_MAX_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM);
- else;
- }
- QD_MotorStep = 0;
- }
- }
- else
- {
- if(!X_DRV)
- {
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(1,length_buff - QD_PARAM_OFFSET_LENGTH - QD_PARAM_TC_LENGTH);
- }
- else if(cZipCnt == 0)
- {
- go_length_buff = cRealPos - save_buff;
- }
- else
- {
- if((cRealPos - save_buff) >(length_buff + QD_PARAM_MAX_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else if((cRealPos - save_buff)<(length_buff - QD_PARAM_MAX_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM);
- else;
- }
- QD_MotorStep = 0;
- }
- }
- }
- break;
- case 40:
- if(dwTickCount >= QD_MotorDelay)
- {
- jz_buff = cRealPos;
- QD_JZ_DIR = QD_YDIR_P;
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVEL = 0;
- }
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 41;
-
- }
- break;
-
- case 41: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
- {
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 42;
- }
- break;
- case 42:
- // 切断完成后拉电机动作
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_PARAM_GZ_BACK_DELAY_LENGTH<= (jz_buff - cRealPos))QD_GZ_VAVLE = 0;
- if(((QD_PARAM_SJZ_LENGTH) <= (jz_buff - cRealPos)))
- {
- QD_JD_VAVEL = 0;
- QD_GZ_VAVLE = 0;
- QD_MotorStep = 43;
- }
- else if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 43;
- }
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
- case 50:
- if(!Y_DRV)
- {
- QD_MotorStep = 51;
- QD_YL_DIR = QD_YL_DIR_P;
- // AxisMovePos(Y_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_YL_SL_LENGTH);
- if(QD_PARAM_YL_SL_TIME != 0)
- {
- if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS, QD_PARAM_BACK_SPEED,QD_YL_DIR_P,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- QD_MotorDelay = dwTickCount + QD_PARAM_YL_SL_TIME;
- }
- else
- QD_MotorDelay = dwTickCount;
- QD_YLBackDelay = dwTickCount + QD_PARAM_DELAY_YL_BACK;
- }
- break;
- case 51: if(dwTickCount >= QD_MotorDelay)
- {
- AxisEgmStop(Y_AXIS);
- QD_MotorStep = 52;
- }
- if(dwTickCount >= QD_YLBackDelay) QD_YL_VAVLE = 0;
- break;
- case 52: if(dwTickCount >= QD_YLBackDelay)
- {
- QD_YL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
- case 61: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 50;
- }
-
- if(!QD_TL_VAVLE)
- {
- if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
- {
- QD_TuiLianStep = 1;
- }
- }
- QD_CQ_VAVLE = 1;
- QD_CQDelay = dwTickCount + QD_PARAM_CQ_TIME;
- QD_MotorStep = 62;
- break;
- case 62:
- if((QD_ShenJiangStep == 0) && QD_YL_ORIGIN_IN)
- {
- QD_MotorStep = 63;
- }
- case 63:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN || QD_QIAN_DEC_IN)
- {
- QD_JZ_DIR = QD_YDIR_P;
- AxisMovePos(X_AXIS,20,-2000);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 64;
- QD_JD_VAVEL = 0;
- }
- break;
- case 64:
- if(!QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay) && !QD_SHANG_MU_LIMIT_IN && !QD_JD_IN)
- {
- go_buff = cRealPos;
- QD_JZ_DIR = QD_YDIR_N;
-
- if((cZipCnt > 0) || (QD_PARAM_DEC_MODE == 2))
- {
- if(!X_DRV)MoveAction_Const_Stop_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);//
- }
- else
- {
- if(!X_DRV)MoveAction_Const_Stop_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- }
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =65;
- }
- break;
- case 65:
- if(cZipCnt > 0)
- {
- if(QD_PARAM_DEC_MODE == 1) // 长度输入模式
- {
- if(((go_buff - cRealPos) > ((QD_PARAM_ZIPPER_LENGTH + QD_PARAM_OFFSET_LENGTH - QD_PARAM_TC_LENGTH - QD_PARAM_FZ_LENGTH) - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC_SPEED))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
- else if(QD_PARAM_DEC_MODE == 2) //纯感应方式
- {
- if(QD_PARAM_LONG_MODE)
- {
- if(QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
- else
- {
- if((QD_QIAN_DEC_IN_UP && !QD_PARAM_SPEED_MODE)
- || ((QD_QIAN_DEC_IN_UP || ((go_buff - cRealPos) > (go_length_buff - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC_SPEED))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) ) && QD_PARAM_SPEED_MODE))
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
- }
- else
- {
- if(((go_buff - cRealPos) > ((go_length_buff - QD_PARAM_TC_LENGTH - QD_PARAM_FZ_LENGTH) - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC_SPEED))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
-
- }
- else
- {
- if(QD_PARAM_DEC_MODE == 2) //纯感应方式
- {
- if(QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =66;
- }
- }
- else
- QD_MotorStep =66;
- }
-
- break;
- case 66:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + QD_PARAM_JD_DELAY;
- QD_MotorStep = 67;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
- break;
- case 67:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay))
- {
- QD_JD_VAVEL = 1;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 68;
-
- }
- break;
- case 68:
- if(1)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QD_MotorStep = 69;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_JD_IN_ALARM);
- }
- break;
- case 69:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
- case 128:
-
-
- if(!X_DRV)
- {
- if(QD_QIAN_DEC_IN || QD_QIAN_LIMIT_IN)
- {
- QD_SetAlarmCode(QD_DEC_ALARM);
- }
- else
- {
- QD_MotorStep = 129;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_YL_VAVLE = 1;
-
- if(!QD_PARAM_SJ_ENABLE)
- {
- QD_ShenJiangStep = 0;
- QD_R_UP_VAVLE = 0;
- QD_R_JD = 0;
- }
- else
- {
- if(QD_ShenJiangStep == 0)QD_ShenJiangStep = 1;
- }
- QD_YL_DIR = QD_YL_DIR_P;
- }
- }
- else
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 150;
- }
- else
- {
- if(QD_GOUZHEN_IN)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- }
- }
- break;
- case 150:
- if(dwTickCount >= QD_GZDelay)
- {
- QD_GZ_VAVLE = 1;
- QD_MotorStep = 151;
- }
- break;
- case 151:
- {
- QD_MotorDelay = dwTickCount + 3000;
- QD_MotorStep = 152;
- }
- break;
- case 152:
- {
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_YD_VAVLE = 1;
- QD_MotorStep = 153;
- }
- else if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 153:
- {
- if(!X_DRV)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- }
- break;
- case 129:
- if(!QD_YL_ORIGIN_IN)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_YL;
- QD_MotorStep = 131;
- }
- else if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_YL_LIMIT_ALARM);
- break;
- case 131:
- if(dwTickCount >= QD_MotorDelay)
- {
- gou_zhen_buff = cRealPos;
- save_buff = cRealPosY;
- if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS, QD_PARAM_YL_HIGH_SPEED,QD_YL_DIR_P,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_ACC_SPEED);
- QD_MotorStep = 132;
- }
- break;
- case 132:
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_XMDelay = dwTickCount + QD_PARAM_DELAY_XM;
- QD_GZDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- AxisChangeSpeed(Y_AXIS,QD_PARAM_YL_LOW_SPEED);
- QD_MotorStep = 133;
- }
- break;
- case 133:
- if(dwTickCount >= QD_XMDelay)QD_XM_VAVLE = 1;
- if(dwTickCount >= QD_GZDelay)QD_GZ_VAVLE = 1;
-
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(Y_AXIS);
- QD_XM_VAVLE = 1;
- QD_YD_VAVLE = 1;
- QD_MotorStep = 134;
- }
- break;
- case 134:
- if(!Y_DRV)
- {
- {
- QD_YD_VAVLE = 1;
- QD_YL_DIR = QD_YL_DIR_N;
- AxisMovePos(Y_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 135;
- }
- }
- break;
- case 135:
- if(cZipCnt == 0);
- else if(cZipCnt == 1)
- {
- length_buff = save_buff - cRealPosY;
- }
- else
- {
- }
- QD_MotorStep = 0;
- break;
- }
- }
- //电机动作
- void QueDuan_Motor(void) //
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_NO_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_Motor_NoGL();break;
- default:;
- }
- }
- //超声方式下切
- void QueDuan_XiaQue_CS(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- QD_XiaQieStep = 2;
- QD_GZ_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + 1000;
- break;
- case 2:
- if(((QD_XIA_MU_LIMIT_IN || !bRunning)&& (QD_PARAM_CS_MODE == 1)) || (QD_PARAM_CS_MODE == 0))
- {
- QD_XiaQieStep = 3;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 3:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_TFK_VAVEL = 1;
- QD_XiaQieDelay = dwTickCount + 1000;
- QD_XiaQieStep = 4;
- }
- break;
- case 4:
- if(QD_GOUZHEN_IN)
- {
- cTuiFangKuaiCnt = 0;
- QD_XM_VAVLE = 1;
- if(bRunning)QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- else
- QD_XiaQieDelay = dwTickCount;
- QD_XiaQieStep = 5;
- }
- else if((dwTickCount >= QD_XiaQieDelay))
- {
-
- if((cTuiFangKuaiCnt == 0) && bRunning)
- {
- QD_TFK_VAVEL = 0;
- cTuiFangKuaiCnt++;
- QD_XiaQieDelay = dwTickCount + 1000;
- QD_XiaQieStep = 20;
- }
- else
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 1;
- 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_CS_MODE == 0)))
- {
- if(QD_PARAM_CS_MODE)
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 100;
- }
- else
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY; //
- QD_XiaQieStep = 7;
- }
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 20:
- if((dwTickCount >= QD_XiaQieDelay))
- {
- QD_XiaQieStep = 2;
- }
- break;
- case 7:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- // QD_TFK_VAVEL = 0;
- QD_BL_VAVLE = 0;
- QD_YL_VAVLE = 0;
- QD_GZ_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 8;
- }//
- break;
- case 8:
- if(!QD_XIA_MU_LIMIT_IN && !QD_SHANG_MU_LIMIT_IN)
- {
- QD_XiaQieStep = 0;
- if(QD_TuiLianStep == 0) QD_TuiLianStep = 1;
- if(cLengthErrorFlg == 1)
- {
- cLengthErrorFlg = 0;
- if(QD_MotorStep==0)QD_MotorStep = 40;
- }
- AddToTal(QD_QIE_DUAN_TOTAL_ADDR);
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
- break;
- case 100:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
- QD_XiaQieStep = 101;
- }
- break;
- case 101:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_CS_OUT = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
- QD_XiaQieStep = 7;
- }
- break;
- }
- }
- void QueDuan_TuiLianNormal(void)
- {
- switch(QD_TuiLianStep)
- {
- case 0:
- break;
- case 1:
- QD_TuiLianStep = 2;
- QD_TFK_VAVEL = 1;
- break;
- case 2:
- QD_TLDelay = dwTickCount+QD_PARAM_TL_DELAY;
- QD_TuiLianStep = 3;
- break;
- case 3:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TL_VAVLE = 1;
- QD_TLDelay = dwTickCount;
- QD_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TuiLianStep = 0;
- }
- break;
- }
- }
- void QueDuan_TuiLianNoGL(void)
- {
- switch(QD_TuiLianStep)
- {
- case 0:
- break;
- case 1:
- QD_TuiLianStep = 2;
- break;
- case 2:
- if(!QD_YD_VAVLE)QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
- else
- QD_TLDelay = dwTickCount;
- QD_YD_VAVLE = 1;
- QD_TuiLianStep = 3;
- break;
- case 3:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TL_VAVLE = 1;
- QD_TLDelay = dwTickCount;
- QD_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TuiLianStep = 0;
- }
- break;
- }
- }
- void QueDuan_TuiLianAction(void)
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_NO_CS_TUIFANGKUAI:QueDuan_TuiLianNormal();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_TuiLianNoGL();break;
- default:;
- }
- }
- void QueDuan_XiaQue_NO_GL(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- QD_YD_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 2;
- break;
- case 2:
- if(!QD_TL_VAVLE)
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 3;
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_TL_ALARM);
- break;
- case 3:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- // if((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))
- {
- QD_SM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 4;
- }
- }
- break;
- case 4:
- if(QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_PARAM_CS_MODE)
- {
- QD_XiaQieStep = 20;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- }
- else
- {
- QD_XiaQieStep = 5;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
- }
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_XM_VAVLE = 0;
- if(!QD_PARAM_GZ_BACK_DELAY_LENGTH)QD_GZ_VAVLE = 0;
- QD_SM_VAVLE = 0;
- QD_YL_VAVLE = 0;
- QD_BL_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(!QD_SHANG_MU_LIMIT_IN)
- {
- if(bRunning)
- {
- if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- }
- if(!bRunning)QD_JD_VAVEL = 0;
- QD_XiaQieStep = 0;
- if(cLengthErrorFlg)
- {
- cLengthErrorFlg = 0;
- if(QD_MotorStep==0)QD_MotorStep = 40;
- }
- AddToTal(QD_QIE_DUAN_TOTAL_ADDR);
-
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_DAOWEI);
- }
- break;
- case 20:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
- QD_XiaQieStep = 21;
- }
- break;
- case 21:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_CS_OUT = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
- QD_XiaQieStep = 5;
- }
- break;
- }
- }
- //切断动作
- void QueDuan_XiaQue(void)
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- default:;
- }
- }
- #endif
|