Go to Post It's official: we've run out of things to talk about. - Jessica Boucher [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 05-02-2012, 07:46
tilky's Avatar
tilky tilky is offline
Registered User
AKA: Ryan Thielke
FRC #3137
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Connetquot
Posts: 188
tilky is an unknown quantity at this point
waits

What exactly do waits do in labview. does it wait before executing or wait before going on after. And if you have a motor go forward for 1000 ms, do you have to put it in a for loop?
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2012, 08:15
tilky's Avatar
tilky tilky is offline
Registered User
AKA: Ryan Thielke
FRC #3137
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Connetquot
Posts: 188
tilky is an unknown quantity at this point
Re: waits

sorry i worded that wrong. In a flat sequence fram, would you need a for loop or will a wait do it.
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2012, 08:41
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,713
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: waits

In a flat sequence just use a Wait.
That must complete before the frame is considered complete.

The way it works is that everything in a frame must complete before it will move on to the next frame.

Things run in parallel within the frame, so the motor operations are happening at the same moment the timer is running. If you had a timer that happened to be shorter than the other operations taking place within the frame, then the frame would still not go on until the other operations were also completed.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2012, 09:15
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,748
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: waits

In your situation, a wait will do.

A wait node in LV works as follows:
Once its inputs are available, it notes the time, adds the delay to it, and sets an alarm for delay milliseconds in the future. The node will not be considered complete (it is executing, but without using the CPU), until that alarm goes off. Any dependent code is postponed, and parallel code is not.

Now the reason that it impacts loops and sequences the way it does is because of the most commonly overlooked element of LV -- the diagram. The open space on the window, the white background of the loop and sequence is the same as the {} bracketed code within other languages. The while loop's diagram is not complete until all nodes on it are complete. Same for sequence and other structure nodes that contain a diagram. Executing a diagram consists of executing all nodes it contains once and only once, and it is not complete and cannot execute again until all the nodes complete execution.

For example, I attached an image of a loop with various parallel things going on inside it. They are the i (which some may not count and may even be compiled out), the Bool wired to the loop continuation (similarly trivial), and the three waits (two for 1000ms and one for 500ms).

When the loop starts to execute its diagram, it will allow all of the parallel tasks to proceed at their own rate. So in this case, the three waits will run in parallel and the overall loop rate will be about 1Hz. If additional code is inserted into the loop that reads sensors or computes math, and it runs in parallel, it will not impact the loop rate unless the code takes longer than 1000ms to complete.

The second image shows how to run code before and after a delay, make sure there is an execution dependency -- either a data flow dependency or as shown in the image, a sequence dependency. The third image shows another common usage where you want to start something, not waiting for it to complete, and 500 ms after starting it, start something else.

I hope this helped.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-02-05 at 7.22.08 AM.png
Views:	62
Size:	8.6 KB
ID:	11732  Click image for larger version

Name:	Screen Shot 2012-02-05 at 7.58.46 AM.png
Views:	70
Size:	10.4 KB
ID:	11733  Click image for larger version

Name:	Screen Shot 2012-02-05 at 8.14.14 AM.png
Views:	68
Size:	10.5 KB
ID:	11734  
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2012, 11:42
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,015
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: waits

Quote:
Originally Posted by Greg McKaskle View Post
The third image shows another common usage where you want to start something, not waiting for it to complete, and 500 ms after starting it, start something else.
The wording is confusing me just a bit. If "Do something" takes longer than 500ms, you don't start "Do something else" until "Do something is complete", yes?

In other words, "after something is done, or 500ms elapses" means "after something is done, or 500ms elapses - whichever is longer", correct?

Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2012, 13:43
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: waits

Quote:
Originally Posted by Greg McKaskle View Post
The third image shows another common usage where you want to start something, not waiting for it to complete, and 500 ms after starting it, start something else.
Quote:
Originally Posted by Ether View Post
The wording is confusing me just a bit. If "Do something" takes longer than 500ms, you don't start "Do something else" until "Do something is complete", yes?
The wording is only confusing because you've changed it. Read what he wrote, not what you did.
Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2012, 15:06
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,748
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: waits

Sorry for the confusion. That is what I get for taking so long to write a post and then rushing out at the last minute and not reviewing it carefully.

I agree with your wording Ether. The point of all this is that statements running in parallel on a diagram determine when the diagram completes, and the completion of that diagram determines when dependent code, such as the next frame of a sequence, or the next iteration of a loop can begin.

Greg McKaskle
Reply With Quote
  #8   Spotlight this post!  
Unread 05-02-2012, 17:14
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,748
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: waits

After reading my post again, I want to correct it.

The final image was meant convey the case where the start times are what you want to use for the time reference. I hope this is one is clearer.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-02-05 at 4.12.16 PM.png
Views:	21
Size:	12.8 KB
ID:	11742  
Reply With Quote
  #9   Spotlight this post!  
Unread 05-02-2012, 17:50
tilky's Avatar
tilky tilky is offline
Registered User
AKA: Ryan Thielke
FRC #3137
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Connetquot
Posts: 188
tilky is an unknown quantity at this point
Re: waits

so will this run the motors for 1 second, or will it pulse the motors once, and then wait 1 second before moving on
Attached Thumbnails
Click image for larger version

Name:	run motors.PNG
Views:	24
Size:	5.3 KB
ID:	11743  
Reply With Quote
  #10   Spotlight this post!  
Unread 05-02-2012, 18:07
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,713
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: waits

That will start the motors, while the Wait twiddles it's virtual thumbs letting them run for one second, before leaving the frame.

Of course, the way it's written, nothing stops the motors, so after the frame finishes executing the motors will still be running and will continue to run until told otherwise.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 05-02-2012 at 18:41.
Reply With Quote
  #11   Spotlight this post!  
Unread 05-02-2012, 18:12
tilky's Avatar
tilky tilky is offline
Registered User
AKA: Ryan Thielke
FRC #3137
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Connetquot
Posts: 188
tilky is an unknown quantity at this point
Re: waits

ok think i got it now. thanks
Reply With Quote
  #12   Spotlight this post!  
Unread 05-02-2012, 18:45
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: waits

Quote:
Originally Posted by tilky View Post
so will this run the motors for 1 second, or will it pulse the motors once, and then wait 1 second before moving on
It will tell the motors to run, then wait one second. It doesn't keep telling the motors to run after it's done it once. For most motors, that means they will continue to run, but not for Drive motors.

Quote:
Originally Posted by Mark McLeod View Post
Of course, the way it's written, nothing stops the motors, so after the frame finishes executing the motors will still be running and will continue to run until told otherwise.
It's a Drive function, so the motor safety will stop the motors after a tenth of a second unless something has been changed from the default configuration.
Reply With Quote
  #13   Spotlight this post!  
Unread 05-02-2012, 19:11
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,713
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: waits

True enough.
What Alan means is, your structure would work the way you intend for individual motors, but drive motors (Open2Motor, Open4Motor) have an automatically applied Safety that will shut down the motors if you don't keep rapidly telling them what to do.

To make your structure work the way you intend it would need an extra vi call.
And at the end you would re-enable the Safety, before Teleop began, as well as set your motors to neutral.
Attached Thumbnails
Click image for larger version

Name:	MotorSafety.jpg
Views:	29
Size:	9.9 KB
ID:	11745  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #14   Spotlight this post!  
Unread 06-02-2012, 06:54
tilky's Avatar
tilky tilky is offline
Registered User
AKA: Ryan Thielke
FRC #3137
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Connetquot
Posts: 188
tilky is an unknown quantity at this point
Re: waits

ok, so this way i don't have to use for loops every time i try to drive in autonomous
Reply With Quote
  #15   Spotlight this post!  
Unread 06-02-2012, 07:19
tilky's Avatar
tilky tilky is offline
Registered User
AKA: Ryan Thielke
FRC #3137
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Connetquot
Posts: 188
tilky is an unknown quantity at this point
Re: waits

one more question: is there a way to get the time from the driver station? The wait time is not at all accurate, and it would be easier than using encoders
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 08:49.

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