Go to Post Gosh, I wish that we would've named IndianaFIRST after a candy. - Andy Baker [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 16-01-2014, 22:45
Iaquinto.Joe's Avatar
Iaquinto.Joe Iaquinto.Joe is offline
RPI 2018
AKA: Joe Iaquinto
FRC #0308 (The Monsters)
Team Role: Alumni
 
Join Date: Jan 2013
Rookie Year: 2011
Location: United States
Posts: 166
Iaquinto.Joe is a jewel in the roughIaquinto.Joe is a jewel in the roughIaquinto.Joe is a jewel in the rough
Lightbulb SubVI Re-entrant Option

Our team is using a subvi to take an encoder and our optimal speed in in/s to control our drivetrain with 4 custom PID controls. We had 4 of these SubVIs (One for each wheel) and we were running into an issue where all of the PIDs were all tied together (When you manually twisted a wheel, all of them moved to compensate). We searched for awhile and we learned that when you have multiple instances of the same VI, their IO is shared on the same memory. This can be stopped by going to the front panel of the SubVI, right clicking the icon in the top right, going to VI Options, going to Execution in the drop down, and checking the radio button under "Preallocated clone reentrant execution". This allows you to call the same subvi on your crio multiple times. You will most likely need this for any custom VIs you create. I just thought this was a little obscure and deserves a thread for clarity. Good luck!
__________________
4 year 2011 - 2014 FRC team 308 member, Lead Programmer - C++ / LabVIEW

3 year 2011, 2013, 2014 OCCRA member, Co-Captain OCCRA team 308
  • OCCRA Engineering Excellence - Waterford Kettering 2013
  • Innovation in Control - 2011
  • Quality award- Northville 2012
  • Engineering Excellence- Howell 2014
  • Innovation in Controls- Livonia 2014

Last edited by Iaquinto.Joe : 16-01-2014 at 22:46. Reason: Clarity.
Reply With Quote
  #2   Spotlight this post!  
Unread 17-01-2014, 07:22
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: SubVI Re-entrant Option

You described it well, but let me give just a bit more background.

Normal subVIs act as functions in the language. By default, they act as a critical section. So resources they access can be viewed as short transactions and made safe. This is very useful for protecting access to a device or state data in a parallel environment. Normal subVIs are also not reentrant and do not support recursion. This means that any static data or state data you put in the subVI is shared across all calls to the subVI. This is good if you want one global piece of data like a sum or global running average.

When it is not what you want. When you want a piece of state data for each instance of robot, you have a few choices.

The one you outlined is to go to the VI Properties>>Execution, and enable the Preallocated reentrant property. This does two things -- it allows for multiple calls to the function to proceed in parallel, and it gives each instance its own state.

Shared clones are reentrant, but are used when there is no state data. Shared clones means that a cache of instances builds up as you run. It will only allocate for needs of simultaneous parallelism, not state data management. It also allows recursion.

Another approach is to make your subVI treat the state as a parameter and hold the state at a higher level.

A third option is to put the state into objects such as the actor pattern. This is very powerful, but not for the faint of heart.

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 20:59.

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