View Single Post
  #2   Spotlight this post!  
Unread 03-03-2012, 18:04
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Driving based on range?

To answer the direct question, no. You do not need to worry about feeding motors more than one zero. The safety will kick in and set them to zero as well, but there is no harm and no need.

But. I looked at your code, and it doesn't do what you describe.

The loop that reads the ultrasound will not exit until the value from it is greater than 39.75 units -- not sure what the units are. Then it will start the motors at .65 and will no longer read the ultrasonic. I suspect that the initial state of the motors is zero, so the robot may not move at all.

Remember that data doesn't leave a loop via a wire until the loop finishes, and if you want two loops to run in parallel, you can't have wires between them.

I attached a picture of some code for comparison that looks at the ultrasonic and sets the motors to either 0.65 or 0.0, and stops the loop when the limit is reached. The sequence says that the other stuff starts only after the loop is complete.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-03-03 at 5.02.41 PM.png
Views:	27
Size:	13.1 KB
ID:	12184  
Reply With Quote