Go to Post My sister's husband told me when I was just a wee one, "momentum will take you where traction will not." - Joe Johnson [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-08-2013, 17:11
tcjinaz tcjinaz is offline
Tim
FRC #3853
Team Role: Mentor
 
Join Date: May 2011
Rookie Year: 2011
Location: Arizona
Posts: 206
tcjinaz has a spectacular aura abouttcjinaz has a spectacular aura about
Flat sequence in Begin.vi

While perusing 2337's code (Thanks for publishing it!), I saw that they use a flat sequence in Begin. What are the relative merits of doing this? Does it end up executing faster with less thinking required of the scheduler?

Tim
__________________
Software Mentor
3853 Pridetronics[

  #2   Spotlight this post!  
Unread 11-08-2013, 20:39
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,756
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: Flat sequence in Begin.vi

If you give a link to the code, I can explain how the code would be compiled differently and would execute differently. But faster isn't necessarily a good expectation.

Greg McKaskle
  #3   Spotlight this post!  
Unread 12-08-2013, 01:01
John Sabath's Avatar
John Sabath John Sabath is offline
LabVIEW Software Developer
FRC #3792 (The Army Ants)
Team Role: Alumni
 
Join Date: Mar 2012
Rookie Year: 2012
Location: Columbia, MO
Posts: 53
John Sabath is a splendid one to beholdJohn Sabath is a splendid one to beholdJohn Sabath is a splendid one to beholdJohn Sabath is a splendid one to beholdJohn Sabath is a splendid one to beholdJohn Sabath is a splendid one to beholdJohn Sabath is a splendid one to beholdJohn Sabath is a splendid one to behold
Re: Flat sequence in Begin.vi

An image of the Begin.vi for reference

In the very first frame of the sequence structure they are initializing variables that will be used in the frames following. The first frame MUST finish executing completely before moving down the line, so they're avoiding potential race conditions with the variable assignment.

This entire VI could have been condensed into a two frame sequence structure (like so) and wouldn't have affected the end result. The reason that they split the sequence structure up further was for readability. Which in a graphical programming language like LabVIEW, goes a long way.
__________________
Freshman at Missouri S&T ( Computer Science )

FRC 3792 (The Army Ants) from 2012-2013
  #4   Spotlight this post!  
Unread 12-08-2013, 18:40
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Flat sequence in Begin.vi

Can u add a link to the post where they have published it?
  #5   Spotlight this post!  
Unread 12-08-2013, 21:27
tcjinaz tcjinaz is offline
Tim
FRC #3853
Team Role: Mentor
 
Join Date: May 2011
Rookie Year: 2011
Location: Arizona
Posts: 206
tcjinaz has a spectacular aura abouttcjinaz has a spectacular aura about
Re: Flat sequence in Begin.vi

Here's a link to hunt down the code (I hope):
http://www.chiefdelphi.com/forums/sh...=2337+git+code

Thanks for the answers. I really needed to learn the variable initialization part, I think we got bit by not controlling that better last year.

Any other good insights Greg?
__________________
Software Mentor
3853 Pridetronics[

  #6   Spotlight this post!  
Unread 13-08-2013, 08:27
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,756
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: Flat sequence in Begin.vi

Well, since you ask ...

I'm not sure I'd use the network variables for that purpose. They are meant for shared data across computers. Those aren't local variables as previously stated. They will obviously work as a variable, but they are rather heavy to replace a constant and of course need something like the sequence to prevent a race condition.

There are many alternatives.

The first year, there was no refnum registry. You would allocate things in Begin, bundle them together, and pass them through the subVI as a parameter and into the other functions where the references would be indexed by name. The difficulty of creating or modifying a type and getting it to match with the various inputs and outputs suggested we do something simpler. But if you are ready to create clusters and/or typedefs, this would be the most commonly used solution by professionals.

The refnum registry, introduced in year two, stores the refnums in a named global location. It uses strings, to refer to the refnums for store and read operations. This is far simpler to understand, but it does allow for misspellings to cause a bug. But the misspelling will result in messages going to the DS Message box, so it is pretty easy to detect. And if your "misspelling" was to use front when you really meant back, that isn't really a misspelling and none of the solutions will prevent that mistake.

If you would like to modify the refnum registry, you can add your own wrapper that takes in an enum instead of a string. You'll create a typedef enum that contains all motor names. The store and read operations will then use the enum instead of the string, but adding a motor will mean updating the registry to know about the new motor name. Enums -- enumerations -- are really just numbers at runtime, but in your code you get to use a name for enhanced readability. LV enums are further restricted to be compact ordinals.

I'm not sure this was what you looking for, but that is my input on the code I was shown.

Greg McKaskle
  #7   Spotlight this post!  
Unread 13-08-2013, 14:07
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,113
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: Flat sequence in Begin.vi

Quote:
Originally Posted by Greg McKaskle View Post
If you would like to modify the refnum registry, you can add your own wrapper that takes in an enum instead of a string.
The TechnoKats did exactly that this past season. We also created a vi full of global arrays that defined which cRIO resource was to be associated with each enum, and used for loops to Open each resource using the specified attributes. Adding a new motor meant adding it to the enum, then defining its PWM number (and its invert flag value) in the global array.

We started out by ignoring the refnum registry entirely, but that kept us from using Test mode.
  #8   Spotlight this post!  
Unread 26-08-2013, 00:59
kenavt's Avatar
kenavt kenavt is offline
Registered User
AKA: Colin S
no team
Team Role: Alumni
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Ann Arbor
Posts: 253
kenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond repute
Re: Flat sequence in Begin.vi

Tim, just as John Sabath said, the intent of the flat sequence structure (besides avoiding a race condition) was readability, especially with younger programmers not familiar with LabVIEW.

Quote:
Originally Posted by Greg McKaskle View Post
<snip>
Thanks for the feedback, Greg. We started using network variables because of how well they are organized and viewed in the Project Explorer, and because they simply seemed like a another type of global variable. Interestingly enough, we actually got the idea of using network variables to store refnum names from FRC68, in order to avoid the errors due to misspelling refnum names (when creating string constants, as the default code is set up to do), after they saw how we used network variables to share local robot state data across VI's.

Our intent was always to be able to view all of those variables constantly - sharing them between computers - but accomplishing that in FRC means pushing them through the Dashboard, or manually using UDP or TCP packets, not actually utilizing the network variable itself (I assume).

I think that what Greg proposed - an enum (perhaps one for each type of refnum - motor, digital I/O, solenoid) would be the best way to evolve this system further. I think the ideal solution would be for LabVIEW to throw an error if refnum names were misspelled (similar to how in a text-based language, if variable names are misspelled, errors are thrown) - but I don't know how that would be implemented in a visual language like LabVIEW, where most data flow isn't named.

Sorry for the graveyard resurrection, but I thought some input from 2337 would be nice, even after the fact.
__________________
University of Michigan Computer Engineering '17

FRC 2337 student alumni (2010-2013)
  #9   Spotlight this post!  
Unread 26-08-2013, 07:16
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,756
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: Flat sequence in Begin.vi

It would be very easy for the refnum get operation to return a runtime error, but not possible for a compile time error using a string. That is where the enum would help. Textual or visual, you'll have the same difficulties here -- strings aren't sets.

The network variables are/were too heavy weight to be used in FRC. They were developed a number of years ago for industrial automation, and meant for exactly what you describe. They were used and still are used for monitoring or control machines to share status and set points with each other. But the memory the libraries needed pushed other things out. Additionally, they have a somewhat complicated set of options for quality and alarms. So we tried several times to get them to fit on the cRIO, and eventually put our eggs in the Smart Dashboard basket. It is the same concept, but with a much reduced feature set and implementation.

Greg McKaskle
  #10   Spotlight this post!  
Unread 02-09-2013, 19:29
tcjinaz tcjinaz is offline
Tim
FRC #3853
Team Role: Mentor
 
Join Date: May 2011
Rookie Year: 2011
Location: Arizona
Posts: 206
tcjinaz has a spectacular aura abouttcjinaz has a spectacular aura about
Re: Flat sequence in Begin.vi

Greg,
Thanks for the detailed answers. I always learn more than a couple thing when you post.

Using an enum to manage the motor references is going to be used by us. It is a great answer to constantly spell checking by hand when motor control goes wrong.

Thanks again to 2337 for going open kimono with their code and spurring me to learn some things. I am about to start another thread on something else I saw in there.

Tim
__________________
Software Mentor
3853 Pridetronics[

Closed Thread


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 03:29.

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