LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use one Boolean control in several places in various structures

Solved!
Go to solution

Hey,

I am looking to use one Boolean control on the front panel to control different event structures in different case structures all within a while loop. The simple answer may just be that I need to entirely restructure my labview program (although I hope not). Is there a way to prevent having to three buttons on the front panel based on the simplified labview program attached? Is it possible to have just one button to control all three event structures depending on which case structure I am in? I have also attached the bigger labview program (Full_Linkam_Controller) that is a work in progress so you can see what I am attempting (hopefully). The other two VIs are subVIs within the Full_Linkam_Controller. Thanks.

0 Kudos
Message 1 of 8
(4,425 Views)
Solution
Accepted by topic author wjstraka

Hi wjstraka,

 

The simple answer may just be that I need to entirely restructure my labview program

Yes, that's the simple answer!

 

Is it possible to have just one button to control all three event structures depending on which case structure I am in?

No, not the way you programmed it.

In a VI only one event structure can be assigned to handle the button!

(You might try to start with user-defined events and enabling/disabling them for each case, but then a clean "restructure" is the better way to go with less hazzle in the end.)

 

On your "main application": this all looks way to complicated. It might get mentioned in the Rube-Goldberg thread😄

 

Example:

check.png

 The Search1DArray does most of the work for you and FormatIntoString most often can replace ConcatString…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(4,410 Views)

Thanks for the reply. Unfortunately, that's what no formal training and occassional self learning looks like. Smiley Happy

0 Kudos
Message 3 of 8
(4,404 Views)

Hi wjstraka,

 

the event structure is not the easiest to master by a LabVIEW beginner.

I can recommend to read its help entry as well as the "Event structure caveats" mentioned in the help…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(4,398 Views)

Just some hints.

  1. About the Example.vi:
    1. NEVER use multiple Event Structures in a VI! You only need ONE! The solution is very simple: use a single Event structure. Have a look at the several Event driven state machine examples...
    2. Why do you use that 5 msec timeout case for your Event Structures? Just delete the timeout cases. The code will wait until the user interacts with a button. There are valid use cases for timeouts, but I do not see why you need them here.
    3. That Stop button should be also an event case of the SINGLE Event Structure.
    4. Really have a look some official State Machine examples. You are on the right track, but not 100% yet...
  2. "Full linkam controller.vi":
    1. Again, your Timeout event cases could be deleted!
    2. Use a Type defined enum for your states!
    3. Otherwise, it is not a bad attempt, you are close to a proper event driven state machine: using a SINGLE Event structure inside one of the cases of the State machine.

I cannot really comment on your serial setup/programming, since I do not know this hardware. Are you sure you do not need to use some termination characters to ensure proper Read/Write comm?

0 Kudos
Message 5 of 8
(4,384 Views)

I want to clear up some misinformation. There is no problem having multiple event structures in a single VI, but you should never hide them inside case structures unless you can guarantee that they are reached by dataflow with little delay. If you have multiple event strictures, they should each be in their own while loop. You can also have multiple event structures reacting to the same button. They all will fire. (exceptions are discarded filtering events, etc.). What is this VI actually supposed to do?

 

(linkam pump speed) Yes, your iteration using a while loop is extremely dangerois, for example if there is no match, the loop will spin forever. Unlike a FOR loop, a while loop does not stop if it runs out of elements at an autoindexing input tunnel. Yes search array is the correct function. There is a +1 primitive. You should use a array diagram constant. The addition and division belongs after the loop. You can add the percentage sing to the format statement (as %%), no need to concatenate. Are you sure there is mo "math" way to convert the bytes to speed?

 

(full linkam controller) How often is the "Pre T command" case executed? If the code spends any length of time in other cases, you cannot have the event structure there. I strongly suggest to make your enum a typedef. You already have mismatched version.

 

(Lincam convert temp) Pure rube goldberg! Way too much duplicate and unnecessary code. Do you have a spec sheet describing the math? I am sure the correct method could fit on a postage stamp. 😄

 

 

Message 6 of 8
(4,365 Views)

If you can guarantee that the input to "pump speed" is not malformed, here's a VI that does exactly the same thing! try it!

 

Pumper.png

 

(Of course you might want to do some input and output range checking, but that should not be hard)

0 Kudos
Message 7 of 8
(4,356 Views)

Hello Wjstraka  

I am contacting you on behalf of Linkam Scientific. I understand that you posted in the NI forums regarding connecting to Linkam equipment using LabVIEW. This is possible through either our full SDK product or our standalone .Net control, so please send us an email at support@linkam.co.uk with more information on what you would like to do and we will be glad to get you up and running. 

 

Kind Regards

 

Ujas 

Software Engineer

Linkam Scientific Instruments 

(support@linkam.co.uk)

 

0 Kudos
Message 8 of 8
(4,174 Views)