Go to Post our electronics boards had begun to look like we'd planted a wire bush and it grew - daltore [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 16-02-2013, 15:12
JamesAnthony's Avatar
JamesAnthony JamesAnthony is offline
Registered User
FRC #4181 (Quack Attack)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Blackduck, MN
Posts: 4
JamesAnthony is an unknown quantity at this point
Trouble understanding timed tasks in Periodic vi

My team is using the 2-wire VEX motor 393 to "kick" the frisbee into a wheel that is meant to shoot it. We only want to turn it once so I figured that since the motor is 100 rpm then one revolution would take 600 ms. I know that to do a timed event, you must use the Periodic Tasks VI but I'm not sure on how this works in a block diagram (I was a text based programmer before this). I was thinking that our primary joystick, "Joystick I", would trigger some sort of case structure when Button 1 is pressed and then have the motor, "Initator", turn for 600 ms. I've looked at resources such as Team 358's very helpful LabVIEW resources but I don't understand why the outside while has a wait for 10 ms. Attached is the resource that I am referencing.

Thanks for any help that you can give me.
Reply With Quote
  #2   Spotlight this post!  
Unread 16-02-2013, 15:34
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
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,833
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: Trouble understanding timed tasks in Periodic vi

The outer loop runs all the time just checking to see if the button has been pressed.
The button can't be pressed any faster than 20ms, because that's how often a fresh command packet arrives from the Driver Station.

The outside Wait is just to keep the outer loop from running as fast as possible and sucking up all the available CPU when it really isn't doing anything. All loops should be throttled by a Wait of some kind, because the Wait releases the CPU for time sharing with other tasks that are running on the cRIO.
The outside Wait can actually be 20ms.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 16-02-2013 at 15:36.
Reply With Quote
  #3   Spotlight this post!  
Unread 16-02-2013, 17:31
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: Trouble understanding timed tasks in Periodic vi

Let me restate what Mark said a different way.

There are four things in the loop that run simultaneously. They are the Wait for 10ms, the production of the i, determining if the loop runs another iteration, and the test of joystick button and conditional motor stuff.

The iteration of a loop completes when all inner tasks complete, and the wait of 10 ensures that it doesn't run faster than 100 times per second. With no delay, it would be way faster than you need and would take all of the CPU time that others aren't using.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 17-02-2013, 20:49
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: Trouble understanding timed tasks in Periodic vi

The spreadsheet represents how it would execute if the code and wait were serialized. Since there isn't a data connection, the delay and code run in parallel. The attached image shows a loop with a number of things that take 10ms -- they all happen to be wait functions. And the loop will therefore will execute approximately every 10ms.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Clipboard 1.png
Views:	16
Size:	22.2 KB
ID:	14072  
Reply With Quote
  #5   Spotlight this post!  
Unread 17-02-2013, 20:58
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
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: Trouble understanding timed tasks in Periodic vi

Quote:
Originally Posted by Greg McKaskle View Post
The spreadsheet represents how it would execute if the code and wait were serialized. Since there isn't a data connection, the delay and code run in parallel.
Hmm. Referring to this paper:

http://team358.org/files/programming...Everything.PDF

... it looks like the 10ms wait causes an average execution time of 12 ms, whereas the "wait until next multiple" averages 10ms. That's why I assumed the wait was serialized.

Mark, could you expound on that?

(I deleted the original post pending resolution of this. I don't want anyone to be misled by it.)



Last edited by Ether : 17-02-2013 at 21:12.
Reply With Quote
  #6   Spotlight this post!  
Unread 17-02-2013, 21:21
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: Trouble understanding timed tasks in Periodic vi

The point of their paper is correct. Wait 10ms will guarantee that the loop period will be 10ms minimum. If enough other stuff is going on, it will accumulate extra time. The ms multiple version will have an initial wait that aligns to the clock phase and will then stay in phase and skip with large overages. The timed loop has many options and has the least jitter by far.

But on the topic, the language doesn't serialize them, and most users don't either.

Greg McKaskle
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: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