📄 followline.lst
字号:
152 1 {
153 2 MotorLeft((Speed+1),1); //Right leaning more
154 2 //original value is +3
155 2 _nop_ ();
156 2 MotorRight((Speed-2),1);
157 2 _nop_ ();
158 2 // Delay(Speed*1);
159 2 }
160 1 else // (CurStaMidSensor1 == 1)&&(CurStaMidSensor2 == 1)
161 1 {
162 2 BackAdjFlag = 1;
163 2 //Stop();
164 2 if(PreStaMidSensor1 == 1)
165 2 {
166 3 if(PreStaMidSensor2 == 0)
167 3 {
168 4 MotorLeft((Speed+3),1); //original value is -2
169 4 _nop_();
170 4 MotorRight((Speed-3),1); //orignal value is +3
171 4 _nop_();
172 4 }
173 3 else //PreStaMidSensor1 == 1, PreStaMidSensor2 ==1
174 3 {
175 4 /*
176 4 rotate left and right about 30 degree
177 4 parameter 120, 80 ,6200 6300 are carefully selected
178 4 using CurStaMidSensor instead ofMidsenso to capture the line
C51 COMPILER V7.09 FOLLOWLINE 06/11/2004 17:13:17 PAGE 4
179 4 */
180 4
181 4 while((MidSensor1)
182 4 && (iLostLoopTime <= LoopLostLine1))
183 4 // totally lost and loop in the time of LoopLostLine1
184 4 // leaning left loop time 100
185 4 {
186 5 //
187 5 MotorLeft(10,1);
188 5 _nop_();
189 5 MotorRight(10,0);
190 5 _nop_();
191 5 iLostLoopTime++;
192 5 _nop_();
193 5 Delay(100); //after adjustment about 20 degree
194 5 //original value is 141
195 5 }
196 4 if((!MidSensor1)) // Delta impulse to stop
197 4 {
198 5 Stop();
199 5 Delay(1000);
200 5 iLostLoopTime = 0;
201 5 }
202 4
203 4 // do not find the white line back to the original status
204 4 else // scaning left false
205 4 {
206 5 MotorLeft(10,0);
207 5 _nop_();
208 5 MotorRight(10,1);
209 5 _nop_();
210 5 Delay(10000); // after adjustment orignal value is 8200
211 5 iLostLoopTime = 0; // clear the flag
212 5
213 5 //leaning right using LoopLostLine2
214 5 while((MidSensor2) && (iLostLoopTime<=LoopLostLine2))
215 5 //leaning right
216 5 {
217 6 MotorLeft(10,0);
218 6 _nop_();
219 6 MotorRight(10,1);
220 6 _nop_();
221 6 iLostLoopTime++;
222 6 _nop_();
223 6 Delay(110); //125
224 6 }
225 5 if((!MidSensor2)) // Delta impulse to stop
226 5 {
227 6 Stop();
228 6 Delay(1000);
229 6 iLostLoopTime = 0;
230 6 }
231 5
232 5 //~~~~~~~~~~~~~
233 5 else // scaning false rotate back to the original position and backward
234 5 {
235 6
236 6 MotorLeft(10,1);
237 6 _nop_();
238 6 MotorRight(10,0);
239 6 _nop_();
240 6 Delay(12700); // the original value is 6300
C51 COMPILER V7.09 FOLLOWLINE 06/11/2004 17:13:17 PAGE 5
241 6 // move back to find the lost position
242 6
243 6 Stop();
244 6 Delay(1000);
245 6 MotorLeft((Speed-3),0);
246 6 _nop_();
247 6 MotorRight((Speed-3),0);
248 6 _nop_();
249 6
250 6 BackAdjFlag = 0; //forbid LineCounter
251 6 _nop_();
252 6 Delay(7700);
253 6 Stop();
254 6 Delay(1000);
255 6
256 6 }
257 5 }
258 4 }
259 3
260 3 }
261 2 else //PreStaMidSensor1 == 0, PreStaMidSensor2 ==1
262 2 {
263 3 MotorLeft((Speed-3),1); //orignal value is +3
264 3 _nop_();
265 3 MotorRight((Speed+3),0); //orignal value is -2
266 3 _nop_();
267 3 }
268 2 BackAdjFlag = 1;
269 2 _nop_();
270 2
271 2 }
272 1 // Delay(40); // parameter 1 need further adjustment
273 1 // LineCounter
274 1 if ((!HozSensor1) && (!HozSensor2) && // the original is CurStaHozSensor
275 1 (!CounterFlag) &&
276 1 (BackAdjFlag))
277 1 {
278 2 CounterFlag = 1;
279 2 LineCounterP++;
280 2 }
281 1
282 1 if ((HozSensor1) && (HozSensor2) &&
283 1 (CounterFlag))
284 1 {
285 2 CounterFlag = 0; // reset to enable counter
286 2 }
287 1
288 1 }
289
290
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 464 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 13 ----
IDATA SIZE = ---- ----
BIT SIZE = 6 2
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
C51 COMPILER V7.09 FOLLOWLINE 06/11/2004 17:13:17 PAGE 6
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 + -