123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575 |
- #include "global.h"
- #if XI_DONG_MACHINE
- /**************************************
- //X000 正转启动
- //X001 反转启动
- //X002 停止
- //X003 步进电机点动
- //X004 电机正、反转开关
- //X005 摆丝电机计数下反转
- //X006 摆丝电机右接近开关
- //X007 摆丝电机左接近开关
- //X010 摆丝电机暂停正、反转开关
- //X011 摆丝电机加速开关
- //X012 摆丝电机点动正、反转
- //X013 卷丝电机点动正、反转
- //X014 1号压丝电机点动正、反转
- //X015 2号压丝电机点动正、反转
- //X016 3号压丝电机点动正、反转
- //X017 4号压丝电机点动正、反转
- //X020 5号压丝电机点动正、反转
- //X021 变频器异常
- //X022 摆丝电机到位接近开关
- //X023 6号压丝电机点动正、反转
- //X024 7号压丝电机点动正、反转
- //X025 8号压丝电机点动正、反转
- //X026 9号压丝电机点动正、反转
- //X027
- //Y000 启动
- //Y001 摆丝电机加速
- //Y002 摆丝电机正转
- //Y003 摆丝电机反转
- //Y004 卷丝电机正转
- //Y005 卷丝电机反转
- //Y006 1号压丝电机正转
- //Y007 1号压丝电机反转
- //Y010 2号压丝电机正转
- //Y011 2号压丝电机反转
- //Y012 3号压丝电机正转
- //Y013 3号压丝电机反转
- //Y014 4号压丝电机正转
- //Y015 4号压丝电机反转
- //Y016 5号压丝电机正转
- //Y017 5号压丝电机反转
- ***************************************/
- #define LS_SETCSB_DIS() SETY015()
- #define LS_SETCSB_EN() CLRY015()
- unsigned char LS_Y02_EN,LS_Y03_EN,LS_bRunning;
- unsigned long LS_cTotal;
- void LS_InitAction(void)
- {
- XGearRatio = 1;
- YGearRatio = 1;
- }
- void LS_Action(void)
- {
- //正转启动 反转启动 变频器异常 停止
- if((X00_UP || X01_UP) && X21 && (X02 == 0) && (LS_bRunning == 0))
- {
- LS_bRunning = 1;
- cStepMByte = 1;
- LS_cTotal = 0;
- SETY000();
- SETY004();
- SETY010();
- SETY012();
- SETY014();
- SETY016();
- SETY020();
- SETY022();
- SETY024();
- SETY026();
- SETY006();
- LS_Y02_EN = 0;
- LS_Y03_EN = 0;
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[3] * 10;
- SETDR();
- LS_SETCSB_DIS();
- if(X01_UP)
- {
- cStepMByte = 11;
- SETY003();
- LS_Y03_EN = 1;
- }
- else
- {
- SETY002();
- LS_Y02_EN = 1;
- }
- }
-
- if(X011)
- {
- SETY001();
- }
- else if(X11_DW)
- CLRY001();
- //手动状态
- if((LS_bRunning == 0) && (X002 == 0) && (dwTickCount >= cDelayTime2))
- {
- if(X003) //
- {
- if(!X_DRV && X03_UP)
- {
- LS_SETCSB_DIS();
- if(X004 == 0) //正转
- {
- SETDR();
- AxisMovePosAccDec(X_AXIS, 5, 10 * user_datas[5],user_datas[4],1,1);
- }
- else if(!X022)
- {
- CLRDR(); //反转
- MoveAction_Const_AccDec(X_AXIS,LS_DIR_P,user_datas[4],user_datas[4],1,1);
- }
- }
- if(X004 != 0) //反转回原点
- {
- if(X022 && (user_datas[6] == 1))AxisEgmStop(X_AXIS);
- }
- }
- else if(X03_DW)
- {
- if(X004 != 0) AxisEgmStop(X_AXIS);
-
- }
- if(X12_UP) //摆丝机点动
- {
- if(X004 == 0) //正转
- {
- SETY002();
- CLRY003();
- }
- else //反转
- {
- CLRY002();
- SETY003();
- }
- }
- else if(X012 == 0)
- {
- CLRY002();
- CLRY003();
- }
- if(X13_UP) //卷丝机点动
- {
- if(X004 == 0) //正转
- {
- SETY004();
- CLRY005();
- }
- else //反转
- {
- CLRY004();
- SETY005();
- }
- }
- else if(X013 == 0)
- {
- CLRY004();
- CLRY005();
- }
- if(X14_UP) //1号压丝机
- {
- if(X004 == 0)
- {
- SETY006();
- CLRY007();
- }
- else
- {
- CLRY006();
- SETY007();
- }
- }
- else if(X014 == 0)
- {
- CLRY006();
- CLRY007();
- }
- if(X15_UP) //2号压丝机
- {
- if(X004 == 0)
- {
- SETY010();
- CLRY011();
- }
- else
- {
- CLRY010();
- SETY011();
- }
- }
- else if(X015 == 0)
- {
- CLRY010();
- CLRY011();
- }
- if(X16_UP) //3号压丝机
- {
- if(X004 == 0)
- {
- SETY012();
- CLRY013();
- }
- else
- {
- CLRY012();
- SETY013();
- }
- }
- else if(X016 == 0)
- {
- CLRY012();
- CLRY013();
- }
- if(X17_UP) //4号压丝机
- {
- if(X004 == 0)
- {
- SETY014();
- CLRY015();
- }
- else
- {
- CLRY014();
- SETY015();
- }
- }
- else if(X017 == 0)
- {
- CLRY014();
- CLRY015();
- }
- if(X20_UP) //5号压丝机
- {
- if(X004 == 0)
- {
- SETY016();
- CLRY017();
- }
- else
- {
- CLRY016();
- SETY017();
- }
- }
- else if(X020 == 0)
- {
- CLRY016();
- CLRY017();
- }
- if(X23_UP) //6号压丝机
- {
- if(X004 == 0)
- {
- SETY020();
- CLRY021();
- }
- else
- {
- CLRY020();
- SETY021();
- }
- }
- else if(X023 == 0)
- {
- CLRY020();
- CLRY021();
- }
- if(X24_UP) //7号压丝机
- {
- if(X004 == 0)
- {
- SETY022();
- CLRY023();
- }
- else
- {
- CLRY022();
- SETY023();
- }
- }
- else if(X024 == 0)
- {
- CLRY022();
- CLRY023();
- }
- if(X25_UP) //8号压丝机
- {
- if(X004 == 0)
- {
- SETY024();
- CLRY025();
- }
- else
- {
- CLRY024();
- SETY025();
- }
- }
- else if(X025 == 0)
- {
- CLRY024();
- CLRY025();
- }
- if(X26_UP) //9号压丝机
- {
- if(X004 == 0)
- {
- SETY026();
- CLRY027();
- }
- else
- {
- CLRY026();
- SETY027();
- }
- }
- else if(X026 == 0)
- {
- CLRY026();
- CLRY027();
- }
- }
- else if(LS_bRunning) //自动运行
- {
-
- switch(cStepMByte)
- {
- case 1:
- if((X006 || (X022 && (user_datas[6] == 0)))&& (dwTickCount >= cDelayTime1))
- {
- cStepMByte = 2;
- cDelayTime1 = dwTickCount + 1;
- LS_cTotal = 0;
- }
- else if(!X006 && ((!X022 && (user_datas[6] == 0)) || (user_datas[6] == 1)))
- {
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[3] * 10;
- }
- break;
- case 2:
- if((X05_UP || (user_datas[0] == 0)) && (dwTickCount >= cDelayTime1))
- {
- cDelayTime1 = dwTickCount + 15;
- LS_cTotal++;
- if(LS_cTotal >= user_datas[0])
- {
- LS_cTotal = 0;
- cStepMByte = 3;
- }
- }
- break;
- case 3:
- CLRY002();
- CLRY003();
- LS_Y02_EN = 0;
- LS_Y03_EN = 0;
- cStepMByte = 4;
- cDelayTime1 = dwTickCount + 1;
- break;
- case 4:
- if((X05_UP || (user_datas[1] == 0)) && (dwTickCount >= cDelayTime1))
- {
- cDelayTime1 = dwTickCount + 15;
- LS_cTotal++;
- if(LS_cTotal >= user_datas[1])
- {
- LS_cTotal = 0;
- cStepMByte = 5;
- }
- }
- break;
- case 5:
- CLRY002();
- SETY003();
- LS_Y03_EN = 1;
- SETY001();
- cStepMByte = 6;
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[3] * 10;
-
- break;
- case 6:
- CLRY002();
- SETY003();
- SETY001();
- if(!X006 && ((!X022 && (user_datas[6] == 0)) || (user_datas[6] == 1)) && (dwTickCount >= cDelayTime1))
- {
- cStepMByte = 7;
- cDelayTime1 = dwTickCount + 1;
- LS_cTotal = 0;
- }
- else if(X006 || (X022 && (user_datas[6] == 0)))
- {
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[3] * 10;
- }
- break;
- case 7:
- if((X05_UP || (user_datas[2] == 0))&& (dwTickCount >= cDelayTime1))
- {
- cDelayTime1 = dwTickCount + 15;
- LS_cTotal++;
- if(LS_cTotal >= user_datas[2])
- {
- LS_cTotal = 0;
- cStepMByte = 8;
- }
- }
- break;
- case 8:
- CLRY001();
- cStepMByte = 9;
- AxisMovePosAccDec(X_AXIS, 5, 10 * user_datas[5],user_datas[4],1,1);
- break;
- case 9:
- cStepMByte = 11;
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[3] * 10;
- break;
- case 11:
- if((X007 || (X022 && (user_datas[6] == 0))) && (dwTickCount >= cDelayTime1))
- {
- cStepMByte = 12;
- cDelayTime1 = dwTickCount + 1;
- LS_cTotal = 0;
- }
- else if(!X007 && ((!X022 && (user_datas[6] == 0)) || (user_datas[6] == 1)))
- {
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[3] * 10;
- }
- break;
- case 12:
- if((X05_UP || (user_datas[0] == 0)) && (dwTickCount >= cDelayTime1))
- {
- cDelayTime1 = dwTickCount + 15;
- LS_cTotal++;
- if(LS_cTotal >= user_datas[0])
- {
- LS_cTotal = 0;
- cStepMByte = 13;
- }
- }
- break;
- case 13:
- CLRY002();
- CLRY003();
- LS_Y02_EN = 0;
- LS_Y03_EN = 0;
- cStepMByte = 14;
- cDelayTime1 = dwTickCount + 1;
- break;
- case 14:
- if((X05_UP || (user_datas[1] == 0)) && (dwTickCount >= cDelayTime1))
- {
- cDelayTime1 = dwTickCount + 15;
- LS_cTotal++;
- if(LS_cTotal >= user_datas[1])
- {
- LS_cTotal = 0;
- cStepMByte = 15;
- }
- }
- break;
- case 15:
- SETY002();
- LS_Y02_EN = 1;
- CLRY003();
- SETY001();
- cStepMByte = 16;
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[3] * 10;
-
- break;
- case 16:
- SETY002();
- CLRY003();
- SETY001();
- if(!X007 && ((!X022 && (user_datas[6] == 0)) || (user_datas[6] == 1)) && (dwTickCount >= cDelayTime1))
- {
- cStepMByte = 17;
- cDelayTime1 = dwTickCount + 1;
- LS_cTotal = 0;
- }
- else if(X007 || (X022 && (user_datas[6] == 0)))
- {
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[3] * 10;
- }
- break;
- case 17:
- if((X05_UP || (user_datas[2] == 0)) && (dwTickCount >= cDelayTime1))
- {
- cDelayTime1 = dwTickCount + 15;
- LS_cTotal++;
- if(LS_cTotal >= user_datas[2])
- {
- LS_cTotal = 0;
- cStepMByte = 18;
- }
- }
- break;
- case 18:
- CLRY001();
- cStepMByte = 19;
- AxisMovePosAccDec(X_AXIS, 5, 10 * user_datas[5],user_datas[4],1,1);
- break;
- case 19:
- cStepMByte = 1;
- break;
- }
- }
- //停止
- if(X002 || (LS_bRunning && (X012 || X013 || X014 || X015 || X016 || X017 ||
- X020 || X023 || X024 || X025 || X026 )) || !X021)
- {
- if(dwTickCount >= cDelayTime3)
- {
- LS_bRunning = 0;
- cStepMByte = 0;
- Y00 = 0;
- Y01 = 0;
- Y02 = 0;
- Y03 = 0;
- Y04 = 0;
- Y05 = 0;
- Y07 = 0;
- Y10 = 0;
- Y11 = 0;
- Y13 = 0;
- Y14 = 0;
- cStepMByte = 0;
- cStepMByte1 = 0;
- cStepMByte2 = 0;
- cStepMByte3 = 0;
- cStepMByte4 = 0;
- cStepMByte5 = 0;
- cStepMByte6 = 0;
- LS_bRunning = 0;
- AxisEgmStop(X_AXIS);
- LS_Y02_EN = 0;
- LS_Y03_EN = 0;
- cDelayTime2 = dwTickCount + 150;
- if(!X_DRV)LS_SETCSB_EN();
- }
- }
- else
- cDelayTime3 = dwTickCount + 50;
- //暂停功能
- if(X010)
- {
- CLRY001();
- CLRY002();
- CLRY003();
- }
- else if(X10_DW)
- {
- if(LS_Y02_EN)
- SETY002();
- if(LS_Y03_EN)
- SETY003();
- }
- }
- #endif
|