LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI not finishing execution when called by an event structure

Dear LabView community: I am running into the following problem: I have a main Program, which includes several buttons to start certain measurements. My SubVI is a simple counter which works just fine, when used as a standalone program. But when I call it by an event structure it does perform the measurement but keeps in some idle state instead of finishing the execution and returning the measurement values (Run button says "SubVI waiting to run").

 

SentecDE_0-1687255435179.png

SentecDE_1-1687255478814.png

 

 

0 Kudos
Message 1 of 16
(1,421 Views)

Hi Sentec,

 


@SentecDE wrote:

when I call it by an event structure it does perform the measurement but keeps in some idle state instead of finishing the execution and returning the measurement values (Run button says "SubVI waiting to run").


When the subVI is "waiting to run" then it waits for a call from its MainVI!

So the real question is: does your MainVI work as expected and does it call your subVI as expected?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 16
(1,390 Views)

The SubVI is executed when pressing the assigned button in the main VI frontend. It performs the measuring task and as far as I can observe it using the "highlight execution" method, the output values are further processed but are not passed through the frame of the event case.

0 Kudos
Message 3 of 16
(1,360 Views)

Hi Sentec,

 


@SentecDE wrote:

The SubVI is executed when pressing the assigned button in the main VI frontend. It performs the measuring task and as far as I can observe it using the "highlight execution" method, the output values are further processed but are not passed through the frame of the event case.


THINK DATAFLOW: When the subVI has finished execution the calling VI (aka your event structure) can continue to execute and so it should receive/process the data.

As you didn't provide any code we cannot verify your experiences…

 

(When attaching code I would prefer LV2019. Use "Save for previous" to save for older LabVIEW versions.)

Best regards,
GerdW


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

I'm glimpsing another Event Structure in your main VI.  A loop should only ever have 1 Event Structure.  Many argue there should only be 1 Event Structure in a single VI.  But unless both of your Event Structure run, your loop is stuck waiting for everything to complete before it can iterate.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 16
(1,346 Views)

Please provide us real (editable, executable) LabVIEW code, which means (all the) files with the extension ".vi".  We cannot "see" or understand "pieces of pictures of code" that are static images.

 

It also helps if you "save for previous version" (from the "File" menu) and choose LabVIEW 2019 or LabVIEW 2021, which most of the more experienced Forum users are using (while most of the "first-timers" are using LabVIEW 2023, which we can't open, yet ...).

 

I see a structure in your "picture" which suggests you were using an Express VI (possibly the Dreaded DAQ Assistant), and "blew up" its "express" personality.  When you do this, you make it a little harder for us to tell how you configured the Express VI.

 

If you are working in a LabVIEW Project, I strongly recommend that you attach the entire Project.  The easiest way to do this is as follows:

  1. Close LabVIEW.
  2. In File Explorer, find the Folder containing your Project.
  3. Right-click on the Folder, choose "Send To:", choose "Compressed (zipped) folder".
  4. Attach the resulting .zip file to your reply.

Bob Schofr

0 Kudos
Message 6 of 16
(1,344 Views)

Others have already pointed out some glaring mistakes. However we need to full set (caller and all dependencies) as described to troubleshoot, not pictures!

 

  • The caller does not seem to have a visible toplevel loop.
  • The caller has two event structures in parallel on the same (sub) diagram.
  • Events need to be able to react AND complete in milliseconds and should not contain lengthy code. Ever!
  • We don't know how the subVI call is set up (e.g. open when called and close afterwards)
  • We don't know how the events are configured (e.g. lock panel or not).
  • We have no idea what that other subVI is doing (the one with the "3" on the icon)
  • We have no idea what typical control values are.
  • etc.

 

 

0 Kudos
Message 7 of 16
(1,308 Views)

Maybe your event structure returns the measured values, but your next event does erase them, as you have 'use default values if unwired'.

For a quick test you can place a case structure around the output (Co60 & Co60ZR) and a true constant to activate this case.

 

Else you have enough ideas here.

0 Kudos
Message 8 of 16
(1,223 Views)

Here I have the two files attached for 2019.

I deleted all other event cases as recommended and simplified the whole program to the necessary features.

I actually found out it passes on the measured values correctly, but only if the respective cells in the array are "activated" e.g. by manually writing in some values. (Can I actually have those 6 entries of the arrays activated by default?)

But, as the Sub-VI is not closed the timer is not reset, and if I call the Sub-VI again it instantly stops the measurement as the current time already exceeds the time-limit.

Download All
0 Kudos
Message 9 of 16
(1,195 Views)

Hi Sentec,

 

your main VI should rather look like this:

Apply better programming rules on your VI:

  • you don't need to duplicate the whole measurement stuff when the only things that changes is a numeric constant!
  • you should use shift registers instead of local variables!
  • you need to initialize arrays correctly, otherwise you aren't able to replace (non-existing) elements!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 16
(1,181 Views)