⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _io.c

📁 全自动剥线机(C语言源码+DOC文档说明)
💻 C
📖 第 1 页 / 共 5 页
字号:
  Cr_Inst_Data(flag,indata);  /* write the X start address. */
  indata = CN_CR_YSTA+36;
  Cr_Inst_Data(flag,indata);  /* write the Y start address. */
  Reset_Watchdog();   
  for(i=0;i<17;i++)
  {   
     j = ADTELCODE[i]*7;
     d_hzptr = &ADSTARTNUM[j];
     for(n=0;n<7;n++)
     {
     	if(4==i && 0==n)
     	{
     	   AD_CR_A2 = 0; AD_CR_A1 = 1;
           flag = CN_CR_IN;
           indata = CN_CR_XSTA+7;
           Cr_Inst_Data(flag,indata);  /* write the X start address. */
           indata = CN_CR_YSTA;
           Cr_Inst_Data(flag,indata);  /* write the Y start address. */	
     	}
     	if(13==i && 1==n)
     	{
     	   AD_CR_A2 = 1; AD_CR_A1 = 0;
           flag = CN_CR_IN;
           indata = CN_CR_XSTA+7;
           Cr_Inst_Data(flag,indata);  /* write the X start address. */
           indata = CN_CR_YSTA;
           Cr_Inst_Data(flag,indata);  /* write the Y start address. */	
     	}
        flag = CN_CR_DA;
        indata = *d_hzptr;
        Cr_Inst_Data(flag,indata);  
        d_hzptr++;
     }
  }   
}

