三洋步进电机控制(带驱动器)

源代码在线查看: 复件 timercom_step.lst

软件大小: 16 K
上传用户: hqq
关键词: 三洋 步进电机控制 驱动器
下载地址: 免注册下载 普通下载 VIP

相关代码

				C51 COMPILER V7.50   复件_TIMERCOM_STEP                                                    09/24/2008 20:57:19 PAGE 1   
				
				
				C51 COMPILER V7.50, COMPILATION OF MODULE 复件_TIMERCOM_STEP
				OBJECT MODULE PLACED IN 复件 TIMERCOM_STEP.OBJ
				COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 复件 TIMERCOM_STEP.C BROWSE DEBUG OBJECTEXTEND
				
				line level    source
				
				   1          #include
				   2          #define uchar unsigned char
				   3          #define uint unsigned int
				   4          sbit opt=P0^3;   //驱动器使能//
				   5          sbit sp=P0^2;    //脉冲
				   6          sbit dir=P0^1;   //方向
				   7          sbit ena=P0^0;   //步进机使能
				   8          sbit S2=P3^2;     //启动键//
				   9          sbit S3=P3^3;     //正转键//
				  10          sbit S4=P3^4;     //反转键//
				  11          sbit S5=P3^5;   //加速键//
				  12          sbit S6=P3^6;  //减速键//
				  13          sbit S7=P3^7;     //停止键//
				  14          uchar width=0xb3;   //脉冲速度定值
				  15          void delay(unsigned int i)         //延时
				  16          {
				  17   1        while(i--);
				  18   1      }
				  19          void timer0() interrupt 1 using 1     //定时0
				  20          {
				  21   1       sp=~sp;
				  22   1       TL0=width;
				  23   1       TH0=0x72;
				  24   1      }
				  25          void jiasu()
				  26          {
				  27   1       if(width-20>0)
				  28   1       width=width-20;
				  29   1      }
				  30          void jiansu()
				  31          {
				  32   1       if(width+20				  33   1       width=width+25;
				  34   1      }
				  35          
				  36          //键盘扫描//
				  37          void keyscan(void)
				  38          {
				  39   1        if(S2==0)
				  40   1          {
				  41   2            delay(10000);
				  42   2            if(S2==0)
				  43   2            {
				  44   3              while(S2==0)    {ena=1; opt=1;}    //启动
				  45   3            }
				  46   2          }
				  47   1          else if(S5==0)
				  48   1          {
				  49   2            delay(10000);
				  50   2            if(S5==0)
				  51   2            {
				  52   3              while(S5==0)    {ena=0; opt=0;}    //停止
				  53   3            }
				  54   2          }
				  55   1          else if(S3==0)
				C51 COMPILER V7.50   复件_TIMERCOM_STEP                                                    09/24/2008 20:57:19 PAGE 2   
				
				  56   1          {
				  57   2            delay(10000);
				  58   2            if(S3==0)
				  59   2            {
				  60   3              while(S3==0)    {jiasu(); }    //速度 1
				  61   3            }
				  62   2          }
				  63   1         else if(S6==0)
				  64   1         {
				  65   2           delay(10000);
				  66   2           if(S6==0)
				  67   2           {
				  68   3            while(S6==0)      {jiansu();}   //速度 2
				  69   3           }
				  70   2         }
				  71   1         else if (S4==0)
				  72   1         {
				  73   2           delay(10000);
				  74   2           if(S4==0)
				  75   2           {
				  76   3            while(S4==0)     {jiansu();}        //速度  3
				  77   3           }
				  78   2         }
				  79   1        else if (S7==0)
				  80   1        {
				  81   2          delay(10000);
				  82   2          if(S7==0)
				  83   2          {
				  84   3            while(S7==0)         {tingzhi();}       //速度 4
				*** WARNING C206 IN LINE 84 OF 复件 TIMERCOM_STEP.C: 'tingzhi': missing function-prototype
				  85   3          }
				  86   2        }
				  87   1      }
				  88          //主函数//
				  89           void main(void)
				  90          {
				  91   1       opt=1;ena=0;sp=0;dir=0;    //初状态//
				  92   1       TMOD=0x01;      //定时器
				  93   1       IE=0x9a;        //中断    
				  94   1      
				  95   1      
				  96   1       //TL0=width;       //定时器0
				  97   1       //TH0=0xfe;
				  98   1       TR0=1;           //启动定时器0
				  99   1       while(1)
				 100   1         {
				 101   2          keyscan();
				 102   2         }
				 103   1      }
				
				
				MODULE INFORMATION:   STATIC OVERLAYABLE
				   CODE SIZE        =    192    ----
				   CONSTANT SIZE    =   ----    ----
				   XDATA SIZE       =   ----    ----
				   PDATA SIZE       =   ----    ----
				   DATA SIZE        =      1    ----
				   IDATA SIZE       =   ----    ----
				   BIT SIZE         =   ----    ----
				END OF MODULE INFORMATION.
				
				
				C51 COMPILATION COMPLETE.  1 WARNING(S),  0 ERROR(S)
							

相关资源