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

📄 _io.h

📁 全自动剥线机(C语言源码+DOC文档说明)
💻 H
字号:
/* this is the _io.h module, all the system I/O address is define here. */

/* specification */
/* this program define the following prefix as a rule */
/* p     - pointer variable
   g     - global variable
   d     - local variable
   c     - counter
   b     - bit  
   lc    - local counter
   gc    - global counter
   uchar - unsigned char
   uint  - unsigned int
   ulong - unsigned long
   f     - function
   CN    - constant data     
   AD    - constant address         */

/* define the program process mode. */
#define    CN_AUTODETECT  FALSE  /* if auto detect the wire radius.  */ 
#define    CN_BACKFORUP   TRUE   /* if back wire for tube up easily. */
#define    CN_GOODCOVER   TRUE   /* ensure strip good cover.         */
#define    CN_CUTDIRECT   TRUE   /* no matter wire-radius, cut it directly. */
#define    CN_SHORTNOUP   FALSE  /* if wire rail short, then no up tube. */ 
#define    CN_SHORTVALUE  13     /* 3mm, if short then this value, not up tube.  */

/* define the  IO port address */
#define    AD_RAM        0x2010   /* from 0x2010 -- 0x2FFF, total 8K byte.  */ 
#define    AD_PROGRAM    0x2100   /* the start address of the program.      */
#define    AD_MIDSRAM    0x2D20   /* the middle strip prog start address.   */
#define    AD_LASTRAM    0x2FFC   /* the last address of the NVRAM.         */
#define    AD_WFMOTOR    0x4001   /* the wire feed motor port address.      */
#define    AD_CUMOTOR    0x6001   /* the cutter motor output port address.  */
#define    AD_CRYSTAL    0x8001   /* the crystal screen output address.     */
#define    AD_OUTPUT     0xA001   /* the IO signal output port address.     */
#define    AD_KEYIN      0xE001   /* the keyboard input port address.       */

/* define the system register address. */
#define    AD_PROGCNTER  0x0010   /* the system program counter,uint style. */
#define    AD_PRDUCNTER  0x0012   /* the product counter,uint style.        */
#define    AD_GROUPCNTER 0x0014   /* the group counter, uint style.         */
#define    AD_STARTTRAN  0x0016   /* the data transfer start address.       */
#define    AD_LASTTRAN   0x0018   /* the data transfer last address.        */
#define    AD_STARTDEL   0x001A   /* the data delete start address.         */
#define    AD_LASTDEL    0x001C   /* the data delete last address.          */
#define    AD_MACHNO     0x001E   /* the machine No. address, uchar style.  */
#define    AD_TOMACH     0x001F   /* the transfer to machine No.uchar style.*/
#define    AD_TEMPDOTSTA 0x0020   /* the dot status, uchar style.           */
#define    AD_BACKCLEAR  0x0021   /* the back direction gear clearence.     */
#define    AD_FRONTCLEAR 0x0022   /* the front direction gear clearecne.    */
                                  /* the current program register segment.  */
#define    AD_CURPROG    0x0023   /* the following 28 byte be used.         */ 
#define    AD_TEMPMID    0x003F   /* 8 byte,temp save mid-strip parameter.  */

/* define the process program data offset address */
#define    AD_RUNSPEED   0  /* process speed.                   */
#define    AD_WIRELONG   1  /* the length of the wire rod.      */
#define    AD_WIREHEAD   3  /* the length of the wire rod head. */
#define    AD_STRIPHEAD  5  /* the length of the strip head.    */
#define    AD_WIRERAIL   7  /* the length of the wire rod rail. */ 
#define    AD_STRIPRAIL  9  /* the length of the strip rail.    */
#define    AD_WIRERADS   11 /* the radius-area of the wire rod. */
#define    AD_CUTTBACK   12 /* the cutter back length.          */ 
#define    AD_PERGROUP   13 /* the set number of per group.     */ 
#define    AD_TOTALGROUP 15 /* the set value of the group numb. */
#define    AD_RESERVED   17 /* the reserved byte.               */
#define    AD_MIDSTRIP0  18 /* the middle strip 0.              */
#define    AD_MIDSTRIP1  20 /* the middle strip 1.              */
#define    AD_MIDSTRIP2  22 /* the middle strip 2.              */
#define    AD_MIDSTRIP3  24 /* the middle strip 3.              */
#define    AD_STRIPLENG  26 /* the strip length in mid-strip.   */

/* define the watchdog address */
#define    AD_WDG    T1         /* P3.5 */ 

/* respond to  ADPROINFO[3][6] */
#define CN_NOWIREINFO  0
#define CN_PROFINISH   1
#define CN_CUTTDAMAGE  2

