Subject:
|
Re: Problem in program
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Fri, 2 May 1997 11:35:39 GMT
|
Original-From:
|
Pandit Panburana <pdp@ix.netcom.=Spamcake=com>
|
Viewed:
|
689 times
|
| |
| |
Hi Terry,
From looking at the code shortly, I believe the problem is at
(and at the right side, .. as well).
> while (digital (15)) /* Left sensor */
> bk(2);
> if (digital (15)) printf ("Left object detected\n");
The detection of from digital input 15 works and move the
motor back ward until it does not detect no more thing.
The print statement is printed out from the second check
the the same digital input which may no longer ther since
the robot may have moved away from the object. Try this:
while (digital(15)) { /* Left sensor detects */
bk(2); /* move away */
printf("Left object detected\n");
/*
May have to insert small sleep here to see or during
debug. But if the robot does not run into other thing
agian to quickly then you will always see the last
thing that is printed out. I would try with out first.
*/
}
....
-Pandit
----------
> From: King, Terry <Terry.King@fmr.com>
> To: Handyboard <handyboard@media.mit.edu>
> Subject: Problem in program
> Date: Thursday, May 01, 1997 5:08 PM
>
> Greetings everyone!
> I'm working on a navigation program that has a funny quirk in it. I'm
> hoping one of you IC pros can explain my error. As far as reading the
> info from the sensors (RS 40 Khz IR module) and activating the motor
> ports, it works fine. The strange thing is that the printf statements
> "Left object detected" and "Right object detected" don't always print to
> the LCD even though the digital port responded properly by activating
> the motor port. Several repeated triggerings will eventually result in
> the proper statement,but with no definitive pattern. If one of the
> statements does appear and then the other dig port is triggered, the
> other statement does not always "flip".
>
> The "Object Ahead" statement always responds. By no means are these
> statements crucial to my project, but I have the need to understand what
> I'm doing wrong. Is there some kind of precedence statement I need to
> include or what?
>
> Here is the program:
>
> void main (){
> printf ("NAV. TEST\n");
> fd(0); /* Left caterpillar
> drive */
> fd(2); /* Right
> caterpillar drive */
> while(1) {
> while (digital (15)) /* Left sensor */
> bk(2);
> if (digital (15)) printf ("Left object detected\n");
> else fd(2);
> while (digital (14)) /* Right sensor */ /* Line 10
> */
> bk(0);
> if (digital (14)) printf ("Right object detected\n");
> else fd(0);
> while (digital (13)) /* Front sensor */
> if (digital (13)){ printf ("Object ahead\n");
> ao();
> sleep(1.0);
> bk(0);
> bk(2);
> sleep(1.0); /* Experimental-protect
> gears*/
> fd(0);
> bk(2);
> sleep(1.0);}
> else{
> fd(0);
> fd(2);}
> }
> }
>
> Thanks for any ideas,
> Terry King
> Terry.King@fmr.com
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|