/***************************************************************************

NAME:       Proinfo_Show

FUNCTION:   This procedure will show the process information.

INPUTS:     information kind 
            0-no wire or wire tie
            1-process finish successfully

OUTPUTS:    NONE

***************************************************************************/
void Proinfo_Show(uchar d_prokind)
{
  bit flag;
  uchar indata;
  uchar x,y;
  uchar i,j,n;
  uchar code *d_hzptr;
   
  for(i=0;i<6;i++) /* the process information have 6 hz. */
  {
    Reset_Watchdog();
    if(0==i)
    {
      x=3; y=48;   /* the 1st hz. */
      j = 0;
      AD_CR_A2 = 0; AD_CR_A1 = 0;
      flag = CN_CR_IN;
      indata = CN_CR_XSTA+x;
      Cr_Inst_Data(flag,indata); /* write the x start address. */
      indata = CN_CR_YSTA+y;
      Cr_Inst_Data(flag,indata); /* write the y start address. */
    } 
    indata = ADPROINFO[d_prokind][i];   
    d_hzptr=&ADHZLIB[(uint)(indata)*32]; /* get the hz offset address. */
    for(n=0;n<32;)
    {
      flag = CN_CR_DA; 	
      indata = *d_hzptr;
      Cr_Inst_Data(flag,indata); /* write the hz dot array */
      d_hzptr++;
      n++;
      if(16==n)
      {
        x++;
        flag = CN_CR_IN;
        indata = CN_CR_XSTA+x;
        Cr_Inst_Data(flag,indata); 
        indata = CN_CR_YSTA+y;
        Cr_Inst_Data(flag,indata);
      } 
    }
    x--;
    y=y+16;
    if(y>=64)
    { 
      y=0;
      j++;
      if(1==j)
      {AD_CR_A2 = 0; AD_CR_A1 = 1;}	
      else if(2==j)
      {AD_CR_A2 = 1; AD_CR_A1 = 0;}
    }
    flag = CN_CR_IN;
    indata = CN_CR_XSTA+x;
    Cr_Inst_Data(flag,indata); 
    indata = CN_CR_YSTA+y;
    Cr_Inst_Data(flag,indata);
  }
}
/***************************************************************************

NAME:       Get_Key

FUNCTION:   This procedure will get the key value. 

INPUTS:     NONE

OUTPUTS:    key value

***************************************************************************/
uchar Get_Key()
{
   uchar d_keyvalue;
  
   g_char_ptr = (uchar xdata *)AD_KEYIN;  /* point to the key input port. */
   d_keyvalue = *g_char_ptr;     /* get the key value.       */
   d_keyvalue = d_keyvalue&0x3F; /* set the high 2 bit as 0. */ 
   if(d_keyvalue!=CN_KEYNONE)
   {	
      if(TRUE==g_keypress)   /* the key has pressed. */   
      {	
      	 if(d_keyvalue==CN_KEYUP || d_keyvalue==CN_KEYDOWN || d_keyvalue==CN_KEYCHGP)
      	 {
      	   g_keytimer++;
      	   if(g_keytimer>=CN_OTHERKEY) 
      	   {
      	     g_keypress = FALSE; /* another key pressed event occur. */
      	     g_keytimer = 0;
      	   }
      	 }
      	 d_keyvalue = CN_KEYNONE; /* it's not a key pressed event. */   
      }
      else  /* when alarm mode, press any key to finish it. */
      {
      	 g_keypress = TRUE;    /* the key is pressed. */
         g_keytimer = 0;
         g_t2counter = CN_DELAYSTR; 
         if(g_selnumber==FALSE)
         {
      	    TR2 = 0;              /* Timer2 stop.            */
      	    g_outsw = CN_MENTON;  /* the mention voice on.   */
            g_char_ptr = (uchar xdata *)AD_OUTPUT;  /* point to the output port. */
           *g_char_ptr = g_outsw;    /* IO command output.     *
            TR2  = 1;             /* Start Timer2.             */
         }
         g_selnumber = FALSE;  
         /* when edit status, press chgpage key enter respond function. */
         if(g_systemsta==CN_EDITSTA && d_keyvalue==CN_KEYCHGP)
         {
            g_selnumber = TRUE;	
            d_keyvalue = CN_KEYENTER;
            g_keypress = FALSE;
         } 
        #if CN_AUTODETECT 
         /* auto detect the wire radius. */
         if(g_systemsta==CN_SELSTA && d_keyvalue==CN_KEYDOT)
         {
            if(g_pagecnter==1 && g_itemcnter==0)
            {   
               g_selnumber = TRUE;
               d_keyvalue = CN_KEYENTER;
               g_keypress = FALSE;  
            }
         }
        #endif      
         /* when sel status,press number key enter respond function. */
         /* eumlate once press-enter event.                          */
         if(g_systemsta==CN_SELSTA && d_keyvalue<=9 && g_itemcnter!=8)
         {
            if(g_pagecnter==0)
            {  	
               g_selnumber = TRUE;	
               d_keyvalue = CN_KEYENTER;
               g_keypress = FALSE;
            }
            if(g_pagecnter==2)
            {
               switch(g_itemcnter)
               {	
                  case 0:
                  case 1:
                  case 2:
                  case 3:
                  case 4:
                       g_uint_ptr = (uint xdata *)AD_PROGCNTER;
                       if((*g_uint_ptr)>=CN_COMPROG)
                       {
                       	  g_selnumber = TRUE;
                          d_keyvalue = CN_KEYENTER;
                          g_keypress = FALSE;   	
                       }
                       break;
                  case 6:     
                  case 7:
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                       break;
                  default:
                       break;     
               }           
            }	
            if(g_pagecnter==1)
            {
               switch(g_itemcnter)
               {
                  case 0:
                  case 1:
                  case 2:
                  case 3:
                  case 4:
                  case 6:
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
               	       break;
               	  case 5:
               	       if(g_transall==CN_SEGSET)
               	       {
               	          g_selnumber = TRUE;
                          d_keyvalue = CN_KEYENTER;
                          g_keypress = FALSE;
                       }   
               	       break;     
               	  default:
                       break;     
               }       	
            }
         }
         /* the following handle the hotkey enter parameter edit status. */
         /* wirelong, wirehead, wirerail,striphead, striprail, wirerads, cuttback. */
         if((g_systemsta==CN_EDITSTA) && !(g_pagecnter==1 && g_itemcnter==6)
            && !(g_pagecnter==2 && g_itemcnter==7))
         {
            switch(d_keyvalue)
            {
               case CN_KEYPROGNUM:
                    if(!(g_pagecnter==0 && g_itemcnter==0))
                    {
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                    }   
               	    break;
               case CN_KEYWIREH:
                    if(!(g_pagecnter==0 && g_itemcnter==4))
                    {
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                    }   
               	    break;	
               case CN_KEYWIRER:
                    if(!(g_pagecnter==0 && g_itemcnter==6))
                    {
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                    }   
               	    break;
               case CN_KEYSTRIPH:
                    if(!(g_pagecnter==0 && g_itemcnter==5))
                    {
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                    }   
               	    break;
               case CN_KEYSTRIPR:
                    if(!(g_pagecnter==0 && g_itemcnter==7))
                    {
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                    }   
               	    break;
               case CN_KEYWIREL:
                    if(!(g_pagecnter==0 && g_itemcnter==2))
                    {
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                    }   
               	    break;
               case CN_KEYWIRERA:
                    if(!(g_pagecnter==1 && g_itemcnter==0))
                    {
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                    }   
               	    break;
               case CN_KEYCUTBK:
                    if(!(g_pagecnter==1 && g_itemcnter==1))
                    {
                       g_selnumber = TRUE;
                       d_keyvalue = CN_KEYENTER;
                       g_keypress = FALSE;
                    }   
               	    break;
               default:
                    break;	    
            }    
         }
         if(g_alarmflag==TRUE)    /* press any key to escape the alarm mode.  */
         {
            g_alarmflag = FALSE;
            Init_Crystal();
            g_pagecnter = 0; /* the 0 page. */
            g_itemcnter = 8; /* the 8 item. */
            g_systemsta = CN_SELSTA;
            Page0_Show();  
            Show_Crystal();
            d_keyvalue = CN_KEYNONE;
         }      
      }  
   }
   else
   { 
      g_keypress = FALSE;
      g_selnumber = FALSE;
   }   	

   return d_keyvalue;
   
}   

