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

📄 main.lst

📁 蛇形机器人程序
💻 LST
字号:
C51 COMPILER V7.09   MAIN                                                                  07/03/2004 20:16:45 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 CloseSensor2Com = 1;
  14          bit FrontFlag = 0;
  15          bit StopFlag = 0;
  16          bit CrashFlag = 1;      //touching sensor to the 2 score zone
  17          bit ClampFlag = 0;              // 1 = 
  18          
  19          unsigned char iCrashTime = 0;
  20          unsigned int iStopTime = 0;
  21          //~~~~~~~~~~~~~~~~~Function Declaration~~~~~~~~~~~~~~~~~~~~
  22          void Delay(unsigned int time);
  23          extern void initial(void);
  24          
  25          //***************************************************
  26          //~~~~~~~~~~~~~~~~Main function~~~~~~~~~~~~~~~~~~~~~*
  27          //***************************************************
  28          void main (void)
  29          {
  30   1      
  31   1              _nop_();
  32   1              Delay(1);  //.25ms
  33   1              _nop_();
  34   1              initial();                                                
  35   1              _nop_();
  36   1      
  37   1       //     start up 
  38   1      //~~~~~~~~~~~~~~~~~~~~~~~
  39   1      // 3 places need debug
  40   1      //~~~~~~~~~~~~~~~~~~~~~~~ 
  41   1      
  42   1              MotorLeft(1,1);
  43   1              MotorRight(1,1);
  44   1              Delay(2200);
  45   1              MotorLeft(3,1);
  46   1              MotorRight(3,1);
  47   1              Delay(2200);
  48   1              
  49   1              MotorLeft(16,1);
  50   1              MotorRight(16,1);
  51   1              Delay(2200);    
  52   1      
  53   1              MotorLeft(31,1);
  54   1              MotorRight(31,1);
C51 COMPILER V7.09   MAIN                                                                  07/03/2004 20:16:45 PAGE 2   

  55   1      //~~~~~~~~~~~~~~~~~~~~~~
  56   1      // first place needs debug
  57   1      // straight move to mid wall  ATTENTION do not touch the wall
  58   1      //~~~~~~~~~~~~~~~~~~~~~~~ 
  59   1              Delay(16000);                           // original value is 15000
  60   1      
  61   1      
  62   1              Stop();
  63   1              Delay(4000);
  64   1      
  65   1      
  66   1              MotorLeft(16,0);
  67   1              MotorRight(16,1);
  68   1      //~~~~~~~~~~~~~~~~~~~~~~
  69   1      // second place needs debug
  70   1      // trun about 75 degree ATTENTION do not out of 90
  71   1      //~~~~~~~~~~~~~~~~~~~~~~~ 
  72   1              Delay(7000);                             // need further adjustment
  73   1      
  74   1              Stop();
  75   1              Delay(1000);
  76   1      
  77   1      
  78   1              while(CloseSensor2)
  79   1              {       
  80   2                      MotorLeft(28,1);
  81   2                      MotorRight(28,1);
  82   2              }
  83   1        
  84   1              MotorLeft(31,1);
  85   1              MotorRight(27,1);
  86   1              Delay(10000);
  87   1              
  88   1              MotorLeft(31,1);
  89   1              MotorRight(28,1);
  90   1              Delay(10000);
  91   1              
  92   1      
  93   1              MotorLeft(31,1);
  94   1              MotorRight(30,1);
  95   1              Delay(40000);
  96   1      
  97   1              iLoop = 0;
  98   1              iSensorConfirm= 0;
  99   1              while(CloseSensor2Com)
 100   1              {
 101   2                      iLoop++;
 102   2                      MotorLeft(31,1);
 103   2                      MotorRight(29,1);               
 104   2                      if(CloseSensor2)
 105   2                      {
 106   3                              Delay(20);
 107   3                              iSensorConfirm++;
 108   3                      }
 109   2                      if(iLoop == 20)
 110   2                      {                                                                        // filter to avoid noise
 111   3                              if(iSensorConfirm > 18)
 112   3                              {
 113   4                                      CloseSensor2Com = 0; 
 114   4                                      iLoop = 0;
 115   4                              }
 116   3                              else
C51 COMPILER V7.09   MAIN                                                                  07/03/2004 20:16:45 PAGE 3   

 117   3                              {
 118   4                                      CloseSensor2Com = 1; 
 119   4                                      iLoop = 0;
 120   4                              }
 121   3                      }
 122   2      
 123   2              }
 124   1              CloseSensor2Com = 0;
 125   1      
 126   1              MotorLeft(16,1);
 127   1              MotorRight(14,1);           
 128   1              Delay(500);
 129   1      
 130   1      
 131   1              MotorLeft(8,1);
 132   1              MotorRight(6,1);            
 133   1              Delay(500);
 134   1              
 135   1                      
 136   1              Stop();
 137   1              Delay(30000);
 138   1      //catch right position
 139   1      
 140   1                      
 141   1              MotorLeft(16,1);        
 142   1              MotorRight(16,0);
 143   1      //~~~~~~~~~~~~~~~~~~~~~~
 144   1      // last place needs debug
 145   1      // trun about 60 to 80 ATTENTION do not out of 90
 146   1      //~~~
 147   1              Delay(8000);
 148   1      
 149   1              Stop();
 150   1              Delay(1000);
 151   1              
 152   1              MotorLeft(16,1);
 153   1              MotorRight(16,1);
 154   1              Delay(60000);
 155   1              
 156   1              while(TouchSensor1 && TouchSensor2)
 157   1              {
 158   2                  ET1=1;
 159   2                  TR1=1;
 160   2                      MotorLeft(16,1);
 161   2                      MotorRight(16,1);
 162   2              }
 163   1      
 164   1              MotorLeft(31,1);
 165   1              MotorRight(31,1);
 166   1              Delay(800);
 167   1               //adjust to fit the bridge edge 
 168   1                      while((TouchSensor1 || TouchSensor2) && CrashFlag )
 169   1              {
 170   2                      if ((!TouchSensor1)&&(TouchSensor2)     )        //left touch
 171   2                      {
 172   3                              MotorLeft(10,0);
 173   3                              MotorRight(8,0);                                
 174   3                              Delay(2500);                                    
 175   3                              Stop();
 176   3                              Delay(800);
 177   3                      }
 178   2                      else if ((TouchSensor1)&&(!TouchSensor2)) //right touch
C51 COMPILER V7.09   MAIN                                                                  07/03/2004 20:16:45 PAGE 4   

 179   2                      {
 180   3                              MotorLeft(8,0);
 181   3                              MotorRight(10,0);       
 182   3                              Delay(2500);
 183   3                              Stop();
 184   3                              Delay(800);
 185   3                      }
 186   2                      else if ((TouchSensor1)&&(TouchSensor2))  // try to crash
 187   2                      {
 188   3                              MotorLeft(16,1);
 189   3                              MotorRight(16,1);       
 190   3                              Delay(3200);
 191   3                              iCrashTime++;
 192   3                      }
 193   2                      if(iCrashTime >5 )         // if crash time is over 3time false to try
 194   2                      {CrashFlag = 0;}
 195   2      
 196   2      
 197   2              }
 198   1              Stop();
 199   1              ReleaseMotor = 0;               //release the blocker?
 200   1      
 201   1              Delay(6000);
 202   1              ReleaseMotor = 1;
 203   1      
 204   1              Stop();
 205   1              while(1);
 206   1      
 207   1      
 208   1      }
 209          
 210          
 211          //~~~~~~~~~Delay Function~~~~~~~~~~~~~~~~~~~~~~~
 212          void Delay(unsigned int time) //time /ms
 213          {
 214   1              unsigned int i;
 215   1              unsigned char j;
 216   1              time *=2;
 217   1              for (i=0;i<time;i++)
 218   1              {
 219   2                      _nop_ ();
 220   2                      for (j=0;j<10;j++)
 221   2                      {
 222   3                              _nop_ ();
 223   3                      }
 224   2              }
 225   1      } 
 226          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    559    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      5    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
C51 COMPILER V7.09   MAIN                                                                  07/03/2004 20:16:45 PAGE 5   

END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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