From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

(LV7.1) Globals and event programming?

Solved!
Go to solution

I have a problem with a LabVIEW 7.1 application I am developing.  I have previously used LabWindows/CVI and am used to event-drivent programming.  My application involves setting and reading data from about a dozen test instruments (all of different types), depending upon what the user wants to do.  The diagram of the application is a While Loop with an Event Structure inside of it.  The while loop runs until a "stop" button is pressed, and the event structure handles each different instrument.  I initialize all the instrument settings outside the loop so that they have default values, but allow the user to change them as desired via one of the events. 

 

When I first set up this application, I used Feedback nodes and it initially seemed to work ok, but as the application got bigger I ran into a problem where the values were reset to zero after every event.  I figured that perhaps Globals would get around this, so I changed the structure to resemble the attached code (picture included for those who don't have LV7.1).  However, now the problem is that the value change event doesn't actually change the values - they get reset back to the defaults every time.

 

Anyone have suggestions on how to fix this (or a better way to implement it)?

Thanks!

 

Michael Tracy
Synergy Microwave

 

0 Kudos
Message 1 of 5
(2,462 Views)

The problem is nothing is related to anything else.

 

You have 3 hidden controls of cluster, cluster1 and cluster2.  You have a global variable of clusNumber.

 

When you start, cluster goes to clusternumber global

 If you hit change Number SetNumber VI runs.  All it does is take the controls you have set in the subVI and send it to cluster1.

Display settings takes cluster number2, unbundles the elements and sends it out to numeric 1, 2, and 3, all hidden indicators.  That subVI does the unbundling as rapidly as possible until you hit stop on the subVI.

 

No where in the code do you assign values between the different clusters.

 

You must be very new to LabVIEW.  I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

 

Ultimately what you will want is a single cluster that is carried through the iterations of the while loop by way of a shift register.

Message Edited by Ravens Fan on 02-23-2009 02:05 PM
Message 2 of 5
(2,450 Views)
Solution
Accepted by SynergyMike
Well, of course things get reset back to the defaults. You are not passing the new values to your SetNums subVI so all it can do is display the defaults the next time it is called. The use of globals is not doing anything. Below is an image of how the main VI and subVI can be rewritten. I can't post them as 7.1.
Download All
Message 3 of 5
(2,449 Views)

Thanks, Dennis - shift registers did the trick, but I had to wire each one through every event, whether it was being used or not. 

 

To the other poster - the clusters are all derived from the Globals (if you right click on a global, you can create an indicator or control based on it, which I did and then renamed them), so I assumed (yeah, yeah I know, I saw the Odd Couple episode too) they would write to and read from the Global as current content.  Yes, I am new to LabVIEW, having used it sporadically for a couple of months now.  Although I've programmed in 6 different computer languages over close to 3 decades, that background didn't seem to help as much as I expected.  😉

 

Regards,

 

Michael Tracy

Synergy Microwave

 

 

0 Kudos
Message 4 of 5
(2,418 Views)

HI Michael,

 

Before you go to far you may want to review the Nugget I wrote on Action Engines (they take advantage of the fact that a shift register acts a lot like a static local) becuase they are a way of encapsulating the Shift Register and using them wherever you want.

 

Re: having to wire all of the tunnels.

 

IN LV 8.5 there is an option assign tunnel pairs so they all get wired up automatically.

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 5
(2,407 Views)