Go to Post Just remember that you can get just as much inspiration from making a simple system's details work really well as you can from just making a complex system work... - Rob [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 Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 01-02-2010, 14:48
Ziaholic's Avatar
Ziaholic Ziaholic is offline
Elec/SW Mentor
AKA: Marc
FRC #1164 (Project NEO)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2002
Location: Las Cruces, NM
Posts: 194
Ziaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the rough
LV Mastery Question ... Main Shifter and Command Global

I've been adapting our team code to be more like the code in the LV Mastery videos. I've watched many of them, many times, and am trying to follow the advice of not actually "doing" anything within the Teleop.VI

I've added a shift register to the primary While-Loop, calling it Main Shifter.

I'm toying with different architecture decisions now, but the TipJar videos don't necessarily address my questions.

Primarily, I'm torn between a couple choices that are interrelated ... namely the Main Shifter, and the Robot Command Global.

If I make the Main Shifter a Global, and write to it just before the main loop cycles, then I don't necessarily need a Robot Command, as long as those commands are in the Main Shifter. Right?

I know that I can get it to work either way, but I'm just wondering which one might be more efficient and/or more wasteful.
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2010, 19:45
ASTDan ASTDan is offline
Registered User
no team
 
Join Date: Dec 2009
Location: Lansing MI
Posts: 6
ASTDan is an unknown quantity at this point
Re: LV Mastery Question ... Main Shifter and Command Global

Storing data in shift registers is always more preferable than a global variable. Whenever you call a global you are making a copy of your data.. Also with global variables because you have copies you can get into race conditions. Here is an article on NI's website regarding global variables.

A more elegant way to pass data around your program is a functional global variable.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2010, 06:17
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: LV Mastery Question ... Main Shifter and Command Global

You referring to what is explained in this video?

http://frcmastery.com/try-me/state-machines/

-Tanner
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2010, 08:32
Ziaholic's Avatar
Ziaholic Ziaholic is offline
Elec/SW Mentor
AKA: Marc
FRC #1164 (Project NEO)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2002
Location: Las Cruces, NM
Posts: 194
Ziaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the rough
Re: LV Mastery Question ... Main Shifter and Command Global

After working on the structure a little more, I think that I answered my own question ...

(Yes, Tanner, that's exactly what I'm talking about)

I think I've come up with a few rules of thumb to follow:

1) ShiftReg's
  • for Right-to-Left data flow (memory between loops)
  • used to control the logic and flow of the state machine (case structures)
  • A variable that isn't READ from the ShiftReg, to control the logic, probably doesn't belong in the ShiftReg
2) Globals are more Up/Down based, to immediately get data into other VI's
  • Write to the Global within the cases of the state-machine

I'm probably NOT going to put my Drive Command Global into the Main ShiftReg and I'm probably going to remove the Main Shifter from my list of Globals.

In actuality, I'm sure that either method would work, I'm just trying to write efficient code that doesn't waste resources and/or clock cycles.
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics
Reply With Quote
  #5   Spotlight this post!  
Unread 07-02-2010, 22:16
LVMastery LVMastery is offline
LabVIEW Educator and Mentor
AKA: Ben Zimmer
FRC #0843 (Wildcats)
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 47
LVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud of
Re: LV Mastery Question ... Main Shifter and Command Global

Ziaholic,

I'm so glad you're enjoying our videos... and asking (then self-answering) very astute questions.

You could put the main shifter into a global. The reason I didn't was because it was simpler to only have what you needed, and better to reduce the quantity of data. Also, I wanted to be able to use it in an autonomous independent.

Some general comments:

What we have here is the biggest problem when working in LabVIEW - breaking out of the dataflow paradigm - efficiently.

In a nutshell, I use this rule of thumb:
- Shift register only when you have a single loop: no locals or globals
- When you have parallel loops, you can pass small amounts of data around using globals. Only write in ONE place. Read in many. That can be tricky, and is what motivated last year's approach of the command signal to go from teleop (or autonomous) --> other loops. Remember that when the other loops needed to send info back, they used their own global, so that it was only written in one place.
- When you have large amounts of data to pass around, use a functional global variable. That's a tricky but very useful beast. I don't think I've brought it up in any videos, nor do I think you **need** it for FRC, but it is interesting. In 10 words or less: an uninitialized shift register in a while loop which only runs once in a subVI will remember stuff. (OK that was more than 10).

Good luck!

Ben
__________________
Ben Zimmer
Enable Education
www.EnableEducation.com
www.FRCMastery.com
email: ben@enabletc.com
Phone/Fax: (905) 864-1858
Toll Free: (877) 872-4619
Reply With Quote
  #6   Spotlight this post!  
Unread 14-02-2010, 17:10
Andy Bradley Andy Bradley is offline
Registered User
FRC #0233
 
Join Date: Jan 2010
Location: Florida
Posts: 15
Andy Bradley is an unknown quantity at this point
Re: LV Mastery Question ... Main Shifter and Command Global

Quote:
Originally Posted by LVMastery View Post
Also, I wanted to be able to use it in an autonomous independent.
Thanks very much for the outstanding videos; they have been a huge help. I'm using the shifter example for our kicker and it really simplifies things.

I don't quite understand how we access the main shifter in autonomous independent though. I have set up a shifter like in your video, and have it implemented in teleop.vi. But Robot Main calls Autonomous Iterative during the Autonomous Enable case, and from what I understand Autonomous Independent runs in parallel if it is selected in Begin (although I am really fuzzy on this one). Do you know how I can use the shifter in Autonomous Independent and then retain that state to be used during teleop.vi (so I don't have to reset the kicker at the start of teleop)? Thanks
Reply With Quote
  #7   Spotlight this post!  
Unread 18-02-2010, 14:06
LVMastery LVMastery is offline
LabVIEW Educator and Mentor
AKA: Ben Zimmer
FRC #0843 (Wildcats)
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 47
LVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud ofLVMastery has much to be proud of
Re: LV Mastery Question ... Main Shifter and Command Global

Andy,

Awesome question. This is tricky because you have to use globals to get the data to/from the autonomous independent.

I haven't ported this example and video over to 2010, but I think you will get the gist if you take a look: http://www.lvmastery.com/TipJar2009-02-08_2

Ben
__________________
Ben Zimmer
Enable Education
www.EnableEducation.com
www.FRCMastery.com
email: ben@enabletc.com
Phone/Fax: (905) 864-1858
Toll Free: (877) 872-4619
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
Super Shifter Question Ice Berg General Forum 8 25-06-2008 16:12
Global variable question Nathan Programming 3 27-01-2008 18:02
Command and Conquer captainking Games/Trivia 1 08-01-2008 23:20
AM Shifter Assembly Question Jeff Waegelin Technical Discussion 17 18-02-2007 20:32
AM Shifter 2 question ForgottenSalad Technical Discussion 2 20-02-2006 14:26


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

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