123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463 |
- #include "global.h"
- #if TONG_YONG_MACHINE
- void HMDZ_ManualAction(void);
- void HMDZ_AutoAction(void);
- void HMDZ_StepCheckStart(void);
- void HMDZ_Motor(void);
- void HMDZ_ExtiActionX31(void);
- static long save_limit_pos,cRealPos;
- void HMDZ_ExtiActionX31(void)
- {
-
- }
- void HMDZ_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(HMDZ_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void HMDZ_InitAction(void)
- {
- HMDZ_SZ_OUT = 1;
- }
- void HMDZ_Action(void)
- {
- HMDZ_Motor();
- HMDZ_ManualAction();
- HMDZ_AutoAction();
- HMDZ_StepCheckStart(); // 调用脚踏开关检测程序
- }
- //手动动作
- void HMDZ_ManualAction(void)
- {
- if(HMDZ_bRunning == 0)
- {
- if(HMDZ_bClearTotal) //切断计数清零
- {
- HMDZ_bClearTotal = 0;
- ClrcToTal(HMDZ_TOTAL_ADDR);
- }
-
- if(HMDZ_bSS)
- {
- HMDZ_bSS = 0;
- HMDZ_SS_VAVLE = ~HMDZ_SS_VAVLE;
- }
- if(HMDZ_bDL)
- {
- HMDZ_bDL = 0;
- HMDZ_DL_VAVLE = ~HMDZ_DL_VAVLE;
- }
-
- if(HMDZ_bQS)
- {
- HMDZ_bQS = 0;
- HMDZ_QS_VAVEL = ~HMDZ_QS_VAVEL;
- }
- if(HMDZ_bTS)
- {
- HMDZ_bTS = 0;
- HMDZ_TS_VAVLE = ~HMDZ_TS_VAVLE;
- }
-
- if(HMDZ_bJL)
- {
- HMDZ_bJL = 0;
- HMDZ_JL_VAVLE = ~HMDZ_JL_VAVLE;
- }
- if(HMDZ_bYL)
- {
- HMDZ_bYL = 0;
- HMDZ_CL_VAVLE = ~HMDZ_CL_VAVLE;
- }
-
- if(HMDZ_bCL)
- {
- HMDZ_bCL = 0;
- HMDZ_SS_VAVLE = ~HMDZ_SS_VAVLE;
- }
- //电机控制
- if(HMDZ_bGoMotor)
- {
- HMDZ_SZ_OUT = 0;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,HMDZ_DIR_N,5,1,5,5);
- }
-
- if(HMDZ_bBackMotor)
- {
- HMDZ_SZ_OUT = 0;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,HMDZ_DIR_P,5,1,5,5);
- }
-
- if(!HMDZ_bGoMotor && !HMDZ_bBackMotor && (HMDZ_MotorStep == 0))
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
-
-
- }
- }
- void HMDZ_AutoAction(void)
- {
- if(HMDZ_bRunning)
- {
- switch(HMDZ_AutoStep)
- {
- case 1:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_AutoStep = 2;
- HMDZ_JL_VAVLE = 1;
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_YL_DELAY;
- }
- break;
- case 2:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_YL_VAVLE = 1;
- HMDZ_JL_VAVLE = 0;
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_DL_DELAY;
- HMDZ_AutoStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_DL_VAVLE = 1;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 4;
- }
- break;
- case 4:
- if(HMDZ_DL_LIMIT_IN && HMDZ_SG_LIMIT_IN)
- {
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_SS_DELAY;
- HMDZ_AutoStep = 5;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- {
- if(!HMDZ_DL_LIMIT_IN)HMDZ_SetAlarmCode(HMDZ_DL_LIMIT_ALARM);
- else HMDZ_SetAlarmCode(HMDZ_SG_LIMIT_ALARM);
- }
- break;
- case 5:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_SS_VAVLE = 1;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 6;
- }
- break;
- case 6:
- if(HMDZ_SS_LIMIT_IN)
- {
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_SS_BACK_DELAY;
- HMDZ_AutoStep = 7;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_SS_LIMIT_ALARM);
- break;
- case 7:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_SS_VAVLE = 0;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 8;
- }
- break;
- case 8:
- if(HMDZ_SS_ORIGIN_IN && !HMDZ_MOTOR_ORIGIN_IN)
- {
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_RS_MOTOR_DELAY+50;
- HMDZ_SZ_OUT = 0;
- HMDZ_AutoStep = 9;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- {
- if(!HMDZ_SS_ORIGIN_IN)
- HMDZ_SetAlarmCode(HMDZ_SS_ORIGIN_ALARM);
- else
- HMDZ_SetAlarmCode(HMDZ_MOTOR_ORIGIN_ALARM);
- }
- break;
- case 9:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,HMDZ_DIR_N,HMDZ_PARAM_RS_MOTOR_SPEED,HMDZ_PARAM_RS_MOTOR_START_SPEED,HMDZ_PARAM_RS_MOTOR_ACC,HMDZ_PARAM_RS_MOTOR_DEC);
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 10;
- }
- break;
- case 10:
- if(HMDZ_MOTOR_ORIGIN_IN)
- {
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 11;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_MOTOR_ORIGIN_ALARM);
- break;
- case 11:
- if(HMDZ_RS_LIMIT_IN)
- {
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_RS_MOTOR_STOP_DELAY;
- HMDZ_AutoStep = 12;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_RS_LIMIT_ALARM);
- break;
- case 12:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- HMDZ_AutoStep = 13;
- }
- break;
- case 13:
- if(!X_DRV)
- {
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_TS_DELAY;
- HMDZ_AutoStep = 14;
- }
- break;
- case 14:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_TS_VAVLE = 1;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 15;
- }
- break;
- case 15:
- if(HMDZ_TS_LIMIT_IN)
- {
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_QS_DELAY;
- HMDZ_AutoStep = 16;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_TS_LIMIT_ALARM);
- break;
- case 16:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_QS_VAVEL = 1;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 17;
- }
- break;
- case 17:
- if(HMDZ_QS_LIMIT_IN)
- {
- HMDZ_AutoDelay = dwTickCount;
- HMDZ_AutoStep = 18;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_QS_LIMIT_ALARM);
- break;
- case 18:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_DL_VAVLE = 0;
- HMDZ_TS_VAVLE = 0;
- HMDZ_YL_VAVLE = 0;
- HMDZ_CL_VAVLE = 1;
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_CL_BACK_DELAY;
- HMDZ_AutoStep = 19;
- }
- break;
- case 19:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_CL_VAVLE = 0;
- HMDZ_QS_VAVEL = 0;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 20;
- }
- break;
- case 20:
- if(HMDZ_DL_ORIGIN_IN && HMDZ_QS_ORIGIN_IN && HMDZ_TS_ORIGIN_IN && HMDZ_SS_ORIGIN_IN)
- {
- HMDZ_AutoDelay = dwTickCount;
- HMDZ_AutoStep = 21;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- {
- if(!HMDZ_DL_ORIGIN_IN)
- HMDZ_SetAlarmCode(HMDZ_DL_ORIGIN_ALARM);
- else if(!HMDZ_QS_ORIGIN_IN)
- HMDZ_SetAlarmCode(HMDZ_QS_ORIGIN_ALARM);
- else if(!HMDZ_TS_ORIGIN_IN)
- HMDZ_SetAlarmCode(HMDZ_TS_ORIGIN_ALARM);
- else
- HMDZ_SetAlarmCode(HMDZ_SS_ORIGIN_ALARM);
- }
- break;
- case 21:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,HMDZ_DIR_P,HMDZ_PARAM_RS_MOTOR_SPEED,HMDZ_PARAM_RS_MOTOR_START_SPEED,HMDZ_PARAM_RS_MOTOR_ACC,HMDZ_PARAM_RS_MOTOR_DEC);
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 22;
- }
- break;
- case 22:
- if(HMDZ_MOTOR_ORIGIN_IN)
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- HMDZ_AutoStep = 23;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_MOTOR_ORIGIN_ALARM);
- break;
- case 23:
- if(!X_DRV)
- {
- HMDZ_SS_VAVLE = 1;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 24;
- }
- break;
- case 24:
- if(HMDZ_SS_LIMIT_IN)
- {
- HMDZ_SS_VAVLE = 0;
- HMDZ_QS_VAVEL = 1;
- HMDZ_AutoStep = 25;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_SS_LIMIT_ALARM);
- break;
- case 25:
- if(HMDZ_QS_LIMIT_IN)
- {
- HMDZ_CL_VAVLE = 1;
- HMDZ_AutoStep = 26;
- HMDZ_AutoDelay = dwTickCount+HMDZ_PARAM_CL_BACK_DELAY;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_QS_LIMIT_ALARM);
- break;
- case 26:
- if(dwTickCount >= HMDZ_AutoDelay)
- {
- HMDZ_CL_VAVLE = 0;
- HMDZ_QS_VAVEL = 0;
- HMDZ_AutoDelay = dwTickCount+VAVLE_ALARM_TIME;
- HMDZ_AutoStep = 27;
- }
- break;
- case 27:
- if(HMDZ_QS_ORIGIN_IN)
- {
- HMDZ_AutoStep = 28;
- }
- else if(dwTickCount >= HMDZ_AutoDelay)
- HMDZ_SetAlarmCode(HMDZ_QS_ORIGIN_ALARM);
- break;
- case 28:
- if(HMDZ_MotorStep == 0)
- {
- AddToTal(HMDZ_TOTAL_ADDR);
- CalProSP(HMDZ_PROSPEED_ADDR);
- HMDZ_AutoStep = 1;
- }
- break;
- }
- }
- }
- void HMDZ_StepCheckStart(void)
- {
- // 启动
- if((HMDZ_START_IN) || HMDZ_bStart)
- {
- HMDZ_bStart = 0;
-
- if(!HMDZ_bRunning && (HMDZ_AutoStep == 0))
- {
- if(!HMDZ_MOTOR_ORIGIN_IN)HMDZ_SetAlarmCode(HMDZ_MOTOR_ORIGIN_ALARM);
- else if(!HMDZ_DL_ORIGIN_IN)HMDZ_SetAlarmCode(HMDZ_DL_ORIGIN_ALARM);
- else if(!HMDZ_QS_ORIGIN_IN)HMDZ_SetAlarmCode(HMDZ_QS_ORIGIN_ALARM);
- else if(!HMDZ_TS_ORIGIN_IN) HMDZ_SetAlarmCode(HMDZ_TS_ORIGIN_ALARM);
- else if(!HMDZ_SS_ORIGIN_IN)HMDZ_SetAlarmCode(HMDZ_SS_ORIGIN_ALARM);
- else
- {
- HMDZ_bRunning = 1;
- HMDZ_AutoStep = 1;
- }
- }
- }
- //停止
- if(HMDZ_STOP_IN_UP || HMDZ_bStop)
- {
- HMDZ_bStop = 0;
- HMDZ_bRunning = 0;
- HMDZ_AutoStep = 0;
- HMDZ_MotorStep = 0;
- HMDZ_SS_VAVLE = 0;
- HMDZ_DL_VAVLE = 0;
- HMDZ_QS_VAVEL = 0;
- HMDZ_TS_VAVLE = 0;
- HMDZ_JL_VAVLE = 0;
- HMDZ_YL_VAVLE = 0;
- HMDZ_CL_VAVLE = 0;
- HMDZ_SZ_OUT = 1;
- AxisDecStop(X_AXIS);
- if(GetAlarmCode(HMDZ_ALARM_ADDR) != 0)SetAlarmCode(HMDZ_ALARM_ADDR,0);
- }
-
- if(HMDZ_bAlarmStop)
- {
- HMDZ_bAlarmStop = 0;
- HMDZ_bRunning = 0;
- HMDZ_AutoStep = 0;
- HMDZ_MotorStep = 0;
- HMDZ_SS_VAVLE = 0;
- HMDZ_DL_VAVLE = 0;
- HMDZ_QS_VAVEL = 0;
- HMDZ_TS_VAVLE = 0;
- HMDZ_JL_VAVLE = 0;
- HMDZ_YL_VAVLE = 0;
- HMDZ_CL_VAVLE = 0;
- }
-
- }
- void HMDZ_Motor(void)
- {
- user_datas[121]= HMDZ_MotorStep;
- user_datas[125] = HMDZ_AutoStep;
- switch(HMDZ_MotorStep)
- {
- }
- }
- #endif
|