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

📄 twoscoremid.lst

📁 蛇形机器人程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.09   TWOSCOREMID                                                           06/03/2004 19:30:55 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE TWOSCOREMID
OBJECT MODULE PLACED IN TwoScoreMid.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE TwoScoreMid.c OMF2 ROM(COMPACT) OPTIMIZE(SIZE) REGFILE(.\FollowLine.ORC) BR
                    -OWSE DEBUG

line level    source

   1          /*
   2                  Put the cube from right side of zone to two-score zone
   3          */
   4          
   5          #include<reg52.h>
   6          #include<FollowLine.h>
   7          #include<intrins.h>
   8          
   9          //FollowLineTime Control
  10          unsigned int iTurnTime = 0;
  11          extern unsigned int iFollowLineTime;
  12          #define TwoSensorMid  5000                               //about 1000 = 1s       2000
  13          //
  14          extern const unsigned char LoopLostLine1; 
  15          extern const unsigned char LoopLostLine2;
  16          unsigned char iMidSearchTime = 0;
  17          
  18          //~~~~~~Function Delaration~~~~~~~~~~~~~~~
  19          extern void Delay(unsigned int time);
  20          extern void FollowLine(char Speed);
  21          extern void SensorSta(void);
  22          extern void MotorLeft(char Speed,bit Direction);
  23          extern void MotorRight(char Speed,bit Direction);
  24          extern void Stop(void);
  25          extern void UpdateStatus(void);
  26          
  27          void TwoScoreMidRight(char Speed);
  28          void TwoScoreMidRightBack(char Speed);
  29          void TwoScoreLeft(char Speed);
  30          void TwoScoreRight(char Speed);
  31          //~~~~~~~~~~~~~~~~~~~~~~~~
  32          void TwoScoreMidRight(char Speed)
  33                          // from right side to Two Score Zone 
  34          {
  35   1                      while(iFollowLineTime < 1500)
  36   1              {
  37   2                      SensorSta();
  38   2                      FollowLine((Speed+1));                  
  39   2                      iFollowLineTime++;                                
  40   2              }
  41   1              iFollowLineTime = 0;
  42   1      /*
  43   1              MotorLeft((Speed-3),1);
  44   1              _nop_();                
  45   1              MotorRight((Speed-3),1);
  46   1              _nop_();
  47   1              Delay(17500);   
  48   1       */
  49   1              MotorLeft((Speed+1),1);
  50   1              _nop_();                
  51   1              MotorRight((Speed+3),1);
  52   1              _nop_();
  53   1              Delay(20000);
  54   1      
C51 COMPILER V7.09   TWOSCOREMID                                                           06/03/2004 19:30:55 PAGE 2   

  55   1              //leaing left
  56   1              MotorLeft((Speed-2),1);                 // in the current version moving forward
  57   1              _nop_();                                // in the reality 0
  58   1              MotorRight((Speed+2),1);
  59   1              _nop_();
  60   1              Delay(35000);
  61   1      
  62   1              
  63   1              while((HozSensor1) || (MidSensor1))
  64   1              {
  65   2                      MotorLeft((Speed-3),1);                 // in the current version moving forward
  66   2                      _nop_();                                // in the reality 0
  67   2                      MotorRight((Speed-1),1);
  68   2                      _nop_();
  69   2                      //SensorSta();
  70   2              }
  71   1      
  72   1      
  73   1              if( !( (HozSensor1) && (MidSensor2) &&
  74   1                              (MidSensor1)))
  75   1              {
  76   2                      Delay(7500);
  77   2                      
  78   2                      Stop(); 
  79   2                      Delay(1000);
  80   2                      Stop();
  81   2                      Delay(50000);   //for test
  82   2                      Delay(50000);   //for test
  83   2                      while(HozSensor2 == 1)  // left hoz sensor 
  84   2                                                                      //use driect Hozsensor flag
  85   2                      {
  86   3                              MotorLeft(5,1);         //deccerate                3
  87   3                              _nop_ ();
  88   3                              MotorRight(5,0);        //Right: Speed 3 backward
  89   3                              _nop_ ();
  90   3                      //pressume the distance between sensor and the rotate origin is 30 cm
  91   3                      //all 4 sensor have lost the line :CurStaHozSensor1 == 0 Not available          
  92   3                              UpdateStatus();                 // prepare for FollowLine
  93   3                      }
  94   2                      while(MidSensor2 == 1)  //use driect sensor flag
  95   2                      {
  96   3                              MotorLeft(3,1);         //left: speed 2 forward
  97   3                              _nop_ ();
  98   3                              MotorRight(3,0);        //Right: Speed 2 backward
  99   3                              _nop_ ();
 100   3                      //pressume the distance between sensor and the rotate origin is 30 cm
 101   3                      //all 4 sensor have lost the line :CurStaHozSensor1 == 0 Not available          
 102   3                              UpdateStatus();                 //
 103   3                      }
 104   2              
 105   2              Stop();
 106   2              Delay(500);
 107   2              while(//(iTurnTime < 1000)&&
 108   2                                      (MidSensor1 == 1)||(MidSensor2 == 1))
 109   2              {
 110   3                      MotorLeft(5,0);
 111   3                      _nop_();
 112   3                      MotorRight(5,1);
 113   3                      _nop_();
 114   3                      iTurnTime++;
 115   3              }
 116   2              iTurnTime = 0;
C51 COMPILER V7.09   TWOSCOREMID                                                           06/03/2004 19:30:55 PAGE 3   

 117   2      
 118   2              Stop();
 119   2              
 120   2                      Delay(50000);   //for test
 121   2                      Delay(50000);   //for test
 122   2              }
 123   1              
 124   1              MotorLeft((Speed-2),1);
 125   1              _nop_();                
 126   1              MotorRight((Speed-2),1);
 127   1              _nop_();
 128   1              Delay(5000);
 129   1      
 130   1              while(iFollowLineTime < TwoSensorMid)
 131   1              {
 132   2                      SensorSta();
 133   2                      FollowLineMid((Speed-2));                       
 134   2                      iFollowLineTime++;                                
 135   2              }
 136   1              iFollowLineTime = 0;
 137   1      
 138   1      }
 139          
 140          void TwoScoreLeft(char Speed)
 141          {
 142   1              MotorLeft(Speed,1);
 143   1              MotorRight(Speed,1);
 144   1              Delay(50000);
 145   1              Delay(50000);
 146   1              Delay(50000);
 147   1              Stop();
 148   1              Delay(50000);
 149   1      
 150   1              MotorLeft((Speed+1),1);
 151   1              MotorRight((Speed),1);
 152   1              Delay(10000);
 153   1      
 154   1              MotorLeft(Speed,1);
 155   1              MotorRight(Speed,1);
 156   1              Delay(50000);
 157   1      
 158   1              Stop();
 159   1              Delay(50000);   //for test
 160   1              
 161   1              while((HozSensor1) || (MidSensor1)||(MidSensor2)||(HozSensor2))

⌨️ 快捷键说明

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