123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- #include "global.h"
- #if FJ_YING_XING_MACHINE==1
- void JSDC_CheckStart(void);
- void JSDC_Motor(void);
- void JSDC_XiaChong(void);
- void JSDC_ChuiQi(void);
- void JSDC_ValveAction(void);
- void JSDC_ManualAction(void);
- void JSDC_AutoAction(void);
- unsigned char JSDC_cLFengTimer,JSDC_cRFengTimer;
- unsigned char JSDC_cGZDW_CNT=0,JSDC_SingOne=0,JSDC_oneDEL=0,JSDC_twoDEL=0;
- unsigned char JSDC_SingOneFlag = 0,JSDC_FirstFlg = 0;
- unsigned char JSDC_cAlarmStopFlg = 0;
- //故障报警
- void JSDC_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(JSDC_ALARM_ADDR,alarm_code);
- JSDC_bAlarmStop = 1;
-
- }
- void JSDC_InitAction(void)
- {
- float length_buff,pulse_buff;
- length_buff = JSDC_PARAM_DAILUN_LENGTH;
- pulse_buff = JSDC_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
- JSDC_SZ_OUT = 1;
- }
- void JSDC_Action(void)
- {
-
- JSDC_CheckStart(); //启动
- JSDC_XiaChong(); //下冲
- JSDC_ChuiQi();
- JSDC_ValveAction();
- JSDC_Motor(); //拖带控制
- JSDC_ManualAction();
- JSDC_AutoAction();
-
- }
- void JSDC_ManualAction(void)
- {
- if((JSDC_bRunning) == 0) ////手动
- {
- if(JSDC_bXiaChong | JSDC_ManualXC_IN_UP)
- {
- JSDC_bXiaChong = 0;
-
- JSDC_twoDEL=1;
- JSDC_cValveStep=1;
-
- if(JSDC_cXiaChongStep == 0)
- JSDC_cXiaChongStep = 1;
- }
- if(JSDC_bMotorSZ)
- {
- JSDC_bMotorSZ = 0;
- JSDC_SZ_OUT = ~JSDC_SZ_OUT;
- }
- //手动测试气缸
-
- if(JSDC_bDingZhen)
- {
-
- JSDC_bDingZhen = 0;
- JSDC_DingZhen_VAVLE = ~JSDC_DingZhen_VAVLE;
- }
- if(JSDC_bRightXuanChi)
- {
- JSDC_bRightXuanChi = 0;
- JSDC_RightXC_VAVLE = ~JSDC_RightXC_VAVLE;
- }
-
- if(JSDC_bLeftXuanChi)
- {
- JSDC_bLeftXuanChi = 0;
- JSDC_LeftXC_VAVLE = ~JSDC_LeftXC_VAVLE;
- }
-
-
-
- //点动下冲
- if((JSDC_bDotXiaChong))
- {
- JSDC_bDotXiaChong = 0;
- if(JSDC_cXiaChongStep == 0)JSDC_cXiaChongStep = 20;
- }
-
-
- }
- }
- void JSDC_AutoAction(void)
- {
- //监控参数
- user_datas[121] = JSDC_cAutoStep;
- user_datas[122] = JSDC_cMotorStep;
- user_datas[123] = 1;
- user_datas[124] = JSDC_cXiaChongStep;
- user_datas[125] = 2;
- user_datas[126] = 3;
- user_datas[127] = dwRealPos;
- user_datas[128]= dwRealPos;
- dwRealPos = GetPos(X_AXIS);
- if(JSDC_bRunning)
- {
- switch(JSDC_cAutoStep)
- {
- case 0:
- break;
- case 1:
- if(dwTickCount >= JSDC_cAutoDelay)
- {
- JSDC_cAutoStep = 2;
- }
- break;
- case 2:
-
- if(dwTickCount >= JSDC_cAutoDelay)
- {
- JSDC_cAutoStep = 3;
- JSDC_cMotorStep = 1; //启动拖带
-
- }
- break;
- case 3:
- //拖带已经完成
- if(JSDC_cMotorStep == 0)
- {
- JSDC_cValveStep=1;
- JSDC_cAutoStep = 4;
- }
- break;
- case 4:
- if(JSDC_cValveStep == 0)
- {
- JSDC_cAutoStep = 5;
- }
- break;
- case 5:
- if(JSDC_cXiaChongStep == 0)
- {
- JSDC_cXiaChongStep = 1; //下冲电机启动
- JSDC_cAutoStep = 6;
- }
- break;
- case 6: //下冲已完成
- if((JSDC_cXiaChongStep == 0) || (JSDC_cXiaChongStep == 6))
- {
-
-
-
-
- DISPLAY_DATA0 =1;
- dwZipCnt++;
- if(JSDC_cGZDW_CNT < 3)
- JSDC_cGZDW_CNT++;
-
- if(!JSDC_SingOneFlag)
- {
- AddToTal(JSDC_TOTAL_ADDR); //计数增加和保存
- CalProSP(JSDC_PROSPEED_ADDR);
- }
- JSDC_cAutoStep = 7;
-
-
-
-
- }
- break;
- case 7:
- if(!JSDC_GouZhen_IN)
- {
- if(GetTotal(JSDC_TOTAL_ADDR) >= JSDC_SET_TOTAL)
- {
- JSDC_SetAlarmCode(JSDC_TOTAL_ALARM);
- }
- JSDC_cAutoStep = 8;
- }
- break;
- case 8:
- JSDC_cAutoDelay = dwTickCount + JSDC_PARAM_MOTOR_DELAY;
- JSDC_cAutoStep = 1;
- if(JSDC_SingOneFlag)
- {
- JSDC_cGZDW_CNT=0;
- dwZipCnt = 0;
- JSDC_SingOneFlag = 0;
- JSDC_SingOne=1;
- JSDC_cAutoStep = 0;
- JSDC_bRunning = 0;
-
- }
-
- break;
- }
- }
- }
- // 检测是否踏了脚踏开关
- void JSDC_CheckStart(void)
- {
- // 停止键 不能在工作,手动,停止过程中
- if((JSDC_bRunning == 0) && (JSDC_START_IN_UP || JSDC_bStart || JSDC_Single))
- {
-
- if(GetTotal(JSDC_TOTAL_ADDR) >= JSDC_SET_TOTAL)JSDC_SetAlarmCode(JSDC_TOTAL_ALARM);
- else if(JSDC_KaDai_IN)JSDC_SetAlarmCode(JSDC_KA_DAI_ALARM);
- else
- {
- if(JSDC_Single)
- {
- JSDC_SingOneFlag = 1;
- JSDC_Single = 0;
- }
- JSDC_bRunning = 1;
- JSDC_twoDEL=0;
- JSDC_cAutoStep = 1;
- JSDC_SingOne=0;
- JSDC_GouZhen_VAVLE = 1;
- JSDC_cGZDW_CNT = 0;
- JSDC_cGouZhenTime = 1;
-
- dwZipCnt = 0;
- JSDC_cAutoDelay = dwTickCount;
- JSDC_cMotorDelay = dwTickCount;
- JSDC_cXiaChongDelay = dwTickCount;
-
- }
- JSDC_bStart = 0;
- JSDC_Single = 0;
- }
- //卡带感应
- if(JSDC_KaDai_IN)
- {
- JSDC_SetAlarmCode(JSDC_KA_DAI_ALARM);
- }
- else
- {
- if(GetAlarmCode(JSDC_ALARM_ADDR) == JSDC_KA_DAI_ALARM)SetAlarmCode(JSDC_ALARM_ADDR,0);
- }
-
-
- if(JSDC_KaDai_IN_UP)
- {
- if(JSDC_cChuiQiStep == 0)JSDC_cChuiQiStep = 1;
- }
- if(JSDC_bStop)
- {
- JSDC_bStop = 0;
- if(JSDC_bRunning)JSDC_SingOneFlag = 1;
- }
-
-
-
- if(JSDC_START_IN_UP || JSDC_bStop)
- {
- JSDC_bStop = 0;
- if(JSDC_bRunning)
- {
- if(JSDC_cXiaChongStep==0)
- {
- if(JSDC_cChuiQiStep == 0)JSDC_cChuiQiStep = 1;
-
- }
- JSDC_cGZDW_CNT=0;
- JSDC_SingOne=0;
- JSDC_twoDEL=1;
- JSDC_bRunning = 0;
- JSDC_cAutoStep = 0;
-
- JSDC_cMotorStep = 0;
- AxisEgmStop(X_AXIS);
-
- JSDC_SingOneFlag = 0;
- }
- else
- {
- JSDC_bRunning = 0;
- JSDC_cAutoStep = 0;
- JSDC_cMotorStep = 0;
- JSDC_cXiaChongStep = 0;
- JSDC_SingOne=0;
- JSDC_SingOneFlag = 0;
-
- if((JSDC_cChuiQiStep == 0) &&(JSDC_cXiaChongStep==0))
- JSDC_cChuiQiStep = 1;
- AxisEgmStop(X_AXIS);
- SetAlarmCode(JSDC_ALARM_ADDR,0);//报警清零
- JSDC_SetAlarmCode(0);//报警清零
- }
- }
-
- if(JSDC_bAlarmStop)
- {
- JSDC_bAlarmStop = 0;
- JSDC_Single = 0;
- JSDC_bRunning = 0;
- JSDC_cAutoStep = 0;
- JSDC_SingOne=0;
- JSDC_cMotorStep = 0;
- JSDC_SingOneFlag = 0;
- AxisEgmStop(X_AXIS);
- }
- }
- void JSDC_ValveAction(void)
- {
- switch(JSDC_cValveStep)
- {
-
- }
-
- }
- void JSDC_ChuiQi(void)
- {
- //吹气
- if(JSDC_XiaChong_IN_UP)
- {
- if(JSDC_cChuiQiStep == 0)JSDC_cChuiQiStep = 1;
- }
-
- switch(JSDC_cChuiQiStep)
- {
- case 1:
- JSDC_cChuiQiStep = 2;
- JSDC_cChuiQiDelay = dwTickCount+JSDC_PARAM_DELAY_CHUIQI_TIME;
- break;
- case 2:
- if(dwTickCount >= JSDC_cChuiQiDelay)
- {
- JSDC_cChuiQiDelay = dwTickCount + JSDC_PARAM_CHUIQI_TIME;
- JSDC_ChuiQi_VAVLE = 1;//
- JSDC_cChuiQiStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= JSDC_cChuiQiDelay)
- {
- JSDC_ChuiQi_VAVLE = 0;//
- JSDC_cChuiQiStep = 0;
- }
- break;
-
- case 6:
- JSDC_cChuiQiDelay = dwTickCount + JSDC_TDCQ_TIME;
- JSDC_ChuiQi_VAVLE = 1;//
- JSDC_cChuiQiStep = 7;
-
- break;
- case 7:
- if(dwTickCount >= JSDC_cChuiQiDelay)
- {
- JSDC_ChuiQi_VAVLE = 0;//
- JSDC_cChuiQiStep = 0;
- }
- break;
-
- }
- }
- void JSDC_Motor(void)
- {
-
- switch(JSDC_cMotorStep)
- {
- }
- }
- //下冲
- void JSDC_XiaChong(void)
- {
- switch(JSDC_cXiaChongStep)
- {
-
- }
- }
- #endif
|