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

📄 main.lst

📁 蛇形机器人程序
💻 LST
字号:
C51 COMPILER V7.09   MAIN                                                                  07/01/2004 21:24:08 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN Main.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE Main.c OMF2 ROM(COMPACT) OPTIMIZE(SIZE) REGFILE(.\FollowLine.ORC) BROWSE DE
                    -BUG

line level    source

   1          /*
   2                  Main Prgram
   3          */
   4          
   5          #include<reg52.h>
   6          #include<FollowLine.h>
   7          #include<intrins.h>
   8          //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   9          #define CatchBoxTime 2000               // original time is 2000
  10          #define CalibrateLine  2000
  11          #define BackLineTime 2500
  12          
  13          bit CloseSensor1Com = 1;
  14          bit CloseSensor2Com = 1;
  15          bit FrontFlag = 0;
  16          bit StopFlag = 0;
  17          bit CrashFlag = 1;      //touching sensor to the 2 score zone
  18          bit ClampFlag = 0;              // 1 = 
  19          
  20          unsigned char iCrashTime = 0;
  21          unsigned int iStopTime = 0;
  22          //~~~~~~~~~~~~~~~~~Function Declaration~~~~~~~~~~~~~~~~~~~~
  23          void Delay(unsigned int time);
  24          extern void initial(void);
  25          
  26          //***************************************************
  27          //~~~~~~~~~~~~~~~~Main function~~~~~~~~~~~~~~~~~~~~~*
  28          //***************************************************
  29          void main (void)
  30          {
  31   1      
  32   1              _nop_();
  33   1              Delay(1);  //.25ms
  34   1              _nop_();
  35   1              initial();                                                
  36   1              _nop_();
  37   1      
  38   1       //     start up 
  39   1      
  40   1       
  41   1              MotorLeft(1,1);
  42   1              MotorRight(1,1);
  43   1              Delay(2200);
  44   1              MotorLeft(3,1);
  45   1              MotorRight(3,1);
  46   1              Delay(2200);
  47   1              
  48   1              MotorLeft(16,1);
  49   1              MotorRight(16,1);
  50   1              Delay(2200);    
  51   1      
  52   1              MotorLeft(31,1);
  53   1              MotorRight(31,1);
  54   1              Delay(16000);                           // original value is 15000
C51 COMPILER V7.09   MAIN                                                                  07/01/2004 21:24:08 PAGE 2   

  55   1              Stop();
  56   1              Delay(4000);
  57   1      
  58   1      
  59   1              MotorLeft(16,1);
  60   1              MotorRight(16,0);
  61   1              Delay(6300);                             // need further adjustment
  62   1      
  63   1              Stop();
  64   1              Delay(1000);
  65   1      
  66   1      
  67   1              while(CloseSensor1)
  68   1              {       
  69   2                      MotorLeft(28,1);
  70   2                      MotorRight(28,1);
  71   2              }
  72   1      
  73   1              MotorLeft(27,1);
  74   1              MotorRight(31,1);
  75   1              Delay(10000);
  76   1      
  77   1              MotorLeft(28,1);
  78   1              MotorRight(31,1);
  79   1              Delay(10000);
  80   1      
  81   1              MotorLeft(30,1);
  82   1              MotorRight(31,1);
  83   1              Delay(40000);
  84   1      
  85   1              iLoop = 0;
  86   1              iSensorConfirm= 0;
  87   1              while(CloseSensor1Com)
  88   1              {
  89   2                      iLoop++;
  90   2                      MotorLeft(31,1);
  91   2                      MotorRight(29,1);               
  92   2                      if(CloseSensor1)
  93   2                      {
  94   3                              Delay(20);
  95   3                              iSensorConfirm++;
  96   3                      }
  97   2                      if(iLoop == 20)
  98   2                      {                                                                        // filter to avoid noise
  99   3                              if(iSensorConfirm > 18)
 100   3                              {
 101   4                                      CloseSensor1Com = 0; 
 102   4                                      iLoop = 0;
 103   4                              }
 104   3                              else
 105   3                              {
 106   4                                      CloseSensor1Com = 1; 
 107   4                                      iLoop = 0;
 108   4                              }
 109   3                      }
 110   2      
 111   2              }
 112   1              CloseSensor1Com = 0;
 113   1              Delay(1500);
 114   1              
 115   1              Stop();
 116   1              Delay(800);
C51 COMPILER V7.09   MAIN                                                                  07/01/2004 21:24:08 PAGE 3   

 117   1      //catch right position
 118   1      
 119   1                      
 120   1              MotorLeft(16,0);        // turn about 45 degree
 121   1              MotorRight(16,1);
 122   1              Delay(6900);
 123   1      
 124   1              Stop();
 125   1              Delay(1000);
 126   1              
 127   1              MotorLeft(31,1);
 128   1              MotorRight(31,1);
 129   1              Delay(11300);
 130   1              
 131   1              while(TouchSensor1 && TouchSensor2)
 132   1              {
 133   2                  ET1=1;
 134   2                  TR1=1;
 135   2                      MotorLeft(31,1);
 136   2                      MotorRight(31,1);
 137   2              }
 138   1              MotorLeft(31,1);
 139   1              MotorRight(31,1);
 140   1              Delay(800);
 141   1               //adjust to fit the bridge edge 
 142   1                      while((TouchSensor1 || TouchSensor2) && CrashFlag )
 143   1              {
 144   2                      if ((!TouchSensor1)&&(TouchSensor2)     )        //left touch
 145   2                      {
 146   3                              MotorLeft(16,0);
 147   3                              MotorRight(14,0);                               
 148   3                              Delay(2000);                                    
 149   3                              Stop();
 150   3                              Delay(800);
 151   3                      }
 152   2                      else if ((TouchSensor1)&&(!TouchSensor2)) //right touch
 153   2                      {
 154   3                              MotorLeft(14,0);
 155   3                              MotorRight(16,0);       
 156   3                              Delay(2000);
 157   3                              Stop();
 158   3                              Delay(800);
 159   3                      }
 160   2                      else if ((TouchSensor1)&&(TouchSensor2))  // try to crash
 161   2                      {
 162   3                              MotorLeft(31,1);
 163   3                              MotorRight(31,1);       
 164   3                              Delay(2500);
 165   3                              iCrashTime++;
 166   3                      }
 167   2                      if(iCrashTime >5 )         // if crash time is over 3time false to try
 168   2                      {CrashFlag = 0;}
 169   2      
 170   2      
 171   2              }
 172   1              Stop();
 173   1              ReleaseMotor = 0;               //release the blocker?
 174   1      
 175   1              Delay(6000);
 176   1              ReleaseMotor = 1;
 177   1      
 178   1              Stop();
C51 COMPILER V7.09   MAIN                                                                  07/01/2004 21:24:08 PAGE 4   

 179   1              while(1);
 180   1      
 181   1      
 182   1      }
 183          
 184          
 185          //~~~~~~~~~Delay Function~~~~~~~~~~~~~~~~~~~~~~~
 186          void Delay(unsigned int time) //time /ms
 187          {
 188   1              unsigned int i;
 189   1              unsigned char j;
 190   1              time *=2;
 191   1              for (i=0;i<time;i++)
 192   1              {
 193   2                      _nop_ ();
 194   2                      for (j=0;j<10;j++)
 195   2                      {
 196   3                              _nop_ ();
 197   3                      }
 198   2              }
 199   1      } 
 200          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    524    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      6    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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