1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178 |
- #include "global.h"
- #if (CHANG_SHENG_GEI_LI_MACHINE==1)
- void QueDuan_AlarmProtect(void);
- void QueDuan_ManualAction(void);
- void QueDuan_AutoAction(void);
- void QueDuan_StepCheckStart(void);
- void QueDuan_XiaQue(void);
- void QueDuan_SecondXiaQue(void);
- void QueDuan_Motor(void);
- void QueDuan_YuanDianAction(void);
- void QueDuan_TuiLianAction(void);
- void QueDuan_ExtiActionX31(void);
- void QueDuan_BingLian(void);
- void QDN_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;
- unsigned char NQDJGNUNMBER = 0;
- short *length_buffer;
- void QueDuan_ExtiActionX31(void)
- {
- cCheckLianFlg = 1;
- }
- void QDN_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(QDN_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- //电机松轴
- void Motor_SZ(unsigned char En)
- {
- if(En) //使能
- {
- if(QDN_PARAM_MOTOR_SELECT)
- QDN_SZ_OUT = 1; //伺服电机
- else
- QDN_SZ_OUT = 0; //步进电机
- }
- else //松轴
- {
- if(QDN_PARAM_MOTOR_SELECT)
- QDN_SZ_OUT = 0; //伺服电机
- else
- QDN_SZ_OUT = 1; //步进电机
- }
- }
- void QueDuan_NewStr_InitAction(void)
- {
- float length_buff,pulse_buff;
- length_buff = QDN_PARAM_CYCLE_LENGTH;
- pulse_buff = QDN_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
- if(QDN_PARAM_KAIBEE_SELECT > 1)
- QDN_PARAM_KAIBEE_SELECT = 1;
- Motor_SZ(QDN_MOTOR_DIS); //电机松轴
- QDCT_SetAlarmCode(QDN_NO_ALARM);
-
- }
- void QueDuan_NewStr_Action(void)
- {
- InputPinConfig();
- QueDuan_AlarmProtect();
- QueDuan_Motor();
- QueDuan_XiaQue();
- QueDuan_ManualAction();
- QueDuan_TuiLianAction();
- QueDuan_BingLian();
- QueDuan_SecondXiaQue();
- QueDuan_AutoAction();
- QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
- OutputPinConfig();
- }
- //手动动作
- void QueDuan_ManualAction(void)
- {
- if(bRunning == 0)
- {
- cGoLimitEn = 0;
- if(QDN_bClearTotal) //切断计数清零
- {
- QDN_bClearTotal = 0;
- ClrcToTal(QDN_TOTAL_ADDR);
- }
-
- if(QDN_bClearNowTotal)
- {
- QDN_bClearNowTotal = 0;
- QDN_PARAM_NOW_CNT = 0;
- }
-
- if(QDN_PARAM_KAIBEE_SELECT)
- {
- if(!QDN_GOUZHEN_HOU_IN && !QDN_GOUZHEN_HOU_IN)
- QDN_GZDW_OUT=1;
- }
- else
- {
- QDN_GZDW_OUT=0;
- }
-
- if(QDN_bXiaQie || QDN_MAN_QIEDUAN_IN_UP)
- {
- QDN_bXiaQie = 0;
- if((QDN_XiaQieStep == 0) && !QDN_TL_VAVLE)
- {
- if(!QDN_PARAM_KAIBEE_SELECT)
- QDN_XiaQieStep = 1;
- else
- QDN_XiaQieStep = 1;
- }
- }
- //前点定位
- if(QDN_bQianDianDW)
- {
- QDN_bQianDianDW = 0;
- if(QDN_MotorStep == 0)
- {
- QDN_MotorStep = 61;
- cZipCnt = 0;
- Motor_SZ(QDN_MOTOR_EN); //电机锁轴
- QDN_MotorDelay = dwTickCount + 150;
- }
- }
-
- if(QDN_bTL)
- {
- QDN_bTL = 0;
- if(QDN_TL_VAVLE)
- {
- QDN_TL_VAVLE = 0;
- }
- else if(!QDN_GZ_VAVLE && !QDN_SM_VAVLE)
- {
- QDN_TL_VAVLE = ~QDN_TL_VAVLE;
- }
- }
-
-
- if(QDN_bYD)
- {
- QDN_bYD = 0;
- QDN_YD_VAVLE = ~QDN_YD_VAVLE;
- }
-
- if(QDN_bGZ || QDN_MAN_GOUZHEN_IN_UP)
- {
- QDN_bGZ = 0;
- QDN_GZ_VAVLE = ~QDN_GZ_VAVLE;
- }
-
- if(QDN_bJD)
- {
- QDN_bJD = 0;
- QDN_JD_VAVLE = ~QDN_JD_VAVLE;
- }
-
- if(QDN_bXM)
- {
- QDN_bXM = 0;
- if(QDN_XM_KAIKOU_VAVLE || QDN_XM_VAVLE)
- {
- QDN_XM_VAVLE = 0;
- QDN_XM_KAIKOU_VAVLE = 0;
- }
- else
- {
- if(QDN_PARAM_KAIBEE_SELECT) //闭口
- {
-
- QDN_XM_VAVLE = 1;
- }
- else
- {
- QDN_XM_KAIKOU_VAVLE = 1;
-
- }
- }
- }
-
- if(QDN_bSM)
- {
- QDN_bSM = 0;
- if(QDN_SM_VAVLE)
- QDN_SM_VAVLE = 0;
- else if(!QDN_TL_VAVLE)
- QDN_SM_VAVLE = 1;
- }
- //推方块
- if(QDN_bTFK || QDN_MAN_TUIDAI_IN_UP)
- {
- QDN_bTFK = 0;
- QDN_TFK_VAVLE = ~QDN_TFK_VAVLE;
- }
- //台面电机
- if(QDN_bTB)
- {
- QDN_bTB = 0;
- QDN_TABLE_VAVLE = ~QDN_TABLE_VAVLE;
- }
-
- // if(QDN_bYBD)
- // / {
- // QDN_bYBD = 0;
- // QDN_YBD_VAVLE = ~QDN_YBD_VAVLE;
- // }
-
- if(QDN_bTestCS)
- {
- QDN_bTestCS = 0;
- QDN_CS_OUT = 1;
- QDN_CSDelay = dwTickCount + QDN_PARAM_CS_TIME;
- }
-
- if(QDN_bBL)//合链
- {
- QDN_bBL = 0;
- QDN_BL_VAVLE = ~QDN_BL_VAVLE;
- }
-
- if(QDN_bHL) //护链,双开用
- {
- QDN_bHL = 0;
- // QDN_HL_VAVLE = ~QDN_HL_VAVLE;
- }
-
- if(QDN_bYX)
- {
- QDN_bYX = 0;
- // QDN_YX_VAVLE = ~QDN_YX_VAVLE;
- }
- if(QDN_XiaQieStep == 0)
- {
- if(dwTickCount >= QDN_CSDelay) QDN_CS_OUT = 0;
- }
-
- //电机控制
- if(QDN_bGoMotor && !QDN_QIAN_LIMIT_IN)
- {
- Motor_SZ(QDN_MOTOR_EN); //电机锁轴
- if(!X_DRV)
- {
-
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED,10,12);
- }
- }
-
- if(QDN_bBackMotor) //后退限位已经取消
- {
- Motor_SZ(QDN_MOTOR_EN); //电机锁轴
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_P,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED,10,12);
- }
-
- if(!QDN_bGoMotor && !QDN_bBackMotor && (QDN_MotorStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
-
- if(QDN_QIAN_LIMIT_IN && (QDN_MotorStep == 0) && !QDN_bBackMotor &&(QDN_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
- }
- }
- void QueDuan_AlarmProtect(void)
- {
- cRealPos = GetPos(X_AXIS);
-
- if(!bRunning)
- {
- if(QDN_BACK_LIMIT_IN)
- {
- if((QDN_MotorStep != 0) || X_DRV && QDN_bBackMotor) //到后限不能再后退但可以点前进
- {
- QDN_bBackMotor = 0;
-
- AxisDecStop(X_AXIS);
- QDN_JD_VAVLE = 0;
- QDN_SetAlarmCode(QDN_BACK_ALARM);
-
- }
- }
- }
- else
- {
- //软件限位
- if(QDN_PARAM_RUN_LENGTH < 5000)
- QDN_PARAM_RUN_LENGTH= 5000;
- if((cRealPos > QDN_PARAM_RUN_LENGTH) && (cGoLimitEn != 0)) //第一条手动时不保护
- {
- AxisEgmStop(X_AXIS);
- QDN_JD_VAVLE = 0;
- QDN_SetAlarmCode(QDN_BACK_ALARM);
- }
- //硬件限位
- if(QDN_BACK_LIMIT_IN && GetDir(X_AXIS)==QDN_DIR_P)
- {
- if(X_DRV)
- {
- AxisEgmStop(X_AXIS);
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDN_BACK_ALARM);
- }
- }
- }
- }
- void QueDuan_AutoAction(void)
- {
- if(bRunning)
- {//台面电机定时关掉
- if(dwTickCount >= QDN_TBDelay)
- QDN_TABLE_VAVLE = 0;
- switch(QDN_AutoStep)
- {
- case 1:
- if(dwTickCount >= QDN_AutoDelay)
- {
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- QDN_AutoStep = 2;
- if(QDN_MotorStep == 0)
- {
- QDN_MotorStep = 61; //前点定位
- }
- cGoLimitEn = 0;
- }
- }
- break;
- case 2:
- if(QDN_MotorStep == 0)
- {
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- QDN_MotorStep = 30;
- QDN_AutoStep = 3;
- cGoLimitEn = 1;
- }
- }
- break;
- case 3: //后面两步为延时反转步
- if((QDN_MotorStep == 0) || (QDN_MotorStep == 390) || (QDN_MotorStep == 391))
- {
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- if(QDN_SAFE_IN)
- {
- bStop = 1;
- }
- else
- {
-
- if(QDN_XiaQieStep == 0)
- QDN_XiaQieStep = 1;
- QDN_AutoStep = 4;
- }
- }
- }
- break;
- case 4:
- // 闭口
- if((QDN_XiaQieStep == 0) || ((QDN_XiaQieStep == 6) && (QDN_PARAM_KAIBEE_SELECT == 1))|| ((QDN_XiaQieStep == 13) && (QDN_PARAM_KAIBEE_SELECT == 0)))// && !QDN_SHANG_MU_LIMIT_IN)
- {
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- if(QDN_MotorStep == 0)
- {
- QDN_MotorStep = 40; //切完后退
- QDN_AutoStep = 5;
- }
- }
- }
- break;
- case 5:
- if(QDN_MotorStep == 0)
- {
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- if(QDN_PARAM_SecondDAO_LENGTH && QDN_PARAM_KAIBEE_SELECT && QDN_PARAM_BKGZ_NUMBER )
- {
- QDN_SecondXiaQueStep = 1;
- QDN_AutoStep=0;
- }
- else
- {
- if(NQDJGNUNMBER==0)
- QDN_AutoStep = 6;
- else if(NQDJGNUNMBER==1)
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- else if(NQDJGNUNMBER==2)
- QDN_SetAlarmCode(QDN_LENGTH_SHORT_ALARM);
-
- }
- }
- }
- break;
- case 6:
-
- if(QDN_MotorStep == 0)
- {
- cZipCnt++;
- QDN_PARAM_NOW_CNT++;
- cTableCnt++;
- AddToTal(QDN_TOTAL_ADDR);
- AddToTal(CT_WORKTOTAL_ADDR);
- CalProSP(QDN_PROSPEED_ADDR);
-
- if(cTableCnt >= QDN_PARAM_TABLE_NUM)
- {
- cTableCnt = 0;
- QDN_TABLE_VAVLE = 1;
- QDN_TBDelay = dwTickCount + QDN_PARAM_TB_TIME;
- }
-
- if(/*(GetTotal(QDN_TOTAL_ADDR) >= QDN_PARAM_SET_TOTAL) ||*/ SingOneFlg)
- {
- /*
- if((QDN_PARAM_SET_TOTAL == 0) && !SingOneFlg)
- {
- QDN_AutoDelay = dwTickCount + QDN_PARAM_CYCLE_DELAY;
- QDN_AutoStep = 1;
- }
- else
- */
- {
- bRunning = 0;
- QDN_AutoStep = 0;
- SingOneFlg = 0;
-
- }
-
- // if(GetTotal(QDN_TOTAL_ADDR) >= QDN_PARAM_SET_TOTAL) QDN_SetAlarmCode(QDN_TOTAL_ALARM);
- }
- else
- {
- QDN_AutoStep = 1;
-
- if((QDN_PARAM_NOW_CNT >= QDN_PARAM_ZHA_SHU) && (QDN_PARAM_ZHA_SHU > 0))
- {
- QDN_AutoDelay = dwTickCount + QDN_PARAM_ZS_STOP_TIME;
- QDN_PARAM_NOW_CNT = 0;
- if(QDN_PARAM_ZS_STOP_TIME == 0)
- {
- bRunning = 0;
- QDN_AutoStep = 0;
- SingOneFlg = 0;
- QDN_SetAlarmCode(QDN_TOTAL_ALARM);
- }
- }
- else
- QDN_AutoDelay = dwTickCount + QDN_PARAM_CYCLE_DELAY;
- }
- }
- break;
- }
- }
- }
- void QueDuan_StepCheckStart(void)
- {
- // 启动
- if((QDN_START_IN_UP) || bStart || QDN_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (QDN_AutoStep == 0))
- {
- if((QDN_XIA_MU_LIMIT_IN | QDN_KAIKUO_XIAMO_LIMIT_IN) && !QDN_PARAM_XM_ENABLE)QDN_SetAlarmCode(QDN_XM_DAOWEI);
- // else if(GetAlarmCode(QDN_ALARM_ADDR) != 0);
- //else if(GetTotal(QDN_TOTAL_ADDR) >= QDN_PARAM_SET_TOTAL) QDN_SetAlarmCode(QDN_TOTAL_ALARM);
- else if(QDN_ANQUANMEN_LIMIT_IN)QDN_SetAlarmCode(QDN_PARAM_ANQUANMEN_ALARM);
- else if(QDN_SM_VAVLE)QDN_SetAlarmCode(QDN_SM_ALARM);
- else if(QDN_GOUZHEN_QIAN_IN || QDN_GOUZHEN_HOU_IN)QDN_SetAlarmCode(QDN_GZ_ALARM);
- else
- {
- bRunning = 1;
- QDN_AutoStep = 1;
- if(QDN_bSingle)
- SingOneFlg= 1;
- cZipCnt = 0;
- cTuiFangKuaiCnt = 0;
- NQDJGNUNMBER = 0;
- QDN_BL_VAVLE = 0; //并链关
- QDN_DGLG_VAVLE = 0; //顶过链杆关
- SetAlarmCode(QDN_ALARM_ADDR,0);
- Motor_SZ(QDN_MOTOR_EN); //电机锁轴
- QDN_AutoDelay = dwTickCount + 150;
- if(QDN_PARAM_KAIBEE_SELECT)
- QDN_GZDW_OUT=1;
- else
- QDN_GZDW_OUT=0;
- }
- }
- QDN_bSingle = 0;
- }
- //停止
- if(QDN_STOP_IN_UP || bStop)
- {
- bStop = 0;
- if(bRunning)
- {
- QDN_AutoDelay = dwTickCount;
- QDN_MotorDelay = dwTickCount;
- QDN_XiaQieDelay = dwTickCount;
- QDN_KaDaiDelay = dwTickCount;
- QDN_CSDelay = dwTickCount;
- QDN_TBDelay = dwTickCount;
- QDN_TFKDelay = dwTickCount;
- QDN_TLDelay = dwTickCount;
- dwTickCount = QDN_TBDelay;
- NQDJGNUNMBER = 0;
- SingOneFlg = 0;
- QDN_JD_VAVLE = 0;
- QDN_SM_VAVLE = 0;
- QDN_XM_VAVLE = 0;
- QDN_XM_KAIKOU_VAVLE=0;
- QDN_YD_VAVLE = 0;
- QDN_TFK_VAVLE= 0;
- QDN_TL_VAVLE = 0;
- // QDN_HL_VAVLE = 0;
- QDN_CS_OUT = 0;
- QDN_XiaQieStep = 0;
- QDN_MotorStep = 0;
- QDN_TuiLianStep = 0;
- QDN_GZ_VAVLE = 0;
- QDN_TABLE_VAVLE = 0;
- QDN_DGLG_VAVLE = 0; //顶过链杆关
- AxisDecStop(X_AXIS);
- QDN_BinLianStep = 0;
- QDN_BL_VAVLE = 0;
- user_datas[121] = 0;
- user_datas[122] = 0;
- SetAlarmCode(QDN_ALARM_ADDR,0);
- }
- else
- {
- QDN_AutoDelay = dwTickCount;
- QDN_MotorDelay = dwTickCount;
- QDN_XiaQieDelay = dwTickCount;
- QDN_KaDaiDelay = dwTickCount;
- QDN_CSDelay = dwTickCount;
- QDN_TBDelay = dwTickCount;
- QDN_TFKDelay = dwTickCount;
- QDN_TLDelay = dwTickCount;
- dwTickCount = QDN_TBDelay;
- NQDJGNUNMBER = 0;
- SingOneFlg = 0;
- QDN_JD_VAVLE = 0;
- QDN_SM_VAVLE = 0;
- QDN_XM_VAVLE = 0;
- QDN_XM_KAIKOU_VAVLE = 0;
- QDN_YD_VAVLE = 0;
- QDN_TFK_VAVLE= 0;
- // QDN_YX_VAVLE = 0;
- // QDN_HL_VAVLE = 0;
- QDN_TL_VAVLE = 0;
- QDN_DGLG_VAVLE = 0; //顶过链杆关
- QDN_GZ_VAVLE = 0;
- QDN_CS_OUT = 0;
- QDN_XiaQieStep = 0;
- QDN_MotorStep = 0;
- QDN_TuiLianStep = 0;
- QDN_TABLE_VAVLE = 0;
- AxisEgmStop(X_AXIS);
- Motor_SZ(QDN_MOTOR_DIS); //电机松轴
- QDN_BinLianStep = 0;
- QDN_BL_VAVLE = 0;
- SetAlarmCode(QDN_ALARM_ADDR,0);
- }
- bRunning = 0;
- QDN_XiaQieStep = 0;
- QDN_AutoStep = 0;
- QDN_MotorStep = 0;
- QDN_TuiLianStep = 0;
- cTuiFangKuaiCnt=0;
- }
- if(bAlarmStop)
- {
- bAlarmStop = 0;
- QDN_XiaQieStep = 0;
- QDN_AutoStep = 0;
- QDN_MotorStep = 0;
- QDN_TuiLianStep = 0;
- NQDJGNUNMBER = 0;
- QDN_XiaQieStep = 0;
- QDN_MotorStep = 0;
- QDN_TuiLianStep = 0;
- QDN_AutoDelay = dwTickCount;
- QDN_MotorDelay = dwTickCount;
- QDN_XiaQieDelay = dwTickCount;
- QDN_KaDaiDelay = dwTickCount;
- QDN_CSDelay = dwTickCount;
- QDN_TBDelay = dwTickCount;
- QDN_TFKDelay = dwTickCount;
- QDN_TLDelay = dwTickCount;
- SingOneFlg = 0;
- bRunning = 0;
- AxisDecStop(X_AXIS);
- dwTickCount = QDN_TBDelay;
- QDN_TABLE_VAVLE = 0;
- QDN_JD_VAVLE=0;
- QDN_GZ_VAVLE=0;
- cTuiFangKuaiCnt=0;
- }
-
- }
- //记忆长度模式误差检测
- void QueDuan_CheckLength(long zip_length)
- {
- static long start_dist;
- switch(QDN_CheckLengthStep)
- {
- case 0:break;
- case 1:
- start_dist = cRealPos;
- dwSaveLength = 0;
- QDN_CheckLengthStep = 2;
- break;
- case 2:
- if(QDN_GUO_LIAN_IN_DW){
- dwSaveLength = cRealPos - start_dist;
- // user_datas[127] = cRealPos;
- }
- break;
- }
- }
- #if 1//!QDN_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] = QDN_AutoStep;
- user_datas[122] = QDN_MotorStep;
- user_datas[123] = cRealPos;
- user_datas[124] = length_buff;
- user_datas[125] = GetCurSpeed(X_AXIS);
- user_datas[126] = QDN_XiaQieStep;
- user_datas[127] = QDN_XiaQieStep;
- QueDuan_CheckLength(length_buff);
-
- switch(QDN_MotorStep)
- {
- case 30:
- switch(QDN_PARAM_BACK_MODE) //开口分四种模式
- {
- case 0: //单数控模式
- QDN_MotorStep = 310; //每种模式留20步
- QDN_DGLG_VAVLE = 1; //顶过链杆关
- break;
- case 1://单感应模式
- QDN_MotorStep = 330; //每种模式留20步
-
- break;
- case 2: //先感应后数控模式+检测
- QDN_MotorStep = 350; //每种模式留20步
- break;
- default: //数控模式+过链检测长度
- QDN_MotorStep = 370; //每种模式留20步
- break;
- }
- QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
- break;
- //310步到315步为数控模式
- case 310:
- QDN_MotorStep = 311;
- // QDN_JZ_DIR = QDN_YDIR_P;
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 1; //并链起动
- length_buffer = &QDN_PARAM_OFFSET_LENGTH;
- break;
- case 311:
- if(dwTickCount >= QDN_MotorDelay)
- {
-
- //李永庆代码
- //SetDir(X_AXIS, QDN_DIR_N);
- //两段速度移动距离 拉链长度+慢速长度停止
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH -(*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
- QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_DIR_P,
- QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
-
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
-
-
- QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDN_MotorStep = 312;
- }
- break;
- case 312:
- //勾针提前输出 ,争取时间推方块
- if (!QDN_GZ_VAVLE && (cRealPos >= (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer)- QDN_PARAM_GOUZHEN_LENGTH)))
- {
- QDN_GZ_VAVLE = 1;
- //QDN_XM_KAIKOU_VAVLE=1;
- }
- if((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
- {
- QDN_MotorStep = 313;
-
- }
- else if(cRealPos >= (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer) + QDN_PARAM_ERROR_LENGTH))
- {
- AxisEgmStop(X_AXIS);
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- }
- break;
- case 313:
- if(!QDN_GZ_VAVLE && ((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer) - QDN_PARAM_GOUZHEN_LENGTH)))
- {
- QDN_GZ_VAVLE = 1;
- //QDN_XM_KAIKOU_VAVLE=1;
- }
- if(!X_DRV)
- {
- //AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
- QDN_MotorStep = 314;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
-
- if((QDN_PARAM_BACK_MODE == 2) && !QDN_DGLG_VAVLE) //模式2,先检测长度后数控
- {//对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里对比长度
- if(cZipCnt > 1) //长度检测
- {
- if(QDN_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
- {
- if(((dwSaveLength + QDN_PARAM_MOTOR_DELAY_LENGTH) > (length_buff + QDN_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
- {
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);//拉链变长,对比警告
- }
- else if((dwSaveLength + QDN_PARAM_MOTOR_DELAY_LENGTH+ QDN_PARAM_ERROR_LENGTH) < length_buff)
- {
- QDN_SetAlarmCode(QDN_LENGTH_SHORT_ALARM); ////拉链变短
- }
- QDN_CheckLengthStep = 0;
- }
- }
- }
- }
- if(cRealPos >= (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer) + QDN_PARAM_ERROR_LENGTH))
- {
- AxisEgmStop(X_AXIS);
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- }
- break;
- case 314:
- if(!X_DRV && (dwTickCount >= QDN_MotorDelay)) //数控到停止
- {
- QDN_MotorStep = 315;
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_TFK_VAVLE = 1; //推方块输出
- }
- break;
- case 315:
- if(QDN_GOUZHEN_QIAN_IN)
- {
- QDN_MotorStep = 0;
- }
- else if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- break;
- //330步到349步单感应模式
- case 330:
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 331;
- // QDN_JZ_DIR = QDN_YDIR_P;
- save_buff = cRealPos;
- length_buffer = &QDN_PARAM_OFFSET_LENGTH;
- //user_datas[127] = 0;
- break;
- case 331:
- if(dwTickCount >= QDN_MotorDelay)
- {
- if(cZipCnt < 2)
- {
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 10; //并链起动
- //第一条都是过链感应,后拉速度减半//原来QDN_PARAM_CHECK_BACK_HSPEED/2
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,10,13);
-
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH + (*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_DIR_P);
- QDN_MotorStep = 332;
- }
- else
- {
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 1; //并链起动
- //因为每条都是过链感应,所以直接运行检测模式后拉速度
- // X轴 运行速度 启动速度 加速度 减速度
- //AxisContinueMoveAcc(X_AXIS,QDN_PARAM_CHECK_BACK_HSPEED,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- if(length_buff>QDN_PARAM_BACK_LOW_SPEED_LENGTH)
- AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,length_buff-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
- QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
- else
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,8,13);
- QDN_MotorStep = 334;
- }
- }
- break;
- case 332:
- //第一二条工作
- {
- if(QDN_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
- QDN_MotorDelay = dwTickCount + 0;//QDN_PARAM_DELAY_XM;
- QDN_MotorStep = 333;
- }
- // else if((cRealPos >= QDN_PARAM_RUN_LENGTH) && (QDN_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
- // {
- // QDN_SetAlarmCode(QDN_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
- // }
- }
- break;
- case 333:
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_MotorStep = 334;
- }
- break;
- case 334:
- if(QDN_GUO_LIAN_IN_DW && ((cRealPos-save_buff)> (length_buff-QDN_PARAM_BACK_LOW_SPEED_LENGTH) || (cZipCnt < 2))) //下降沿,定位长度
- {
- //滤波有待调试
- // if((((cRealPos - checkdelay_buff) >= QDN_PARAM_DELAY_CHECK) && (QDN_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QDN_PARAM_NO_LT_DELAY_CHECK) && (QDN_PARAM_LT_ENABLE == 0)))
- // {
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 335;
- }
- // }
- }
- break;
- case 335:
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
-
- }
- //在空们都把延时清零
- if(QDN_GUO_LIAN_IN)
- {
- gou_zhen_buff = cRealPos;
- }
- if(((cRealPos - gou_zhen_buff) >= QDN_PARAM_MOTOR_DELAY_LENGTH/4) && !QDN_GUO_LIAN_IN)
- {
- QDN_GZ_VAVLE = 1;
- //QDN_XM_KAIKOU_VAVLE=1;
- //QDN_MotorStep = 336;
-
- }
- //定位停止
- if(((cRealPos - gou_zhen_buff) >= QDN_PARAM_MOTOR_DELAY_LENGTH) && !QDN_GUO_LIAN_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_MotorStep = 336;
- QDN_GZ_VAVLE = 1;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- }
- break;
- case 336:
- if(!X_DRV)
- {
- QDN_GZ_VAVLE = 1;
-
- QDN_MotorDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
- // QDN_XM_VAVLE = 1;
- QDN_MotorStep = 337;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- }
- break;
- case 337:
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_TFK_VAVLE = 1; //推方块输出
- QDN_MotorStep = 338;
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- break;
- case 338:
- if(QDN_GOUZHEN_QIAN_IN)
- {
- QDN_MotorStep = 339;
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- else if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- break;
- case 339:
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- //需要补偿推方块增加的距离
- SetData32bits(QDN_PARAM_ZIPPER_LENGTH_ADDR,length_buff + (*length_buffer));
- }
- else if(cZipCnt > 1) //长度检测
- {
- if(QDN_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
- {
- if(cRealPos >= length_buff) //拉链变长,对比警告
- {
- if((cRealPos - save_buff) > (length_buff+QDN_PARAM_ERROR_LENGTH))
- NQDJGNUNMBER=1;
- }
- else //拉链变短
- {
- if((cRealPos - save_buff + QDN_PARAM_ERROR_LENGTH) < (length_buff))
- NQDJGNUNMBER=2;
- }
- }
- }
- QDN_MotorStep = 0;
- break;
- //350步到369步单感应模式
- case 350:
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- QDN_MotorStep = 351;
- // QDN_JZ_DIR = QDN_YDIR_P;
- length_buffer = &QDN_PARAM_OFFSET_LENGTH;
-
- break;
- case 351:
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_MotorStep = 352;
- //第一,二条都是过链感应,测量长度
- if(cZipCnt < 2)
- {
- if(QDN_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
- QDN_BinLianStep = 10; //并链起动
- QDN_DGLG_VAVLE = 0; //顶过链杆关
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_GO_LOW_SPEED,8,12);
-
- }
- else
- {
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 1; //并链起动
- QDN_DGLG_VAVLE = 1; //顶过链杆关
- QDN_CheckLengthStep = 1; //长度检测,第3条才有对比
- //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
- QDN_MotorStep = 311;
- }
- }
- break;
- case 352:
- //前两条都按最低速度工作
- if(QDN_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
-
-
- QDN_MotorDelay = dwTickCount + 2;//因慢速,加8MS滤波
- QDN_MotorStep = 353;
- }
- else if((cRealPos >= QDN_PARAM_RUN_LENGTH) && (QDN_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
- {
- // QDN_SetAlarmCode(QDN_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
- }
- break;
- case 353:
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_MotorStep = 354;
- }
- break;
- case 354:
- if(QDN_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- //滤波有待调试
- // if((((cRealPos - checkdelay_buff) >= QDN_PARAM_DELAY_CHECK) && (QDN_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QDN_PARAM_NO_LT_DELAY_CHECK) && (QDN_PARAM_LT_ENABLE == 0)))
- // {
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 355;
- }
- // }
- }
- break;
- case 355:
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
-
- }
- //在空们都把延时清零
- if(QDN_GUO_LIAN_IN)
- {
- gou_zhen_buff = cRealPos;
- }
- if(((cRealPos - gou_zhen_buff) >= QDN_PARAM_MOTOR_DELAY_LENGTH/4) && !QDN_GUO_LIAN_IN)
- {
- QDN_GZ_VAVLE = 1;
- //QDN_XM_KAIKOU_VAVLE=1;
-
- }
- //定位停止
- if(((cRealPos - gou_zhen_buff) >= QDN_PARAM_MOTOR_DELAY_LENGTH) && !QDN_GUO_LIAN_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorStep = 356;
- QDN_GZ_VAVLE = 1;
- }
- break;
- case 356:
- if(!X_DRV)
- {
- QDN_GZ_VAVLE = 1;
-
- QDN_MotorDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
- // QDN_XM_VAVLE = 1;
- QDN_MotorStep = 357;
- }
- break;
- case 357:
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_TFK_VAVLE = 1; //推方块输出
- QDN_MotorStep = 358;
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- break;
- case 358:
- if(QDN_GOUZHEN_QIAN_IN)
- {
- QDN_MotorStep = 359;
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- else if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- break;
- case 359:
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- //测量出来长度,补偿推方块的距离
- SetData32bits(QDN_PARAM_ZIPPER_LENGTH_ADDR,length_buff + (*length_buffer));
- }
- QDN_MotorStep = 0;
- break;
- //370步到389步为数控模式
- case 370:
- QDN_MotorStep = 371;
- // QDN_JZ_DIR = QDN_YDIR_P;
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 1; //并链起动
-
- QDN_CheckLengthStep = 1; //长度检测开始
- length_buffer = &QDN_PARAM_OFFSET_LENGTH;
- break;
- case 371:
- if(dwTickCount >= QDN_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- //李永庆代码
- //SetDir(X_AXIS, QDN_DIR_N);
- //两段速度移动距离 拉链长度+慢速长度停止
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH -(*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
- QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_DIR_P,
- QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
-
-
- QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDN_MotorStep = 372;
- }
- break;
- case 372:
- //勾针提前输出 ,争取时间推方块
- if (!QDN_GZ_VAVLE && (cRealPos >= (QDN_PARAM_ZIPPER_LENGTH- (*length_buffer) - QDN_PARAM_GOUZHEN_LENGTH)))
- {
- QDN_GZ_VAVLE = 1;
- //QDN_XM_KAIKOU_VAVLE=1;
- }
- if((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH- (*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
- {
- QDN_MotorStep = 373;
-
- }
- break;
- case 373:
- if(!QDN_GZ_VAVLE && ((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH- (*length_buffer) - QDN_PARAM_GOUZHEN_LENGTH)))
- {
- QDN_GZ_VAVLE = 1;
- //QDN_XM_KAIKOU_VAVLE=1;
- }
- if(!X_DRV)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
- QDN_MotorStep = 374;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- //对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
- if(cZipCnt > 1) //长度检测
- {
- if((QDN_PARAM_ERROR_LENGTH != 0) && length_buff) //长度误差值不能为0
- {
- if((dwSaveLength > (length_buff + QDN_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
- {
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);//拉链变长,对比警告
- }
- //上升沿的长度
- else if((dwSaveLength + QDN_PARAM_ERROR_LENGTH) < length_buff)
- {
- QDN_SetAlarmCode(QDN_LENGTH_SHORT_ALARM); ////拉链变短
- }
-
- QDN_CheckLengthStep = 0;
- }
- }
- else if(cZipCnt == 1) //长度检测
- {
- if(dwSaveLength)
- length_buff = dwSaveLength;
- }
- }
- break;
- case 374:
- if(!X_DRV && (dwTickCount >= QDN_MotorDelay)) //数控到停止
- {
- QDN_MotorStep = 315;
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_TFK_VAVLE = 1; //推方块输出
- }
- break;
- case 375:
- if(QDN_GOUZHEN_QIAN_IN)
- {
- QDN_MotorStep = 0;
- }
- else if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- break;
- //切完延时后拉带松夹子
- case 40:
- if(QDN_PARAM_SJZ_LENGTH == 0)
- {
- QDN_JD_VAVLE = 0;
- }
- QDN_MotorDelay = dwTickCount + QDN_PARAM_CUT_BACK_DELAY;
- SetDir(X_AXIS, QDN_DIR_P);
- // QDN_JZ_DIR = QDN_YDIR_P;
- SetDir(X_AXIS, QDN_DIR_N);
- QDN_MotorStep = 41;
- break;
- case 41:
-
- if((dwTickCount >= QDN_MotorDelay))
- {
- jz_buff = cRealPos;
- if(QDN_JD_VAVLE)
- //两段速度移动距离
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,QDN_PARAM_SJZ_LENGTH,5000,
- QDN_PARAM_BACK_LENGTH,QDN_DIR_P,QDN_PARAM_START_SPEED,
- QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- else
- //夹子已经张开
- AxisMovePosAccDec(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH),
- QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,10,10,0);
- // AxisMovePos(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH));
- QDN_MotorStep = 42;
- }
- break;
- case 42:
-
- if(((QDN_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- {
- QDN_JD_VAVLE = 0;
- QDN_MotorStep = 43;
- }
- if(!X_DRV)
- {
- QDN_JD_VAVLE = 0;
- QDN_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QDN_MotorStep = 0;
- QDN_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- QDN_BL_VAVLE = 0;//并链也要打开
- if(dwTickCount >= QDN_MotorDelay)
- {
-
-
- // QDN_JZ_DIR = QDN_YDIR_N;
- if(!QDN_TL_VAVLE && cZipCnt) //没送链情况下主动送链
- {
- if(!QDN_SHANG_MU_LIMIT_IN && (QDN_TuiLianStep == 0))
- {
- QDN_TuiLianStep = 1;
- QDN_MotorStep = 62;
- }
- }
- else
- QDN_MotorStep = 62;
- }
- break;
- case 62:
- if(dwTickCount >= QDN_MotorDelay)
- {
- if(QDN_QIAN_LIMIT_IN)
- {
- SetPos(X_AXIS, 0);//在前点,直接置零点
- // QDN_JZ_DIR = QDN_YDIR_P;
- //前点亮的情况下先退出
- AxisMovePos(X_AXIS,QDN_PARAM_GO_LOW_SPEED,1000);
- QDN_MotorDelay = dwTickCount + 300;
- }
- QDN_MotorStep = 63;
- QDN_JD_VAVLE = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QDN_QIAN_LIMIT_IN && (dwTickCount >= QDN_MotorDelay))// && !QDN_SHANG_MU_LIMIT_IN)
- {
- SetDir(X_AXIS, QDN_DIR_N);
- // QDN_JZ_DIR = QDN_YDIR_N;
- //SetDir(X_AXIS, QDN_DIR_P);
- go_buff = cRealPos;
- //QDN_YD_VAVLE = 1; //开口不用压带
- // QDN_HL_VAVLE = 1;
- // QDN_YX_VAVLE = 1;
- //李永庆代码,当位置在慢速之外,走数控到慢速点
- if(cZipCnt > 0)
- {
-
- if(cRealPos>(QDN_PARAM_GO_LOW_SPEED_LENGTH))
- {
-
- // AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos-QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- // SetStartSpeed(X_AXIS,QDN_PARAM_START_SPEED);
- // SetAccTime(X_AXIS,QDN_PARAM_ACC);
- // SetDecTime(X_AXIS,QDN_PARAM_DCC);
- //两段速度移动距离
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos-QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED_LENGTH+ 100,QDN_DIR_N);
- //跑三段速度
- // AxisMoveThreePosNoStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos -QDN_PARAM_GO_LOW_SPEED_LENGTH-300-150,
- // QDN_PARAM_GO_HIGH_SPEED*2/3,350,
- // QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED_LENGTH+150,QDN_DIR_N) ;
- AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,-(cRealPos -QDN_PARAM_GO_LOW_SPEED_LENGTH),
- QDN_PARAM_START_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED/3,QDN_PARAM_GO_LOW_SPEED/3,15,15);
-
- // MoveAction_Const_AccDec(X_AXIS, QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- }
-
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED/3,QDN_PARAM_GO_LOW_SPEED/3,15,15);
- // MoveAction_Const_AccDec(X_AXIS, QDN_DIR_N,QDN_PARAM_FIRST_GO_HIGHSPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);//
- }
-
- QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDN_MotorStep =64;
- }
-
- break;
- case 64:
- if(cZipCnt > 1)
- {
- //李永庆代码
- if(((cRealPos) < (QDN_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QDN_QIAN_DEC_IN))
- {
- //user_datas[126]= GetCurSpeed(X_AXIS);
- // MoveChangSpeedDec(X_AXIS,QDN_PARAM_GO_HIGH_SPEED*2/3,6,8);
- // AxisChangeSpeed(X_AXIS,40);
- QDN_MotorStep =65;
- }
-
- if(QDN_QIAN_LIMIT_IN)
- {
-
- back_buff=cRealPos;
- QDN_MotorStep = 301;
-
- }
-
-
-
- }
- else
- { if(QDN_QIAN_LIMIT_IN)
- {
-
- back_buff=cRealPos;
- QDN_MotorStep = 301;
-
- }
-
-
-
-
-
-
- }
- break;
-
-
- case 301:
-
- if(QDN_QIAN_LIMIT_IN && back_buff-cRealPos >= QDN_PARAM_KKQIANDIAN_LENGTH ) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorStep = 66;
- }
-
- break;
- case 65:
- if(QDN_QIAN_LIMIT_IN)
- {
-
- back_buff=cRealPos;
- QDN_MotorStep = 301;
-
- }
-
- else if(dwTickCount >= QDN_MotorDelay)
- QDN_SetAlarmCode(QDN_NO_ZIPPER_ALARM);
-
- break;
- case 66:
- if(!X_DRV)
- {
- SetPos(X_AXIS, 0);
- QDN_MotorDelay = dwTickCount;
- QDN_MotorStep = 67;
- }
- break;
- case 67: //等推链完成后,
- if((dwTickCount >= QDN_MotorDelay) && (QDN_TuiLianStep == 0) && ((QDN_PARAM_TIAOSHI_MODE && QDN_bTS) || (QDN_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QDN_JD_VAVLE = 1;
- QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
- }
- QDN_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_YD_VAVLE = 0;
- QDN_TFK_VAVLE = 0;
- // QDN_HL_VAVLE = 0;
- // QDN_YX_VAVLE = 0;
- QDN_TL_VAVLE = 0;
- QDN_MotorStep = 0;
- QDN_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- #endif
- void QueDuan_BingLian(void)
- {
- static long bl_pos_buff,HL_delay;
-
- switch(QDN_BinLianStep)
- {
- case 0:break;
- case 1:
- bl_pos_buff = cRealPos;
- QDN_BinLianStep = 2;
- break;
- case 2:
- if((cRealPos - bl_pos_buff) >= QDN_PARAM_DELAY_HL_LENGTH)
- {
- QDN_BL_VAVLE = 1;
- QDN_BinLianStep = 3;
- }
- break;
- case 3://有过链检测
- if((cRealPos - bl_pos_buff) >= (QDN_PARAM_ZIPPER_LENGTH - QDN_PARAM_HL_DELAY_BACK))
- {
- QDN_BL_VAVLE = 0;
- QDN_BinLianStep = 0;
- }
- break;
- case 10:
- bl_pos_buff = cRealPos;
- QDN_BinLianStep = 11;
- break;
- case 11:
- if((cRealPos - bl_pos_buff) >= QDN_PARAM_DELAY_HL_LENGTH)
- {
- QDN_BL_VAVLE = 1;
- QDN_BinLianStep = 12;
- }
- break;
- case 12://有过链检测
- if(QDN_GUO_LIAN_IN_DW)
- {
- QDN_BinLianStep = 13;
- QDN_BingLianDelay = dwTickCount + 50;
- }
- break;
- case 13:
- if(QDN_GUO_LIAN_IN)
- QDN_BinLianStep = 12;
- if(dwTickCount>=QDN_BingLianDelay)
- {
- if(!QDN_GUO_LIAN_IN)
- {
- QDN_BL_VAVLE = 0;
- QDN_BinLianStep = 0;
- }
- else
- {
- QDN_BinLianStep = 12;
- }
- }
- break;
- default:;
- }
-
- }
- #if 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[121] = QDN_AutoStep;
- user_datas[122] = QDN_MotorStep;
- user_datas[123] = cRealPos;
- user_datas[124] = length_buff;
- user_datas[125] = GetCurSpeed(X_AXIS);
- user_datas[126] = QDN_XiaQieStep;
- user_datas[127] = QDN_XiaQieStep;
- switch(QDN_MotorStep)
- {
- case 30:
- switch(QDN_PARAM_BACK_MODE) //开口分四种模式
- {
- case 0: //单数控模式
- QDN_MotorStep = 310; //每种模式留20步
- QDN_DGLG_VAVLE = 1; //顶过链杆关
- break;
- case 1://单感应模式
- QDN_MotorStep = 330; //每种模式留20步
-
- break;
- case 2: //先感应后数控模式+检测
- QDN_MotorStep = 350; //每种模式留20步
- break;
- default: //数控模式+过链检测长度
- QDN_MotorStep = 370; //每种模式留20步
- break;
- }
- QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
- break;
- //310步到315步为数控模式
- case 310:
- QDN_MotorStep = 311;
- // QDN_JZ_DIR = QDN_YDIR_P;
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 1; //并链起动
- break;
- case 311:
- if(dwTickCount >= QDN_MotorDelay)
- {
- length_buffer = &QDN_PARAM_OFFSET_LENGTH;
-
- AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
- QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDN_MotorStep = 312;
- }
- break;
- case 312:
- //勾针提前输出
- if (!QDN_GZ_VAVLE && ((cRealPos + QDN_PARAM_GOUZHEN_LENGTH) >= (QDN_PARAM_ZIPPER_LENGTH )))
- {
- QDN_GZ_VAVLE = 1;
- }
- if((cRealPos) >= (QDN_PARAM_ZIPPER_LENGTH - QDN_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
- {
- QDN_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- QDN_MotorStep = 313;
- }//下面条件为无效代码
- else if((cRealPos >= (QDN_PARAM_ZIPPER_LENGTH + QDN_PARAM_ERROR_LENGTH)) && QDN_PARAM_ERROR_LENGTH)
- {
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- }
- break;
- case 313:
- if(!QDN_GZ_VAVLE && (cRealPos + QDN_PARAM_GOUZHEN_LENGTH) > (QDN_PARAM_ZIPPER_LENGTH ))
- {
- QDN_GZ_VAVLE = 1;
- }
- //提前12MM取消数控模式,进入连续运动
- // if((cRealPos + 100) > (QDN_PARAM_ZIPPER_LENGTH ))
- // {
- // //CancelPmoveState(X_AXIS);
- // SetStartSpeed(X_AXIS,1500);
- // AxisChangeSpeed(X_AXIS,1500);
- // }
- if(QDN_GOUZHEN_HOU_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + 0;
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 314;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else if((cRealPos >= (QDN_PARAM_ZIPPER_LENGTH + QDN_PARAM_ERROR_LENGTH)) && QDN_PARAM_ERROR_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= QDN_MotorDelay)
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- }
-
- // else if((cRealPos >= QDN_PARAM_ZIPPER_LENGTH + (*length_buffer)))// && dwTickCount >= QDN_MotorDelay)
- // {
-
- // }
- break;
-
- case 314:
- if(!X_DRV && (dwTickCount >= QDN_MotorDelay))
- {
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_YD_VAVLE = 1;//压带
- QDN_MotorStep = 315;
- }
- break;
- case 315:
- if(cZipCnt == 0) //第一条把误差到正负9MM
- {
- ch = QDN_PARAM_ZIPPER_LENGTH -90;
- kk = QDN_PARAM_ZIPPER_LENGTH +90;
- }
- else
- {
- ch = QDN_PARAM_ZIPPER_LENGTH -70;
- kk = QDN_PARAM_ZIPPER_LENGTH +70;
- }
-
- if(((cRealPos) < (ch)))
- {
- SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
- if(dwTickCount >= QDN_MotorDelay)
- bAlarmStop = 1;
- }
- else if((cRealPos > kk))//(QDN_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
- {
- SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
- if(dwTickCount >= QDN_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
- QDN_MotorStep = 390; //延时反转步
- }
- break;
- //330步到349步单感应模式
- case 330:
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff=cRealPos;
- QDN_MotorStep = 331;
- break;
- case 331:
- if(dwTickCount >= QDN_MotorDelay)
- {
-
- if(cZipCnt < 2)
- {
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 10; //并链起动
- //第一条都是过链感应,后拉速度减半//原来QDN_PARAM_CHECK_BACK_HSPEED/2
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,8,13);
-
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH + (*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_DIR_P);
- QDN_MotorDelay = dwTickCount + 20;
- QDN_MotorStep = 332;
- }
- else
- {
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 1; //并链起动
- //因为每条都是过链感应,所以直接运行检测模式后拉速度
- // X轴 运行速度 启动速度 加速度 减速度
- //AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- if(length_buff>QDN_PARAM_BACK_LOW_SPEED_LENGTH)
- AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,length_buff-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
- QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
- else
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,8,13);
- QDN_MotorStep = 334;
- }
- }
- break;
- case 332:
- if(QDN_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
- QDN_MotorDelay = dwTickCount + 20;
- }
- if(QDN_GUO_LIAN_IN && dwTickCount >= QDN_MotorDelay)
- {
- QDN_MotorDelay = dwTickCount + QDN_PARAM_FEEL_GZ_DELAY;//QDN_PARAM_DELAY_XM;
- QDN_MotorStep = 333;
- }
- else if(!QDN_GUO_LIAN_IN)
- {
- QDN_MotorDelay = dwTickCount + 20;
- }
- break;
- case 333: //此步为前两条运行
- if(!QDN_PARAM_BKGZ_NUMBER) //有钩针模式
- {
-
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_MotorStep = 334;
-
- QDN_GZ_VAVLE = 1;
-
- }
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 335;
- QDN_GZ_VAVLE = 1;
-
- }
- }
- else // 无钩针模式
- {
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 335;
-
- }
-
- }
- break;
- case 334:
- if(!QDN_PARAM_BKGZ_NUMBER) // 有钩针模式
- {
- if(QDN_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 335;
- QDN_GZ_VAVLE = 1;
- }
- if(cZipCnt > 1) //第三条开始要长度误差
- {
- if(cRealPos >= (length_buff + QDN_PARAM_ERROR_LENGTH))
- {
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- //user_datas[128] = 1;
- }
- }
- }
- else // 无钩针模式
- {
- if(QDN_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 335;
- }
- if(cZipCnt > 1) //第三条开始要长度误差
- {
- if(cRealPos >= (length_buff + QDN_PARAM_ERROR_LENGTH))
- {
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- //user_datas[128] = 1;
- }
- }
- }
- break;
- case 335:
- if(!QDN_PARAM_BKGZ_NUMBER) //有钩针模式
- {
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
-
- }
- //在空们都把延时清零
- if(QDN_GUO_LIAN_IN)
- {
- gou_zhen_buff = cRealPos;
- }
- //距离到停
- // if(cRealPos -gou_zhen_buff > QDN_PARAM_BKGY_LENGTH )
- // {
- // AxisEgmStop(X_AXIS);
- // QDN_MotorDelay = dwTickCount + 10;
- // QDN_YD_VAVLE = 1;
- // QDN_MotorStep = 336;
- // QDN_BL_VAVLE = 0; //停止时并链一定要打开
- // }
- //感应到停
- if(QDN_GOUZHEN_HOU_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + 10;
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 336;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else
- {
- if(cZipCnt > 1) //2 条后才有长度误差
- {
- if(cRealPos >= (length_buff + QDN_PARAM_ERROR_LENGTH))
- {
- AxisEgmStop(X_AXIS);
- //user_datas[128] = 2;
- if(dwTickCount >= QDN_MotorDelay)
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- }
- }
- }
- else
- {
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
-
- }
- //在空们都把延时清零
- if(QDN_GUO_LIAN_IN)
- {
- gou_zhen_buff = cRealPos;
- }
- if(cRealPos -gou_zhen_buff > QDN_PARAM_BKGY_LENGTH )
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + 10;
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 336;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else
- {
- if(cZipCnt > 1) //2 条后才有长度误差
- {
- if(cRealPos >= (length_buff + QDN_PARAM_ERROR_LENGTH))
- {
- AxisEgmStop(X_AXIS);
- //user_datas[128] = 2;
- if(dwTickCount >= QDN_MotorDelay)
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- }
- }
-
-
- }
- break;
- case 336:
- if(cZipCnt > 1) //长度检测
- {
- ch = QDN_PARAM_ZIPPER_LENGTH;
- //user_datas[127] = ch;
- if(((cRealPos + QDN_PARAM_ERROR_LENGTH) < (ch)) && QDN_PARAM_ERROR_LENGTH)
- {
- NQDJGNUNMBER =1;
- //user_datas[128] = 3;
- if(dwTickCount >= QDN_MotorDelay)
- bAlarmStop = 1;
- }
- else if((cRealPos > (ch + QDN_PARAM_ERROR_LENGTH)) && QDN_PARAM_ERROR_LENGTH)//(QDN_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
- {
- //user_datas[128] = 4;
- NQDJGNUNMBER = 2;
- if(dwTickCount >= QDN_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
- QDN_MotorStep = 337;
- }
- }
- else
- {
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(QDN_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
- }
- QDN_MotorStep = 337;
- }
- break;
- case 337:
- QDN_MotorStep = 390;
-
- // SetDir(X_AXIS, QDN_DIR_N);
- // if(dwTickCount >= QDN_MotorDelay)
- // {
- // AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,QDN_PARAM_ACC,QDN_PARAM_DCC);
- // QDN_MotorStep = 0;
- // }
- break;
- //350步到369步单感应模式
- case 350:
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff=cRealPos;
- QDN_MotorStep = 351;
- break;
- case 351:
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_MotorStep = 352;
- //第一,二条都是过链感应,测量长度
- if(cZipCnt < 2)
- {
- if(QDN_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
- QDN_BinLianStep = 10; //并链起动
- QDN_DGLG_VAVLE = 0; //顶过链杆关
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,8,12);
- QDN_MotorDelay = dwTickCount + 20;
- }
- else
- {
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 1; //并链起动
- QDN_DGLG_VAVLE = 1; //顶过链杆关
- QDN_CheckLengthStep = 1; //长度检测,第3条才有对比
- //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
- QDN_MotorStep = 311;
- }
- }
- break;
- case 352:
- //前两条都按最低速度工作
- if(QDN_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
- QDN_MotorDelay = dwTickCount + 20;
- }
- if(QDN_GUO_LIAN_IN && dwTickCount >= QDN_MotorDelay)
- {
- QDN_MotorDelay = dwTickCount + QDN_PARAM_FEEL_GZ_DELAY;//QDN_PARAM_DELAY_XM;
- QDN_MotorStep = 353;
- }
- else if(!QDN_GUO_LIAN_IN)
- {
- QDN_MotorDelay = dwTickCount + 20;
- }
- break;
- case 353:
- //此步为前两条运行
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_MotorStep = 354;
- QDN_GZ_VAVLE = 1;
- }
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 355;
- QDN_GZ_VAVLE = 1;
- }
- break;
- case 354:
- if(QDN_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- if(QDN_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QDN_MotorStep = 355;
- QDN_GZ_VAVLE = 1;
- }
- }
- break;
- case 355:
- //在空们都把延时清零
- if(QDN_GOUZHEN_HOU_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + 10;
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 356;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- }
- break;
- case 356:
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(QDN_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
- }
- QDN_MotorStep = 357;
-
- break;
- case 357:
- QDN_MotorStep = 390; //延时反转步
- // SetDir(X_AXIS, QDN_DIR_N);
- // AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,QDN_PARAM_ACC,QDN_PARAM_DCC);
- // QDN_MotorStep = 0;
- break;
-
- //370步到389步为数控模式
- case 370:
- QDN_MotorStep = 371;
- // QDN_JZ_DIR = QDN_YDIR_P;
- if(QDN_PARAM_BL_ENABLE)
- QDN_BinLianStep = 1; //并链起动
-
- QDN_CheckLengthStep = 1; //长度检测开始
-
- break;
- case 371:
- if(dwTickCount >= QDN_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- //李永庆代码
- SetDir(X_AXIS, QDN_DIR_P);
- \
- AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
- QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
-
- QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDN_MotorStep = 372;
- }
- break;
- case 372:
- //勾针提前输出
- if (!QDN_GZ_VAVLE && ((cRealPos + QDN_PARAM_GOUZHEN_LENGTH) >= (QDN_PARAM_ZIPPER_LENGTH )))
- QDN_GZ_VAVLE = 1;
- if((cRealPos + QDN_PARAM_BACK_LOW_SPEED_LENGTH + 20) > (QDN_PARAM_ZIPPER_LENGTH + (*length_buffer))) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
- {
- QDN_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- QDN_MotorStep = 373;
- }
- else if(cRealPos >= (QDN_PARAM_ZIPPER_LENGTH + (*length_buffer)))//QDN_PARAM_ERROR_LENGTH))
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- break;
- case 373:
- //勾针提前输出
- if (!QDN_GZ_VAVLE && ((cRealPos + QDN_PARAM_GOUZHEN_LENGTH) >= (QDN_PARAM_ZIPPER_LENGTH )))
- QDN_GZ_VAVLE = 1;
-
- //提前12MM取消数控模式,进入连续运动
- // if((cRealPos + 100) > (QDN_PARAM_ZIPPER_LENGTH ))
- // {
- // //CancelPmoveState(X_AXIS);
- // SetStartSpeed(X_AXIS,1500);
- // AxisChangeSpeed(X_AXIS,1500);
- // }
- if(QDN_GOUZHEN_HOU_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + 0;
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 374;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else if((cRealPos >= (QDN_PARAM_ZIPPER_LENGTH + QDN_PARAM_ERROR_LENGTH)) && QDN_PARAM_ERROR_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= QDN_MotorDelay)
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- break;
- case 374:
- if(!X_DRV)
- {
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 375;
- }
- break;
- case 375:
- if(cZipCnt == 0) //第一条把误差到正负9MM
- {
- ch = QDN_PARAM_ZIPPER_LENGTH - 90;
- kk = QDN_PARAM_ZIPPER_LENGTH + 90;
- }
- else
- {
- ch = QDN_PARAM_ZIPPER_LENGTH;
- kk = QDN_PARAM_ZIPPER_LENGTH;
- }
-
- if(((cRealPos + QDN_PARAM_ERROR_LENGTH) < (ch)))
- {
- SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
- if(dwTickCount >= QDN_MotorDelay)
- bAlarmStop = 1;
- }
- else if((cRealPos > (kk + QDN_PARAM_ERROR_LENGTH)))//(QDN_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
- {
- SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
- if(dwTickCount >= QDN_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
- // SetDir(X_AXIS, QDN_DIR_N);
- // AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,QDN_PARAM_ACC,QDN_PARAM_DCC);
- QDN_MotorStep = 390; //延时反转步
- }
- break;
- //此两步为到位后反转步
- case 390:
- //SetDir(X_AXIS, QDN_DIR_N);
- QDN_YD_VAVLE=1;//先压带后延时反转
- QDN_MotorDelay = dwTickCount + QDN_PARAM_YD_FZ_DELAY;
- QDN_MotorStep = 391;
- break;
- case 391:
- if(dwTickCount >= QDN_MotorDelay)
- {
- //SetDir(X_AXIS, QDN_DIR_N);
- AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,3000,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
- QDN_MotorStep = 392;
- }
- break;
- case 392:
- if(!X_DRV)
- {
- QDN_MotorStep = 0;
- }
- break;
- #if 0 //下面为老的数控模式
- case 30:
- QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
- length_buffer = &QDN_PARAM_OFFSET_LENGTH;
- if(QDN_PARAM_BL_ENABLE) //
- QDN_BinLianStep = 1;
- if(QDN_MACHINE_TYPE == QDN_CS_TUIFANGKUAI) //双开带过链感应
- {
- if(QDN_PARAM_DEC_MODE == QDN_BACK_NOMAL_DEC_MODE)//测长数控
- QDN_MotorStep = 101;
- else
- QDN_MotorStep = 31;
- }
- else //闭口走长度
- QDN_MotorStep = 31;
- break;
- case 31:
- if(dwTickCount >= QDN_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- length_buffer = &QDN_PARAM_OFFSET_LENGTH;
- //李永庆代码
- SetDir(X_AXIS, QDN_DIR_N);
- //两段速度移动距离
- // 轴 第一段速度 第一段长度要减去送链长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH-200,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH + (*length_buffer),QDN_DIR_P);
-
- //AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,4,QDN_PARAM_DCC+8);
-
- SetDir(X_AXIS,QDN_DIR_P);
- QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDN_MotorStep = 32;
- }
- break;
- case 32:
- //勾针提前输出
- if (!QDN_GZ_VAVLE && ((cRealPos + QDN_PARAM_GOUZHEN_LENGTH + 200) >= (QDN_PARAM_ZIPPER_LENGTH )))
- QDN_GZ_VAVLE = 1;
- if((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
- {
- QDN_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- QDN_MotorStep = 33;
- }
- else if(cRealPos >= (QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))//QDN_PARAM_ERROR_LENGTH))
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- break;
- case 33:
- if(!QDN_GZ_VAVLE && (cRealPos + QDN_PARAM_GOUZHEN_LENGTH + 200) > (QDN_PARAM_ZIPPER_LENGTH ))
- {
- QDN_GZ_VAVLE = 1;
- QDN_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- }
- //提前12MM取消数控模式,进入连续运动
- // if((cRealPos + 180 + 200) > (QDN_PARAM_ZIPPER_LENGTH ))
- // {
- // CancelPmoveState(X_AXIS);
- // SetStartSpeed(X_AXIS,1500);
- // AxisChangeSpeed(X_AXIS,1500);
- // }
- if(QDN_GOUZHEN_HOU_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorDelay = dwTickCount + 10;
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 34;
- QDN_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else if((cRealPos >= QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))// && dwTickCount >= QDN_MotorDelay)
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= QDN_MotorDelay)
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- break;
- case 34:
- if(!X_DRV && (dwTickCount >= QDN_MotorDelay))
- {
- QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 35;
- }
- break;
- case 35:
- if(cZipCnt == 0)
- {
- ch = QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-90;
- kk = QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+90;
- }
- else
- {
- ch = QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-70;
- kk = QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+70;
- }user_datas[128] = ch;
- user_datas[127] = kk;
- if(((cRealPos) < (ch)))
- {
- SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
- if(dwTickCount >= QDN_MotorDelay)
- bAlarmStop = 1;
- }
- else if((cRealPos > kk))//(QDN_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
- {
- SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
- if(dwTickCount >= QDN_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
- SetDir(X_AXIS, QDN_DIR_N);
- SetDir(X_AXIS, QDN_DIR_P);
- AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,QDN_PARAM_ACC,QDN_PARAM_DCC);
- SetDir(X_AXIS, QDN_DIR_P);
- QDN_MotorStep = 0;
- }
-
- break;
- case 101:
- if(dwTickCount >= QDN_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
-
- if(cZipCnt <= 2)
- {
- QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- MoveAction_Const_AccDec(X_AXIS,QDN_DIR_P,QDN_PARAM_FIRST_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- QDN_MotorStep = 102;
- }
- else
- {
- MoveAction_Const_AccDec(X_AXIS,QDN_DIR_P,QDN_PARAM_BACK_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- QDN_MotorStep = 102;
- }
- }
- break;
- case 102:
- if(cZipCnt <= 2)
- {
- //拉链上升沿,就是到空位
- if(QDN_GUO_LIAN_IN_UP)
- {
- QDN_MotorDelay = dwTickCount + QDN_PARAM_GZ_DELAY;
- if(X_DRV)
- AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED); //降速
- QDN_MotorStep = 103;
- }
- }
- else
- {
- //1为双开
- if((QDN_SK_MODE) && (((cRealPos + QDN_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QDN_PARAM_GOUZHEN_LENGTH))))
- {
-
- // QDN_HL_VAVLE = 1;
- }
- if(((cRealPos - gou_zhen_buff) > (length_buff - QDN_PARAM_GOUZHEN_LENGTH)) && !QDN_GZ_VAVLE)
- {
- QDN_GZ_VAVLE = 1;
-
- }
- if((cRealPos - back_buff) > (length_buff - QDN_PARAM_BACK_LOW_SPEED_LENGTH-PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC))))
- {
- if(X_DRV)
- {
- AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
- }
- QDN_MotorStep = 103;
- }
- }
- break;
- case 103:
- if(cZipCnt <= 2)
- {//双开暂不用,先保留
- #if QDN_SK_MODE
- if((QDN_SK_MODE) && ((dwTickCount + QDN_PARAM_GZ_DELAY/2) >= QDN_MotorDelay))
- {
- QDN_YX_VAVLE = 1;
- QDN_HL_VAVLE = 1;
- }
- #endif
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_GZ_VAVLE = 1;
- // QDN_YX_VAVLE = 1;
- #if QDN_SK_MODE //双开暂不用,先保留
- if(QDN_SK_MODE)
- QDN_MotorStep = 154;
- else
- #endif
- QDN_MotorStep = 160;
- }
- }
- else
- {
- #if QDN_SK_MODE //双开暂不用,先保留
- if((QDN_SK_MODE) && (((cRealPos + QDN_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QDN_PARAM_GOUZHEN_LENGTH))))
- {
- QDN_YX_VAVLE = 1;
- QDN_HL_VAVLE = 1;
- }
- #endif
- if(((cRealPos - gou_zhen_buff) > (length_buff - QDN_PARAM_GOUZHEN_LENGTH)))
- {
- QDN_GZ_VAVLE = 1;
-
- #if QDN_SK_MODE //双开暂不用,先保留
- if(QDN_SK_MODE)
- QDN_MotorStep = 154;
- else
- #endif
- QDN_MotorStep = 160;
- }
-
-
- if(((cRealPos - save_buff) >= (QDN_PARAM_ERROR_LENGTH + length_buff)) && QDN_GZ_VAVLE)
- {
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- }
- }
- break;
- case 154:
- #if QDN_SK_MODE //双开暂不用,先保留
- if(QDN_GZ_UP_IN)
- {
- QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_CHECK_GZ;
- QDN_MotorStep = 104;
- }
- #endif
- break;
- case 160:
- if(QDN_GOUZHEN_HOU_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 105;
- }
- else if(((cRealPos - save_buff) >= (QDN_PARAM_ERROR_LENGTH + length_buff)) && QDN_GZ_VAVLE && (cZipCnt > 2))
- {
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- }
- break;
- case 104:
- #if QDN_SK_MODE //双开暂不用,先保留
- if(dwTickCount >= QDN_MotorDelay)
- {
- //勾针离开就是到位
- if(!QDN_GOUZHEN_HOU_IN && QDN_GZ_UP_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_MotorStep = 105;
- }
- }
- #endif
- break;
- case 105:
- if(!X_DRV)
- {
- QDN_MotorStep = 0;
- // QDN_HL_VAVLE = 1;
- QDN_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 - QDN_PARAM_ERROR_LENGTH- (*length_buffer))))QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- else if(((cRealPos - save_buff) > (QDN_PARAM_ERROR_LENGTH + length_buff - (*length_buffer))))QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- else
- {
- }
- }
- AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_FZ_LENGTH,1,QDN_PARAM_ACC,QDN_PARAM_DCC);
-
- }
- break;
- case 106:
- if(!X_DRV)
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- }
- else
- {
- if(QDN_GOUZHEN_HOU_IN)
- {
- AxisEgmStop(X_AXIS);
- QDN_YD_VAVLE = 1;
- QDN_MotorStep = 0;
- }
- }
-
- break;
- #endif
- case 40:
- if(!QDN_SecondXiaQueStep)
- {
- if(QDN_PARAM_SJZ_LENGTH == 0)
- {
- QDN_MotorDelay = dwTickCount + QDN_PARAM_CUT_BACK_DELAY;
- QDN_JD_VAVLE = 0;
- }
- else
- QDN_MotorDelay = dwTickCount + 3;
- }
- else
- {
- if(QDN_PARAM_Secondleave_LENGTH == 0)
- {
- QDN_MotorDelay = dwTickCount + 20;
- QDN_JD_VAVLE = 0;
- }
- else
- QDN_MotorDelay = dwTickCount + 3;
-
- }
-
- SetDir(X_AXIS, QDN_DIR_N);
- QDN_MotorStep = 41;
- jz_buff = cRealPos;
- break;
- case 41:
- if(!QDN_SecondXiaQueStep)
- {
- if((dwTickCount >= QDN_MotorDelay))
- {
- //夹子已经张开
- AxisMovePosAccDec(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH),
- QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,10,10,0);
- // AxisMovePos(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH));
- QDN_MotorStep = 42;
- }
- }
- else
- {
- if((dwTickCount >= QDN_MotorDelay))
- {
- AxisMovePosAccDec(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_Secondleave_LENGTH+QDN_PARAM_BACK_LENGTH),
- QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,10,10,0);
- // AxisMovePos(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH));
- QDN_MotorStep = 42;
- }
- }
- break;
- case 42:
- if(!QDN_SecondXiaQueStep)
- {
- if(((QDN_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- {
- QDN_JD_VAVLE = 0;
- }
- }
- else
- {
- if(((QDN_PARAM_Secondleave_LENGTH) <= (cRealPos - jz_buff)))
- {
- QDN_JD_VAVLE = 0;
- }
- }
-
- if(!X_DRV)
- {
- QDN_JD_VAVLE = 0;
- QDN_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QDN_MotorStep = 0;
- QDN_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- QDN_BL_VAVLE = 0;//并链也要打开
- if(dwTickCount >= QDN_MotorDelay)
- {
-
-
- // QDN_JZ_DIR = QDN_YDIR_N;
- if(!QDN_TL_VAVLE && cZipCnt) //没送链情况下主动送链
- {
- if(!QDN_SHANG_MU_LIMIT_IN && (QDN_TuiLianStep == 0))
- {
- QDN_TuiLianStep = 1;
- QDN_MotorStep = 62;
- }
- }
- else
- QDN_MotorStep = 62;
- }
- break;
- case 62:
- if(dwTickCount >= QDN_MotorDelay)
- {
- if(QDN_QIAN_LIMIT_IN)
- {
- SetPos(X_AXIS, 0);//在前点,直接置零点
- //前点亮的情况下先退出
- AxisMovePos(X_AXIS,QDN_PARAM_GO_LOW_SPEED,1000);
- QDN_MotorDelay = dwTickCount + 300;
- }
- QDN_MotorStep = 63;
- QDN_JD_VAVLE = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QDN_QIAN_LIMIT_IN && (dwTickCount >= QDN_MotorDelay))// && !QDN_SHANG_MU_LIMIT_IN)
- {
- //SetDir(X_AXIS, QDN_DIR_N);
- go_buff = cRealPos;
- QDN_YD_VAVLE = 1;
- // QDN_HL_VAVLE = 1;
- // QDN_YX_VAVLE = 1;
- //李永庆代码,当位置在慢速之外,走数控到慢速点
- if(cZipCnt > 0)
- {
-
- if(cRealPos>(QDN_PARAM_GO_LOW_SPEED_LENGTH))
- {
-
- // AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos-QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- // SetStartSpeed(X_AXIS,QDN_PARAM_START_SPEED);
- // SetAccTime(X_AXIS,QDN_PARAM_ACC);
- // SetDecTime(X_AXIS,QDN_PARAM_DCC);
- //两段速度移动距离
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos-QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED_LENGTH+ 100,QDN_DIR_N);
- //跑三段速度
- // AxisMoveThreePosNoStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos -QDN_PARAM_GO_LOW_SPEED_LENGTH-300,
- // QDN_PARAM_GO_HIGH_SPEED*2/3,350,
- // QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_DIR_N) ;
-
- AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,-(cRealPos -QDN_PARAM_GO_LOW_SPEED_LENGTH),
- QDN_PARAM_START_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED/3,QDN_PARAM_GO_LOW_SPEED/3,15,15);
-
- // MoveAction_Const_AccDec(X_AXIS, QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
- }
-
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED/3,QDN_PARAM_GO_LOW_SPEED/3,15,15);
- // MoveAction_Const_AccDec(X_AXIS, QDN_DIR_N,QDN_PARAM_FIRST_GO_HIGHSPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);//
- }
-
- QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDN_MotorStep =64;
- }
-
- break;
- case 64:
- if(cZipCnt > 1)
- {
- //李永庆代码
- if(((cRealPos) < (QDN_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QDN_QIAN_DEC_IN))
- {
- //user_datas[126]= GetCurSpeed(X_AXIS);
- // MoveChangSpeedDec(X_AXIS,QDN_PARAM_GO_HIGH_SPEED*2/3,6,8);
- // AxisChangeSpeed(X_AXIS,40);
- QDN_MotorStep =65;
- }
- if(QDN_QIAN_LIMIT_IN) //前点限位
- {
- SetPos(X_AXIS, QDN_PARAM_BKQIANDIAN_LENGTH);
- //AxisEgmStop(X_AXIS);
- QDN_MotorStep = 66;
- }
- }
- else
- {
- if(QDN_QIAN_LIMIT_IN) //前点限位
- {
- //AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, QDN_PARAM_BKQIANDIAN_LENGTH);
- QDN_MotorStep = 66;
- }
- }
- break;
- case 65:
- if(QDN_QIAN_LIMIT_IN)
- {
-
- //AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, QDN_PARAM_BKQIANDIAN_LENGTH);
- QDN_MotorStep = 66;
-
- }
- else if(dwTickCount >= QDN_MotorDelay)
- QDN_SetAlarmCode(QDN_NO_ZIPPER_ALARM);
-
- break;
- case 66:
- if(!X_DRV || cRealPos<=0)
- {
- AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, 0);
- QDN_MotorDelay = dwTickCount + 15;
- QDN_MotorStep = 67;
- }
- break;
- case 67: //等推链完成后,
- if((dwTickCount >= QDN_MotorDelay) && (QDN_TuiLianStep == 0) && ((QDN_PARAM_TIAOSHI_MODE && QDN_bTS) || (QDN_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QDN_JD_VAVLE = 1;
- QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
- }
- QDN_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= QDN_MotorDelay)
- {
- QDN_YD_VAVLE = 0;
-
- // QDN_HL_VAVLE = 0;
- // QDN_YX_VAVLE = 0;
- QDN_TL_VAVLE = 0;
- QDN_MotorStep = 0;
- QDN_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- #endif
- //电机动作
- void QueDuan_Motor(void)
- {
- if(QDN_PARAM_KAIBEE_SELECT) //闭口
- {
-
- QueDuan_Motor_NoGL();
-
- }
- else //开口
- {
- //开口
- QueDuan_Motor_KK(); //
- }
- // switch(QDN_MACHINE_TYPE)
- // {
- // case QDN_NO_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
- // case QDN_NO_GL_TUIFANGKUAI: QueDuan_Motor_NoGL();break;
- // case QDN_CS_TUIFANGKUAI:break;
- // default:;
- // }
- }
- //超声方式下切,开口专用
- void QueDuan_XiaQue_KK(void)
- {
- switch(QDN_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- /*
- if(bRunning)
- {
- QDN_XiaQieStep = 6;
- QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- if(QDN_SAFE_IN)
- {
- bStop = 1;
- QDN_XM_VAVLE = 0;
- }
- }
- else
- */
- QDN_XiaQieStep = 2;
- break;
- case 2:
- QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_XiaQieStep = 3;
- break;
- case 3:
- if(1)
- {
- QDN_XiaQieDelay = dwTickCount + 0;//QDN_PARAM_GZ_DELAY;
- QDN_XiaQieStep = 4;
- }
- else if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_SetAlarmCode(QDN_XM_DAOWEI);
- }
- break;
- case 4:
- if(QDN_GZ_VAVLE) //勾针已经有输出就不需要延时
- {
- QDN_XiaQieDelay = dwTickCount + 0;
- }
- else
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
- QDN_GZ_VAVLE = 1;
- cTuiFangKuaiCnt=0;
- QDN_XiaQieStep = 5;
-
- break;
- case 5:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_TFK_VAVLE = 1;
- QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_XiaQieStep = 6;
- }
- break;
- case 6:
- if(1)
- {
- QDN_XiaQieStep = 7;
- QDN_XiaQieDelay = dwTickCount + 1000;
- }
- else if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- QDN_TFK_VAVLE=0;
- QDN_GZ_VAVLE=0;
- }
- break;
- case 7:
- if(QDN_GOUZHEN_QIAN_IN /*| !bRunning*/ )
- {
- cTuiFangKuaiCnt = 0;
- //QDN_YD_VAVLE = 1;
- if(!bRunning)
- QDN_XiaQieDelay = dwTickCount + 200;
- else
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CUT_DELAY;
-
- if(!QDN_QIAN_LIMIT_IN)
- {
- QDN_XiaQieStep = 8;
- }
- else
- {
- QDN_SetAlarmCode(QDN_QIAN_LIMIT_ALARM);
- QDN_TFK_VAVLE=0;
- QDN_GZ_VAVLE=0;
- }
- }
- else if((dwTickCount >= QDN_XiaQieDelay))
- {
- if(cTuiFangKuaiCnt < QDN_PARAM_TFK_NUMBER)
- {
- QDN_TFK_VAVLE = 0;
- cTuiFangKuaiCnt++;
- QDN_XiaQieDelay = dwTickCount + 500;
- QDN_XiaQieStep = 100;
- }
- else
- {
- QDN_SetAlarmCode(QDN_GZ_ALARM);
- QDN_TFK_VAVLE=0;
- QDN_GZ_VAVLE=0;
- }
- }
- break;
- case 100:
- if((dwTickCount >= QDN_XiaQieDelay))
- {
- QDN_XiaQieStep = 5;
- }
- break;
- case 8://上下模同时输出
- if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_SM_VAVLE = 1;
- if(QDN_PARAM_XM_ENABLE == 0) //配置下模动
- QDN_XM_KAIKOU_VAVLE=1;
- QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_XiaQieStep = 9;
- }
- break;
- case 9://上下模到位,调试模下的话,等按下一步按键 下模不动
- if(QDN_SHANG_MU_LIMIT_IN && (QDN_KAIKUO_XIAMO_LIMIT_IN || QDN_PARAM_XM_ENABLE) && ((QDN_bTiaoShiMode && QDN_bTiaoShiStep) || (QDN_bTiaoShiMode == 0)) )
- {
- if(!QDN_PARAM_CS_MODE) //无超声配置
- {
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_DELAYBACK_SM; //
- QDN_XiaQieStep = 12;
- }
- else
- {
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_DELAY_CS; //
- QDN_XiaQieStep = 10;
- }
- }
- else if(dwTickCount >= QDN_XiaQieDelay)
- {
- if(!QDN_SHANG_MU_LIMIT_IN)QDN_SetAlarmCode(QDN_SM_DAOWEI);
- else QDN_SetAlarmCode(QDN_XM_DAOWEI);
- }
- break;
- case 10:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
-
- QDN_CS_OUT = 1;
- //
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CS_TIME; //
- QDN_XiaQieStep = 11;
- }
- break;
- case 11:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_CS_OUT = 0;
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CS_COLD_TIME; //
- QDN_XiaQieStep = 12;
- }
- break;
- case 12:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
-
- QDN_SM_VAVLE = 0;
- if(QDN_PARAM_XM_ENABLE == 0) //配置下模动
- QDN_XM_KAIKOU_VAVLE=0;
- if(!QDN_PARAM_TFK_SELECT) //切断后推方块退
- QDN_TFK_VAVLE = 0;
- QDN_GZ_VAVLE = 0;
- QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QDN_XiaQieStep = 13;
- }//
- break;
- case 13:
- if(!QDN_SHANG_MU_LIMIT_IN)
- {
- //启动推链(送链)
- if((QDN_TuiLianStep == 0) && !QDN_TL_VAVLE)
- QDN_TuiLianStep = 1;
- }
- if(!QDN_SHANG_MU_LIMIT_IN && (!QDN_KAIKUO_XIAMO_LIMIT_IN || QDN_PARAM_XM_ENABLE))
- {
- QDN_XiaQieStep = 0;
- }
- else if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_SetAlarmCode(QDN_SM_YUANWEI);
- }
- break;
- }
- }
- void QueDuan_TuiLianAction(void)
- {
- if(QDN_PARAM_XM_ENABLE == 0)
- {
- QDN_TuiLianStep = 0;
- }
- else
- {
- switch(QDN_TuiLianStep)
- {
- case 1:
- QDN_TuiLianStep = 2;
- break;
- case 2:
- QDN_TLDelay = dwTickCount + QDN_PARAM_YD_DELAY;
- QDN_TuiLianStep = 3;
- break;
- case 3:
- if(!QDN_SM_VAVLE && !QDN_SHANG_MU_LIMIT_IN)//dwTickCount >= QDN_TLDelay)
- {
- QDN_TL_VAVLE = 1;
- if(!bRunning)QDN_TFK_VAVLE = 0;
- QDN_TLDelay = dwTickCount + QDN_PARAM_TL_DELAY;
- QDN_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QDN_TLDelay)
- {
- QDN_TuiLianStep = 0;
- }
- break;
- case 10:
-
- QDN_TuiLianStep = 11;
- break;
- case 11:
- if(!Y_DRV)
- {
- {
- QDN_TuiLianStep = 0;
- }
- }
- break;
- }
- }
- }
- //闭口专用
- void QueDuan_XiaQue_NO_GL(void)
- {
- switch(QDN_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- if(!bRunning)
- {
- if(/*(QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI) && */QDN_SK_MODE)
- {
- //跳到双开
- // QDN_YD_VAVLE = 1;
- QDN_GZ_VAVLE = 1; //勾针
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CUT_DELAY;
- QDN_XiaQieStep = 100;
- }
- else
- {
- // QDN_GZ_VAVLE = 1; //勾针
-
- // QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CUT_DELAY;
- // QDN_XiaQieStep = 100;
- QDN_YD_VAVLE = 1;
- QDN_XiaQieStep = 2;
- QDN_XiaQieDelay = dwTickCount + 30;
- }
- }
- else
- {
- QDN_YD_VAVLE = 1;
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CUT_DELAY;
- QDN_XiaQieStep = 2;
- }
- break;
- case 2:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_XiaQieStep = 3;
- QDN_XiaQieDelay = dwTickCount;
- }
- break;
- case 3:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
- if((QDN_PARAM_TIAOSHI_MODE && QDN_bTS) || (QDN_PARAM_TIAOSHI_MODE == 0))
- {
- QDN_SM_VAVLE = 1;
- if(QDN_PARAM_XM_ENABLE == 0) //配置下模动
- QDN_XM_VAVLE = 1;
- QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QDN_XiaQieStep = 4;
- }
- }
- break;
- case 4:
- if(QDN_SHANG_MU_LIMIT_IN && (QDN_XIA_MU_LIMIT_IN || QDN_PARAM_XM_ENABLE))
- {
- QDN_GZ_VAVLE = 0;
- if(!QDN_PARAM_CS_MODE) //气切
- {
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_DELAYBACK_SM; //
- QDN_XiaQieStep = 5;
- }
- else
- {
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_DELAY_CS; //
- QDN_XiaQieStep = 10;
- } //
- }
- else if(dwTickCount >= QDN_XiaQieDelay)
- {
- if(!QDN_SHANG_MU_LIMIT_IN)
- QDN_SetAlarmCode(QDN_SM_DAOWEI);
- else
- QDN_SetAlarmCode(QDN_XM_DAOWEI);
- }
- break;
- case 5:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
-
- QDN_SM_VAVLE = 0;
- if(QDN_PARAM_XM_ENABLE == 0) //配置下模动
- QDN_XM_VAVLE = 0;
- QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QDN_XiaQieStep = 6;
- }
- break;
- case 6:
- if(!QDN_SHANG_MU_LIMIT_IN && (!QDN_XIA_MU_LIMIT_IN || QDN_PARAM_XM_ENABLE)) //下模不动就不用判断
- {
- if(QDN_TuiLianStep == 0)
- QDN_TuiLianStep = 1;
- if(!bRunning)
- QDN_JD_VAVLE = 0;
- QDN_XiaQieStep = 0;
- }
- else if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_SetAlarmCode(QDN_SM_YUANWEI);
- }
-
- break;
- //10~11步为超声
- case 10:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
- if(QDN_PARAM_CS_ENABLE)QDN_CS_OUT = 1;
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CS_TIME; //
- QDN_XiaQieStep = 11;
- }
- break;
- case 11:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
- QDN_CS_OUT = 0;
- QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CS_COLD_TIME; //
- QDN_XiaQieStep = 5;
- }
- break;
- case 100:
- if(dwTickCount >= QDN_XiaQieDelay)
- {
-
- //这是双开程序,暂时不考虑
- #if 1
- if(QDN_GOUZHEN_HOU_IN)
- {
- QDN_YD_VAVLE = 1;
- QDN_XiaQieStep = 3;
- }
- #endif
- }
- break;
- }
- }
- //第二刀下切步骤
- void QueDuan_SecondXiaQue(void)
- {
-
- switch(QDN_SecondXiaQueStep)
- {
- case 1:
- if(dwTickCount >= QDN_SecondXQDelay)
- {
- QDN_SecondXiaQueStep = 2;
- if(QDN_MotorStep == 0)
- {
- QDN_MotorStep = 61; //前点定位
- }
- }
- break;
- case 2:
- if(QDN_MotorStep == 0)
- {
- QDN_SecondXiaQueStep = 3;
- QDN_SecondXQDelay = dwTickCount + 20;
-
- }
- break;
- case 3:
- if(dwTickCount >= QDN_SecondXQDelay)
- {
- AxisMovePosAccDec(X_AXIS,1000,QDN_PARAM_SecondDAO_LENGTH,1000,1000,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
- QDN_SecondXiaQueStep = 4;
- }
- break;
- case 4:
- if(!X_DRV)
- {
-
- QDN_XiaQieStep=1;
- QDN_SecondXiaQueStep = 5;
-
- }
- break;
- case 5:
- if((QDN_XiaQieStep == 0) || ((QDN_XiaQieStep == 6) && (QDN_PARAM_KAIBEE_SELECT == 1)))
- {
- if(QDN_MotorStep == 0)
- {
- QDN_MotorStep = 40; //切完后退
-
- }
- QDN_SecondXiaQueStep = 6;
- }
- break;
- case 6:
- if(QDN_MotorStep == 0)
- {
- QDN_SecondXiaQueStep = 0;
- if(NQDJGNUNMBER==0)
- QDN_AutoStep = 6;
- else if(NQDJGNUNMBER==1)
- QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
- else if(NQDJGNUNMBER==2)
- QDN_SetAlarmCode(QDN_LENGTH_SHORT_ALARM);
- }
- break;
-
-
- }
- }
- //切断动作
- void QueDuan_XiaQue(void)
- {
-
- if(QDN_PARAM_KAIBEE_SELECT)//QDN_KB_MODE) //闭口
- {
- QueDuan_XiaQue_NO_GL(); //
- }
- else //开口
- {
- QueDuan_XiaQue_KK();
- }
- #if 0
- switch(QDN_MACHINE_TYPE)
- {
- case QDN_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
- case QDN_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- case QDN_CS_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- default:;
- }
- #endif
- }
- #endif
|