/* define the crystal screen control bit address. */
sbit     AD_CR_E   = 0x90;  /* P1.0 */
sbit     AD_CR_RW  = 0x91;  /* P1.1 */
sbit     AD_CR_RS  = 0x92;  /* P1.2 */
sbit     AD_CR_A2  = 0x93;  /* P1.3 */
sbit     AD_CR_A1  = 0x94;  /* P1.4 */
sbit     AD_LAMPOP = 0x96;  /* P1.6 */
sbit     AD_MAGOP  = 0x97;  /* P1.7 */

#define  CN_CRSHON   0x3F   /* crystal screen show on. */
#define  CN_CRSHOFF  0x3E   /* crystal screen show off.*/
#define  CN_CR_XSTA  0x0B8  /* X start address.        */
#define  CN_CR_XLAS  0x0BF  /* X last  address.        */
#define  CN_CR_YSTA  0x40   /* Y start address.        */
#define  CN_CR_YLAS  0x7F   /* Y last  address.        */
#define  CN_CR_WR    0      /* crystal screen write enable. */
#define  CN_CR_RD    1      /* crystal screen read enable.  */
#define  CN_CR_IN    0      /* instrument input enable.     */
#define  CN_CR_DA    1      /* data input enable.           */   

/* define the 485 control bit */
sbit     AD_485TR  = 0x95;  /* P1.5 */
#define  CN_RE_EN    1      /* rs232 receive enable.        */
#define  CN_TR_EN    0      /* rs232 transmit enable.       */

/* define the IO signal input bit */
sbit     AD_STOPIN = 0xB2;  /* P3.2 INT0, the key hand input                */  
sbit     AD_LAMPIN = 0xB3;  /* P3.3 the sensor lamp status check input      */
sbit     AD_POSIN  = 0xB4;  /* P3.4 the cutter axle position check input    */
#define  CN_UNDERZERO  1    /* the cutter is under the zero point(max open).*/
#define  CN_OVERZERO   0    /* the cutter is over the zero point.           */ 

/* define the output IO signal. */
#define  CN_MAGON     AD_MAGOP = 0    /* the magnetic on.   */
#define  CN_MAGOFF    AD_MAGOP = 1    /* the magnetic off.  */
#define  CN_ALARMON   g_outsw&0x00    /* the process finish alarm on.  */
#define  CN_ALARMOFF  g_outsw|0x01    /* the process finish alarm off. */    
#define  CN_MENTON    g_outsw&0x00    /* the mention voice on.  */
#define  CN_MENTOFF   g_outsw|0x01    /* the mention voice off. */  
#define  CN_LAMPON    AD_LAMPOP = 0   /* the sensor lamp on.  */
#define  CN_LAMPOFF   AD_LAMPOP = 1   /* the sensor lamp off. */  

/* define the key value. */
#define  CN_KEYNONE    42   /* no key pressed.  */
#define  CN_KEYDOT     20   
#define  CN_KEYENTER   21
#define  CN_KEYCLR     22
#define  CN_KEYCHGP    23   /* change the page. */
#define  CN_KEYUP      24
#define  CN_KEYDOWN    25
#define  CN_KEYESC     26
#define  CN_KEYSTART   27
#define  CN_KEYSTOP    28
#define  CN_KEYWIREH   29   /* the wire rod head long.    */
#define  CN_KEYWIRER   30   /* the wire rod rail long.    */
#define  CN_KEYSTRIPH  31   /* the strip head long.       */
#define  CN_KEYSTRIPR  32   /* the strip rail long.       */
#define  CN_KEYWIREL   33   /* the wire rod long.         */
#define  CN_KEYWIRERA  34   /* the wire rod radius.       */
#define  CN_KEYCUTBK   35   /* the cutter back value.     */
#define  CN_KEYCLRTA   36   /* clear the product counter. */
#define  CN_KEYPROGNUM 37   /* the current progra number. */

#define  CN_OTHERKEY   25   /* key pressed-time-counter, another key occur. */

/* define the system status identify constant. */
#define  CN_SELSTA     0    /* the system select status. */ 
#define  CN_EDITSTA    1    /* the system edit status.   */
#define  CN_INFOSTA    2    /* show information status.  */

/* define the transfer coefficient from mm to pulse. */
#define  CN_UPCOEFF    11683
#define  CN_DOWNCOEFF  2925
#define  CN_SHORTPULSE 200  /* CN_SHORTLIM*CN_UPCOEFF/CN_DOWNCOEFF.   */
#define  CN_CASTWIRE   300  /* cast out the wire rod.  */
#define  CN_SHORTDELEN 460  /* 65+50=115mm, detect the wire short.    */