/***************************************************************************

NAME:       Handle_Key

FUNCTION:   This procedure will handle the key value.  

INPUTS:     key value

OUTPUTS:    enter sub program

***************************************************************************/
void Handle_Key(uchar d_keyvalue)
{	
   if(d_keyvalue != CN_KEYNONE)
   {
      switch(g_systemsta)
      {
      	 case CN_SELSTA:
      	      Sel_Handle(d_keyvalue);
      	      break;	
   	 case CN_EDITSTA:
              Edit_Handle(d_keyvalue);   	
              break;
         case CN_INFOSTA:     
              g_systemsta = CN_SELSTA;
              g_alarmflag = FALSE;
              break;
         default:
              break;     
      }  
   }
}

/***************************************************************************

NAME:       Cutter_Movedist

FUNCTION:   This procedure will make move cutter to a select distance.  

INPUTS:     move pulse, move direction and accelerate kind.

OUTPUTS:    NONE

***************************************************************************/
void Cutter_Movedist(uchar d_dist, bit d_movedirect, bit acckind)
{
   uchar d_counter;
   uchar d_halfpulse; 
   uchar d_speed;
   	
   g_char_ptr = (uchar xdata *)(AD_CURPROG+AD_RUNSPEED);
   d_speed = *g_char_ptr; /* get the current speed stage. */
   g_char_ptr = (uchar xdata *)AD_CUMOTOR;
   if(d_movedirect==CN_CUTCLOSE)
   { *g_char_ptr = CN_CUTCLOSHG; } /* the cutter motor close direction. */
   else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -