📄 _io.c
字号:
{} /* wait for Timer0 interrupt. */
g_generalbit=TRUE;
}
TR0 = 0; /* stop the Timer0. */
}
#endif
/***************************************************************************
NAME: Backmotor_Stripdist
FUNCTION: This procedure will move back wire motor to strip.
INPUTS: move pulse.
OUTPUTS: NONE
***************************************************************************/
void Backmotor_Stripdist(uint d_dist)
{
idata uint d_counter;
idata uint d_halfpulse;
idata uchar d_speed;
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_RUNSPEED);
d_speed = *g_char_ptr; /* get the current wire move speed. */
g_char_ptr = (uchar xdata *)AD_WFMOTOR;
*g_char_ptr = CN_BKMOTBKHG; /* the back motor go back direction. */
TH0 = CNSTRIPACCE[d_speed][0];
TL0 = CNSTRIPACCE[d_speed][1];
d_halfpulse =(d_dist/2)+(d_dist%2);
g_generalbit = TRUE;
TR0 = 1; /* start the Timer0. */
for(d_counter=0;d_counter<d_dist;d_counter++)
{
g_char_ptr = (uchar xdata *)AD_WFMOTOR;
Reset_Watchdog();
*g_char_ptr = CN_BKMOTBKLW;
if(d_counter<d_halfpulse) /* the accelerate stage. */
{
if(d_counter<CNSTRIPSTEP)
{
g_thvalue = CNSTRIPACCE[d_speed][d_counter*2];
g_tlvalue = CNSTRIPACCE[d_speed][d_counter*2+1];
}
else
{
g_thvalue = CNSTRIPACCE[d_speed][(CNSTRIPSTEP-1)*2];
g_tlvalue = CNSTRIPACCE[d_speed][(CNSTRIPSTEP-1)*2+1];
}
}
else /* the decelerate stage. */
{
if((d_dist-d_counter)<CNSTRIPSTEP)
{
g_thvalue = CNSTRIPACCE[d_speed][(d_dist-d_counter-1)*2];
g_tlvalue = CNSTRIPACCE[d_speed][(d_dist-d_counter-1)*2+1];
}
else
{
g_thvalue = CNSTRIPACCE[d_speed][(CNSTRIPSTEP-1)*2];
g_tlvalue = CNSTRIPACCE[d_speed][(CNSTRIPSTEP-1)*2+1];
}
}
Delay_us(CN_10us);
*g_char_ptr = CN_BKMOTBKHG;
for(;g_generalbit==TRUE;)
{} /* wait for Timer0 interrupt. */
g_generalbit=TRUE;
}
TR0 = 0; /* stop the Timer0. */
}
/***************************************************************************
NAME: Frontmotor_Stripdist
FUNCTION: This procedure will move back wire motor to strip.
INPUTS: move pulse.
OUTPUTS: NONE
***************************************************************************/
void Frontmotor_Stripdist(uint d_dist)
{
idata uint d_counter;
idata uint d_halfpulse;
idata uchar d_speed;
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_RUNSPEED);
d_speed = *g_char_ptr; /* get the current wire move speed. */
g_char_ptr = (uchar xdata *)AD_WFMOTOR;
*g_char_ptr = CN_FRMOTGOHG; /* the front motor go front direction. */
TH0 = CNSTRIPACCE[d_speed][0];
TL0 = CNSTRIPACCE[d_speed][1];
d_halfpulse =(d_dist/2)+(d_dist%2);
g_generalbit = TRUE;
TR0 = 1; /* start the Timer0. */
for(d_counter=0;d_counter<d_dist;d_counter++)
{
g_char_ptr = (uchar xdata *)AD_WFMOTOR;
Reset_Watchdog();
*g_char_ptr = CN_FRMOTGOLW;
if(d_counter<d_halfpulse) /* the accelerate stage. */
{
if(d_counter<CNSTRIPSTEP)
{
g_thvalue = CNSTRIPACCE[d_speed][d_counter*2];
g_tlvalue = CNSTRIPACCE[d_speed][d_counter*2+1];
}
else
{
g_thvalue = CNSTRIPACCE[d_speed][(CNSTRIPSTEP-1)*2];
g_tlvalue = CNSTRIPACCE[d_speed][(CNSTRIPSTEP-1)*2+1];
}
}
else /* the decelerate stage. */
{
if((d_dist-d_counter)<CNSTRIPSTEP)
{
g_thvalue = CNSTRIPACCE[d_speed][(d_dist-d_counter-1)*2];
g_tlvalue = CNSTRIPACCE[d_speed][(d_dist-d_counter-1)*2+1];
}
else
{
g_thvalue = CNSTRIPACCE[d_speed][(CNSTRIPSTEP-1)*2];
g_tlvalue = CNSTRIPACCE[d_speed][(CNSTRIPSTEP-1)*2+1];
}
}
Delay_us(CN_10us);
*g_char_ptr = CN_FRMOTGOHG;
for(;g_generalbit==TRUE;)
{} /* wait for Timer0 interrupt. */
g_generalbit=TRUE;
}
TR0 = 0; /* stop the Timer0. */
}
/***************************************************************************
NAME: Test_Process
FUNCTION: This procedure will make the test wire process.
INPUTS: NONE
OUTPUTS: NONE
***************************************************************************/
void Test_Process()
{
idata uint d_onlyplasleng;
idata uint d_uintreg0;
idata uchar d_charreg0;
bit nousebit;
Reset_Watchdog();
CN_MAGOFF; /* magnetic off, down the wire tube. */
CN_LAMPOFF; /* the system wire detect mode disable, lamp off. */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIRELONG);
d_onlyplasleng = *g_uint_ptr; /* get the wire length. */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIREHEAD);
if(d_onlyplasleng>=*g_uint_ptr)
{ d_onlyplasleng = d_onlyplasleng-(*g_uint_ptr); } /* wire length-wire head. */
else
{ d_onlyplasleng = 0; }
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIRERAIL);
if(d_onlyplasleng>=*g_uint_ptr)
{ d_onlyplasleng = d_onlyplasleng-(*g_uint_ptr); } /* wire length-wirehead-wirerail. */
else
{ d_onlyplasleng = 0; }
g_onrunflag = CN_INWORK; /* Now, system is on process status. */
#if CN_CUTDIRECT /* no matter wire radius, cut it directly. */
Cutter_Movedist(CN_ZEROTOCLOSE+CN_CLOSETOEND,CN_CUTCLOSE,CN_CUTACCEL);
#else
Cutter_Movedist(CN_ZEROTOFORCE,CN_CUTCLOSE,CN_CUTACCEL); /* reach wire. */
Cutter_Movedist(CN_FORCETOCLOSE,CN_CUTCLOSE,CN_CUTCONST); /* cut off wire. */
Cutter_Movedist(CN_CLOSETOEND,CN_CUTCLOSE,CN_CUTACCEL); /* go the cut end. */
#endif
nousebit = Cutter_Reset(); /* cutter go back to the original point. */
if(g_currentisshort==FALSE) /* the normal process mode. */
{
for(;;)
{
Process_Refresh();
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIREHEAD);
d_uintreg0 = *g_uint_ptr; /* get wire head. */
if(d_uintreg0>0)
{
Dbmotor_Movedist(d_uintreg0,CN_MOTFRONT); /* move the wire head length. */
}
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_WIRERADS);
d_charreg0 = *g_char_ptr; /* get the current wire radius. */
d_charreg0 = CN_ZEROTOCLOSE-d_charreg0;
Cutter_Movedist(d_charreg0,CN_CUTCLOSE,CN_CUTACCEL); /* cut the wire cover. */
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_CUTTBACK);
d_charreg0 = *g_char_ptr; /* get the current cutter cutter back value. */
if(d_charreg0>0)
{
g_char_ptr = (uchar xdata *)AD_BACKCLEAR;
d_charreg0 = *g_char_ptr+d_charreg0; /* appair the gear clearence. */
Cutter_Movedist(d_charreg0,CN_CUTOPEN,CN_CUTACCEL); /* cutter back. */
}
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_STRIPHEAD);
d_uintreg0 = *g_uint_ptr; /* get wire strip head. */
if(d_uintreg0>0)
{
Backmotor_Stripdist(d_uintreg0); /* strip the wire strip head. */
}
if(d_charreg0>0)
{
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_WIRERADS);
d_charreg0 = CN_ZEROTOCLOSE-d_charreg0-(*g_char_ptr);
}
else
{
g_char_ptr = (uchar xdata *)AD_BACKCLEAR;
d_charreg0 = *g_char_ptr; /* appair the gear clearence. */
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_WIRERADS);
d_charreg0 = CN_ZEROTOCLOSE-d_charreg0-(*g_char_ptr);
}
Cutter_Movedist(d_charreg0,CN_CUTOPEN,CN_CUTACCEL); /* back zero point.*/
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIRELONG);
d_uintreg0 = *g_uint_ptr; /* get the wire length. */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_STRIPHEAD);
d_uintreg0 = d_uintreg0+(*g_uint_ptr); /* wirelong+striphead */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIREHEAD);
if(d_uintreg0>=*g_uint_ptr)
{ d_uintreg0 = d_uintreg0-(*g_uint_ptr);} /* wire long+striphead-wirehead. */
else
{d_uintreg0 = 0; }
if(d_uintreg0>0)
{
Dbmotor_Movedist(d_uintreg0,CN_MOTFRONT); /* move to the wire rail. */
}
#if CN_CUTDIRECT /* no matter wire radius, cut it directly. */
Cutter_Movedist(CN_ZEROTOCLOSE+CN_CLOSETOEND,CN_CUTCLOSE,CN_CUTACCEL);
#else
Cutter_Movedist(CN_ZEROTOFORCE,CN_CUTCLOSE,CN_CUTACCEL); /* reach wire. */
Cutter_Movedist(CN_FORCETOCLOSE,CN_CUTCLOSE,CN_CUTCONST); /* cut off wire. */
Cutter_Movedist(CN_CLOSETOEND,CN_CUTCLOSE,CN_CUTACCEL); /* go the cut end. */
#endif
#if CN_BACKFORUP
Backmotor_Movedist(CN_BACKWIRE,CN_MOTBACK);
#endif
#if CN_SHORTNOUP
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIRERAIL);
if(*g_uint_ptr>CN_SHORTVALUE)
{
CN_MAGON; /* magnetic on, up the wire tube. */
}
#else
CN_MAGON; /* magnetic on, up the wire tube. */
#endif
Cutter_Openmax(); /* open the cutter max in order to go back the wire rod. */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIRERAIL);
d_uintreg0 = *g_uint_ptr; /* get wire rail. */
if(d_uintreg0>0)
{
Frontmotor_Movedist(d_uintreg0,CN_MOTBACK);
}
g_char_ptr = (uchar xdata *)AD_FRONTCLEAR;
d_charreg0 = *g_char_ptr; /* get the front gear clearence. */
d_charreg0 = d_charreg0+CN_UNDERZERODIST-CN_UNDERZERORST;
Cutter_Movedist(d_charreg0,CN_CUTCLOSE,CN_CUTACCEL);
if(!Cutter_Reset()) /* the cutter sensor damage, stop prcess and alarm on. */
{
Cut_Rst_Failure();
break;
}
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_WIRERADS);
d_charreg0 = *g_char_ptr; /* get the current wire radius. */
#if CN_GOODCOVER
d_charreg0 = CN_ZEROTOCLOSE-d_charreg0-CN_COVERTHICK;
Cutter_Movedist(d_charreg0,CN_CUTCLOSE,CN_CUTACCEL); /* move to the wire. */
Cutter_Movedist(CN_COVERTHICK,CN_CUTCLOSE,CN_CUTACCEL); /* cut the wire cover. */
#else
d_charreg0 = CN_ZEROTOCLOSE-d_charreg0;
Cutter_Movedist(d_charreg0,CN_CUTCLOSE,CN_CUTACCEL); /* cut the wire cover. */
#endif
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_CUTTBACK);
d_charreg0 = *g_char_ptr; /* get the current cutter cutter back value. */
if(d_charreg0>0)
{
g_char_ptr = (uchar xdata *)AD_BACKCLEAR;
d_charreg0 = *g_char_ptr+d_charreg0; /* appair the gear clearence. */
Cutter_Movedist(d_charreg0,CN_CUTOPEN,CN_CUTACCEL); /* cutter back. */
}
AD_LAMPIN = 1; /* lamp detect input enable. */
CN_LAMPOFF; /* the system wire detect mode disable. */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_STRIPRAIL);
d_uintreg0 = *g_uint_ptr; /* get wire strip rail. */
if(d_uintreg0>0)
{
Frontmotor_Stripdist(d_uintreg0); /* strip the wire strip rail. */
}
if(!Cutter_Reset()) /* the cutter sensor damage, stop prcess and alarm on. */
{
Cut_Rst_Failure();
break;
}
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIRERAIL);
d_uintreg0 = *g_uint_ptr; /* get wire rail. */
d_uintreg0 = d_uintreg0+CN_SAFEASSURE;
if(d_uintreg0>0)
{
Frontmotor_Movedist(d_uintreg0,CN_MOTFRONT);
}
CN_MAGOFF; /* magnetic off, down the wire tube. */
Delay_Set(CN_10ms); /* waiting for the wire tube down. */
#if CN_BACKFORUP
Backmotor_Movedist(CN_BACKWIRE,CN_MOTFRONT);
#endif
g_uint_ptr = (uint xdata *)AD_PRDUCNTER;
d_uintreg0 = *g_uint_ptr;
Prodcnt_Show(d_uintreg0); /* refresh the product counter. */
if(g_onrunflag==CN_STOPWORK)
{
Frontmotor_Movedist(CN_CASTWIRE,CN_MOTFRONT);
break; /* stop process. escape to the system sel status. */
}
}
}
else /* the short wire mode. */
{
for(;;)
{
Process_Refresh();
CN_LAMPOFF; /* the system wire detect mode disable, lamp off. */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_WIREHEAD);
d_uintreg0 = *g_uint_ptr; /* get wire head. */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_STRIPRAIL);
d_uintreg0 = d_uintreg0+(*g_uint_ptr); /* wirehead+striprail. */
if(d_uintreg0>0)
{
Dbmotor_Movedist(d_uintreg0,CN_MOTFRONT);
}
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_WIRERADS);
d_charreg0 = *g_char_ptr; /* get the current wire radius. */
d_charreg0 = CN_ZEROTOCLOSE-d_charreg0;
Cutter_Movedist(d_charreg0,CN_CUTCLOSE,CN_CUTACCEL); /* cut the wire cover. */
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_CUTTBACK);
d_charreg0 = *g_char_ptr; /* get the current cutter cutter back value. */
if(d_charreg0>0)
{
g_char_ptr = (uchar xdata *)AD_BACKCLEAR;
d_charreg0 = *g_char_ptr+d_charreg0; /* appair the gear clearence. */
Cutter_Movedist(d_charreg0,CN_CUTOPEN,CN_CUTACCEL); /* cutter back. */
}
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_STRIPHEAD);
d_uintreg0 = *g_uint_ptr; /* get wire strip head. */
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_STRIPRAIL);
d_uintreg0 = d_uintreg0+(*g_uint_ptr); /* striphead+striprail. */
if(d_uintreg0>0)
{
Backmotor_Stripdist(d_uintreg0); /* strip the wire strip head. */
}
if(!Cutter_Reset()) /* the cutter sensor damage, stop prcess and alarm on. */
{
Cut_Rst_Failure();
break;
}
d_uintreg0 = d_uintreg0+d_onlyplasleng;
if(d_uintreg0>0)
{
Dbmotor_Movedist(d_uintreg0,CN_MOTFRONT);
}
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_WIRERADS);
d_charreg0 = CN_ZEROTOCLOSE-(*g_char_ptr);
Cutter_Movedist(d_charreg0,CN_CUTCLOSE,CN_CUTACCEL); /* cut the wire cover. */
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_CUTTBACK);
d_charreg0 = *g_char_ptr; /* get the current cutter back value. */
if(d_charreg0>0)
{
g_char_ptr = (uchar xdata *)AD_BACKCLEAR;
d_charreg0 = *g_char_ptr+d_charreg0; /* appair the gear clearence. */
Cutter_Movedist(d_charreg0,CN_CUTOPEN,CN_CUTACCEL); /* cutter back. */
}
g_uint_ptr = (uint xdata *)(AD_CURPROG+AD_STRIPRAIL);
d_uintreg0 = *g_uint_ptr; /* get the strip rail. */
if(d_uintreg0>0)
{
Backmotor_Stripdist(d_uintreg0); /* strip the wire strip rail. */
}
if(d_charreg0>0)
{
g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_WIRERADS);
d_charreg0 = CN_ZEROTOCLOSE-d_charreg0-(*g_char_ptr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -