GLQueduanChuantou.c 150 KB

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