Go to Post The MAINTENANCE of teams is just as important as the growth. Starting a new team is not always the answer. - 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 06-03-2015, 08:54
stopyourself stopyourself is offline
Registered User
FRC #2335 (Sargon)
Team Role: Leadership
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Prairie Village
Posts: 35
stopyourself is on a distinguished road
Timing Autonomous with While Loops?

In the 2015 timed autonomous tutorial, found here: https://decibel.ni.com/content/docs/DOC-26295 NI uses wait loops to instruct the drive motors. My mentor who worked with me during build season is no longer coming to meetings, but he instructed me to NEVER use these because they're CPU hogs. The thought is giving me anxiety.

Is this the correct way? Is there an alternative?
__________________
2013-2016: Team 2335
Reply With Quote
  #2   Spotlight this post!  
Unread 06-03-2015, 09:39
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,731
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Timing Autonomous with While Loops?

They can be CPU hogs if used incorrectly.
The Wait call inside each one throttles the loop down and avoids sucking the life out of the CPU. So never use a While loop without a Wait.

So that example works as long as you make sure to use Waits.

There are several alternative styles that avoid the use of loops altogether, but Waits are still required to get your timing down.
Here is one alternative using a Flat Sequence Structure: http://www.team358.org/files/program...php#Autonomous
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #3   Spotlight this post!  
Unread 06-03-2015, 09:50
Slade Slade is offline
Registered User
FRC #4471 (Spartrons)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Florida
Posts: 24
Slade is an unknown quantity at this point
Re: Timing Autonomous with While Loops?

Quote:
Originally Posted by Mark McLeod View Post
They can be CPU hogs if used incorrectly.
The Wait call inside each one throttles the loop down and avoids sucking the life out of the CPU. So never use a While loop without a Wait.

So that example works as long as you make sure to use Waits.

There are several alternative styles that avoid the use of loops altogether, but Waits are still required to get your timing down.
Here is one alternative using a Flat Sequence Structure: http://www.team358.org/files/program...php#Autonomous
Well my question would be is what if your moving a motor and you want to stop it at a limit switch, how would you go about doing so without a while loop?
Reply With Quote
  #4   Spotlight this post!  
Unread 06-03-2015, 11:24
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,731
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Timing Autonomous with While Loops?

Loops are used/required a couple of places, such as Robot Main and Periodic Tasks.vi
User programs loop to keep working and checking for driver packets, changes of robot state (Disabled/Enabled/Teleop/Autonomous), etc.

If you have to check constantly to see if a limit switch is reached then a loop can be used (just always throttle it with a Wait). If the operation is commonly used both for Teleop and for Autonomous, then a loop in Periodic Tasks might be a better location for it.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 06-03-2015 at 14:23.
Reply With Quote
  #5   Spotlight this post!  
Unread 06-03-2015, 11:25
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,034
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Timing Autonomous with While Loops?

Quote:
Originally Posted by Slade View Post
Well my question would be is what if your moving a motor and you want to stop it at a limit switch, how would you go about doing so without a while loop?
Attach the limit switch to your motor controller. The motor controller firmware will stop the motor.


Reply With Quote
  #6   Spotlight this post!  
Unread 06-03-2015, 14:14
Slade Slade is offline
Registered User
FRC #4471 (Spartrons)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Florida
Posts: 24
Slade is an unknown quantity at this point
Re: Timing Autonomous with While Loops?

Quote:
Originally Posted by Ether View Post
Attach the limit switch to your motor controller. The motor controller firmware will stop the motor.


How would you go about putting the limit switch to the motor controller. I'm not exactly sure what you mean
Reply With Quote
  #7   Spotlight this post!  
Unread 06-03-2015, 14:32
stopyourself stopyourself is offline
Registered User
FRC #2335 (Sargon)
Team Role: Leadership
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Prairie Village
Posts: 35
stopyourself is on a distinguished road
Re: Timing Autonomous with While Loops?

Quote:
Originally Posted by Slade View Post
How would you go about putting the limit switch to the motor controller. I'm not exactly sure what you mean

I think...our limit switches are in DIO 6 and 7 on out bot. So instead plug it in to the motor controller? I think it would be on a breakout board like this for the Talon SRX: http://www.chiefdelphi.com/media/img...ee71979d_l.jpg
__________________
2013-2016: Team 2335
Reply With Quote
  #8   Spotlight this post!  
Unread 06-03-2015, 14:34
Kevin Phan's Avatar
Kevin Phan Kevin Phan is offline
College Student
FRC #0357 (Royal Assault)
Team Role: Alumni
 
Join Date: Apr 2013
Rookie Year: 2010
Location: PA, United States
Posts: 95
Kevin Phan will become famous soon enoughKevin Phan will become famous soon enough
Re: Timing Autonomous with While Loops?

For the talon srx and jaguar you are able to use a limit switch and put embedded code to stop the motor when the limit switch is pressed. If you do not possess these motor controllers. You probably want to use a condition in your while loop to state that if the limit switch is pressed to stop the loop.
__________________
VEX & FRC Student Team Member #357 Royal Assault 2010-2014 "Dare Mighty Things"
2014-2019 Attending Drexel University Major:Electrical Enginnering

Last edited by Kevin Phan : 06-03-2015 at 14:44.
Reply With Quote
  #9   Spotlight this post!  
Unread 06-03-2015, 14:55
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,034
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Timing Autonomous with While Loops?

Quote:
Originally Posted by Slade View Post
How would you go about putting the limit switch to the motor controller. I'm not exactly sure what you mean
Talon SRX User's Guide; see pages 19 & 20:
http://www.crosstheroadelectronics.c...7s%20Guide.pdf

Jaguar Getting Started Guide; see pages 7 9 10 13 14 22
http://team358.org/files/electrical/MDL-BDC24_GSG.pdf


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 03:54.

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