|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#1
|
||||
|
||||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
||||
|
||||
|
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 |
|
#4
|
||||
|
||||
|
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
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
Re: LV Mastery Question ... Main Shifter and Command Global
Quote:
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 |
|
#7
|
|||
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |