Go to Post Hey that was easy, we settled the argument on CD in one post! :^) - KenWittlief [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 12-01-2009, 19:38
Comatose Comatose is offline
Registered User
AKA: Lead Student Programmer
FRC #0135 (Penn Robotics)
Team Role: Programmer
 
Join Date: Sep 2008
Rookie Year: 2008
Location: United States of America
Posts: 27
Comatose is an unknown quantity at this point
Wait.VI on basic motor tutorial, need clarification.

On the following URL: http://decibel.ni.com/content/docs/DOC-3014

Near the middle/bottom of the page you can download the .pdf of the tutorial. We can't use the video for clarification because of our school's site blocks. On page 9 in the 3rd to last sentence it tells you to put a 10ms wait on the while loop. The tutorial doesn't explain how to do this. We assume it has something to do with the Wait.VI given with the FRC software. Can anyone explain if that’s the correct thing to use for the wait and how to implement it into this code?

Thanks,

Comatose Team 135

Last edited by Comatose : 12-01-2009 at 19:42.
Reply With Quote
  #2   Spotlight this post!  
Unread 12-01-2009, 21:43
BLAQmx's Avatar
BLAQmx BLAQmx is offline
Software Engineer
no team (National Instruments)
Team Role: Engineer
 
Join Date: Sep 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 100
BLAQmx is a glorious beacon of lightBLAQmx is a glorious beacon of lightBLAQmx is a glorious beacon of lightBLAQmx is a glorious beacon of lightBLAQmx is a glorious beacon of lightBLAQmx is a glorious beacon of light
Re: Wait.VI on basic motor tutorial, need clarification.

The wait.vi used in the video is used to sleep the code (thread) running in the while loop for a short period in order to allow the processor time to complete other OS tasks. It is good programming practice to place these in all while loops.

The most common symptom of "starving" threads on the cRIO will be a loss of network connectivity. This would be due to your program consuming 100% of the CPU preventing the network thread from running.
__________________
NI FIRST Community: Where to go for LabVIEW, Wind River, cRIO-FRC, and NXT support.
Reply With Quote
  #3   Spotlight this post!  
Unread 12-01-2009, 21:47
Russ Beavis Russ Beavis is offline
Registered User
no team
 
Join Date: Nov 2005
Location: Manchester, NH - DEKA R&D Corp.
Posts: 341
Russ Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond repute
Re: Wait.VI on basic motor tutorial, need clarification.

In LabVIEW, EVERYTHING runs in parallel as long as its inputs are ready (and as close to "parallel" as a single-threaded machine can really be).

If you have a while loop that keeps repeating, the innards will execute as quickly as the machine can operate unless you force the loop to execute at a fixed rate.

There are a number of ways to force loop timing in LabVIEW but the easiest are using "wait.vi" and "wait until ms multiple.vi". If you place either of these within your while loop, a new parallel process is created in your VI. The loop iteration cannot end until that wait routine is done. So... if you've got a little snippet of code that executes in 1ms and a wait VI with a 10ms control input, your loop iteration will start at t=0 and, at t=1ms your code will finish then at t=10ms the iteration will be done and will restart (if that's warranted based on the conditional for the loop).

To really understand how the above works, I'd encourage you to create a while loop that's set to execute forever and plop down 2 wait VIs - one with 500ms timer and one with a 1 second timer. View the output from the loop's iteration counter (right-click - create indicator on the the "i"), turn on highlight execution mode and then click run. Watch how the two wait VIs operate in parallel and how the 1 second wait VI rules.

The relatively new Timed Loop construct can really help as well. It's not too hard to use and provides some nice features (eg did my loop actually run as fast as I requested?).

My final comment - a while loop without any delays can be a SERIOUS CPU hog. If you create a simple while loop on a PC, it could run at a few MHz and won't allow you to do anything else on your PC while it's running.

Russ
Reply With Quote
  #4   Spotlight this post!  
Unread 16-01-2009, 12:00
Comatose Comatose is offline
Registered User
AKA: Lead Student Programmer
FRC #0135 (Penn Robotics)
Team Role: Programmer
 
Join Date: Sep 2008
Rookie Year: 2008
Location: United States of America
Posts: 27
Comatose is an unknown quantity at this point
Re: Wait.VI on basic motor tutorial, need clarification.

We understand what the VI does and why it should be done but the website gives no directions nor pictures to help explain how to use it. It just says use it on the while loop. Were dumbfounded and have no idea how to attach it to the while loop.

Can anyone give directions how to do this?
Reply With Quote
  #5   Spotlight this post!  
Unread 16-01-2009, 12:10
qwv123 qwv123 is offline
Registered User
FRC #1318
 
Join Date: Dec 2006
Location: Issaquah, WA
Posts: 3
qwv123 is an unknown quantity at this point
Re: Wait.VI on basic motor tutorial, need clarification.

Just put it anywhere inside the while loop. It does not need to be attached to anything besides the input that specifies the amount of time you want the loop to wait. If you care about the wait running before or after the rest of the code in the loop, you will need to add a sequence structure, create two frames, put your code in one frame, and put the wait in the other frame.
Reply With Quote
  #6   Spotlight this post!  
Unread 16-01-2009, 13:18
Russ Beavis Russ Beavis is offline
Registered User
no team
 
Join Date: Nov 2005
Location: Manchester, NH - DEKA R&D Corp.
Posts: 341
Russ Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond repute
Re: Wait.VI on basic motor tutorial, need clarification.

I've attached a really simple VI (unfortunately with LabVIEW 8.2 so I created a PDF of the block diagram).

It's a while loop that runs forever and just increments a number. The Wait VI forces this loop to execute every 10ms. Without that Wait VI, this would run stupid fast and hog the CPU.

Please try using Highlight Execution mode. It really helps (IMHO) to understand how programs flow in the LabVIEW world. In this particular instance (if you could run it), you'd find that the Wait VI and the increment function operate in parallel. Any other functions that are dropped in the while loop will operate in parallel as long as they don't share data/wires.

Russ
Attached Files
File Type: pdf How to use a Wait VI.pdf (17.0 KB, 71 views)
Reply With Quote
  #7   Spotlight this post!  
Unread 16-01-2009, 13:20
Jim Wagner Jim Wagner is offline
Registered User
FRC #1676 (Pascack Pi-oneers)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Pascack Pi-oneers
Posts: 8
Jim Wagner is an unknown quantity at this point
Send a message via Yahoo to Jim Wagner
Re: Wait.VI on basic motor tutorial, need clarification.

How does the wait.vi effect the watchdog? Do you need to use a "Delay and Feed" with the watchdog, or can you simply put a standard delay in the loop?
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Clarification from 2008 Rule <R27> Ed Law Rules/Strategy 14 19-12-2008 10:40
Question about 3rd Tutorial ETA and FRC Modeler Motor Config Ted155 LabView and Data Acquisition 2 21-01-2007 19:45
White Paper Discuss: Basic PHP Tutorial AIBob Extra Discussion 0 07-03-2005 15:11
White Paper Discuss: Basic HTML Tutorial AIBob Extra Discussion 2 13-02-2005 20:49
update 8 clarification, drill motor and blue wires pryoplasm Rules/Strategy 23 13-02-2004 07:26


All times are GMT -5. The time now is 21:11.

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