/* **** the following define the motor move paramater.    *** */
/* define the motor direction. */
#define  CN_MOTFRONT   0  /* the wire move toward front.      */
#define  CN_MOTBACK    1  /* the wire move toward back.       */
#define  CN_CUTOPEN    0  /* the cutter move open, the motor CCW direction.    */
#define  CN_CUTCLOSE   1  /* the cutter move close,the motor CW  direction.    */
#define  CN_HAVEWIRE   0  /* there have wire, and lamp off, detect low level.  */
#define  CN_NOWIRE     1  /* there no wire, and lamp on, detect high level.    */ 
#define  CN_INWORK     0x55 /* the system is in work. */
#define  CN_STOPWORK   0xAA /* the system stop work.  */

/* define the cutter distance and motor direction value. */
/* the D0-motor move pulse, the D1-motor move direction, the D2-connect flag.  */
#define  CN_RESETLIMIT    230   /* if >= this value, then cut sensor damage.   */    
#define  CN_ZEROTOCLOSE   155   /* the zero point to the cutter close point.   */ 
#define  CN_UNDERZERODIST 33    /* from zero point to max open dist.           */
#define  CN_FORCETOCLOSE  60    /* from this dist ,the cutter move with force. */
#define  CN_ZEROTOFORCE   CN_ZEROTOCLOSE-CN_FORCETOCLOSE   
#define  CN_CLOSETOEND    7     /* from close point to the end point.          */
#define  CN_UNDERZERORST  7     /* the pulse of under zero for reset cutter.   */ 
#define  CN_SAFEASSURE    2     /* define the safe number.                     */
#define  CN_TESTFORGEAR   30    /* test for the gear clearence appair.         */
#define  CN_MINCLEARENCE  3     /* the minium gear clearence.                  */
#define  CN_COVERTHICK    25    /* in good cover mode, the default cover thick.*/ 
#define  CN_TESTRADDIST   40    /* move 10mm,for the wire radius auto detect.  */
#define  CN_BACKWIRE      8     /* back 2mm for the wire tube up.              */
#define  CN_CUTACCEL      0     /* select the cutter accelerate form.          */
#define  CN_CUTCONST      1     /* select the cutter constant form.            */
#define  CN_CUTCLOSHG     0x05  /* the cutter motor close direction high pulse.*/
#define  CN_CUTCLOSLW     0x04  /* the cutter motor close direction low pulse. */
#define  CN_CUTOPENHG     0x07  /* the cutter motor open direction high pulse. */
#define  CN_CUTOPENLW     0x06  /* the cutter motor open direction low pulse.  */ 
#define  CN_FRMOTGOHG     0x77  /* the front motor go direction high pulse.    */
#define  CN_FRMOTGOLW     0x76  /* the front motor go direction low pulse.     */
#define  CN_FRMOTBKHG     0x75  /* the front motor back direction high pulse.  */
#define  CN_FRMOTBKLW     0x74  /* the front motor back direction low pulse.   */    
#define  CN_BKMOTGOHG     0x77  /* the back motor go direction high pulse.     */
#define  CN_BKMOTGOLW     0x67  /* the back motor go direction low pulse.      */
#define  CN_BKMOTBKHG     0x57  /* the back motor back direction high pulse.   */
#define  CN_BKMOTBKLW     0x47  /* the back motor back direction low pulse.    */
#define  CN_DBMOTGOHG     0x77  /* the double motor go direction high pulse.   */
#define  CN_DBMOTGOLW     0x66  /* the double motor go direction low pulse.    */
#define  CN_DBMOTBKHG     0x55  /* the double motor back direction high pulse. */
#define  CN_DBMOTBKLW     0x44  /* the double motor back direction low pulse.  */
#define  CN_DBMOTDISA     0x33  /* the double motor disable.                   */
  
/* define the cutter motor accelerate form.                 */
/* from 700Hz accelerate to 1300Hz, 12 step to accelerate.  */
/* 10 kind of speed, the fast speed is 1300Hz.              */
#define CNCUTACCSTEP  12   /* the cutter accelerate step.   */

/* define the cutter motor auto detect the wire radius      */
/* accelerate form. 70 step to accelerate.                  */
/* 10 kinds of speed, the lowest speed is 4000Hz.           */
#define CNCUTDCTSTEP  70   /* the cutter accelerate step.   */

/* define the strip move accelerate form.                   */
/* from 800Hz accelerate 1800Hz, 14 step to accelerate.     */
/* 10 kinds of speed, the lowest speed is 2000Hz.           */
#define CNSTRIPSTEP   14  /* the strip accelerate step.     */

/* define the front and back motor accelerate form.         */
/* from 700Hz accelerate to 2300HZ, 24 step to accelerate.  */
/* 10 kinds of speed, the lowest speed is 1300Hz.           */
#define  CNWIRESTEP   24  /* the wire accelereate step.     */





/**************************************************************************
Edit by:
FRANK	                             		      20030910  ShenZhen
**************************************************************************/

⌨️ 快捷键说明

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