JHQueduanChuantou.c 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735
  1. #include "global.h"
  2. #if JIN_HONG_MACHINE==1
  3. unsigned short cTaiMiamMotor;
  4. unsigned long cSlowPusle;
  5. unsigned char bDecEn,cXiaMo_En,cHemo_OK,cQTltOK,cHTltOk,cQHsltOK,cHHsltOK,cSL_En;
  6. unsigned char bStartOnceTime,bOnceProcess,cBackLimitCheck_EN;
  7. unsigned short cWorkCnt;
  8. unsigned char QTryCnt = 0, HTryCnt = 0;
  9. unsigned short cZhaCnt = 0;
  10. unsigned char QZhuangLiaoOkFlg = 0,HZhuangLiaoOkFlg = 0;
  11. unsigned char QTuiLaTouOkFlg = 0,HTuiLaTouOkFlg = 0;
  12. unsigned char ManFlg;
  13. unsigned char cStopFlg = 0, cResetOrigin_Flag= 0,cCheck_Go_In_Flag;
  14. unsigned char cFirstQStartFlg = 0,cFirstHStartFlg = 0;
  15. unsigned char cCountFlg = 0,cQDCT_TuiLianOKFlag = 0;
  16. short *qdct_length_buff;
  17. long save_limit_pos, cDinWeiPos;
  18. unsigned char cTuiLianStep,cChuan_LianCheckOK = 0,cChuan_Lian_ErrorNum,cSongLaTouEn = 0,cCheckDinWei;
  19. unsigned char KaDaiFlag = 0;
  20. long KaDaiSaveLen,KaDaiSaveLenY;
  21. unsigned char LengthType;
  22. unsigned long CutRemainLength;
  23. long temppos;
  24. void QDCT_ManualAction(void);
  25. void QDCT_JiaLianAction(void);
  26. void QDCT_AutoStepAction(void);
  27. void QDCT_QZhenDongAction(void);
  28. void QDCT_HZhenDongAction(void);
  29. void QDCT_TableAction(void);
  30. void QDCT_Motor(void);
  31. void QDCT_CheckStart(void);
  32. void QDCT_QTuiLT_Step(void);
  33. void QDCT_HTuiLT_Step(void);
  34. void QDCT_XiaQieAction(void);
  35. void QDCT_AlarmProtect(void);
  36. void QDCT_QZLT_Step(void);
  37. void QDCT_HZLT_Step(void);
  38. void QDCT_TuiLian(void);
  39. void QDCT_TuiLianAction(void);
  40. void QDCT_HeMo_Step(void);//装拉头完成合模动作
  41. void QDCT_TestMotor(void);
  42. void QDCT_ExtiActionX31(void)
  43. {
  44. }
  45. void QDCT_SeBiaoAction(void)
  46. {
  47. if(QDCT_SEBIAO_IN_DW)
  48. {
  49. if(cSeBiaoEn && !cSeBiaoOk)
  50. {
  51. cSeBiaoEn = 0;
  52. cSeBiaoOk = 1;
  53. if(QDCT_XM_OUT)
  54. {
  55. AxisChangeSpeedDirect(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED);
  56. }
  57. //user_datas[126] = dwXRealPos;
  58. cDinWeiPos = dwXRealPos;
  59. }
  60. }
  61. }
  62. //故障报警
  63. void QDCT_SetAlarmCode(unsigned alarm_code)
  64. {
  65. SetAlarmCode(QDCT_ALARM_ADDR,alarm_code);
  66. if(alarm_code != QDCT_KD_ALARM)
  67. QDCT_bAlarmStop = 1;
  68. }
  69. //初始化动作
  70. void QDCT_InitAction(void)
  71. {
  72. float buff_pulse,buff_dist;
  73. buff_pulse = QDCT_PARAM_CYCLE_PULSE;
  74. buff_dist = QDCT_PARAM_CYCLE_LENGTH;
  75. XGearRatio = buff_pulse/buff_dist;
  76. buff_pulse = QDCT_PARAM_YLCYCLE_PULSE;
  77. buff_dist = QDCT_PARAM_YLCYCLE_LENGTH;
  78. YGearRatio = buff_pulse/buff_dist;
  79. //QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
  80. SetEnReverse(X_AXIS, 0);
  81. SetEn(X_AXIS, QDCT_MOTOR_DISEN);
  82. SetEn(Y_AXIS, QDCT_MOTOR_DISEN);
  83. QDCT_QZDPStep= 1;
  84. QDCT_HZDPStep= 1;
  85. QDCT_TLPStep = 1;
  86. cWorkCnt = 0;
  87. cZhaCnt = 0;
  88. dwZipCnt = 0;
  89. cBackLimitCheck_EN = 1;
  90. if(QDCT_PARAM_MAX_BACK_LENGTH < 13000) QDCT_PARAM_MAX_BACK_LENGTH = 25000;
  91. SetAlarmCode(QDCT_ALARM_ADDR,QDCT_NO_ALARM);
  92. SetDirReverse(X_AXIS, 0);
  93. //设置加减速模式
  94. //axis_set_parameter(axis_x, AXIS_ACCDEC_MODE,QDCT_SEBIAO_LOW_SPEED);
  95. }
  96. void QDCT_Action(void)
  97. {
  98. //设置加减速模式
  99. //axis_set_parameter(axis_x, AXIS_ACCDEC_MODE,QDCT_SEBIAO_LOW_SPEED);
  100. //InputPinConfig();
  101. QDCT_SeBiaoAction();
  102. QDCT_TuiLian();
  103. QDCT_AlarmProtect();
  104. QDCT_QZhenDongAction();
  105. QDCT_HZhenDongAction();
  106. QDCT_CheckStart();
  107. QDCT_QZLT_Step();
  108. QDCT_HZLT_Step();
  109. QDCT_TableAction();
  110. QDCT_QTuiLT_Step();
  111. QDCT_HTuiLT_Step();
  112. QDCT_JiaLianAction();
  113. QDCT_XiaQieAction();
  114. QDCT_Motor();
  115. QDCT_ManualAction();
  116. QDCT_AutoStepAction();
  117. QDCT_HeMo_Step();
  118. QDCT_TestMotor();
  119. //OutputPinConfig();
  120. }
  121. unsigned char cTestMotorStep;
  122. unsigned long cTesttime;
  123. void QDCT_TestMotor(void)
  124. {
  125. switch(cTestMotorStep)
  126. {
  127. //1到10步为回到原点
  128. case 1:
  129. //QDCT_SZ_OUT = QDCT_MOTOR_EN; //锁轴
  130. SetEn(X_AXIS, QDCT_MOTOR_EN);
  131. QDCT_TestMotorDelay = dwTickCount + 50;
  132. cTestMotorStep = 2;
  133. break;
  134. case 2:
  135. if(dwTickCount >= QDCT_TestMotorDelay)//锁轴时间到
  136. {
  137. AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_GO_LOWSPEED, QDCT_DIR_N,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,10,10);
  138. cTestMotorStep= 3;
  139. }
  140. break;
  141. case 3: //回到原点
  142. if(QDCT_GO_LIMIT_IN) //最前点感应
  143. {
  144. AxisEgmStop(X_AXIS);
  145. QDCT_TestMotorDelay = dwTickCount + 50;
  146. cTestMotorStep= 4;
  147. SetPos(X_AXIS, 0);
  148. }
  149. break;
  150. case 4:
  151. if(!X_DRV)
  152. {
  153. QDCT_TestMotorDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
  154. cTestMotorStep= 5;
  155. }
  156. break;
  157. case 5:
  158. if(dwTickCount >= QDCT_TestMotorDelay)
  159. {
  160. if(1)//QDCT_bTest)
  161. {
  162. QDCT_bTest = 0;
  163. cTestMotorStep= 6;
  164. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_SET_ZIPPER_LENGTH,
  165. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  166. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,100);
  167. // AxisMovePointAccDec(unsigned short axis,unsigned short speed,long pos,unsigned short start_speed,unsigned short acc_pulse,unsigned short dec_pulse)
  168. // AxisMovePoint(X_AXIS,QDCT_PARAM_JJBACK_SPEED,-QDCT_PARAM_SET_ZIPPER_LENGTH);
  169. cTesttime = dwTickCount;
  170. }
  171. }
  172. break;
  173. case 6:
  174. if(!X_DRV)
  175. {
  176. QDCT_TestMotorDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
  177. cTestMotorStep= 7;
  178. }
  179. break;
  180. case 7:
  181. if(dwTickCount >= QDCT_TestMotorDelay)
  182. {
  183. if(1)//QDCT_bTest)
  184. {
  185. QDCT_bTest = 0;
  186. cTestMotorStep= 8;
  187. // MoveAction_Pulse2_AccDec(X_AXIS,PosToPulse(X_AXIS,-(QDCT_PARAM_SET_ZIPPER_LENGTH)),PosToPulse(X_AXIS,-QDCT_PARAM_SET_ZIPPER_LENGTH/2),PosToPulse(X_AXIS,-QDCT_PARAM_SET_ZIPPER_LENGTH/2),5,5,QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  188. // AxisMove(X_AXIS,QDCT_PARAM_JJGO_SPEED,-(QDCT_PARAM_SET_ZIPPER_LENGTH-600),QDCT_PARAM_JJGO_SPEED/2,-600,QDCT_DIR
  189. // AxisMovePos(X_AXIS,QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_SET_ZIPPER_LENGTH);
  190. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,-QDCT_PARAM_SET_ZIPPER_LENGTH,
  191. QDCT_PARAM_START_SPEED,QDCT_PARAM_GO_LOWSPEED,
  192. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,500);
  193. // AxisMovePointAccDec(unsigned short axis,unsigned short speed,long pos,unsigned short start_speed,unsigned short acc_pulse,unsigned short dec_pulse)
  194. // AxisMovePoint(X_AXIS,QDCT_PARAM_JJGO_SPEED,0);
  195. cTesttime = dwTickCount;
  196. }
  197. }
  198. break;
  199. case 8:
  200. if(!X_DRV)
  201. {
  202. // if(dwXRealPos <= (QDCT_PARAM_SET_ZIPPER_LENGTH/2))
  203. // {
  204. // MoveChangSpeed(X_AXIS,5);
  205. cTestMotorStep= 4;
  206. // }
  207. }
  208. break;
  209. }
  210. }
  211. //
  212. void QDCT_TuiLian(void)
  213. {
  214. if(cQDCT_TuiLianOKFlag && (QDCT_YD_OUT && QDCT_SL_OUT))
  215. {
  216. QDCT_TuiLianStep = 0;
  217. return;
  218. }
  219. switch(QDCT_TuiLianStep)
  220. {
  221. case 0:
  222. break;
  223. case 1:
  224. QDCT_TuiLianStep = 2;
  225. QDCT_YD_OUT = 1;
  226. break;
  227. case 2:
  228. QDCT_TLDelay = dwTickCount+QDCT_PARAM_DELAY_SL;
  229. QDCT_TuiLianStep = 3;
  230. break;
  231. case 3:
  232. if(dwTickCount >= QDCT_TLDelay)
  233. {
  234. if(QDCT_PARAM_XM_MODE) QDCT_SL_OUT = 1;
  235. QDCT_TLDelay = dwTickCount;
  236. QDCT_TuiLianStep = 4;
  237. cQDCT_TuiLianOKFlag = 1;
  238. }
  239. break;
  240. case 4:
  241. if(dwTickCount >= QDCT_TLDelay)
  242. {
  243. QDCT_TuiLianStep = 0;
  244. }
  245. break;
  246. }
  247. }
  248. //前振动
  249. void QDCT_QZhenDongAction(void)
  250. {
  251. switch(QDCT_QZDPStep)
  252. {
  253. case 1:
  254. if((dwTickCount >= QDCT_QZhenDongDelay))
  255. {
  256. if(!QDCT_PARAM_QLT_ON && bRunning)
  257. {
  258. QDCT_QZDP_OUT = 0;
  259. QDCT_QZDPStep = 0;
  260. }
  261. else
  262. {
  263. if(!QDCT_QZDP_IN)
  264. {
  265. QDCT_QZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_DELAY_WORK;
  266. QDCT_QZDPStep = 2;
  267. }
  268. else
  269. {
  270. QDCT_QZDP_OUT = 0;
  271. }
  272. }
  273. }
  274. break;
  275. case 2:
  276. if((dwTickCount >= QDCT_QZhenDongDelay))
  277. {
  278. QDCT_QZDP_OUT = 1;
  279. if(QDCT_QZDP_IN)
  280. {
  281. QDCT_QZDPStep = 3;
  282. QDCT_QZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_WORK_TIME;
  283. }
  284. }
  285. break;
  286. case 3:
  287. if((QDCT_QZDPStep == 3) && (dwTickCount >= QDCT_QZhenDongDelay))
  288. {
  289. if(QDCT_QZDP_IN)
  290. {
  291. QDCT_QZDPStep = 1;
  292. QDCT_QZDP_OUT = 0;
  293. }
  294. else
  295. {
  296. QDCT_QZDPStep = 2;
  297. }
  298. }
  299. break;
  300. }
  301. //打拉片,两个共用一个盘
  302. if((QDCT_TLPStep == 1) && (dwTickCount >= QDCT_TLPDelay))
  303. {
  304. if((QDCT_QZDP_OUT | QDCT_HZDP_OUT) && QDCT_PARAM_TLP_ENABLE)
  305. {
  306. QDCT_TLPStep = 2;
  307. QDCT_TLPDelay = dwTickCount + QDCT_PARAM_TLP_TIME;
  308. QDCT_TLP_OUT = 1;
  309. }
  310. }
  311. else if((QDCT_TLPStep == 2) && (dwTickCount >= QDCT_TLPDelay))
  312. {
  313. QDCT_TLPStep = 1;
  314. QDCT_TLPDelay = dwTickCount + QDCT_PARAM_TLP_TIME;
  315. QDCT_TLP_OUT = 0;
  316. }
  317. if(QDCT_QZDP_OUT || QDCT_HZDP_OUT)
  318. {
  319. QDCT_ZDPCQ_OUT = 1;
  320. }
  321. else
  322. {
  323. QDCT_ZDPCQ_OUT = 0;
  324. }
  325. }
  326. //后振动盘
  327. void QDCT_HZhenDongAction(void)
  328. {
  329. switch(QDCT_HZDPStep)
  330. {
  331. case 1:
  332. if((dwTickCount >= QDCT_HZhenDongDelay))
  333. {
  334. //后拉头使能
  335. if(!QDCT_PARAM_HLT_ON && bRunning)
  336. {
  337. QDCT_HZDP_OUT = 0;
  338. QDCT_HZDPStep = 0;
  339. }
  340. else
  341. {
  342. if(!QDCT_HZDP_IN)
  343. {
  344. QDCT_HZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_DELAY_WORK;
  345. QDCT_HZDPStep = 2;
  346. }
  347. else
  348. {
  349. QDCT_HZDP_OUT = 0;
  350. }
  351. }
  352. }
  353. break;
  354. case 2:
  355. if((dwTickCount >= QDCT_HZhenDongDelay))
  356. {
  357. QDCT_HZDP_OUT = 1;
  358. if(QDCT_HZDP_IN)
  359. {
  360. QDCT_HZDPStep = 3;
  361. QDCT_HZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_WORK_TIME;
  362. }
  363. }
  364. break;
  365. case 3:
  366. if((dwTickCount >= QDCT_HZhenDongDelay))
  367. {
  368. if(QDCT_HZDP_IN)
  369. {
  370. QDCT_HZDPStep = 1;
  371. QDCT_HZDP_OUT = 0;
  372. }
  373. else
  374. {
  375. QDCT_HZDPStep = 2;
  376. }
  377. }
  378. break;
  379. }
  380. }
  381. void QDCT_AlarmProtect(void)
  382. {
  383. static unsigned short ka_dai_cnt;
  384. dwXRealPos = GetPos(X_AXIS);
  385. dwYRealPos = GetPos(Y_AXIS);
  386. if(QDCT_PARAM_BACK_ALARM_MODE)
  387. { //感应后限模式
  388. if(!bRunning)
  389. {
  390. if(QDCT_BACK_LIMIT_IN_UP)
  391. {
  392. if(X_DRV && (QDCT_bMotorBack) || (QDCT_MotorStep != 0)) //到后限不能再后退但可以点前进
  393. {
  394. QDCT_bMotorBack = 0;
  395. AxisEgmStop(X_AXIS);
  396. QDCT_JD_OUT = 0;
  397. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  398. user_datas[128] = 1;
  399. }
  400. }
  401. }
  402. else
  403. {
  404. if(QDCT_BACK_LIMIT_IN)
  405. {
  406. if((dwTickCount >= QDCT_MotorBackLimitDelay) && cBackLimitCheck_EN && X_DRV)
  407. {
  408. AxisEgmStop(X_AXIS);
  409. QDCT_JD_OUT = 0;
  410. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  411. }
  412. }
  413. else
  414. {
  415. QDCT_MotorBackLimitDelay = dwTickCount + 30;
  416. }
  417. }
  418. }
  419. else //软件限位
  420. {
  421. }
  422. if(QDCT_KA_DAI_IN)
  423. {
  424. if(ka_dai_cnt < 110)ka_dai_cnt++;
  425. }
  426. else
  427. {
  428. ka_dai_cnt = 0;
  429. // if(GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_KD_ALARM)QDCT_SetAlarmCode(QDCT_NO_ALARM);
  430. }
  431. if(ka_dai_cnt > 100)
  432. {
  433. QDCT_YD_OUT = 0;
  434. if(bRunning)
  435. {
  436. QDCT_SetAlarmCode(QDCT_KD_ALARM);
  437. if(KaDaiFlag==0)
  438. {
  439. KaDaiSaveLen = dwXRealPos;
  440. KaDaiSaveLenY = dwYRealPos;
  441. KaDaiFlag = 1;
  442. }
  443. }
  444. }
  445. }
  446. void QDCT_JiaLianAction(void)
  447. {
  448. switch(QDCT_JiaLianStep)
  449. {
  450. case 1:
  451. QDCT_JD_Delay = dwTickCount + QDCT_PARAM_JD_DELAY;
  452. QDCT_JiaLianStep = 2;
  453. break;
  454. case 2:
  455. if(dwTickCount >= QDCT_JD_Delay)
  456. {
  457. QDCT_JD_OUT = 1;
  458. QDCT_JD_Delay = dwTickCount + QDCT_PARAM_DELAY_KL;
  459. QDCT_JiaLianStep = 3;
  460. }
  461. break;
  462. case 3:
  463. if((dwTickCount >= QDCT_JD_Delay))
  464. {
  465. if(!QDCT_PARAM_QLT_ON && !QDCT_PARAM_HLT_ON)
  466. {
  467. QDCT_JD_Delay = dwTickCount;
  468. QDCT_YD_OUT = 0;
  469. QDCT_JiaLianStep = 4;
  470. }
  471. else
  472. {
  473. QDCT_CQ_OUT = 1;
  474. //QDCT_KL_OUT = 1;
  475. QDCT_CQDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
  476. QDCT_JD_Delay = dwTickCount;
  477. QDCT_JiaLianStep = 4;
  478. }
  479. }
  480. break;
  481. case 4:
  482. if(dwTickCount >= QDCT_JD_Delay)
  483. {
  484. //QDCT_KL_OUT = 0;
  485. QDCT_JiaLianStep = 0;
  486. }
  487. break;
  488. }
  489. }
  490. unsigned char QDCT_CheckLength(void)
  491. {
  492. //无限长度
  493. if(QDCT_LONG_LENGTH_USE)
  494. {
  495. if(QDCT_PARAM_SET_ZIPPER_LENGTH > QDCT_PARAM_TRANS_LENGTH)
  496. return 1;
  497. else
  498. return 0;
  499. }
  500. else
  501. return 0;
  502. }
  503. //自动动作
  504. void QDCT_AutoStepAction(void)
  505. {
  506. static unsigned char jz_over;
  507. if(bRunning)
  508. {
  509. switch(QDCT_AutoStep)
  510. {
  511. case 1:
  512. jz_over = 0;
  513. QTryCnt = 0;
  514. cChuan_Lian_ErrorNum = 0;
  515. QDCT_AutoStep = 2;
  516. if(QDCT_QZDPStep == 0 && !QZDPAutoDisable)
  517. QDCT_QZDPStep = 1;
  518. if(QDCT_HZDPStep == 0 && !HZDPAutoDisable)
  519. QDCT_HZDPStep = 1;
  520. QDCT_AutoDelay = dwTickCount + 5;
  521. if(!QZhuangLiaoOkFlg)
  522. QDCT_QZhuangLiaoStep = 1;//前装料
  523. if(!HZhuangLiaoOkFlg)
  524. QDCT_HZhuangLiaoStep = 1;//后装料
  525. cSL_En = 2; //第一条可不受限制横送料
  526. break;
  527. case 2:
  528. if((QDCT_MotorStep == 0))
  529. {
  530. cSL_En = 2; //第一条可不受限制横送料
  531. if(dwTickCount >= QDCT_AutoDelay)
  532. {
  533. QDCT_AutoStep = 3;
  534. SetAlarmCode(QDCT_ALARM_ADDR,0);
  535. }
  536. user_datas[122]=0;
  537. }
  538. break;
  539. case 3:
  540. if(QDCT_MotorStep == 0)
  541. {
  542. QDCT_MotorStep = 61; //前进定位好后自动夹链和开链
  543. QDCT_AutoStep = 4;
  544. cBackLimitCheck_EN = 0;
  545. }
  546. break;
  547. case 4:
  548. //考虑第一条电机在前点要退出来,第二条后也不可能在前点,不能合模
  549. if(!QDCT_GO_LIMIT_IN || QDCT_JD_OUT)
  550. QDCT_AutoStep = 9;
  551. break;
  552. case 5:
  553. QDCT_AutoStep = 9;
  554. break;
  555. case 6:
  556. QDCT_AutoStep = 7;
  557. break;
  558. case 7:
  559. QDCT_AutoStep = 8;
  560. break;
  561. case 9:
  562. if(((QDCT_GO_LIMIT_IN || dwZipCnt) && !QDCT_PARAM_HM_MODE)
  563. || ((QDCT_MotorStep == 68 || QDCT_MotorStep == 0) && QDCT_PARAM_HM_MODE)) //第一条要到前限位才能合模
  564. {
  565. if((cCheckDinWei == 0) && (QDCT_PARAM_QLT_ON || QDCT_PARAM_HLT_ON))
  566. {
  567. QDCT_HeMoStep = 1;
  568. QDCT_HeMoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  569. }
  570. QTryCnt = 0;
  571. QDCT_AutoStep = 10;
  572. }
  573. break;
  574. case 10:
  575. if((QDCT_MotorStep == 0) && (QDCT_HeMoStep == 0)) //前定位完成,QDCT_GO_LIMIT_IN也肯定有信号
  576. {
  577. cXiaMo_En = 0;
  578. QDCT_AutoStep = 11;
  579. cCheck_Go_In_Flag = 1;
  580. }
  581. break;
  582. case 11:
  583. if((QDCT_MotorStep == 0)) //开始后拉穿入
  584. {
  585. cBackLimitCheck_EN = 1;
  586. if(QDCT_SEBIAO_MODE) //色标模式
  587. {
  588. QDCT_MotorStep = 1;
  589. }
  590. else
  591. {
  592. QDCT_MotorStep = 30;//穿入启动
  593. }
  594. cSL_En = 0; //不受限制横送料
  595. cChuan_LianCheckOK = 0;
  596. QDCT_AutoStep = 12;
  597. }
  598. break;
  599. case 12:
  600. if(((QDCT_MotorStep == 0) || (QDCT_MotorStep == 40)) && !X_DRV)
  601. {
  602. QDCT_AutoStep = 13;
  603. }
  604. break;
  605. case 13:
  606. if(QDCT_CheckLength()) //判断长度转换压轮电机拖带
  607. {
  608. QDCT_AutoStep = 50;
  609. }
  610. else
  611. {
  612. if(LengthType==0)
  613. QDCT_AutoStep = 14;
  614. else
  615. QDCT_AutoStep = 15;
  616. }
  617. break;
  618. case 14:
  619. if((QDCT_XiaQieStep == 0))
  620. {
  621. QDCT_XiaQieStep = 1;
  622. cSL_En = 0; //下切时只横送不能锁紧拉头
  623. QDCT_AutoStep = 15;
  624. }
  625. break;
  626. case 15://拖带完成
  627. if(!X_DRV && !Y_DRV)
  628. {
  629. if(((QDCT_XiaQieStep == 0) || (QDCT_XiaQieStep == 7)) && !QDCT_SQ_LIMIT_IN && (!QDCT_XQ_LIMIT_IN || QDCT_PARAM_XM_MODE))
  630. {
  631. if(QDCT_MotorStep == 0)
  632. {
  633. if(jz_over)//无限长方式由压轮带出拉链
  634. {
  635. jz_over = 0;
  636. QDCT_MotorStepY = 160;
  637. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_YL_SL_DELAY;
  638. }
  639. else
  640. QDCT_MotorStep = 80;
  641. QDCT_AutoStep = 16;
  642. }
  643. }
  644. }
  645. break;
  646. /**/
  647. case 16:
  648. if((QDCT_MotorStep == 0) && (QDCT_CheckLength()==0 || QDCT_MotorStepY==0 || QDCT_MotorStepY==162 || QDCT_MotorStepY==163))
  649. {
  650. cXiaMo_En= 1;
  651. cSL_En = 2; //横送料打开
  652. if(bStartOnceTime)
  653. {
  654. bStartOnceTime = 0;
  655. SingOneFlg = 1;
  656. }
  657. if((QDCT_CHUAN_LIAN_CHECK_SELECT == 0) || (!QDCT_PARAM_QLT_ON && !QDCT_PARAM_HLT_ON) || cChuan_LianCheckOK)
  658. {
  659. CalProSP(QDCT_SPEED_ADDR); //计算生产速度
  660. if(cCheckDinWei == 0)
  661. {
  662. AddToTal(QDCT_TOTAL_ADDR); //生产总量加1并保存
  663. AddToTal(QDCT_NOWTOTAL_ADDR); //生产总量加1并保存
  664. cWorkCnt++;
  665. cZhaCnt++;
  666. QDCT_PARAM_TB_CNT1++;
  667. QDCT_PARAM_TB_CNT2++;
  668. cChuan_Lian_ErrorNum = 0;
  669. if(GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_CLOK_ALARM)
  670. SetAlarmCode(QDCT_ALARM_ADDR,QDCT_NO_ALARM);
  671. }
  672. else
  673. {
  674. SingOneFlg = 1;
  675. }
  676. cCheckDinWei = 0;
  677. if(dwZipCnt < 3)
  678. dwZipCnt++;
  679. }
  680. else
  681. {
  682. cChuan_Lian_ErrorNum++;
  683. if(cChuan_Lian_ErrorNum >= 1)
  684. {
  685. SetAlarmCode(QDCT_ALARM_ADDR,QDCT_CLOK_ALARM);
  686. if(cChuan_Lian_ErrorNum >= 2)
  687. SingOneFlg = 1;
  688. }
  689. }
  690. if(QDCT_PARAM_TB_CNT1 >= QDCT_PARAM_TABLE_NUM)
  691. {
  692. QDCT_TB_OUT = 1;
  693. QDCT_PARAM_TB_CNT1 = 0;
  694. //QDCT_PARAM_TB_CNT2 = 0;
  695. QDCT_TableDelay = dwTickCount + QDCT_PARAM_TABLE_TIME;
  696. }
  697. if((GetTotal(QDCT_TOTAL_ADDR) >= GetTotal(QDCT_SETTOTAL_ADDR)) && (GetTotal(QDCT_SETTOTAL_ADDR) != 0))
  698. {
  699. SetAlarmCode(QDCT_ALARM_ADDR,QDCT_TOTAL_ALARM);
  700. SingOneFlg = 1;
  701. QDCT_AutoStep = 17;
  702. }
  703. else
  704. {
  705. QDCT_AutoStep = 17;
  706. }
  707. }
  708. break;
  709. case 17:
  710. if(GetTotal(QDCT_NOWTOTAL_ADDR) >= QDCT_ZHA_NO) //扎数到
  711. {
  712. //扎数到了,台面输出
  713. QDCT_TB_OUT = 1;
  714. QDCT_PARAM_TB_CNT1 = 0;
  715. QDCT_TableDelay = dwTickCount + QDCT_PARAM_TABLE_TIME2;
  716. ClrcToTal(QDCT_NOWTOTAL_ADDR);
  717. QDCT_AutoDelay = dwTickCount + QDCT_PARAM_CYCLE_DELAY;
  718. if(( QDCT_ZHA_STOP_TIME > 0)) //扎数不能为0
  719. {
  720. if(QDCT_ZHA_NO > 0)
  721. {
  722. QDCT_AutoDelay = dwTickCount + QDCT_ZHA_STOP_TIME;
  723. dwZipCnt = 0;
  724. SetAlarmCode(QDCT_ALARM_ADDR,QDCT_ZHA_ALARM);
  725. }
  726. }
  727. else
  728. {
  729. SetAlarmCode(QDCT_ALARM_ADDR,QDCT_ZHA_ALARM);
  730. SingOneFlg = 1;
  731. }
  732. if(SingOneFlg)
  733. {
  734. SingOneFlg = 0;
  735. QDCT_AutoStep = 0;
  736. bRunning = 0;
  737. //QDCT_HHSL_OUT = 0;
  738. }
  739. else
  740. QDCT_AutoStep = 2;
  741. }
  742. else
  743. {
  744. QDCT_AutoDelay = dwTickCount + QDCT_PARAM_CYCLE_DELAY;
  745. //单条停止
  746. if(SingOneFlg)
  747. {
  748. SingOneFlg = 0;
  749. QDCT_AutoStep = 0;
  750. bRunning = 0;
  751. //QDCT_HHSL_OUT = 0;
  752. }
  753. else
  754. QDCT_AutoStep = 2;
  755. }
  756. break;
  757. case 50:
  758. if(GetEn(Y_AXIS) == QDCT_MOTOR_DISEN)
  759. {
  760. SetEn(Y_AXIS, QDCT_MOTOR_EN);
  761. }
  762. if(QDCT_SYL_OUT && !QDCT_SYL_ORIGIN_IN)
  763. {
  764. QDCT_AutoDelay = dwTickCount + 1;
  765. QDCT_AutoStep = 52;
  766. }
  767. else
  768. {
  769. QDCT_SYL_OUT = 1;
  770. QDCT_AutoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  771. QDCT_AutoStep = 51;
  772. }
  773. break;
  774. case 51:
  775. if(!QDCT_SYL_ORIGIN_IN)
  776. {
  777. QDCT_AutoDelay = dwTickCount + QDCT_PARAM_YL_DELAY;
  778. QDCT_AutoStep = 52;
  779. }
  780. else if(dwTickCount >= QDCT_AutoDelay)
  781. QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
  782. break;
  783. case 52:
  784. if(dwTickCount >= QDCT_AutoDelay)
  785. {
  786. QDCT_YL_OUT = 1;
  787. QDCT_AutoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  788. QDCT_AutoStep = 53;
  789. }
  790. break;
  791. case 53:
  792. if(QDCT_YL_LIMIT_IN)
  793. {
  794. QDCT_AutoDelay = dwTickCount + QDCT_PARAM_YL_DELAY;
  795. QDCT_AutoStep = 54;
  796. }
  797. else if(dwTickCount >= QDCT_AutoDelay)
  798. QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
  799. break;
  800. case 54:
  801. if((dwTickCount >= QDCT_AutoDelay) && (QDCT_MotorStep == 0))
  802. {
  803. //QDCT_YL_DIR = QDCT_YL_DIR_N;
  804. jz_over = 1;
  805. QDCT_MotorStep = 150; //走松夹子
  806. if(!Y_DRV)//压轮电机动作
  807. AxisMovePosAccDec(Y_AXIS,QDCT_PARAM_YL_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH-QDCT_PARAM_TRANS_LENGTH),
  808. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_YL_SPEED/400,QDCT_PARAM_YL_SPEED/400,0);
  809. QDCT_AutoStep = 55;
  810. }
  811. break;
  812. case 55:
  813. if((dwTickCount >= QDCT_AutoDelay))
  814. {
  815. if(!Y_DRV && KaDaiFlag==0)
  816. {
  817. QDCT_AutoStep = 56;
  818. //QDCT_YL_DIR = QDCT_YL_DIR_P;
  819. QDCT_AutoDelay = dwTickCount + QDCT_PARAM_YL_FZ_DELAY;
  820. }
  821. //卡带处理,停止后可再次启动
  822. if(KaDaiFlag==1)
  823. {
  824. if(Y_DRV)
  825. AxisDecStop(Y_AXIS);
  826. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  827. {
  828. QDCT_bOnceStart=0;
  829. bStartOnceTime = 1;
  830. KaDaiFlag=0;
  831. AxisMovePosAccDec(Y_AXIS,QDCT_PARAM_YL_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH-QDCT_PARAM_TRANS_LENGTH-KaDaiSaveLenY),
  832. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_YL_SPEED/400,QDCT_PARAM_YL_SPEED/400,0);
  833. }
  834. else
  835. {
  836. KaDaiSaveLenY=dwYRealPos;
  837. }
  838. }
  839. }
  840. break;
  841. case 56:
  842. if((dwTickCount >= QDCT_AutoDelay))
  843. {
  844. if(!Y_DRV)AxisMovePosAccDec(Y_AXIS,QDCT_PARAM_YL_SPEED,(-QDCT_PARAM_FZ_LENGTH),
  845. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,10,10,0);
  846. QDCT_AutoStep = 14;
  847. }
  848. break;
  849. //检测到拉链没有穿进去
  850. case 70:
  851. if((dwTickCount >= QDCT_AutoDelay)) //张开夹子
  852. {
  853. //检测到拉链没有穿入,进到第一个拉头处夹住出不计数
  854. QDCT_MotorStep = 200;
  855. QDCT_AutoStep = 71;
  856. }
  857. break;
  858. case 71:
  859. if(QDCT_MotorStep == 0)
  860. {
  861. QDCT_XM_OUT = 0; //下模退
  862. QDCT_QJLT_OUT = 0; //前后夹拉头退
  863. QDCT_HJLT_OUT = 0;
  864. QDCT_AutoDelay = dwTickCount + 40;
  865. QDCT_AutoStep = 72;
  866. }
  867. break;
  868. case 72:
  869. if((dwTickCount >= QDCT_AutoDelay)) //延时下切
  870. {
  871. if(cChuan_Lian_ErrorNum == 0)
  872. QDCT_AutoStep = 14;
  873. else
  874. QDCT_SetAlarmCode(QDCT_CLOK_ALARM);
  875. }
  876. break;
  877. }
  878. }
  879. }
  880. //台面电机动作
  881. void QDCT_TableAction(void)
  882. {
  883. if(QDCT_TB_OUT && (dwTickCount >= QDCT_TableDelay))
  884. QDCT_TB_OUT = 0;
  885. }
  886. void QDCT_CheckStart(void)
  887. {
  888. static unsigned char long_stop_flg = 0,yd_back_flg,sl_flg;
  889. static unsigned long long_time_delay,yd_back_delay,sl_delay,sl_delayStart,dw_Stop_In_Delay;
  890. QDCT_STATE_RUN = bRunning;
  891. if(GetAlarmCode(QDCT_ALARM_ADDR) == 0)
  892. QDCT_STATE_ERROR = 0;
  893. else
  894. QDCT_STATE_ERROR = 1;
  895. //启动 自动启动 单一自动
  896. if((QDCT_START_IN_UP || bStart || (QDCT_bOnceStart && !KaDaiFlag) || QDCT_bCheckDinWei))
  897. {
  898. if((dwTickCount >= sl_delayStart) && !bRunning)
  899. {
  900. if(QDCT_bOnceStart)
  901. {
  902. QDCT_bOnceStart = 0;
  903. bStartOnceTime = 1;
  904. dwZipCnt = 0;
  905. }
  906. bStart = 0;
  907. if(!QDCT_NO_ZIPPER_CHECK_IN)QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
  908. else if(QDCT_PARAM_SET_ZIPPER_LENGTH <500)QDCT_SetAlarmCode(QDCT_ZIPPER_LENGTH_ALARM);
  909. else if((QDCT_QLTCZ_IN || QDCT_HLTCZ_IN) && !QDCT_XM_OUT)QDCT_SetAlarmCode(QDCT_START_LTCZ_ALARM);
  910. else if(!QDCT_QHSL_ORIGIN_IN || !QDCT_HHSL_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_GL_ORIGIN_ALARM);
  911. else if(QDCT_HHSL_LIMIT_IN || QDCT_QHSL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_START_SL_LIMIT_ALARM);
  912. //else if(!QDCT_XQ_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_XQ_ORIGIN_ALARM);
  913. else if(!QDCT_XM_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_SM_ORIGIN_ALARM);
  914. else if(QDCT_XQ_LIMIT_IN && !QDCT_PARAM_XM_MODE)QDCT_SetAlarmCode(QDCT_XQ_LIMIT_ALARM);
  915. else if(QDCT_SQ_LIMIT_IN)QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  916. else if(QDCT_YL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
  917. else if(!QDCT_SYL_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
  918. else if(QDCT_KA_DAI_IN)QDCT_SetAlarmCode(QDCT_KD_ALARM);
  919. else if(QDCT_GO_LIMIT_IN && (QDCT_YD_OUT && ((QDCT_SL_OUT && QDCT_PARAM_XM_MODE) || !QDCT_PARAM_XM_MODE) || (GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_ZLT_ALARM)))
  920. {
  921. if(((GetAlarmCode(QDCT_ALARM_ADDR) == 0) || (GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_ZLT_ALARM)))
  922. {
  923. AxisEgmStop(X_AXIS);
  924. cCheckDinWei = QDCT_bCheckDinWei;
  925. bRunning = 1;
  926. cTuiLianStep = 0;
  927. yd_back_flg = 0;
  928. QDCT_AutoStep = 4;
  929. SetAlarmCode(QDCT_ALARM_ADDR,0);
  930. sl_flg = 0;
  931. QDCT_MotorStep = 66;
  932. cWorkCnt = 0;
  933. QTryCnt = 0;
  934. HTryCnt = 0;
  935. QTuiLaTouOkFlg = 1;
  936. HTuiLaTouOkFlg = 1;
  937. if(QDCT_QJLT_OUT)// 前夹拉头关
  938. {
  939. QZhuangLiaoOkFlg = 1;
  940. }
  941. else
  942. {
  943. QZhuangLiaoOkFlg = 0;
  944. QDCT_QZhuangLiaoStep = 1;
  945. }
  946. if(QDCT_HJLT_OUT)
  947. {
  948. HZhuangLiaoOkFlg = 1;
  949. }
  950. else
  951. {
  952. HZhuangLiaoOkFlg = 0;
  953. QDCT_HZhuangLiaoStep = 1;
  954. }
  955. HTuiLaTouOkFlg = 1;
  956. dwZipCnt = 0;
  957. cFirstQStartFlg = 1;
  958. cFirstHStartFlg = 1;
  959. if(!QZDPAutoDisable)
  960. QDCT_QZDPStep = 1;
  961. if(!HZDPAutoDisable)
  962. QDCT_HZDPStep = 1;
  963. QDCT_TLPStep = 1;
  964. SingOneFlg = 0;
  965. cCheck_Go_In_Flag = 1;
  966. cSL_En = 2;
  967. cXiaMo_En = 1;
  968. SetPos(X_AXIS, 0);
  969. cBackLimitCheck_EN = 1;
  970. if(QDCT_TB_OUT)
  971. QDCT_TableDelay = dwTickCount + 300;
  972. KaDaiFlag = 0;
  973. KaDaiSaveLen=0;
  974. KaDaiSaveLenY=0;
  975. }
  976. }
  977. else
  978. {
  979. if((GetAlarmCode(QDCT_ALARM_ADDR) == 0))
  980. {
  981. AxisEgmStop(X_AXIS);
  982. cCheckDinWei = QDCT_bCheckDinWei;
  983. cBackLimitCheck_EN = 1;
  984. bRunning = 1;
  985. yd_back_flg = 0;
  986. QDCT_AutoStep = 1;
  987. cWorkCnt = 0;
  988. QTryCnt = 0;
  989. HTryCnt = 0;
  990. QTuiLaTouOkFlg = 1;
  991. HTuiLaTouOkFlg = 1;
  992. dwZipCnt = 0;
  993. cFirstQStartFlg = 1;
  994. cFirstHStartFlg = 1;
  995. if(QDCT_QJLT_OUT)// 前夹拉头关
  996. {
  997. QZhuangLiaoOkFlg = 1;
  998. }
  999. else
  1000. {
  1001. QZhuangLiaoOkFlg = 0;
  1002. QDCT_QZhuangLiaoStep = 1;
  1003. }
  1004. if(QDCT_HJLT_OUT)
  1005. {
  1006. HZhuangLiaoOkFlg = 1;
  1007. }
  1008. else
  1009. {
  1010. HZhuangLiaoOkFlg = 0;
  1011. QDCT_HZhuangLiaoStep = 1;
  1012. }
  1013. if(!QZDPAutoDisable)
  1014. QDCT_QZDPStep = 1;
  1015. if(!HZDPAutoDisable)
  1016. QDCT_HZDPStep = 1;
  1017. QDCT_TLPStep = 1;
  1018. SingOneFlg = 0;
  1019. cCheck_Go_In_Flag = 1;
  1020. cSL_En = 2;
  1021. cXiaMo_En = 1;
  1022. if(QDCT_TB_OUT)
  1023. QDCT_TableDelay = dwTickCount + 300;
  1024. KaDaiFlag = 0;
  1025. KaDaiSaveLen=0;
  1026. KaDaiSaveLenY=0;
  1027. }
  1028. }
  1029. }
  1030. QDCT_bCheckDinWei= 0;
  1031. }
  1032. if(cStopFlg == 1)
  1033. {
  1034. if(!X_DRV) cStopFlg = 0;
  1035. }
  1036. if(bStop)
  1037. {
  1038. SingOneFlg = 1;
  1039. bStop = 0;
  1040. }
  1041. //停止
  1042. if(QDCT_STOP_IN_UP && (dwTickCount >= dw_Stop_In_Delay))
  1043. {
  1044. //
  1045. SingOneFlg = 0;
  1046. if(bRunning)
  1047. {
  1048. dw_Stop_In_Delay = dwTickCount +50;
  1049. //SetDecTime(X_AXIS,12) ;
  1050. //SetDecTime(Y_AXIS,12) ;
  1051. AxisDecStop(X_AXIS);
  1052. AxisDecStop(Y_AXIS);
  1053. bRunning = 0;
  1054. QDCT_bOnceStart = 0;
  1055. bStartOnceTime = 0;
  1056. bStop = 0;
  1057. QDCT_AutoStep = 0;
  1058. //QDCT_QZhuangLiaoStep = 0;
  1059. //QDCT_HZhuangLiaoStep = 0;
  1060. QDCT_HeMoStep = 0;
  1061. QDCT_MotorStep = 0;
  1062. QDCT_JiaLianStep = 0;
  1063. if(!QDCT_PARAM_CS_ENABLE)QDCT_XiaQieStep = 0;
  1064. QDCT_ZhenDongStep = 0;
  1065. QDCT_QTLTStep = 0;
  1066. QDCT_HTLTStep = 0;
  1067. ManFlg = 0;
  1068. cBackLimitCheck_EN = 1;
  1069. QDCT_MotorStepY = 0;
  1070. QDCT_YL_OUT = 0;
  1071. QDCT_SYL_OUT = 0;
  1072. }
  1073. else
  1074. {
  1075. if(!X_DRV)
  1076. //QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
  1077. SetEn(X_AXIS, QDCT_MOTOR_DISEN);
  1078. if(!Y_DRV)
  1079. SetEn(Y_AXIS, QDCT_MOTOR_DISEN);
  1080. //SetDecTime(X_AXIS,12) ;
  1081. //SetDecTime(Y_AXIS,12) ;
  1082. AxisDecStop(X_AXIS);
  1083. AxisDecStop(Y_AXIS);
  1084. bRunning = 0;
  1085. QDCT_bOnceStart = 0;
  1086. bStop = 0;
  1087. bStartOnceTime = 0;
  1088. QDCT_AutoStep = 0;
  1089. QDCT_QZhuangLiaoStep = 0;
  1090. QDCT_HZhuangLiaoStep = 0;
  1091. QDCT_MotorStep = 0;
  1092. QDCT_JiaLianStep = 0;
  1093. QDCT_XiaQieStep = 0;
  1094. QDCT_ZhenDongStep = 0;
  1095. QDCT_HeMoStep = 0;
  1096. QDCT_QTLTStep = 0;
  1097. QDCT_HTLTStep = 0;
  1098. QDCT_SQ_OUT = 0;
  1099. if(!QDCT_PARAM_XM_MODE)QDCT_XQ_OUT = 0;
  1100. QDCT_XM_OUT = 0;
  1101. QDCT_JD_OUT = 0;
  1102. QDCT_QTLT_OUT = 0;
  1103. QDCT_HTLT_OUT = 0;
  1104. QDCT_QHSL_OUT = 0;
  1105. //QDCT_KL_OUT = 0;
  1106. QDCT_YL_OUT = 0;
  1107. QDCT_SYL_OUT = 0;
  1108. QDCT_CS_OUT = 0;
  1109. KaDaiFlag = 0;
  1110. KaDaiSaveLen=0;
  1111. KaDaiSaveLenY=0;
  1112. long_stop_flg = 1;
  1113. long_time_delay = dwTickCount+1500;
  1114. QDCT_HHSL_OUT= 0;
  1115. SetAlarmCode(QDCT_ALARM_ADDR,QDCT_NO_ALARM);
  1116. ManFlg = 0;
  1117. cSL_En = 2;
  1118. cXiaMo_En = 1;
  1119. cBackLimitCheck_EN = 1;
  1120. if((dwTickCount - QDCT_TableDelay) >= 1000)
  1121. QDCT_TableDelay = dwTickCount + 300;
  1122. QDCT_MotorStepSave=0;
  1123. QDCT_MotorStepY = 0;
  1124. }
  1125. //测试停止
  1126. cTestMotorStep = 0;
  1127. }
  1128. if(sl_flg)
  1129. {
  1130. if(dwTickCount >= sl_delay)
  1131. {
  1132. sl_flg = 0;
  1133. if(QDCT_PARAM_XM_MODE) QDCT_SL_OUT = 0;
  1134. sl_delayStart = dwTickCount+500;
  1135. }
  1136. }
  1137. if(long_stop_flg)
  1138. {
  1139. if(dwTickCount >= long_time_delay)
  1140. {
  1141. if(QDCT_STOP_IN)
  1142. {
  1143. QDCT_QJLT_OUT = 0;
  1144. QDCT_HJLT_OUT = 0;
  1145. QDCT_YD_OUT = 0;
  1146. if(QDCT_PARAM_XM_MODE) QDCT_SL_OUT = 0;
  1147. }
  1148. }
  1149. else if(!QDCT_STOP_IN)
  1150. {
  1151. long_stop_flg = 0;
  1152. }
  1153. }
  1154. if(QDCT_bAlarmStop)
  1155. {
  1156. bRunning = 0;
  1157. QDCT_bOnceStart = 0;
  1158. QDCT_bAlarmStop = 0;
  1159. bStartOnceTime = 0;
  1160. AxisDecStop(X_AXIS);
  1161. AxisDecStop(Y_AXIS);
  1162. QDCT_AutoStep = 0;
  1163. QDCT_QZhuangLiaoStep = 0;
  1164. QDCT_HZhuangLiaoStep = 0;
  1165. QDCT_MotorStep = 0;
  1166. QDCT_MotorStepY = 0;
  1167. QDCT_JiaLianStep = 0;
  1168. QDCT_ZhenDongStep = 0;
  1169. if(!QDCT_QTLT_OUT)
  1170. QDCT_QTLTStep = 0;
  1171. if(!QDCT_HTLT_OUT)
  1172. QDCT_HTLTStep = 0;
  1173. ManFlg = 0;
  1174. KaDaiFlag = 0;
  1175. KaDaiSaveLen=0;
  1176. KaDaiSaveLenY=0;
  1177. if(GetAlarmCode(QDCT_ALARM_ADDR) != QDCT_ZLT_ALARM && !QDCT_JD_OUT)
  1178. {
  1179. if(QDCT_SL_OUT && QDCT_PARAM_XM_MODE)
  1180. {
  1181. QDCT_YD_OUT = 1;
  1182. sl_flg = 1;
  1183. sl_delay = dwTickCount+1000;
  1184. }
  1185. }
  1186. }
  1187. }
  1188. unsigned long GetLength(long dist0,long dist1)
  1189. {
  1190. if(dist0 < dist1)
  1191. return (dist1-dist0);
  1192. else
  1193. return (dist0-dist1);
  1194. }
  1195. //电机控制动作
  1196. void QDCT_Motor(void) //
  1197. {
  1198. /*
  1199. 1~5步追色标
  1200. 30步开始后拉
  1201. 61 前进定位
  1202. 80步开始为切断后后拉松夹子
  1203. 200步,进去一定位置夹废料
  1204. */
  1205. static long save_buff,length_buff,gou_zhen_buff,back_dec_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff,xm_delay_back;
  1206. unsigned short start_speed;
  1207. user_datas[127] = length_buff;
  1208. qdct_length_buff = (short *)&QDCT_PARAM_OFFSET_LENGTH;
  1209. if(!QDCT_NO_ZIPPER_CHECK_IN && bRunning)
  1210. {
  1211. QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
  1212. }
  1213. switch(QDCT_MotorStepY)//走链
  1214. {
  1215. case 160:
  1216. if((dwTickCount >= QDCT_MotorYDelay) && !Y_DRV)
  1217. {
  1218. if(!Y_DRV)
  1219. {
  1220. AxisMovePosAccDec(Y_AXIS,QDCT_PARAM_YL_SL_SPEED,QDCT_PARAM_YL_SL_LENGTH,
  1221. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_YL_SL_SPEED/400,QDCT_PARAM_YL_SL_SPEED/400,0);
  1222. //user_datas[123]++;
  1223. }
  1224. QDCT_MotorYDelay = dwTickCount + QDCT_PARAM_YL_BACK_DELAY;
  1225. QDCT_MotorStepY = 161;
  1226. }break;
  1227. case 161:
  1228. if(dwTickCount >= QDCT_MotorYDelay)QDCT_YL_OUT = 0;
  1229. if(!Y_DRV)
  1230. {
  1231. QDCT_YL_OUT = 0;
  1232. QDCT_MotorYDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1233. QDCT_MotorStepY = 162;
  1234. }
  1235. break;
  1236. case 162:
  1237. if(!QDCT_YL_LIMIT_IN)
  1238. {
  1239. QDCT_SYL_OUT=0;//送压轮退
  1240. QDCT_MotorYDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1241. QDCT_MotorStepY = 163;
  1242. }
  1243. else if(dwTickCount >= QDCT_MotorYDelay)
  1244. QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
  1245. break;
  1246. case 163:
  1247. if(QDCT_SYL_ORIGIN_IN)
  1248. {
  1249. QDCT_MotorStepY = 0;
  1250. SetEn(Y_AXIS, QDCT_MOTOR_DISEN);
  1251. }
  1252. else if(dwTickCount >= QDCT_MotorYDelay)
  1253. QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
  1254. break;
  1255. }
  1256. switch(QDCT_MotorStep)
  1257. {
  1258. case 1:
  1259. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
  1260. QDCT_MotorStep = 2;
  1261. QDCT_YD_OUT = 0;
  1262. LengthType = 0;
  1263. break;
  1264. case 2:
  1265. cSeBiaoOk = 0;
  1266. cSeBiaoEn = 0;
  1267. SetPos(X_AXIS,0);
  1268. if(dwTickCount >= QDCT_MotorDelay)
  1269. {
  1270. back_buff = dwXRealPos;
  1271. back_dec_buff = dwXRealPos;
  1272. cSeBiaoOk = 0;
  1273. cSeBiaoEn = 0;
  1274. cChuan_LianCheckOK = 0;
  1275. if(dwZipCnt>=1)
  1276. {
  1277. //夹子运动到模具位置时变为穿入速度
  1278. if( QDCT_PARAM_Mold_Distance > 120)
  1279. AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED*2,QDCT_PARAM_Mold_Distance,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
  1280. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,50);
  1281. else
  1282. AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED*2,QDCT_PARAM_Mold_Distance+10,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
  1283. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  1284. }
  1285. else//第一条测长度
  1286. {
  1287. AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED,QDCT_DIR_P,
  1288. QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
  1289. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1290. }
  1291. QDCT_MotorStep = 3;
  1292. if(QDCT_PARAM_XM_MODE)
  1293. QDCT_SL_OUT = 0;//送带退
  1294. }
  1295. break;
  1296. case 3:
  1297. //到拉链空位
  1298. if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwXRealPos >= (length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH) && dwZipCnt>=1)) //空位变慢
  1299. {
  1300. AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
  1301. cSeBiaoOk = 0;
  1302. cSeBiaoEn = 1;
  1303. QDCT_MotorStep = 7;
  1304. break;
  1305. }
  1306. if(QDCT_CHUAN_LIAN_OK)
  1307. cChuan_LianCheckOK = 1;
  1308. //如果穿入长度到
  1309. if((dwXRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1310. {
  1311. QDCT_MotorStep = 5;
  1312. if(QDCT_PARAM_MODE) //反穿停电机
  1313. {
  1314. AxisEgmStop(X_AXIS);
  1315. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
  1316. }
  1317. else
  1318. {
  1319. QDCT_MotorDelay = dwTickCount;
  1320. }
  1321. QDCT_XM_OUT = 0;
  1322. if(cCheckDinWei == 0)
  1323. QDCT_QJLT_OUT = 0;
  1324. if(QDCT_PARAM_XM_MODE)
  1325. QDCT_SL_OUT = 0;//送带退
  1326. if(QDCT_PARAM_HLT_ON )
  1327. {
  1328. QDCT_HJLT_OUT = 0;
  1329. }
  1330. break;
  1331. }
  1332. else if((dwXRealPos + 100) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1333. {
  1334. if(QDCT_PARAM_HLT_ON )
  1335. {
  1336. QDCT_HJLT_OUT = 0;
  1337. }
  1338. }
  1339. if(dwZipCnt>=1)
  1340. {
  1341. //如果慢速长度到,
  1342. if(dwXRealPos >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH))
  1343. {
  1344. //拉链长度大于(模具长度 + 穿入长度)说明穿入部分还有拉链加速
  1345. if(length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH > QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH)
  1346. AxisMovePosAccDecNotStop(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,QDCT_PARAM_PUTIN_LENGTH - QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH,
  1347. QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_ACC_PULSE+10,QDCT_PARAM_DEC_PULSE+10,0);
  1348. else
  1349. AxisMovePosAccDecNotStop(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH-dwXRealPos,
  1350. QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,QDCT_PARAM_ACC_PULSE+10,QDCT_PARAM_DEC_PULSE+10,0);
  1351. }
  1352. QDCT_MotorStep = 4;
  1353. }
  1354. //卡带处理,停止后可再次启动
  1355. if(KaDaiFlag==1)
  1356. {
  1357. if(X_DRV)
  1358. AxisDecStop(X_AXIS);
  1359. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  1360. {
  1361. QDCT_bOnceStart=0;
  1362. bStartOnceTime = 1;
  1363. KaDaiFlag=0;
  1364. AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  1365. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1366. }
  1367. else
  1368. {
  1369. KaDaiSaveLen=dwXRealPos;
  1370. }
  1371. }
  1372. //行程超限
  1373. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1374. {
  1375. QDCT_JD_OUT = 0;
  1376. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1377. user_datas[128] = 4;
  1378. }
  1379. break;
  1380. case 4:
  1381. //到拉链空位
  1382. if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwXRealPos >= (length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH) && dwZipCnt>=1)) //空位变慢
  1383. {
  1384. AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
  1385. cSeBiaoOk = 0;
  1386. cSeBiaoEn = 1;
  1387. QDCT_MotorStep = 7;
  1388. break;
  1389. }
  1390. if(QDCT_CHUAN_LIAN_OK)
  1391. cChuan_LianCheckOK = 1;
  1392. //如果穿入长度到
  1393. if((dwXRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1394. {
  1395. QDCT_MotorStep = 5;
  1396. if(QDCT_PARAM_MODE) //反穿停电机
  1397. {
  1398. AxisEgmStop(X_AXIS);
  1399. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
  1400. }
  1401. else
  1402. {
  1403. QDCT_MotorDelay = dwTickCount;
  1404. }
  1405. QDCT_XM_OUT = 0;
  1406. if(cCheckDinWei == 0)
  1407. QDCT_QJLT_OUT = 0;
  1408. if(QDCT_PARAM_XM_MODE)
  1409. QDCT_SL_OUT = 0;//送带退
  1410. if(QDCT_PARAM_HLT_ON )
  1411. {
  1412. QDCT_HJLT_OUT = 0;
  1413. }
  1414. break;
  1415. }
  1416. else if((dwXRealPos + 100) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1417. {
  1418. if(QDCT_PARAM_HLT_ON )
  1419. {
  1420. QDCT_HJLT_OUT = 0;
  1421. }
  1422. }
  1423. //卡带处理,停止后可再次启动
  1424. if(KaDaiFlag==1)
  1425. {
  1426. if(X_DRV)
  1427. AxisDecStop(X_AXIS);
  1428. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  1429. {
  1430. QDCT_bOnceStart=0;
  1431. bStartOnceTime = 1;
  1432. KaDaiFlag=0;
  1433. AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  1434. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1435. }
  1436. else
  1437. {
  1438. KaDaiSaveLen=dwXRealPos;
  1439. }
  1440. }
  1441. //行程超限
  1442. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1443. {
  1444. QDCT_JD_OUT = 0;
  1445. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1446. user_datas[128] = 4;
  1447. }
  1448. break;
  1449. case 5:
  1450. if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwXRealPos >= (length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH) && dwZipCnt>=1) ) //空位变慢
  1451. {
  1452. AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
  1453. cSeBiaoOk = 0;
  1454. cSeBiaoEn = 1;
  1455. QDCT_MotorStep = 7;
  1456. break;
  1457. }
  1458. // //到达穿入长度位置
  1459. if(dwTickCount>= QDCT_MotorDelay)
  1460. {
  1461. if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
  1462. {
  1463. if(cCheckDinWei == 0)
  1464. {
  1465. if(QDCT_PARAM_QLT_ON )//&& !QDCT_GO_LIMIT_IN)
  1466. {
  1467. QDCT_QJLT_OUT = 0;
  1468. }
  1469. }
  1470. if(dwZipCnt>=1)
  1471. {
  1472. if(dwXRealPos+QDCT_SEBIAO_BACK_LSPEED_LENGTH+QDCT_SEBIAO_LENGTH+50 < length_buff)
  1473. AxisMovePosAccDecNotStop(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,length_buff-dwXRealPos-QDCT_SEBIAO_BACK_LSPEED_LENGTH-QDCT_SEBIAO_LENGTH,
  1474. QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,QDCT_PARAM_ACC_PULSE+10,QDCT_PARAM_DEC_PULSE+10,0);
  1475. else
  1476. AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
  1477. }
  1478. else
  1479. {
  1480. if(!X_DRV)//反穿轴停的情况,要重新启动后拉
  1481. AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED,QDCT_DIR_P,
  1482. QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
  1483. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1484. }
  1485. QDCT_MotorStep = 6;
  1486. }
  1487. }
  1488. //卡带处理,停止后可再次启动
  1489. if(KaDaiFlag==1)
  1490. {
  1491. if(X_DRV)
  1492. AxisDecStop(X_AXIS);
  1493. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  1494. {
  1495. QDCT_bOnceStart=0;
  1496. bStartOnceTime = 1;
  1497. KaDaiFlag=0;
  1498. AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED, QDCT_DIR_P,QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
  1499. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1500. }
  1501. else
  1502. {
  1503. KaDaiSaveLen=dwXRealPos;
  1504. }
  1505. }
  1506. //行程超限
  1507. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1508. {
  1509. QDCT_JD_OUT = 0;
  1510. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1511. user_datas[128] = 4;
  1512. }
  1513. break;
  1514. case 6:
  1515. if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwXRealPos >= (length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH) && dwZipCnt>=1) ) //空位变慢
  1516. {
  1517. AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
  1518. cSeBiaoOk = 0;
  1519. cSeBiaoEn = 1;
  1520. QDCT_MotorStep = 7;
  1521. user_datas[129] = dwXRealPos;
  1522. break;
  1523. }
  1524. //卡带处理,停止后可再次启动
  1525. if(KaDaiFlag==1)
  1526. {
  1527. if(X_DRV)
  1528. AxisDecStop(X_AXIS);
  1529. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  1530. {
  1531. QDCT_bOnceStart=0;
  1532. bStartOnceTime = 1;
  1533. KaDaiFlag=0;
  1534. AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED, QDCT_DIR_P,QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
  1535. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1536. }
  1537. else
  1538. {
  1539. KaDaiSaveLen=dwXRealPos;
  1540. }
  1541. }
  1542. //行程超限
  1543. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1544. {
  1545. QDCT_JD_OUT = 0;
  1546. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1547. user_datas[128] = 4;
  1548. }
  1549. break;
  1550. case 7:
  1551. if((cCheckDinWei == 0))
  1552. {
  1553. if(QDCT_XM_OUT)
  1554. {
  1555. if(dwXRealPos >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1556. {
  1557. if(QDCT_PARAM_HLT_ON )
  1558. QDCT_HJLT_OUT = 0;
  1559. if(QDCT_PARAM_MODE) //反穿停电机
  1560. {
  1561. AxisEgmStop(X_AXIS);
  1562. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
  1563. }
  1564. else
  1565. {
  1566. QDCT_MotorDelay = dwTickCount;
  1567. }
  1568. QDCT_XM_OUT = 0;
  1569. QDCT_QJLT_OUT = 0;
  1570. }
  1571. else if((dwXRealPos + 100) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1572. {
  1573. if(QDCT_PARAM_HLT_ON )
  1574. {
  1575. QDCT_HJLT_OUT = 0;
  1576. }
  1577. }
  1578. }
  1579. else
  1580. {
  1581. if(dwTickCount >= QDCT_MotorDelay)
  1582. {
  1583. if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
  1584. {
  1585. if(QDCT_PARAM_QLT_ON )
  1586. {
  1587. QDCT_QJLT_OUT = 0;
  1588. }
  1589. if(!X_DRV && !KaDaiFlag)//反穿轴停的情况,要重新启动后拉
  1590. AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED,QDCT_DIR_P,
  1591. QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
  1592. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1593. }
  1594. }
  1595. }
  1596. }
  1597. if(cSeBiaoOk)
  1598. {
  1599. if(cCheckDinWei == 0)
  1600. {
  1601. if(QDCT_XM_OUT)
  1602. {
  1603. if((dwXRealPos + 300) >= (cDinWeiPos + QDCT_SEBIAO_LENGTH ))
  1604. {
  1605. if(QDCT_PARAM_HLT_ON )
  1606. QDCT_HJLT_OUT = 0;
  1607. if(QDCT_PARAM_MODE) //反穿停电机
  1608. {
  1609. AxisEgmStop(X_AXIS);
  1610. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
  1611. }
  1612. else
  1613. {
  1614. QDCT_MotorDelay = dwTickCount;
  1615. }
  1616. QDCT_XM_OUT = 0;
  1617. if(cCheckDinWei == 0)
  1618. QDCT_QJLT_OUT = 0;
  1619. }
  1620. else if((dwXRealPos + 400) >= (cDinWeiPos + QDCT_SEBIAO_LENGTH ))
  1621. {
  1622. if(QDCT_PARAM_HLT_ON )
  1623. {
  1624. QDCT_HJLT_OUT = 0;
  1625. }
  1626. }
  1627. }
  1628. else
  1629. {
  1630. if(dwTickCount >= QDCT_MotorDelay)
  1631. {
  1632. if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
  1633. {
  1634. if(QDCT_PARAM_QLT_ON )
  1635. {
  1636. QDCT_QJLT_OUT = 0;
  1637. }
  1638. AxisMovePosAccDec(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,cDinWeiPos + QDCT_SEBIAO_LENGTH-dwXRealPos,
  1639. QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  1640. QDCT_MotorStep = 8;
  1641. }
  1642. }
  1643. }
  1644. }
  1645. }
  1646. if(((dwXRealPos >= (cDinWeiPos + QDCT_SEBIAO_LENGTH )))&& cSeBiaoOk)
  1647. {
  1648. AxisEgmStop(X_AXIS);
  1649. if(cCheckDinWei == 0)
  1650. {
  1651. if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
  1652. {
  1653. if(QDCT_PARAM_QLT_ON )
  1654. {
  1655. QDCT_QJLT_OUT = 0;
  1656. }
  1657. }
  1658. }
  1659. if((dwZipCnt >= 1) && QDCT_SEBIAO_ERROR_LENGHT && (((dwXRealPos > (length_buff + QDCT_SEBIAO_ERROR_LENGHT))
  1660. || dwXRealPos < (length_buff - QDCT_SEBIAO_ERROR_LENGHT))))
  1661. {
  1662. QDCT_SetAlarmCode(QDCT_SE_BIAO_ALARM);
  1663. }
  1664. else
  1665. {
  1666. QDCT_MotorStep = 9;
  1667. //第一条保存长度
  1668. if(dwZipCnt==0) length_buff = dwXRealPos;
  1669. }
  1670. }
  1671. //卡带处理,停止后可再次启动
  1672. if(KaDaiFlag==1)
  1673. {
  1674. if(X_DRV)
  1675. AxisDecStop(X_AXIS);
  1676. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  1677. {
  1678. QDCT_bOnceStart=0;
  1679. bStartOnceTime = 1;
  1680. KaDaiFlag=0;
  1681. AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED, QDCT_DIR_P,QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
  1682. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1683. }
  1684. else
  1685. {
  1686. KaDaiSaveLen=dwXRealPos;
  1687. }
  1688. }
  1689. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1690. {
  1691. QDCT_JD_OUT = 0;
  1692. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1693. user_datas[128] = 3;
  1694. }
  1695. break;
  1696. case 8:
  1697. if(((dwXRealPos >= (cDinWeiPos + QDCT_SEBIAO_LENGTH )))&& cSeBiaoOk || (!X_DRV && !KaDaiFlag))
  1698. {
  1699. AxisEgmStop(X_AXIS);
  1700. if(cCheckDinWei == 0)
  1701. {
  1702. if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
  1703. {
  1704. if(QDCT_PARAM_QLT_ON )
  1705. {
  1706. QDCT_QJLT_OUT = 0;
  1707. }
  1708. }
  1709. }
  1710. if(QDCT_SEBIAO_ERROR_LENGHT && (((dwXRealPos > (QDCT_PARAM_SET_ZIPPER_LENGTH + QDCT_SEBIAO_ERROR_LENGHT))
  1711. || dwXRealPos < (QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_SEBIAO_ERROR_LENGHT))))
  1712. {
  1713. QDCT_SetAlarmCode(QDCT_SE_BIAO_ALARM);
  1714. }
  1715. else
  1716. {
  1717. QDCT_MotorStep = 9;
  1718. //第一条保存长度
  1719. if(dwZipCnt==0) length_buff = dwXRealPos;
  1720. }
  1721. }
  1722. //卡带处理,停止后可再次启动
  1723. if(KaDaiFlag==1)
  1724. {
  1725. if(X_DRV)
  1726. AxisDecStop(X_AXIS);
  1727. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  1728. {
  1729. QDCT_bOnceStart=0;
  1730. bStartOnceTime = 1;
  1731. KaDaiFlag=0;
  1732. AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED, QDCT_DIR_P,QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
  1733. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1734. }
  1735. else
  1736. {
  1737. KaDaiSaveLen=dwXRealPos;
  1738. }
  1739. }
  1740. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1741. {
  1742. QDCT_JD_OUT = 0;
  1743. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1744. user_datas[128] = 3;
  1745. }
  1746. break;
  1747. case 9:
  1748. QDCT_MotorStep = 0;
  1749. break;
  1750. case 30:
  1751. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
  1752. if(GetEn(X_AXIS) == QDCT_MOTOR_DISEN)
  1753. {
  1754. //QDCT_SZ_OUT = QDCT_MOTOR_EN;
  1755. SetEn(X_AXIS, QDCT_MOTOR_EN);
  1756. if(QDCT_PARAM_DELAY_BACK < 50)
  1757. QDCT_MotorDelay = dwTickCount + 50;
  1758. }
  1759. QDCT_YD_OUT = 0; //压带
  1760. QDCT_MotorStep = 31;
  1761. cCheck_Go_In_Flag = 0;
  1762. cChuan_LianCheckOK = 0;
  1763. SetPos(X_AXIS,0);
  1764. break;
  1765. case 31:
  1766. if(dwTickCount >= QDCT_MotorDelay)
  1767. {
  1768. gou_zhen_buff = dwXRealPos;
  1769. save_buff = dwXRealPos;
  1770. back_buff = dwXRealPos;
  1771. if((*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH) < 0)
  1772. *qdct_length_buff = 0;
  1773. //拉链长度小于刀口到模具距离加穿入长度,需要在切断后继续穿入
  1774. if((*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH < QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH))
  1775. {
  1776. CutRemainLength = QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH - (*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH);
  1777. LengthType = 1;
  1778. }
  1779. else
  1780. {
  1781. LengthType = 0;
  1782. }
  1783. if(QDCT_PARAM_PUTIN_LOW_SPEED < QDCT_PARAM_START_SPEED)
  1784. start_speed = QDCT_PARAM_PUTIN_LOW_SPEED;
  1785. else
  1786. start_speed = QDCT_PARAM_START_SPEED;
  1787. if(LengthType == 0)
  1788. {
  1789. if( QDCT_PARAM_Mold_Distance > 120)
  1790. //夹子运动到模具位置时变为穿入速度
  1791. AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED*2,QDCT_PARAM_Mold_Distance,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
  1792. 10,10,50);
  1793. else
  1794. AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_Mold_Distance+10,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
  1795. 10,10,0);
  1796. QDCT_MotorStep = 33;
  1797. }
  1798. else//超短链
  1799. {
  1800. //拉链长度小于刀口到模具距离,走到拉链长度停
  1801. if(*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH < QDCT_PARAM_Mold_Distance)
  1802. {
  1803. AxisMovePosAccDec(X_AXIS,start_speed*3,*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_PUTIN_LOW_SPEED,10,10,0);
  1804. }
  1805. else
  1806. {
  1807. AxisMovePosAccDecNotStop(X_AXIS,start_speed*3,QDCT_PARAM_Mold_Distance,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,10,10,0);
  1808. }
  1809. QDCT_MotorStep = 433;
  1810. }
  1811. cChuan_LianCheckOK = 0;
  1812. }
  1813. break;
  1814. case 33:
  1815. if(QDCT_CHUAN_LIAN_OK)
  1816. cChuan_LianCheckOK = 1;
  1817. //下切刀提前输出
  1818. if(!QDCT_GO_LIMIT_IN && !QDCT_PARAM_XM_MODE && !QDCT_PARAM_CS_ENABLE && (dwXRealPos >= QDCT_PARAM_Mold_Distance))
  1819. QDCT_XQ_OUT = 1;
  1820. //如果当前长度到达拉链长,最优先停
  1821. if(dwXRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
  1822. {
  1823. QDCT_MotorStep = 35;
  1824. break;
  1825. }
  1826. //如果穿入长度到也停止,开模
  1827. if((dwXRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1828. {
  1829. QDCT_MotorStep = 35;
  1830. break;
  1831. }
  1832. //如果慢速长度到,
  1833. if(dwXRealPos >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH))
  1834. {
  1835. if(QDCT_PARAM_XM_MODE)
  1836. QDCT_SL_OUT = 0;//送带退
  1837. //穿入长度大于穿入慢速
  1838. if(QDCT_PARAM_PUTIN_LENGTH > QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH)
  1839. AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_PUTIN_LENGTH - QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH,
  1840. QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_START_SPEED,
  1841. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  1842. QDCT_MotorStep = 34;
  1843. }
  1844. //卡带处理,停止后可再次启动
  1845. if(KaDaiFlag==1)
  1846. {
  1847. if(X_DRV)
  1848. AxisDecStop(X_AXIS);
  1849. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  1850. {
  1851. QDCT_bOnceStart=0;
  1852. bStartOnceTime = 1;
  1853. KaDaiFlag=0;
  1854. AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  1855. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1856. }
  1857. else
  1858. {
  1859. KaDaiSaveLen=dwXRealPos;
  1860. }
  1861. }
  1862. //行程超限
  1863. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1864. {
  1865. QDCT_JD_OUT = 0;
  1866. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1867. user_datas[128] = 4;
  1868. }
  1869. break;
  1870. case 34:
  1871. if(QDCT_CHUAN_LIAN_OK)
  1872. cChuan_LianCheckOK = 1;
  1873. //到达拉链长度要停止
  1874. if(dwXRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
  1875. {
  1876. QDCT_MotorStep = 35;
  1877. break;
  1878. }
  1879. //如果穿入长度到也停止,开模
  1880. if((dwXRealPos + 8) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1881. {
  1882. QDCT_MotorStep = 35;
  1883. break;
  1884. }
  1885. else if((dwXRealPos + 80) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
  1886. {
  1887. if(QDCT_PARAM_HLT_ON && (cChuan_LianCheckOK || (QDCT_CHUAN_LIAN_CHECK_SELECT == 0)) && !QDCT_GO_LIMIT_IN)
  1888. {
  1889. QDCT_HJLT_OUT = 0;
  1890. }
  1891. }
  1892. //卡带处理,停止后可再次启动
  1893. if(KaDaiFlag==1)
  1894. {
  1895. if(X_DRV)
  1896. AxisDecStop(X_AXIS);
  1897. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  1898. {
  1899. QDCT_bOnceStart=0;
  1900. bStartOnceTime = 1;
  1901. KaDaiFlag=0;
  1902. AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  1903. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  1904. }
  1905. else
  1906. {
  1907. KaDaiSaveLen=dwXRealPos;
  1908. }
  1909. }
  1910. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1911. {
  1912. QDCT_JD_OUT = 0;
  1913. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1914. user_datas[128] = 5;
  1915. }
  1916. break;
  1917. case 35:
  1918. if(QDCT_PARAM_MODE)//反穿停
  1919. {
  1920. AxisEgmStop(X_AXIS);
  1921. if(QDCT_PARAM_QLT_ON)
  1922. {
  1923. QDCT_QJLT_OUT = 0;
  1924. }
  1925. }
  1926. else
  1927. {
  1928. AxisChangeSpeedDirect(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED/3);
  1929. }
  1930. if(QDCT_PARAM_HLT_ON && (cChuan_LianCheckOK || (QDCT_CHUAN_LIAN_CHECK_SELECT == 0)) && !QDCT_GO_LIMIT_IN)
  1931. {
  1932. QDCT_HJLT_OUT = 0;
  1933. }
  1934. QDCT_XM_OUT = 0;
  1935. if(QDCT_PARAM_XM_MODE)
  1936. QDCT_SL_OUT = 0;//送带退
  1937. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
  1938. QDCT_MotorStep = 37;
  1939. break;
  1940. case 36:
  1941. break;
  1942. case 37:
  1943. //两路顶针离开
  1944. if(!QDCT_XM_OUT && ((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
  1945. {
  1946. if(QDCT_PARAM_QLT_ON )
  1947. {
  1948. QDCT_QJLT_OUT = 0;
  1949. }
  1950. if(dwTickCount >= QDCT_MotorDelay)
  1951. {
  1952. if(dwXRealPos < QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)
  1953. {
  1954. if(QDCT_CheckLength())//无限长
  1955. {
  1956. if((QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff) > (dwXRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
  1957. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff-dwXRealPos),
  1958. QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
  1959. else
  1960. AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff-dwXRealPos),
  1961. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  1962. }
  1963. else//普通长
  1964. {
  1965. if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff) > (dwXRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
  1966. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwXRealPos),
  1967. QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
  1968. else
  1969. AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwXRealPos),
  1970. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  1971. }
  1972. }
  1973. QDCT_MotorStep = 38;
  1974. }
  1975. }
  1976. else if(dwTickCount >= QDCT_MotorDelay+2000)
  1977. {
  1978. if((QDCT_QLTCZ_IN && QDCT_PARAM_QLT_ON) || (QDCT_HLTCZ_IN && QDCT_PARAM_HLT_ON))
  1979. QDCT_SetAlarmCode(QDCT_START_LTCZ_ALARM);
  1980. }
  1981. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  1982. {
  1983. QDCT_JD_OUT = 0;
  1984. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  1985. user_datas[128] = 6;
  1986. }
  1987. break;
  1988. case 38:
  1989. if(((dwXRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH + 400)) && (QDCT_PARAM_SET_ZIPPER_LENGTH > (dwXRealPos + 4000)))
  1990. {
  1991. cSL_En = 2;
  1992. }
  1993. if(QDCT_CheckLength() && !QDCT_YL_LIMIT_IN && !QDCT_GO_LIMIT_IN && dwXRealPos>=4000)
  1994. {
  1995. QDCT_SYL_OUT=1;//送压轮
  1996. }
  1997. if((!X_DRV && !KaDaiFlag) || (dwXRealPos>= QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
  1998. {
  1999. AxisEgmStop(X_AXIS);
  2000. if(!QDCT_CheckLength())
  2001. {
  2002. QDCT_YD_OUT = 1;
  2003. }
  2004. QDCT_MotorStep = 390;
  2005. QDCT_MotorDelay = dwTickCount+10;
  2006. }
  2007. //卡带处理,停止后可再次启动
  2008. if(KaDaiFlag==1)
  2009. {
  2010. if(X_DRV)
  2011. AxisDecStop(X_AXIS);
  2012. else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
  2013. {
  2014. QDCT_bOnceStart=0;
  2015. bStartOnceTime = 1;
  2016. KaDaiFlag=0;
  2017. if(dwXRealPos < QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)
  2018. {
  2019. if(QDCT_CheckLength())//无限长
  2020. {
  2021. if((QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff) > (dwXRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
  2022. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff-dwXRealPos),
  2023. QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
  2024. else
  2025. AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff-dwXRealPos),
  2026. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  2027. }
  2028. else//普通长
  2029. {
  2030. if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff) > (dwXRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
  2031. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwXRealPos),
  2032. QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
  2033. else
  2034. AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwXRealPos),
  2035. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  2036. }
  2037. }
  2038. }
  2039. else
  2040. {
  2041. KaDaiSaveLen=dwXRealPos;
  2042. }
  2043. }
  2044. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  2045. {
  2046. QDCT_JD_OUT = 0;
  2047. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  2048. user_datas[128] = 6;
  2049. }
  2050. break;
  2051. case 390:
  2052. if(dwTickCount >= QDCT_MotorDelay)
  2053. {
  2054. if(QDCT_PARAM_FZ_LENGTH != 0) //反转长度
  2055. {
  2056. AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,-QDCT_PARAM_FZ_LENGTH,
  2057. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,10,10,0);
  2058. }
  2059. QDCT_MotorStep = 39;
  2060. }
  2061. break;
  2062. case 39:
  2063. if(!X_DRV)
  2064. {
  2065. if(!QDCT_CheckLength())
  2066. {
  2067. QDCT_YD_OUT = 1;
  2068. }
  2069. QDCT_MotorStep = 40;
  2070. if(bRunning)
  2071. {
  2072. if(!QDCT_NO_ZIPPER_CHECK_IN)
  2073. QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
  2074. }
  2075. }
  2076. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  2077. {
  2078. QDCT_JD_OUT = 0;
  2079. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  2080. user_datas[128] = 7;
  2081. }
  2082. break;
  2083. case 40:
  2084. QDCT_MotorStep = 0;
  2085. break;
  2086. //超短链
  2087. case 433:
  2088. //如果当前长度到达拉链长,最优先停
  2089. if(dwXRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
  2090. {
  2091. AxisEgmStop(X_AXIS);
  2092. QDCT_MotorStep = 434;
  2093. QDCT_MotorDelay = dwTickCount + 50;
  2094. if(QDCT_PARAM_XM_MODE)
  2095. {
  2096. QDCT_SL_OUT = 0;//送带退
  2097. }
  2098. }
  2099. //行程超限
  2100. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  2101. {
  2102. QDCT_JD_OUT = 0;
  2103. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  2104. user_datas[128] = 8;
  2105. }
  2106. break;
  2107. case 434:
  2108. if(dwTickCount >= QDCT_MotorDelay)
  2109. {
  2110. //下切
  2111. if((QDCT_XiaQieStep == 0) && (QDCT_SL_ORIGIN_IN || !QDCT_PARAM_XM_MODE))
  2112. {
  2113. QDCT_XiaQieStep = 1;
  2114. cSL_En = 0; //下切时只横送不能锁紧拉头
  2115. QDCT_MotorStep = 435;
  2116. QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2117. }
  2118. }
  2119. break;
  2120. case 435:
  2121. //下切完
  2122. if(QDCT_XiaQieStep==0)
  2123. {
  2124. QDCT_YD_OUT = 0; //压带
  2125. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED,CutRemainLength,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_PUTIN_LOW_SPEED,10,10,0);
  2126. QDCT_MotorStep = 436;
  2127. }
  2128. else if(dwTickCount >= QDCT_MotorDelay)
  2129. {
  2130. QDCT_SetAlarmCode(QDCT_XQ_ALARM);
  2131. }
  2132. break;
  2133. case 436:
  2134. if(dwXRealPos>= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH) || !X_DRV)
  2135. {
  2136. AxisEgmStop(X_AXIS);
  2137. //下模和夹拉头打开
  2138. QDCT_QJLT_OUT = 0; //夹拉头
  2139. QDCT_HJLT_OUT = 0; //夹拉头
  2140. QDCT_XM_OUT = 0; //拉头下模
  2141. QDCT_MotorStep = 437;
  2142. QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2143. if(QDCT_CHUAN_LIAN_OK)
  2144. cChuan_LianCheckOK = 1;
  2145. }
  2146. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  2147. {
  2148. QDCT_JD_OUT = 0;
  2149. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  2150. user_datas[128] = 10;
  2151. }
  2152. break;
  2153. case 437:
  2154. if(QDCT_CHUAN_LIAN_OK)
  2155. cChuan_LianCheckOK = 1;
  2156. //两路顶针离开
  2157. if(!QDCT_XM_OUT && (!QDCT_QLTCZ_IN || !QDCT_PARAM_QLT_ON) && (!QDCT_HLTCZ_IN || !QDCT_PARAM_HLT_ON))
  2158. {
  2159. //结束
  2160. QDCT_MotorStep = 40;
  2161. }
  2162. else if(dwTickCount >= QDCT_MotorDelay)
  2163. {
  2164. QDCT_SetAlarmCode(QDCT_START_LTCZ_ALARM);
  2165. }
  2166. if(bRunning)
  2167. {
  2168. if(!QDCT_NO_ZIPPER_CHECK_IN)
  2169. QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
  2170. }
  2171. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  2172. {
  2173. QDCT_JD_OUT = 0;
  2174. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  2175. user_datas[128] = 10;
  2176. }
  2177. break;
  2178. case 80:
  2179. jz_buff = dwXRealPos;
  2180. if(QDCT_PARAM_SJZ_LENGTH == 0)
  2181. {
  2182. QDCT_JD_OUT = 0;
  2183. }
  2184. QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME;
  2185. QDCT_MotorStep = 81;
  2186. break;
  2187. case 81:
  2188. if(!QDCT_JD_OUT || (dwTickCount >= QDCT_MotorDelay))
  2189. {
  2190. if((QDCT_CHUAN_LIAN_CHECK_SELECT == 0) || cChuan_LianCheckOK)
  2191. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,(QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH),
  2192. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,15,15,50);
  2193. else
  2194. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,(1000 + QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH),
  2195. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,15,15,50);
  2196. QDCT_MotorStep = 82;
  2197. }
  2198. break;
  2199. case 82:
  2200. //松夹子长度
  2201. if(((QDCT_PARAM_SJZ_LENGTH) <= (dwXRealPos - jz_buff)))
  2202. {
  2203. QDCT_JD_OUT = 0;
  2204. QDCT_MotorStep = 83;
  2205. }
  2206. else if(!X_DRV)
  2207. {
  2208. QDCT_JD_OUT = 0;
  2209. QDCT_MotorStep = 83;
  2210. }
  2211. if(!QDCT_JD_OUT || (500 <= (dwXRealPos - jz_buff)))
  2212. {
  2213. cSL_En = 2;
  2214. }
  2215. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  2216. {
  2217. QDCT_JD_OUT = 0;
  2218. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  2219. user_datas[128] = 13;
  2220. }
  2221. break;
  2222. case 83: // 切断完成后拉电机动作
  2223. if(!X_DRV)
  2224. {
  2225. QDCT_MotorStep = 0;
  2226. QDCT_MotorDelay = dwTickCount;
  2227. }
  2228. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
  2229. {
  2230. QDCT_JD_OUT = 0;
  2231. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  2232. user_datas[128] = 14;
  2233. }
  2234. break;
  2235. case 61: // 前点定位数控模式
  2236. QDCT_MotorDelay = dwTickCount;
  2237. if((QDCT_JD_OUT && (!QDCT_GO_LIMIT_IN)) || (GetEn(X_AXIS) == QDCT_MOTOR_DISEN))
  2238. {
  2239. if(!QDCT_GO_LIMIT_IN)
  2240. QDCT_JD_OUT = 0;
  2241. if((GetEn(X_AXIS) == QDCT_MOTOR_DISEN))
  2242. QDCT_MotorDelay = dwTickCount + 40;
  2243. }
  2244. //下模不动时要推链
  2245. if(QDCT_PARAM_XM_MODE && !QDCT_SL_OUT && !QDCT_JD_OUT)
  2246. QDCT_TuiLianStep = 1;
  2247. //QDCT_SZ_OUT = QDCT_MOTOR_EN;
  2248. SetEn(X_AXIS, QDCT_MOTOR_EN);
  2249. QDCT_MotorStep = 62;
  2250. break;
  2251. case 62://电机锁轴时间到
  2252. if(dwTickCount >= QDCT_MotorDelay)
  2253. {
  2254. //已经夹住并且在前点的条件,认为布带已经夹好
  2255. if(QDCT_JD_OUT && QDCT_GO_LIMIT_IN)
  2256. {
  2257. QDCT_MotorStep = 67;
  2258. }
  2259. else{
  2260. //前点亮的情况下要先后退离开
  2261. if(QDCT_GO_LIMIT_IN )
  2262. {
  2263. //后退离开长度
  2264. AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_START_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  2265. 10,10);
  2266. QDCT_MotorDelay = dwTickCount + 500;
  2267. QDCT_MotorStep = 620;
  2268. }
  2269. else
  2270. {
  2271. QDCT_MotorStep = 63;
  2272. QDCT_MotorDelay = dwTickCount;
  2273. }
  2274. QDCT_JD_OUT = 0;
  2275. }
  2276. }
  2277. break;
  2278. case 620:
  2279. if(QDCT_GO_LIMIT_IN)
  2280. {
  2281. SetPos(X_AXIS, 0);
  2282. }
  2283. else //后退离开长度
  2284. {
  2285. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_START_SPEED,500,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  2286. 10,10,0);
  2287. QDCT_MotorStep = 63;
  2288. QDCT_MotorDelay = dwTickCount + 500;
  2289. }
  2290. break;
  2291. case 63:// 前进
  2292. if(!X_DRV && !QDCT_GO_LIMIT_IN && (dwTickCount >= QDCT_MotorDelay) && QDCT_SYL_ORIGIN_IN)
  2293. {
  2294. go_buff = dwXRealPos;
  2295. //不是第一次
  2296. if(dwZipCnt > 0)
  2297. {
  2298. if(dwZipCnt == 5) //扎数到的启动
  2299. AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_JJGO_SPEED/2,-(dwXRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH),
  2300. QDCT_PARAM_START_SPEED,QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,0);
  2301. // AxisMoveTwoPosNoStop(X_AXIS,QDCT_PARAM_JJGO_SPEED/2,(dwXRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH-QDCT_PARAM_JJDINGWEI_LENGTH),
  2302. // QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_GO_LOWSPEED_LENGTH-100,QDCT_DIR_N,
  2303. // QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE+20,QDCT_PARAM_DEC_PULSE+10);
  2304. else
  2305. AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_JJGO_SPEED,-(dwXRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH-QDCT_PARAM_JJDINGWEI_LENGTH),
  2306. QDCT_PARAM_START_SPEED,QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,0);
  2307. // AxisMoveTwoPosNoStop(X_AXIS,QDCT_PARAM_JJGO_SPEED,(dwXRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH-QDCT_PARAM_JJDINGWEI_LENGTH),
  2308. // QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_GO_LOWSPEED_LENGTH-100,QDCT_DIR_N,
  2309. // QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE+20,QDCT_PARAM_DEC_PULSE+10);
  2310. QDCT_MotorStep = 65;
  2311. QDCT_MotorDelay = dwTickCount + QDCT_MOTOR_ALARM_TIME;
  2312. }//第一次
  2313. else
  2314. {
  2315. AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_GO_LOWSPEED,QDCT_DIR_N,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  2316. 15,15);
  2317. QDCT_MotorDelay = dwTickCount + QDCT_MOTOR_ALARM_TIME;
  2318. QDCT_MotorStep = 65;
  2319. }
  2320. }
  2321. else if(dwTickCount >= QDCT_MotorDelay+3000)
  2322. {
  2323. if(!QDCT_SYL_ORIGIN_IN)
  2324. QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
  2325. }
  2326. break;
  2327. case 65:
  2328. //碰到前点限位停止
  2329. if(QDCT_GO_LIMIT_IN)
  2330. {
  2331. SetPos(X_AXIS, QDCT_PARAM_JJDINGWEI_LENGTH);
  2332. QDCT_MotorStep = 66;
  2333. dwXRealPos = GetPos(X_AXIS);
  2334. user_datas[125]=GetCurSpeed(X_AXIS);
  2335. AxisMovePosAccDec(X_AXIS,3000,-QDCT_PARAM_JJDINGWEI_LENGTH,
  2336. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,5,5,0);
  2337. }
  2338. else if(dwTickCount >= QDCT_MotorDelay)
  2339. QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
  2340. break;
  2341. case 66:
  2342. if(dwXRealPos <= 0 || !X_DRV) //位置到零点后停止
  2343. {
  2344. AxisEgmStop(X_AXIS);
  2345. SetPos(X_AXIS, 0);
  2346. QDCT_MotorStep = 67;
  2347. }
  2348. break;
  2349. case 67:
  2350. if(!X_DRV) //电机已经
  2351. {
  2352. QDCT_MotorDelay = dwTickCount;
  2353. QDCT_MotorStep = 68;
  2354. }
  2355. break;
  2356. case 68:
  2357. if(dwTickCount >= QDCT_MotorDelay)
  2358. {
  2359. if(QDCT_JiaLianStep == 0)
  2360. {
  2361. QDCT_JiaLianStep = 1;
  2362. QDCT_MotorStep = 69;
  2363. }
  2364. }
  2365. break;
  2366. case 69:
  2367. if(QDCT_JiaLianStep == 0)
  2368. {
  2369. QDCT_MotorStep = 0;
  2370. if(bRunning == 0)
  2371. {
  2372. SetEn(X_AXIS, QDCT_MOTOR_DISEN); //手动下松轴方便手拉
  2373. QDCT_YD_OUT = 0;
  2374. }
  2375. }
  2376. break;
  2377. case 150:
  2378. jz_buff = dwXRealPos;
  2379. QDCT_JD_OUT = 0;
  2380. QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME;
  2381. QDCT_MotorStep = 151;
  2382. break;
  2383. case 151:
  2384. if(QDCT_JD_OUT || (dwTickCount >= QDCT_MotorDelay))
  2385. {
  2386. if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos+QDCT_PARAM_CUT_BACK_LENGTH)
  2387. {
  2388. temppos = QDCT_PARAM_MAX_BACK_LENGTH-dwXRealPos-200;
  2389. }
  2390. else
  2391. {
  2392. temppos = QDCT_PARAM_CUT_BACK_LENGTH;
  2393. }
  2394. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,temppos,
  2395. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,15,15,0);
  2396. QDCT_MotorStep = 152;
  2397. }
  2398. break;
  2399. case 152:
  2400. if(!X_DRV)
  2401. {
  2402. QDCT_MotorStep = 153;
  2403. QDCT_MotorDelay = dwTickCount + 30;
  2404. }
  2405. break;
  2406. case 153:
  2407. if(dwTickCount >= QDCT_MotorDelay)
  2408. {
  2409. jz_buff = dwXRealPos;
  2410. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJGO_SPEED,-(QDCT_PARAM_TRANS_LENGTH + temppos-3500),
  2411. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  2412. QDCT_MotorStep = 154;
  2413. }
  2414. break;
  2415. case 154:
  2416. if((!X_DRV))
  2417. {
  2418. AxisEgmStop(X_AXIS);
  2419. QDCT_MotorStep = 0;
  2420. }
  2421. break;
  2422. //以下为夹子进去夹废料
  2423. case 200:
  2424. //QDCT_JJ_DIR = QDCT_JJ_DIR_P;
  2425. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_GO_LOWSPEED,dwXRealPos-350,
  2426. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
  2427. QDCT_MotorStep = 201;
  2428. break;
  2429. case 201:
  2430. if(!X_DRV)
  2431. {
  2432. QDCT_JD_OUT = 1;
  2433. QDCT_MotorStep = 202;
  2434. QDCT_MotorDelay = dwTickCount + 50;
  2435. }
  2436. break;
  2437. case 202:
  2438. if(dwTickCount >= QDCT_MotorDelay)
  2439. {
  2440. QDCT_MotorStep = 0;
  2441. }
  2442. break;
  2443. }
  2444. }
  2445. //切断动作
  2446. void QDCT_XiaQieAction(void)
  2447. {
  2448. dwXRealPos = GetPos(X_AXIS);
  2449. dwYRealPos = GetPos(Y_AXIS);
  2450. user_datas[121] = dwXRealPos;// GetPos(Y_AXIS);//QDCT_HZhuangLiaoStep;//QDCT_AutoStep;
  2451. //user_datas[122] = dwYRealPos;
  2452. if(user_datas[122]<GetCurSpeed(X_AXIS))
  2453. user_datas[122] = GetCurSpeed(X_AXIS);
  2454. user_datas[123] = QDCT_MotorStep;
  2455. user_datas[124] = QDCT_AutoStep ;
  2456. //user_datas[125] = QZhuangLiaoOkFlg;//QDCT_XiaQieStep;//cChuan_LianCheckOK;
  2457. user_datas[126] = GetCurSpeed(X_AXIS);
  2458. //user_datas[127] = QDCT_HZhuangLiaoStep;
  2459. //user_datas[128] = QDCT_MotorStepSave;//HZhuangLiaoOkFlg;//QDCT_HeMoStep;//tXAxisStepper.cPmovPulse;
  2460. #if 1
  2461. switch(QDCT_XiaQieStep)
  2462. {
  2463. case 1:
  2464. if(bRunning)
  2465. {
  2466. if(!QDCT_NO_ZIPPER_CHECK_IN)
  2467. {
  2468. QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
  2469. }
  2470. }
  2471. if(QDCT_GO_LIMIT_IN )
  2472. {
  2473. QDCT_SetAlarmCode(QDCT_GO_LIMIT_ALARM);
  2474. QDCT_XiaQieStep = 0;
  2475. }
  2476. else
  2477. {
  2478. QDCT_XiaQieStep = 2;
  2479. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CUT_DELAY;
  2480. }
  2481. break;
  2482. case 2:
  2483. if(dwTickCount >= QDCT_XiaQieDelay)
  2484. {
  2485. QDCT_XiaQieStep = 3;
  2486. QDCT_YD_OUT = 1;
  2487. QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2488. if(!QDCT_PARAM_XM_MODE)// && !QDCT_PARAM_CS_ENABLE)
  2489. {
  2490. QDCT_XQ_OUT = 1;
  2491. }
  2492. }
  2493. break;
  2494. case 3:
  2495. if(QDCT_XQ_LIMIT_IN || QDCT_PARAM_CS_ENABLE)//|| QDCT_PARAM_XM_MODE )//|| QDCT_PARAM_CS_ENABLE)
  2496. {
  2497. QDCT_XiaQieDelay = dwTickCount;
  2498. QDCT_XiaQieStep = 4;
  2499. }
  2500. else if(dwTickCount >= QDCT_XiaQieDelay)
  2501. {
  2502. QDCT_SetAlarmCode(QDCT_XQ_ALARM);
  2503. QDCT_XiaQieStep = 0;
  2504. }
  2505. break;
  2506. case 4:
  2507. if(dwTickCount >= QDCT_XiaQieDelay)
  2508. {
  2509. if(!QDCT_SL_ORIGIN_IN && QDCT_PARAM_XM_MODE)
  2510. QDCT_SetAlarmCode(QDCT_SL_ORIGIN_ALARM);
  2511. else
  2512. {
  2513. QDCT_SQ_OUT = 1; //上切刀输出
  2514. if(!QDCT_PARAM_XM_MODE)QDCT_XQ_OUT = 1;
  2515. QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2516. QDCT_XiaQieStep = 5;
  2517. }
  2518. }
  2519. break;
  2520. case 5:
  2521. //上下切刀到位
  2522. if(QDCT_SQ_LIMIT_IN && (QDCT_XQ_LIMIT_IN || QDCT_PARAM_XM_MODE))
  2523. {
  2524. cQDCT_TuiLianOKFlag = 0;
  2525. if(QDCT_PARAM_CS_ENABLE)
  2526. {
  2527. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_DELAY;
  2528. QDCT_XiaQieStep = 50; //跳到超声处理
  2529. }
  2530. else
  2531. {
  2532. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CUTBACK_DELAY;
  2533. QDCT_XiaQieStep = 6;
  2534. }
  2535. }
  2536. else if(dwTickCount >= QDCT_XiaQieDelay)
  2537. {
  2538. if(!QDCT_SQ_LIMIT_IN)
  2539. {
  2540. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  2541. QDCT_XiaQieStep = 0;
  2542. }
  2543. else if(QDCT_PARAM_XM_MODE== 0) // 下模动才警告下模
  2544. {
  2545. QDCT_SetAlarmCode(QDCT_XQ_ALARM);
  2546. QDCT_XiaQieStep = 0;
  2547. }
  2548. }
  2549. break;
  2550. case 6:
  2551. if(dwTickCount >= QDCT_XiaQieDelay)
  2552. {
  2553. QDCT_SQ_OUT = 0;
  2554. if(!QDCT_PARAM_XM_MODE)QDCT_XQ_OUT = 0;
  2555. QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2556. QDCT_XiaQieStep = 7;
  2557. }
  2558. break;
  2559. case 7:
  2560. if(!QDCT_SQ_LIMIT_IN && (!QDCT_XQ_LIMIT_IN || QDCT_PARAM_XM_MODE))
  2561. {
  2562. //下模动
  2563. if(QDCT_PARAM_XM_MODE && !QDCT_SL_OUT && !bRunning)
  2564. QDCT_TuiLianStep = 1;
  2565. QDCT_XiaQieStep = 0;
  2566. }
  2567. else if(dwTickCount >= QDCT_XiaQieDelay)
  2568. {
  2569. QDCT_XiaQieStep = 0;
  2570. if(QDCT_SQ_LIMIT_IN) QDCT_SetAlarmCode(QDCT_SQ_ORIGIN_ALARM);
  2571. else if(QDCT_XQ_LIMIT_IN)QDCT_SetAlarmCode(QDCT_XQ_ALARM);
  2572. }
  2573. break;
  2574. case 50:
  2575. if(dwTickCount >= QDCT_XiaQieDelay)
  2576. {
  2577. // if(QDCT_PARAM_CS_CONTROL)
  2578. QDCT_CS_OUT = 1;
  2579. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_TIME;
  2580. QDCT_XiaQieStep = 51;
  2581. }
  2582. break;
  2583. case 51:
  2584. if((dwTickCount >= QDCT_XiaQieDelay))
  2585. {
  2586. QDCT_CS_OUT = 0;
  2587. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_COLD_TIME;
  2588. QDCT_XiaQieStep = 6;
  2589. }
  2590. break;
  2591. }
  2592. #endif
  2593. }
  2594. //装拉头完成合模动作
  2595. void QDCT_HeMo_Step(void)
  2596. {
  2597. switch(QDCT_HeMoStep)
  2598. {
  2599. case 0:
  2600. break;
  2601. case 1:
  2602. if(QZhuangLiaoOkFlg && HZhuangLiaoOkFlg && (QDCT_QZhuangLiaoStep == 0) && (QDCT_HZhuangLiaoStep == 0))
  2603. {
  2604. // 前横送输出 前限位 前横送输出 前夹拉头 后横送输出 后夹拉头
  2605. if(!QDCT_QHSL_OUT && (QDCT_GO_LIMIT_IN || cXiaMo_En)&& QDCT_QJLT_IN && !QDCT_HHSL_OUT && QDCT_HJLT_IN)
  2606. {
  2607. QDCT_XM_OUT = 1; //下模输出
  2608. QDCT_HeMoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2609. QDCT_HeMoStep = 2;
  2610. QDCT_QZhuangLiaoStep = 0;
  2611. QDCT_HZhuangLiaoStep = 0;
  2612. }
  2613. else if(dwTickCount >= QDCT_HeMoDelay)
  2614. {
  2615. if(!QDCT_HJLT_IN)
  2616. {
  2617. QDCT_SetAlarmCode(QDCT_HJLT_ALARM);
  2618. }
  2619. else if(!QDCT_QJLT_IN)
  2620. {
  2621. QDCT_SetAlarmCode(QDCT_JLT_ALARM);
  2622. }
  2623. else if(!QDCT_GO_LIMIT_IN)
  2624. {
  2625. QDCT_SetAlarmCode(QDCT_GO_LIMIT_ALARM);
  2626. }
  2627. else if(QDCT_QHSL_OUT || QDCT_HHSL_OUT)
  2628. {
  2629. QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
  2630. }
  2631. }
  2632. }
  2633. break;
  2634. case 2:
  2635. if(QDCT_XM_LIMIT_IN) //下模到位
  2636. {
  2637. QDCT_HeMoStep = 3;
  2638. QDCT_HeMoDelay = dwTickCount + 100;
  2639. }
  2640. else if(dwTickCount >= QDCT_HeMoDelay)
  2641. {
  2642. QDCT_SetAlarmCode(QDCT_XM_LIMIT_ALARM);
  2643. }
  2644. break;
  2645. case 3:
  2646. //两个顶针信号或调试模式
  2647. if((QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) )
  2648. {
  2649. QTryCnt = 0;
  2650. HTryCnt = 0;
  2651. cHemo_OK = 1;
  2652. QDCT_HeMoStep = 0;
  2653. }
  2654. else if(dwTickCount >= QDCT_HeMoDelay)
  2655. {
  2656. if(bRunning)
  2657. {
  2658. QTryCnt++;
  2659. QDCT_HeMoStep = 4;
  2660. if(QTryCnt >= 4)
  2661. {
  2662. SetAlarmCode(QDCT_ALARM_ADDR,QDCT_ZLT_ALARM);
  2663. cHemo_OK = 0;
  2664. if(!QDCT_QLTCZ_IN && QDCT_PARAM_QLT_ON)
  2665. {
  2666. QZhuangLiaoOkFlg = 0;
  2667. QDCT_QJLT_OUT = 0;
  2668. }
  2669. if(!QDCT_HLTCZ_IN && QDCT_PARAM_HLT_ON)
  2670. {
  2671. HZhuangLiaoOkFlg = 0;
  2672. QDCT_HJLT_OUT = 0;
  2673. }
  2674. }
  2675. else
  2676. {
  2677. if(!QDCT_QLTCZ_IN && QDCT_PARAM_QLT_ON)
  2678. QZhuangLiaoOkFlg = 0;
  2679. if(!QDCT_HLTCZ_IN && QDCT_PARAM_HLT_ON)
  2680. HZhuangLiaoOkFlg = 0;
  2681. }
  2682. }
  2683. }
  2684. break;
  2685. case 4:
  2686. if(QDCT_GO_LIMIT_IN || (dwXRealPos > 1600) || ((dwXRealPos > 1200) && !X_DRV))
  2687. {
  2688. QDCT_XM_OUT = 0;
  2689. QDCT_HeMoDelay = dwTickCount + 600;
  2690. if(QTryCnt >= 4)
  2691. {
  2692. QDCT_HeMoStep = 0;
  2693. QDCT_SetAlarmCode(QDCT_ZLT_ALARM);
  2694. }
  2695. else
  2696. QDCT_HeMoStep = 5;
  2697. }
  2698. break;
  2699. case 5:
  2700. if(!QDCT_XM_LIMIT_IN) //下模下到位
  2701. {
  2702. QDCT_HeMoDelay = dwTickCount + 250;
  2703. QDCT_HeMoStep = 6;
  2704. }
  2705. else if(dwTickCount >= QDCT_HeMoDelay)
  2706. {
  2707. QDCT_HeMoStep = 0;
  2708. QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  2709. }
  2710. break;
  2711. case 6:
  2712. if(dwTickCount >= QDCT_HeMoDelay)
  2713. {
  2714. QDCT_HeMoStep = 1;
  2715. QDCT_HeMoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2716. if((QZhuangLiaoOkFlg == 0)&& QDCT_PARAM_QLT_ON)
  2717. {
  2718. QDCT_QJLT_OUT = 0;
  2719. QDCT_QZhuangLiaoStep = 1;
  2720. }
  2721. if((HZhuangLiaoOkFlg== 0 )&& QDCT_PARAM_HLT_ON)
  2722. {
  2723. QDCT_HJLT_OUT = 0;
  2724. QDCT_HZhuangLiaoStep = 1;
  2725. }
  2726. }
  2727. break;
  2728. }
  2729. if(bRunning && (QDCT_HeMoStep == 0) && (QDCT_XM_ORIGIN_IN_UP) && (QTryCnt < 3) && !QDCT_XM_OUT)
  2730. {
  2731. if((!QDCT_QJLT_OUT) && (QDCT_QZhuangLiaoStep == 0) && QDCT_PARAM_QLT_ON)
  2732. {
  2733. QZhuangLiaoOkFlg = 0;
  2734. QDCT_QZhuangLiaoStep = 1;
  2735. }
  2736. if(!QDCT_HJLT_OUT &&(QDCT_HZhuangLiaoStep == 0) && QDCT_PARAM_HLT_ON)
  2737. {
  2738. HZhuangLiaoOkFlg = 0;
  2739. QDCT_HZhuangLiaoStep = 1;
  2740. }
  2741. }
  2742. }
  2743. //前装拉头动作(横送拉头)
  2744. void QDCT_QZLT_Step(void)
  2745. {
  2746. switch(QDCT_QZhuangLiaoStep)
  2747. {
  2748. case 1:
  2749. if(!QDCT_PARAM_QLT_ON) //不打开
  2750. {
  2751. QZhuangLiaoOkFlg = 1;
  2752. QDCT_QJLT_OUT = 1;
  2753. }
  2754. if(QZhuangLiaoOkFlg)
  2755. {
  2756. QDCT_QZhuangLiaoStep = 0;
  2757. }
  2758. else
  2759. {
  2760. if(cFirstQStartFlg && QDCT_QJLT_IN && QDCT_QJLT_OUT)
  2761. {
  2762. QZhuangLiaoOkFlg = 1;
  2763. QDCT_QZhuangLiaoStep = 0;
  2764. cFirstQStartFlg = 0;
  2765. }
  2766. else
  2767. {
  2768. cFirstQStartFlg = 0;
  2769. if(QDCT_QTLTStep == 0)
  2770. {
  2771. QDCT_QTLTStep = 1; //推拉头开始 当QTuiLaTouOkFlg = 1 时动作自动清零
  2772. }
  2773. QDCT_QZhuangLiaoStep = 2;
  2774. }
  2775. }
  2776. break;
  2777. case 2: //推拉头完成
  2778. if(QDCT_QTLTStep == 0)
  2779. {
  2780. QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2781. QDCT_QZhuangLiaoStep = 3;
  2782. }
  2783. break;
  2784. case 3: //横送料原点 下模原点
  2785. if(!QDCT_XM_OUT && QDCT_XM_ORIGIN_IN ) //
  2786. {
  2787. if((cSL_En >= 1) || (!bRunning))
  2788. {
  2789. QDCT_QZhuangLiaoStep = 4;
  2790. QDCT_QZhuangLiaoDelay = dwTickCount + 0;//QDCT_PARAM_HSL_DELAY;
  2791. }
  2792. }
  2793. else if(dwTickCount >= QDCT_QZhuangLiaoDelay)
  2794. {
  2795. if(!QDCT_XM_ORIGIN_IN)
  2796. QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  2797. }
  2798. break;
  2799. case 4: //横送输出
  2800. if((dwTickCount >= QDCT_QZhuangLiaoDelay))
  2801. {
  2802. QDCT_QHSL_OUT = 1; //前横送输出
  2803. QDCT_QJLT_OUT = 0; // 前夹拉头关
  2804. QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2805. QDCT_QZhuangLiaoStep = 5;
  2806. }
  2807. break;
  2808. case 5: //横送到位
  2809. if(QDCT_QHSL_LIMIT_IN)
  2810. {
  2811. QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_PARAM_DELAY_JLT;
  2812. QDCT_QZhuangLiaoStep = 6;
  2813. }
  2814. else if(dwTickCount >= QDCT_QZhuangLiaoDelay)
  2815. {
  2816. if(QDCT_QHSL_OUT) //在自动程序运行结束时关闭了横送的情况,不报横送故障
  2817. QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
  2818. QDCT_QHSL_OUT = 0;
  2819. }
  2820. break;
  2821. case 6://延时夹拉头
  2822. if((dwTickCount >= QDCT_QZhuangLiaoDelay)/* && ((cSL_En >= 2) || (!bRunning))*/)
  2823. {
  2824. QDCT_QJLT_OUT = 1;
  2825. QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2826. QDCT_QZhuangLiaoStep = 7;
  2827. }
  2828. break;
  2829. case 7://夹拉头到位
  2830. if(QDCT_QJLT_IN)
  2831. { //
  2832. QTuiLaTouOkFlg = 0;
  2833. QDCT_QTLTStep = 1; //横送料退回时启动推拉头
  2834. QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_PARAM_HSL_DELAY_BACK;
  2835. QDCT_QZhuangLiaoStep = 8;
  2836. }
  2837. else if(dwTickCount >= QDCT_QZhuangLiaoDelay)
  2838. {
  2839. QDCT_SetAlarmCode(QDCT_JLT_ALARM);
  2840. QDCT_QHSL_OUT = 0;
  2841. }
  2842. break;
  2843. case 8:
  2844. if(dwTickCount >= QDCT_QZhuangLiaoDelay)
  2845. {
  2846. QDCT_QHSL_OUT = 0;
  2847. QZhuangLiaoOkFlg = 1;
  2848. QDCT_QZhuangLiaoStep = 9;
  2849. }
  2850. break;
  2851. case 9:
  2852. if(!QDCT_QHSL_LIMIT_IN)
  2853. {
  2854. QDCT_QZhuangLiaoStep = 10;
  2855. QDCT_QZhuangLiaoDelay = dwTickCount + 30;
  2856. }
  2857. break;
  2858. case 10:
  2859. if((dwTickCount >= QDCT_QZhuangLiaoDelay) || QDCT_QHSL_ORIGIN_IN)
  2860. {
  2861. QDCT_QZhuangLiaoStep = 0;
  2862. }
  2863. break;
  2864. }
  2865. }
  2866. //后装拉头动作
  2867. void QDCT_HZLT_Step(void)
  2868. {
  2869. switch(QDCT_HZhuangLiaoStep)
  2870. {
  2871. case 1:
  2872. if(!QDCT_PARAM_HLT_ON)
  2873. {
  2874. HZhuangLiaoOkFlg = 1;
  2875. QDCT_HJLT_OUT = 1;
  2876. }
  2877. if(HZhuangLiaoOkFlg)
  2878. {
  2879. QDCT_HZhuangLiaoStep = 0;
  2880. }
  2881. else
  2882. {
  2883. if(cFirstHStartFlg && QDCT_HJLT_IN && QDCT_HJLT_OUT)
  2884. {
  2885. HZhuangLiaoOkFlg = 1;
  2886. cFirstHStartFlg = 0;
  2887. QDCT_HZhuangLiaoStep = 0;
  2888. }
  2889. else
  2890. {
  2891. cFirstHStartFlg = 0;
  2892. if(QDCT_HTLTStep == 0)
  2893. {
  2894. QDCT_HTLTStep = 1;
  2895. }
  2896. QDCT_HZhuangLiaoStep = 2;
  2897. }
  2898. }
  2899. break;
  2900. case 2:
  2901. if(QDCT_HTLTStep == 0)//后推拉头完成
  2902. {
  2903. QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2904. QDCT_HZhuangLiaoStep = 3;
  2905. }
  2906. break;
  2907. case 3:
  2908. if(!QDCT_XM_OUT && QDCT_XM_ORIGIN_IN ) //
  2909. {
  2910. if((cSL_En >= 1) || (!bRunning))
  2911. {
  2912. QDCT_HZhuangLiaoDelay = dwTickCount + 0;//QDCT_PARAM_HSL_DELAY;
  2913. QDCT_HZhuangLiaoStep = 4;
  2914. }
  2915. }
  2916. else if(dwTickCount >= QDCT_HZhuangLiaoDelay)
  2917. {
  2918. if(!QDCT_XM_ORIGIN_IN)
  2919. QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  2920. }
  2921. break;
  2922. case 4:
  2923. if(dwTickCount >= QDCT_HZhuangLiaoDelay)
  2924. {
  2925. QDCT_HHSL_OUT = 1; //横送料输出
  2926. QDCT_HJLT_OUT = 0;
  2927. QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2928. QDCT_HZhuangLiaoStep = 5;
  2929. }
  2930. break;
  2931. case 5:
  2932. if(QDCT_HHSL_LIMIT_IN) //横送到位
  2933. {
  2934. QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_PARAM_DELAY_JLT;
  2935. QDCT_HZhuangLiaoStep = 6;
  2936. }
  2937. else if(dwTickCount >= QDCT_HZhuangLiaoDelay)
  2938. {
  2939. if(QDCT_HHSL_OUT) //在自动程序运行结束时关闭了横送的情况,不报横送故障
  2940. QDCT_SetAlarmCode(QDCT_HHSL_LIMIT_ALARM);
  2941. QDCT_HHSL_OUT = 0;
  2942. }
  2943. break;
  2944. case 6: //延时夹拉头
  2945. if((dwTickCount >= QDCT_HZhuangLiaoDelay)/* && ((cSL_En >= 2) || (!bRunning))*/)
  2946. {
  2947. QDCT_HJLT_OUT = 1;
  2948. QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  2949. QDCT_HZhuangLiaoStep = 7;
  2950. }
  2951. break;
  2952. case 7://夹拉头到位
  2953. if(QDCT_HJLT_IN)
  2954. {
  2955. HTuiLaTouOkFlg = 0;
  2956. QDCT_HTLTStep = 1; //横送料退回时启动推拉头
  2957. QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_PARAM_HSL_DELAY_BACK;
  2958. QDCT_HZhuangLiaoStep = 8;
  2959. }
  2960. else if(dwTickCount >= QDCT_HZhuangLiaoDelay)
  2961. {
  2962. QDCT_SetAlarmCode(QDCT_HJLT_ALARM);
  2963. QDCT_HHSL_OUT = 0;
  2964. }
  2965. break;
  2966. case 8: //延时退横送料
  2967. if((dwTickCount >= QDCT_HZhuangLiaoDelay))
  2968. {
  2969. QDCT_HHSL_OUT = 0;
  2970. HZhuangLiaoOkFlg = 1;
  2971. QDCT_HZhuangLiaoStep = 9;
  2972. }
  2973. break;
  2974. case 9:
  2975. if(!QDCT_HHSL_LIMIT_IN)
  2976. {
  2977. QDCT_HZhuangLiaoStep = 10;
  2978. QDCT_HZhuangLiaoDelay = dwTickCount + 30;
  2979. }
  2980. break;
  2981. case 10:
  2982. if((dwTickCount >= QDCT_HZhuangLiaoDelay) || QDCT_HHSL_ORIGIN_IN)
  2983. {
  2984. QDCT_HZhuangLiaoStep = 0;
  2985. }
  2986. break;
  2987. }
  2988. }
  2989. //前推拉头动作
  2990. void QDCT_QTuiLT_Step(void)
  2991. {
  2992. static unsigned long q_dlp_delay;
  2993. if(QDCT_QDLP_OUT && (dwTickCount >= q_dlp_delay))
  2994. QDCT_QDLP_OUT = 0;
  2995. switch(QDCT_QTLTStep)
  2996. {
  2997. case 1:
  2998. //前拉头使能
  2999. if(!QDCT_PARAM_QLT_ON)
  3000. {
  3001. QTuiLaTouOkFlg = 1;
  3002. }
  3003. if(QTuiLaTouOkFlg)
  3004. {
  3005. QDCT_QTLTStep = 0;
  3006. }
  3007. else
  3008. {
  3009. QDCT_QTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  3010. QDCT_QTLTStep = 2;
  3011. }
  3012. break;
  3013. case 2:
  3014. if(QDCT_QHSL_ORIGIN_IN && !QDCT_QHSL_LIMIT_IN)
  3015. {
  3016. QDCT_QTLT_OUT = 1;
  3017. if(QTryCnt<= QDCT_PARAM_TRY_TIMES)
  3018. QDCT_QDLP_OUT = 1;
  3019. q_dlp_delay = dwTickCount + QDCT_PARAM_DLP_TIME;
  3020. QDCT_QTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  3021. QDCT_QTLTStep = 3;
  3022. }
  3023. break;
  3024. case 3:
  3025. if(QDCT_QTLT_LIMIT_IN)
  3026. {
  3027. QDCT_QTLT_Delay = dwTickCount + QDCT_PARAM_SL_BACKDELAY;
  3028. QDCT_QTLTStep = 4;
  3029. }
  3030. else if(dwTickCount >= QDCT_QTLT_Delay)
  3031. {
  3032. QDCT_SetAlarmCode(QDCT_SL_ALARM);
  3033. QDCT_QTLT_OUT=0;
  3034. }
  3035. break;
  3036. case 4:
  3037. if((dwTickCount >= QDCT_QTLT_Delay))
  3038. {
  3039. QDCT_QTLT_OUT = 0;
  3040. QDCT_QTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  3041. QDCT_QTLTStep = 5;
  3042. QTuiLaTouOkFlg = 1;
  3043. }
  3044. break;
  3045. case 5:
  3046. if(!QDCT_QTLT_LIMIT_IN)
  3047. {
  3048. QDCT_QTLTStep = 0;
  3049. QDCT_QTLT_Delay = dwTickCount;
  3050. }
  3051. else if(dwTickCount >= QDCT_QTLT_Delay)
  3052. QDCT_SetAlarmCode(QDCT_SL_ALARM);
  3053. break;
  3054. }
  3055. }
  3056. //后推拉头动作
  3057. void QDCT_HTuiLT_Step(void)
  3058. {
  3059. static unsigned long h_dlp_delay;
  3060. // static unsigned short dlp_flg = 0;
  3061. if(QDCT_HDLP_OUT && (dwTickCount >= h_dlp_delay))
  3062. QDCT_HDLP_OUT = 0;
  3063. switch(QDCT_HTLTStep)
  3064. {
  3065. case 1:
  3066. if(!QDCT_PARAM_HLT_ON)
  3067. {
  3068. HTuiLaTouOkFlg = 1;
  3069. }
  3070. if(HTuiLaTouOkFlg)
  3071. {
  3072. QDCT_HTLTStep = 0;
  3073. }
  3074. else
  3075. {
  3076. QDCT_HTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  3077. QDCT_HTLTStep = 2;
  3078. }
  3079. break;
  3080. case 2:
  3081. if(QDCT_HHSL_ORIGIN_IN && !QDCT_HHSL_LIMIT_IN)
  3082. {
  3083. QDCT_HTLT_OUT = 1;
  3084. if(QTryCnt<= QDCT_PARAM_TRY_TIMES)
  3085. QDCT_HDLP_OUT = 1;
  3086. h_dlp_delay = dwTickCount + QDCT_PARAM_DLP_TIME;
  3087. QDCT_HTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  3088. QDCT_HTLTStep = 3;
  3089. }
  3090. break;
  3091. case 3:
  3092. if(QDCT_HTLT_LIMIT_IN)
  3093. {
  3094. QDCT_HTLT_Delay = dwTickCount + QDCT_PARAM_SL_BACKDELAY;
  3095. QDCT_HTLTStep = 4;
  3096. }
  3097. else if(dwTickCount >= QDCT_HTLT_Delay)
  3098. {
  3099. QDCT_SetAlarmCode(QDCT_SL_ALARM);
  3100. QDCT_HTLT_OUT=0;
  3101. }
  3102. break;
  3103. case 4:
  3104. if((dwTickCount >= QDCT_HTLT_Delay))
  3105. {
  3106. QDCT_HTLT_OUT = 0;
  3107. QDCT_HTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  3108. QDCT_HTLTStep = 5;
  3109. HTuiLaTouOkFlg = 1;
  3110. }
  3111. break;
  3112. case 5:
  3113. if(!QDCT_HTLT_LIMIT_IN)
  3114. {
  3115. QDCT_HTLTStep = 0;
  3116. QDCT_HTLT_Delay = dwTickCount;
  3117. }
  3118. else if(dwTickCount >= QDCT_HTLT_Delay)
  3119. QDCT_SetAlarmCode(QDCT_SL_ALARM);
  3120. break;
  3121. }
  3122. }
  3123. //手动动作
  3124. void QDCT_ManualAction(void)
  3125. {
  3126. static unsigned char cs_flg;
  3127. static long cs_delay;
  3128. //轴使能状态,供屏显示
  3129. if(GetEn(X_AXIS)==QDCT_MOTOR_DISEN)
  3130. {
  3131. QDCT_AxisEn_status=0;
  3132. }
  3133. else
  3134. {
  3135. QDCT_AxisEn_status=1;
  3136. }
  3137. //轴使能状态,供屏显示
  3138. if(GetEn(Y_AXIS)==QDCT_MOTOR_DISEN)
  3139. {
  3140. QDCT_YAxisEn_status=0;
  3141. }
  3142. else
  3143. {
  3144. QDCT_YAxisEn_status=1;
  3145. }
  3146. //前振动盘
  3147. if(QDCT_bManQZD)
  3148. {
  3149. QDCT_bManQZD = 0;
  3150. if(QDCT_QZDPStep)
  3151. {
  3152. QDCT_QZDP_OUT = 0;
  3153. QDCT_QZDPStep = 0;
  3154. QZDPAutoDisable=1;
  3155. }
  3156. else
  3157. {
  3158. QDCT_QZDP_OUT = 1;
  3159. QDCT_QZDPStep = 2;
  3160. if(QDCT_TLPStep==0)QDCT_TLPStep = 1;
  3161. QZDPAutoDisable=0;
  3162. }
  3163. }
  3164. //后振动盘
  3165. if(QDCT_bManHZD)
  3166. {
  3167. QDCT_bManHZD = 0;
  3168. if(QDCT_HZDPStep)
  3169. {
  3170. QDCT_HZDP_OUT = 0;
  3171. QDCT_HZDPStep = 0;
  3172. HZDPAutoDisable=1;
  3173. }
  3174. else
  3175. {
  3176. QDCT_HZDP_OUT = 1;
  3177. QDCT_HZDPStep = 2;
  3178. HZDPAutoDisable=0;
  3179. }
  3180. }
  3181. if(bRunning == 0)
  3182. {
  3183. if(bClearTotal) //切断计数清零
  3184. {
  3185. bClearTotal = 0;
  3186. ClrcToTal(QDCT_TOTAL_ADDR);
  3187. }
  3188. if(QDCT_bClerNowTotal)
  3189. {
  3190. QDCT_bClerNowTotal = 0;
  3191. QDCT_PARAM_TB_CNT1 = 0;
  3192. QDCT_PARAM_TB_CNT2 = 0;
  3193. ClrcToTal(QDCT_NOWTOTAL_ADDR);
  3194. }
  3195. //切断
  3196. if(QDCT_bQieDuan)
  3197. {
  3198. QDCT_bQieDuan = 0;
  3199. if(QDCT_XiaQieStep == 0)
  3200. {
  3201. if(QDCT_PARAM_XM_MODE) //下模不动
  3202. {
  3203. if(QDCT_SL_ORIGIN_IN )
  3204. QDCT_XiaQieStep = 1;
  3205. else
  3206. QDCT_SetAlarmCode(QDCT_SL_ORIGIN_ALARM);
  3207. }
  3208. else
  3209. {
  3210. QDCT_XiaQieStep = 1;
  3211. }
  3212. }
  3213. }
  3214. //测试行程
  3215. if(QDCT_bReset_Origin)
  3216. {
  3217. QDCT_bReset_Origin = 0;
  3218. cTestMotorStep = 1;
  3219. }
  3220. //前点定位
  3221. if(QDCT_bQianDianDW)
  3222. {
  3223. QDCT_bQianDianDW = 0;
  3224. if((QDCT_MotorStep == 0) && !QDCT_SQ_LIMIT_IN && (!QDCT_XQ_LIMIT_IN || QDCT_PARAM_XM_MODE) && QDCT_SYL_ORIGIN_IN && !QDCT_YL_LIMIT_IN)
  3225. {
  3226. QDCT_MotorStep = 61;
  3227. dwZipCnt = 0;
  3228. }
  3229. else if(QDCT_SQ_LIMIT_IN)
  3230. {
  3231. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  3232. }
  3233. else if(!QDCT_SYL_ORIGIN_IN)
  3234. {
  3235. QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
  3236. }
  3237. else if(QDCT_YL_LIMIT_IN)
  3238. {
  3239. QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
  3240. }
  3241. }
  3242. //下模
  3243. if(QDCT_bManXM)
  3244. {
  3245. QDCT_bManXM = 0;
  3246. QDCT_XM_OUT = ~QDCT_XM_OUT;
  3247. if(QDCT_QHSL_OUT || QDCT_HHSL_OUT)QDCT_XM_OUT = 0;
  3248. }
  3249. //上切刀
  3250. if(QDCT_bManSQ)
  3251. {
  3252. QDCT_bManSQ = 0;
  3253. if(QDCT_SQ_OUT)
  3254. QDCT_SQ_OUT = 0;
  3255. // 送料原点 下模动 //下模不动
  3256. else if((QDCT_SL_ORIGIN_IN && (QDCT_PARAM_XM_MODE != 0))||(QDCT_PARAM_XM_MODE == 0))
  3257. {
  3258. QDCT_SQ_OUT = 1;
  3259. cQDCT_TuiLianOKFlag = 0;
  3260. }
  3261. }
  3262. //下切刀
  3263. if(QDCT_bManXQ)
  3264. {
  3265. QDCT_bManXQ = 0;
  3266. if(!QDCT_PARAM_XM_MODE) //有下刀
  3267. {
  3268. QDCT_XQ_OUT = ~QDCT_XQ_OUT;
  3269. //QDCT_SL_OUT = 0;
  3270. }
  3271. else
  3272. {
  3273. QDCT_SL_OUT = ~QDCT_SL_OUT;
  3274. //QDCT_XQ_OUT = 0;
  3275. }
  3276. cQDCT_TuiLianOKFlag = 0;
  3277. if(QDCT_GO_LIMIT_IN)
  3278. {
  3279. QDCT_XQ_OUT = 0;
  3280. QDCT_SL_OUT=0;
  3281. }
  3282. }
  3283. //夹带
  3284. if(QDCT_bManJD)
  3285. {
  3286. QDCT_bManJD = 0;
  3287. QDCT_JD_OUT = ~QDCT_JD_OUT;
  3288. }
  3289. //前推拉头
  3290. if(QDCT_bManQTLT)
  3291. {
  3292. QDCT_bManQTLT = 0;
  3293. if(QDCT_QHSL_ORIGIN_IN)
  3294. {
  3295. if(QDCT_QTLTStep == 0)
  3296. {
  3297. QDCT_QTLTStep = 1;
  3298. QTuiLaTouOkFlg = 0;
  3299. QTryCnt = 0;
  3300. }
  3301. else
  3302. {
  3303. QDCT_QTLT_OUT = 0;
  3304. }
  3305. }
  3306. }
  3307. //后推拉头
  3308. if(QDCT_bManHTLT)
  3309. {
  3310. QDCT_bManHTLT = 0;
  3311. if(QDCT_HHSL_ORIGIN_IN)
  3312. {
  3313. if(QDCT_HTLTStep == 0)
  3314. {
  3315. QDCT_HTLTStep = 1;
  3316. HTuiLaTouOkFlg = 0;
  3317. QTryCnt = 0;
  3318. }
  3319. else //后推拉头
  3320. QDCT_HTLT_OUT = 0;
  3321. }
  3322. }
  3323. //前横送料
  3324. if(QDCT_bManQHSL)
  3325. {
  3326. QDCT_bManQHSL = 0;
  3327. QDCT_QHSL_OUT = ~QDCT_QHSL_OUT;
  3328. if(QDCT_XM_OUT || QDCT_QTLT_LIMIT_IN) QDCT_QHSL_OUT = 0;
  3329. if(QDCT_QHSL_OUT && QDCT_QJLT_OUT) QDCT_QJLT_OUT=0;
  3330. }
  3331. if(QDCT_bManHHSL)
  3332. {
  3333. QDCT_bManHHSL = 0;
  3334. QDCT_HHSL_OUT = ~QDCT_HHSL_OUT;
  3335. if(QDCT_XM_OUT || QDCT_HTLT_LIMIT_IN)QDCT_HHSL_OUT = 0;
  3336. if(QDCT_HHSL_OUT && QDCT_HJLT_OUT) QDCT_HJLT_OUT=0;
  3337. }
  3338. /*
  3339. //前振动盘
  3340. if(QDCT_bManQZD)
  3341. {
  3342. QDCT_bManQZD = 0;
  3343. if(QDCT_QZDPStep)
  3344. {
  3345. QDCT_QZDP_OUT = 0;
  3346. QDCT_QZDPStep = 0;
  3347. }
  3348. else
  3349. {
  3350. QDCT_QZDP_OUT = 1;
  3351. QDCT_QZDPStep = 2;
  3352. if(QDCT_TLPStep==0)QDCT_TLPStep = 1;
  3353. }
  3354. }
  3355. //后振动盘
  3356. if(QDCT_bManHZD)
  3357. {
  3358. QDCT_bManHZD = 0;
  3359. if(QDCT_HZDPStep)
  3360. {
  3361. QDCT_HZDP_OUT = 0;
  3362. QDCT_HZDPStep = 0;
  3363. }
  3364. else
  3365. {
  3366. QDCT_HZDP_OUT = 1;
  3367. QDCT_HZDPStep = 2;
  3368. }
  3369. }
  3370. */
  3371. //前夹拉头
  3372. if(QDCT_bManQJLT)
  3373. {
  3374. QDCT_bManQJLT = 0;
  3375. QDCT_QJLT_OUT = ~QDCT_QJLT_OUT;
  3376. if(!QDCT_QJLT_OUT)
  3377. QZhuangLiaoOkFlg = 0;
  3378. }
  3379. //后夹拉头
  3380. if(QDCT_bManHJLT)
  3381. {
  3382. QDCT_bManHJLT = 0;
  3383. QDCT_HJLT_OUT = ~QDCT_HJLT_OUT;
  3384. if(!QDCT_HJLT_OUT)
  3385. HZhuangLiaoOkFlg = 0;
  3386. }
  3387. //台面电机
  3388. if(QDCT_bTable)
  3389. {
  3390. QDCT_bTable = 0;
  3391. QDCT_TB_OUT = ~QDCT_TB_OUT;
  3392. if(QDCT_TB_OUT)
  3393. QDCT_TableDelay = dwTickCount+100000;
  3394. else
  3395. QDCT_TableDelay = dwTickCount+100;
  3396. }
  3397. //前装料
  3398. if(QDCT_bQZuangLT)
  3399. {
  3400. QDCT_bQZuangLT = 0;
  3401. if(QDCT_QZhuangLiaoStep == 0)
  3402. {
  3403. QTryCnt = 0;
  3404. QTuiLaTouOkFlg = 1;
  3405. QDCT_QZhuangLiaoStep = 3;
  3406. cFirstQStartFlg = 0;
  3407. }
  3408. }
  3409. //后装料
  3410. if(QDCT_bHZuangLT)
  3411. {
  3412. QDCT_bHZuangLT = 0;
  3413. if(QDCT_HZhuangLiaoStep == 0)
  3414. {
  3415. QTryCnt = 0;
  3416. HTuiLaTouOkFlg = 1;
  3417. QDCT_HZhuangLiaoStep = 3;
  3418. cFirstHStartFlg = 0;
  3419. }
  3420. }
  3421. //压带
  3422. if(QDCT_bManYD)
  3423. {
  3424. QDCT_bManYD = 0;
  3425. QDCT_YD_OUT = ~QDCT_YD_OUT;
  3426. }
  3427. //吹气
  3428. if(QDCT_bManCQ)
  3429. {
  3430. QDCT_bManCQ = 0;
  3431. QDCT_CQ_OUT = 1;//~QDCT_CQ_OUT; //吹气
  3432. QDCT_CQDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
  3433. }
  3434. //推拉片
  3435. if(QDCT_bManDLP)
  3436. {
  3437. QDCT_bManDLP = 0;
  3438. QDCT_TLP_OUT = ~QDCT_TLP_OUT;
  3439. }
  3440. //穿拉头
  3441. if(QDCT_bChuanLT)
  3442. {
  3443. QDCT_bChuanLT = 0;
  3444. if(!QDCT_BACK_LIMIT_IN)
  3445. {
  3446. if(QDCT_MotorStep == 0)QDCT_MotorStep = 30;
  3447. }
  3448. }
  3449. //电机松轴
  3450. if(QDCT_bManSZ)
  3451. {
  3452. QDCT_bManSZ = 0;
  3453. if(GetEn(X_AXIS)==QDCT_MOTOR_DISEN)
  3454. {
  3455. SetEn(X_AXIS, QDCT_MOTOR_EN);
  3456. }
  3457. else
  3458. {
  3459. SetEn(X_AXIS, QDCT_MOTOR_DISEN);
  3460. }
  3461. }
  3462. //电机控制
  3463. if(QDCT_bMotorGo && !QDCT_GO_LIMIT_IN && !QDCT_SQ_LIMIT_IN)
  3464. {
  3465. QDCT_JD_OUT = 0;
  3466. //QDCT_JJ_DIR = QDCT_JJ_DIR_P;
  3467. //QDCT_SZ_OUT = QDCT_MOTOR_EN;
  3468. SetEn(X_AXIS, QDCT_MOTOR_EN);
  3469. cBackLimitCheck_EN= 0;
  3470. if(!X_DRV)AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_N,
  3471. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  3472. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  3473. }
  3474. else if(QDCT_bMotorGo && QDCT_SQ_LIMIT_IN)
  3475. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  3476. if(QDCT_bMotorBack && !QDCT_BACK_LIMIT_IN)
  3477. {
  3478. // QDCT_JD_OUT = 0;
  3479. //QDCT_SZ_OUT = QDCT_MOTOR_EN;
  3480. SetEn(X_AXIS, QDCT_MOTOR_EN);
  3481. //QDCT_JJ_DIR = QDCT_JJ_DIR_N;
  3482. cBackLimitCheck_EN = 1;
  3483. if(!X_DRV)AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,
  3484. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  3485. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  3486. }
  3487. if(!QDCT_bMotorGo && !QDCT_bMotorBack && (QDCT_MotorStep == 0) && (cStopFlg == 0) && (cTestMotorStep == 0))
  3488. {
  3489. if(X_DRV)AxisDecStop(X_AXIS);
  3490. }
  3491. if(QDCT_GO_LIMIT_IN && (QDCT_MotorStep == 0) && !QDCT_bMotorBack &&(QDCT_AutoStep == 0) && (cStopFlg == 0) && (cStopFlg == 0) && (cTestMotorStep == 0))
  3492. {
  3493. if(X_DRV)AxisEgmStop(X_AXIS);
  3494. }
  3495. if(QDCT_bYLGO)
  3496. {
  3497. SetEn(Y_AXIS, QDCT_MOTOR_EN);
  3498. //QDCT_YL_DIR = QDCT_YL_DIR_P;
  3499. if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS,QDCT_PARAM_START_SPEED, QDCT_YL_DIR_P,
  3500. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  3501. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  3502. }
  3503. if(QDCT_bYLBACK)
  3504. {
  3505. SetEn(Y_AXIS, QDCT_MOTOR_EN);
  3506. //QDCT_YL_DIR = QDCT_YL_DIR_N;
  3507. if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS,QDCT_PARAM_START_SPEED, QDCT_YL_DIR_N,
  3508. QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
  3509. QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
  3510. }
  3511. if(!QDCT_bYLGO && !QDCT_bYLBACK && (QDCT_MotorStepY == 0) && (QDCT_AutoStep == 0))
  3512. {
  3513. if(Y_DRV)AxisDecStop(Y_AXIS);
  3514. }
  3515. if(QDCT_bYL)
  3516. {
  3517. QDCT_bYL = 0;
  3518. QDCT_YL_OUT = ~QDCT_YL_OUT;
  3519. }
  3520. if(QDCT_bSYL)
  3521. {
  3522. QDCT_bSYL = 0;
  3523. QDCT_SYL_OUT = ~QDCT_SYL_OUT;
  3524. }
  3525. //Y电机松轴
  3526. if(QDCT_bManSZ_Y)
  3527. {
  3528. QDCT_bManSZ_Y = 0;
  3529. if(GetEn(Y_AXIS)==QDCT_MOTOR_DISEN)
  3530. {
  3531. SetEn(Y_AXIS, QDCT_MOTOR_EN);
  3532. }
  3533. else
  3534. {
  3535. SetEn(Y_AXIS, QDCT_MOTOR_DISEN);
  3536. }
  3537. }
  3538. if(QDCT_bManKL)
  3539. {
  3540. QDCT_bManKL = 0;
  3541. //QDCT_KL_OUT = ~QDCT_KL_OUT;
  3542. // QDCT_JiaLianStep = 3;
  3543. }
  3544. if(QDCT_bManCS)
  3545. {
  3546. QDCT_bManCS = 0;
  3547. cs_delay = dwTickCount + QDCT_PARAM_CS_TIME;
  3548. QDCT_CS_OUT = 1;
  3549. cs_flg = 1;
  3550. }
  3551. }
  3552. if(cs_flg)
  3553. {
  3554. if(QDCT_CS_OUT && (dwTickCount >= cs_delay))
  3555. {
  3556. QDCT_CS_OUT = 0;
  3557. cs_flg = 0;
  3558. }
  3559. }
  3560. //这里特殊改动
  3561. // if(QDCT_PARAM_XM_MODE!== 0)
  3562. // {
  3563. if(QDCT_CQ_OUT && (dwTickCount >= QDCT_CQDelay)) QDCT_CQ_OUT = 0;
  3564. // }
  3565. }
  3566. #endif