|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
Re: Driving based on range?
Take two. I changed things up a bit, and added a timed stop in case the rangefinder doesn't work as well as expected. It quits the loop after 10 seconds.
|
|
#3
|
|||
|
|||
|
Re: Driving based on range?
Much better. I notice you put in a delay, where I forgot to. Good for you.
Your bottom logic where you turn Booleans into numbers and add them will work, but you may want to look into the Boolean logic palette. OR is equivalent to what you've written and is the more traditional way of doing this. Again, yours works, I'm just suggesting ways to make it more professional. Now to test it. Greg McKaskle |
|
#4
|
|||
|
|||
|
Re: Driving based on range?
Man, I've been searching for that OR function for 8 weeks now, and it's been answered in a passing suggestion! Thanks!
I'm going to see if I can't hook up our second cRIO to some hardware and test it this coming Monday, but if not, I'll have to test it in the pit at WPI. No big deal. Thanks for your help. Dom |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|