123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 |
- #include "global.h"
- #if JIN_HONG_MACHINE == 1
- //锦泓尼龙上齿机
- void NiLongShangChiJi_ManualAction(void);
- void NiLongShangChiJi_AutoAction(void);
- void NiLongShangChiJi_StepCheckStart(void);
- void NiLongShangChiJi_Motor(void);
- void NiLongShangChiJi_Action(void);
- void SC_FengDai(void);
- void SC_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(SC_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void NiLongShangChiJi_InitAction(void)
- {
-
- float length_buff,pulse_buff;
- // axis_x->speed_unit = 1; //速度频率倍率单位
- // CalFreqTab_X_Free(25);
- length_buff = SC_PARAM_CYCLE_LENGTH;
- pulse_buff = SC_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
- // YGearRatio = 1;
- }
- void NiLongShangChiJi_Action(void)
- {
- //数据监控
- dwRealPos = GetPos(X_AXIS);
- user_datas[121] = SC_MotorStep;
- user_datas[122] = SC_AutoStep;
- user_datas[123] = dwRealPos;
- user_datas[124]=SC_FengDai_Step;
- user_datas[125]=SC_PARAM_LT_TOTAL;
- NiLongShangChiJi_StepCheckStart(); // 调用脚踏开关检测程序
- NiLongShangChiJi_Motor();
- SC_FengDai();
- NiLongShangChiJi_ManualAction();
- NiLongShangChiJi_AutoAction();
-
- }
- void NiLongShangChiJi_ManualAction(void)
- {
- if(!SC_FIRST_RUN)
- {
- if(dwTickCount >= SC_SongSiDelay)
- {
- if(SC_ChengXing_ORIGIN_IN_UP)
- {
- SC_SongSiDelay = dwTickCount + 500;
- SC_SongSi_VAVLE = 1;
- }
- else
- {
- SC_SongSi_VAVLE = 0;
- }
- }
- }
- if(SC_ChengXing_ORIGIN_IN)
- {
- SC_FIRST_RUN =0;
- }
- if(bRunning == 0)
- {
- if(!SC_SUOZHOU)
- {
- SC_SZ_OUT=1;// 开机默认松轴
- }
- //手动钩针
- if(SC_bGouZhen)
- {
- SC_bGouZhen = 0;
- SC_GouZhen_VAVLE = ~SC_GouZhen_VAVLE;
- }
-
- //手动压带
- if(SC_bYaDai)
- {
- SC_bYaDai = 0;
- if(!SC_YaDai_VAVLE)
- SC_YaDai_VAVLE =1;
- else if(SC_YaDai_VAVLE && SC_ChengXing_ORIGIN_IN)
- SC_YaDai_VAVLE=0;
- }
-
- if(SC_bXiaChong)
- {
- SC_bXiaChong=0;
- SC_XiaChong_VAVLE=1;
-
- }
- if(SC_XiaChong_VAVLE)
- {
- if(SC_XIAYA_IN_UP)
- {
- SC_XIAYA=1;
- SC_XiaChongDelay=dwTickCount + SC_PARAM_XiaChong_BACK_DELAY;
- }
- }
-
- if(SC_XIAYA)
- {
- if(dwTickCount >= SC_XiaChongDelay)
- {
- SC_XIAYA=0;
- SC_XiaChong_VAVLE=0;
-
- }
- }
- //手动下压
- if(SC_bXiaYa)
- {
- SC_bXiaYa = 0;
- if(SC_XiaYa_VAVLE)
- SC_XiaYa_VAVLE = 0;
- else if(!SC_XiaYa_VAVLE && SC_ChengXing_IN)
- SC_XiaYa_VAVLE=1;
- }
- //手动成型
- if(SC_bChengXing)
- {
- SC_bChengXing = 0;
- if(SC_ChengXing_VAVLE)
- SC_ChengXing_VAVLE =0;
- else if(!SC_ChengXing_VAVLE && SC_YADAI_IN)
- SC_ChengXing_VAVLE=1;
- }
-
-
-
-
- //手动拖带
- if(SC_bTuoDai)
- {
- if(!X_DRV)
- {
- SC_SZ_OUT=0;
- SetDir(X_AXIS, SC_DIR_P);
- AxisContinueMove(X_AXIS,20,SC_DIR_P);
- }
-
- }
- if((SC_MotorStep == 0) && !SC_bTuoDai && (SC_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
-
- }
- }
- void NiLongShangChiJi_AutoAction(void)
- {
-
- if(bRunning)
- {
- #if 1
- switch(SC_AutoStep)
- {
- case 1:
- if(dwTickCount >= SC_AutoDelay)
- {
- SC_AutoStep = 2;
- SC_MotorStep = 1;
- }
- break;
- case 2:
- if(SC_MotorStep == 0) //电机定位完成
- {
- if(SC_ZipCnt == 1)
- SC_Zipper_Length = dwRealPos;
- SC_AutoDelay=dwTickCount + 30;
- SC_AutoStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= SC_AutoDelay)
- {
- SC_AutoDelay=dwTickCount + VAVLE_ALARM_TIME;
- if(SC_PARAM_FANZHUAN_MODE)
- SC_MotorStep=10;
- SC_AutoStep = 4;
- }
- break;
- case 4:
- if((SC_GZ_IN && (SC_GOUZHEN_ON || SC_PARAM_Mator_Mode) && SC_YADAI_IN) && SC_PARAM_FANZHUAN_MODE) //反转完成
- {
- SC_AutoStep = 5;
- SC_AutoDelay=dwTickCount+VAVLE_ALARM_TIME;
- }
- else if((SC_GZ_IN && (SC_GOUZHEN_ON || SC_PARAM_Mator_Mode) && SC_YADAI_IN) && !SC_PARAM_FANZHUAN_MODE)
- {
- SC_AutoStep = 6;
- SC_AutoDelay=dwTickCount + 10;
- }
- else if(dwTickCount >= SC_AutoDelay)
- {
- SC_SetAlarmCode(SC_GOUZHEN_IN_ALARM);
-
- }
-
- break;
- case 5:
- if(!SC_GZ_IN)
- {
- SC_AutoStep = 6;
- SC_AutoDelay=dwTickCount + SC_PARAM_NOGZ_DELAY;
- }
- else if(dwTickCount >= SC_AutoDelay)
- {
- SC_SetAlarmCode(SC_GOUZHEN_BCAK_ALARM);
-
- }
- break;
- case 6:
- if(dwTickCount >= SC_AutoDelay)
- {
- if(SC_PARAM_Mator_Mode)
- SC_XiaChong_VAVLE=1;
- else
- SC_ChengXing_VAVLE=1;
- SC_AutoStep = 7;
- SC_AutoDelay=dwTickCount+VAVLE_ALARM_TIME;
- }
- break;
- case 7:
- if(SC_PARAM_Mator_Mode)
- {
- if(SC_XIAYA_IN_UP)
- {
- SC_AutoStep = 8;
- SC_AutoDelay=dwTickCount + SC_PARAM_XiaChong_BACK_DELAY;
- }
- else if(dwTickCount >= SC_AutoDelay)
- {
- SC_SetAlarmCode(SC_CHENGXING_IN_ALARM);
- }
-
-
- }
- else
- {
- if(SC_ChengXing_IN)
- {
-
- SC_XiaYa_VAVLE=1;
- SC_AutoDelay=dwTickCount + SC_PARAM_ChengXing_BACK_DELAY;
- SC_AutoStep = 8;
- }
- else if(dwTickCount >= SC_AutoDelay)
- {
- SC_SetAlarmCode(SC_CHENGXING_IN_ALARM);
- }
- }
- break;
- case 8:
- if(dwTickCount >= SC_AutoDelay && (SC_XIAYA_IN || SC_PARAM_Mator_Mode))
- {
- if(SC_PARAM_Mator_Mode)
- {
- SC_AutoDelay=dwTickCount + SC_PARAM_ChengXing_BACK_DELAY;
- SC_XiaChong_VAVLE=0;
- }
-
- SC_XiaYa_VAVLE=0;
- if(!SC_PARAM_YAJINCISHU)
- {
-
- SC_ChengXing_VAVLE=0;
- SC_AutoStep = 9;
- }
- else
- {
- SC_AutoDelay=dwTickCount + 100;
- SC_AutoStep = 101;
- }
- }
- break;
- case 101:
- if(dwTickCount >= SC_AutoDelay)
- {
- SC_XiaYa_VAVLE=1;
- SC_AutoDelay=dwTickCount + 100;
- SC_AutoStep = 102;
-
- }
- break;
- case 102:
- if(dwTickCount >= SC_AutoDelay)
- {
- SC_XiaYa_VAVLE=0;
- SC_ChengXing_VAVLE=0;
- SC_AutoStep = 9;
- }
- break;
- case 9:
- if(SC_PARAM_Mator_Mode)
- {
- if(dwTickCount >= SC_AutoDelay)
- {
- SC_YaDai_VAVLE=0;
- SC_GouZhen_VAVLE=0;
- SC_AutoStep = 10;
- }
-
- }
- else
- {
-
-
- if(SC_ChengXing_ORIGIN_IN)
- {
- SC_YaDai_VAVLE=0;
- SC_GouZhen_VAVLE=0;
- SC_AutoStep = 10;
-
-
- }
- }
- break;
-
- case 10:
- if((SC_ChengXing_ORIGIN_IN || SC_PARAM_Mator_Mode) && !SC_GZ_IN && !SC_GOUZHEN_ON)
- {
- SC_ZipCnt++;
- if(SC_ZipCnt > 2)
- SC_ZipCnt = 3;
-
- if(!SC_Singleone)
- {
- SC_AutoStep = 1;
- AddToTal(SC_TOTAL_ADDR);
- AddToTal(SC_WORKTOTAL_ADDR);
- CalProSP(SC_PROSPEED_ADDR);
- }
- else
- {
- SC_AutoStep = 0;
- SC_Singleone=0;
-
- }
- SC_AutoDelay = dwTickCount + SC_PARAM_TD_TIME;
- }
- break;
- }
- #endif
- }
- }
- void SC_FengDai(void)
- {
- switch(SC_FengDai_Step)
- {
- case 1://不返转
- if(!SC_PARAM_FANZHUAN_MODE)
- {//拉头数
- if(SC_PARAM_LT_TOTAL >= SC_PARAM_SET_LT_TOTAL)
- {
- SC_FengDaiDelay = dwTickCount + SC_PARAM_YaDai_DELAY;
- SC_FengDai_Step = 2;
- }
- }
- else
- SC_FengDai_Step = 0;
- break;
- case 2:
- if(dwTickCount >= SC_FengDaiDelay)
- {
- if(!SC_PARAM_Mator_Mode)
- SC_YaDai_VAVLE = 1;
- SC_FengDai_Step = 0;
- }
- break;
- }
- }
- void NiLongShangChiJi_Motor(void)
- {
-
-
- if(SC_TUITOU_IN_UP && ((dwRealPos >= (SC_LT_buff + SC_PARAM_SET_LT_LENGTH)) || (SC_PARAM_LT_TOTAL == 0)))
- {
- SC_LT_buff = dwRealPos;
- SC_PARAM_LT_TOTAL++;
- }
-
- switch(SC_MotorStep)
- {
-
- case 0:
- break;
- case 1:
- SC_MotorStep = 2;
- SetPos(X_AXIS,0);
- SC_PARAM_LT_TOTAL=0;
- break;
- case 2:
- SC_MotorStep = 3;
- SC_FengDai_Step = 1;
- if(((SC_ZipCnt<2) && (SC_PARAM_SHUKONG_MODE == 1)) || (SC_PARAM_SHUKONG_MODE == 0))
- {
- SC_DianGLG_VAVLE=0;
- AxisContinueMoveAcc(X_AXIS,SC_PARAM_GYGO_HIGN_SPEED,SC_DIR_P,SC_PARAM_START_SPEED,1000,20,50);
- }
- else
- {
-
- SC_MotorStep = 30;
- SC_DianGLG_VAVLE=1;
- if(!SC_PARAM_ZIPPER_LENGTH)
- SC_length_buff=0;
- SC_DCC_TIME_BL=SC_PARAM_GO_HIGN_SPEED/500;
- AxisMovePosAccDecNotStop(X_AXIS,SC_PARAM_GO_HIGN_SPEED,SC_length_buff-500, SC_PARAM_START_SPEED,SC_PARAM_START_SPEED,SC_PARAM_ACC_TIME,SC_DCC_TIME_BL,0);
-
- // AxisMovePosAccDec(X_AXIS,SC_PARAM_GO_HIGN_SPEED,SC_length_buff-500,SC_PARAM_START_SPEED,SC_PARAM_START_SPEED,SC_PARAM_ACC_TIME,SC_PARAM_ACC_TIME,00);
- }
-
- break;
-
- case 3:
- if((dwRealPos >= SC_PARAM_ERROR_LENGTH) && (SC_PARAM_ERROR_LENGTH))
- {
- SC_SetAlarmCode(SC_NO_ZIPPER_ALARM);
- }
- if(!SC_PARAM_Mator_Mode)
- {
- if(SC_GUO_LIAN_IN_UP)
- {
-
- AxisChangeSpeedDirect(X_AXIS,SC_PARAM_GO_LOW_SPEED);
- SC_MotorStep = 4;
- }
- }
- else
- {
- if(SC_PARAM_LT_TOTAL >= SC_PARAM_SET_LT_TOTAL)
- {
- AxisChangeSpeedDirect(X_AXIS,SC_PARAM_GO_LOW_SPEED);
- SC_MotorStep = 5;
- SC_MotorDelay = dwTickCount + SC_PARAM_GOUZHEN_GANYIN_DELAY;
- }
-
-
- }
- break;
-
- case 4:
- if(SC_GUO_LIAN_IN_DW)
- {
- SC_MotorDelay = dwTickCount + SC_PARAM_GOUZHEN_GANYIN_DELAY;
- SC_MotorStep =5;
- }
-
- break;
-
- case 5:
- if(dwTickCount >= SC_MotorDelay)
- {
- SC_GouZhen_VAVLE = 1;
- SC_MotorStep = 6;
- SC_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
-
- break;
- case 6:
- if(SC_GZ_IN)
- {
- AxisEgmStop(X_AXIS);
- if(SC_PARAM_LT_TOTAL >= SC_PARAM_SET_LT_TOTAL)
- {
- SC_YaDai_VAVLE = 1;
- SC_MotorStep = 7;
- SC_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- else
- {
- SC_SetAlarmCode(SC_LATOU_CHECK_ALARM);
- }
- }
- else if(dwTickCount >= SC_MotorDelay)
- {
- SC_SetAlarmCode(SC_GOUZHEN_IN_ALARM);
- }
- break;
- case 7:
- if(!X_DRV && SC_YADAI_IN && (SC_GOUZHEN_ON || SC_PARAM_Mator_Mode))
- {
- SC_MotorStep = 0;
- if(SC_ZipCnt == 1)
- {
- if(SC_PARAM_SHUKONG_MODE == 1)
- {
- SC_length_buff = dwRealPos;
- SetData32bits(SC_PARAM_ZIPPER_LENGTH_ADDR,SC_length_buff);
- }
- }
- }
- else if(dwTickCount >= SC_MotorDelay)
- {
- if(!SC_GOUZHEN_ON)
- SC_SetAlarmCode(SC_GOUZHEN_ON_ALARM);
- if(!SC_YADAI_IN)
- {
- SC_SetAlarmCode(SC_YADAI_IN_ALARM);
- }
- }
- break;
- //10~11 电机反转
- case 10:
- if(SC_GZ_IN && SC_YADAI_IN)
- {
-
- if(SC_PARAM_FANZHUAN_LENGTH)
- {
- // SetDir(X_AXIS, SC_DIR_N);
- AxisMovePosAccDec(X_AXIS,SC_PARAM_CYCLE_PULSE *2,-SC_PARAM_FANZHUAN_LENGTH,SC_PARAM_START_SPEED,1000,SC_PARAM_ACC_TIME,SC_PARAM_DEC_TIME,00);
-
- }
- SC_MotorStep = 11;
- }
- break;
- case 11:
- if(!X_DRV)
- {
- SC_MotorStep = 0;
- }
- break;
-
- // 数控模式
- case 30:
- {
- if((dwRealPos + 20) >= (SC_length_buff-500) && SC_length_buff )
- {
-
-
-
- AxisChangeSpeedDirect(X_AXIS,SC_PARAM_GO_LOW_SPEED); //进入低速
- SC_MotorStep =6;
- SC_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
-
- }
- if((dwRealPos >= SC_PARAM_ERROR_LENGTH) && (SC_PARAM_ERROR_LENGTH))
- {
- SC_SetAlarmCode(SC_NO_ZIPPER_ALARM);
- }
- if((dwRealPos + SC_PARAM_GOUZHEN_LENGTH + 20)>= (SC_length_buff-500))
- {
- SC_GouZhen_VAVLE = 1;
- }
- if(SC_GouZhen_VAVLE && SC_GZ_IN)
- {
- SC_MotorStep = 7;
- SC_YaDai_VAVLE = 1;
- SC_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- AxisEgmStop(X_AXIS);
- }
- }
- break;
-
- }
- }
- void NiLongShangChiJi_StepCheckStart(void)
- {
- // 启动
- if((SC_START_IN_UP) || bStart || SC_bSingleone )
- {
- #if 1
- if(!bRunning && (SC_AutoStep == 0))
- {
- {
- bRunning = 1;
- SC_SZ_OUT=0;
- SC_AutoStep=1;
- if(SC_bSingleone)
- SC_Singleone=1;
- SC_SUOZHOU=1;
- SC_AutoDelay = dwTickCount + 180;
- SetAlarmCode(SC_ALARM_ADDR,0);
- /* if(SC_PARAM_SET_LT_TOTAL == 0)
- SC_PARAM_SET_LT_TOTAL = 1;*/
- }
-
- }
- SC_bSingleone = 0;
- bStart = 0;
-
- #endif
- }
- #if 1
- //停止
- if(SC_STOP_IN_UP || bStop )
- {
-
- if(bRunning)
- {
- SC_ZipCnt=0;
- SC_AutoStep = 0;
- SC_MotorStep = 0;
-
- SC_Singleone=0;
- SC_AutoDelay = dwTickCount;
- SC_MotorDelay = dwTickCount;
- bRunning = 0;
- SC_SUOZHOU=1;
- AxisEgmStop(X_AXIS);
- SC_ChengXing_VAVLE =0;
-
- }
- else
- {
- bRunning = 0;
- SC_ZipCnt=0;
-
- SC_AutoDelay = dwTickCount;
- SetAlarmCode(100,0);
- AxisEgmStop(X_AXIS);
- SC_GouZhen_VAVLE =0;
- SC_Singleone=0;
- SC_XiaYa_VAVLE =0;
- SC_DianGLG_VAVLE=0;
- SC_XiaChong_VAVLE=0;
- SC_SUOZHOU=0;
- SC_ChengXing_VAVLE =0;
- if(SC_ChengXing_ORIGIN_IN)
- SC_YaDai_VAVLE =0;
- SC_SZ_OUT=1;
-
- }
- bStop = 0;
- }
- #endif
-
- #if 1
- if(bAlarmStop)
- {
- SC_ZipCnt=0;
- bAlarmStop = 0;
- bRunning = 0;
- SC_AutoStep = 0;
- SC_MotorStep = 0;
- SC_Singleone=0;
- AxisEgmStop(X_AXIS);
- }
- #endif
-
-
-
- }
- #endif
|