Go to Post Being a mentor only requires an open mind and fifty thousand times more responsibility. - Amanda Morrison [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-03-2012, 14:57
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Driving based on range?

Hello -

I've written a quick snippet for Autonomous which should drive the robot at 0.65 until the rangefinder reads somewhere less than a given number. In this example, I've entered an arbitrary value of 60.

I've placed the drive within a loop, running every 20ms. Once the rangefinder reads a value less than 60, it is set to stop the While loop.

My question is do I need to feed the motors a value of 0 after the While loop is stopped, or don't I? See the attached image.

Thanks, Dom
Attached Thumbnails
Click image for larger version

Name:	cap.JPG
Views:	41
Size:	68.4 KB
ID:	12178  

Last edited by DominickC : 03-03-2012 at 15:01.
Reply With Quote
  #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,752
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:	28
Size:	13.1 KB
ID:	12184  
Reply With Quote
  #3   Spotlight this post!  
Unread 03-03-2012, 18:36
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
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.
Attached Thumbnails
Click image for larger version

Name:	capp.JPG
Views:	28
Size:	66.5 KB
ID:	12185  
Reply With Quote
  #4   Spotlight this post!  
Unread 03-03-2012, 19:29
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,752
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?

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
Reply With Quote
  #5   Spotlight this post!  
Unread 03-03-2012, 19:39
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
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
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi