LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI within a case structure not executing correctly after the 1st iteration

Solved!
Go to solution

Hello All,

I am writing a VI to control and collect voltage data from some hardware. The way the VI works is that I run the main VI, adjust parameters related to the hardware( specifically, a function generator) and collect voltage and time data. I wrote a subVI to take care of the data collection process, and it works great on its own.  However, when trying to implement it into the main VI, which controls the parameters related to my hardware, I begin having data collection issues. Here is a step by step of what happens...

1.I run the main VI, adjust parameters, click "Collect data" which sets a case structure to the "true" case. My "data collection" VI runs, and I get good data, which I save as an excel file (nearly 1000 data points). Case structure returns to false case (i.e., no data collection).

2. After saving, the hardware continues to run, so I can readjust my hardware settings via my main VI if need be.

3. I click "collect data" once more. My case structure once again executes the true case, but this time I receive only one single data point.

 

My question is this: Why will my VI collect data the first time but not after that?

Below are screen shots of my code(Part of Main VI on top, and SubVI on bottom) in case there is anything obvious that could be pointed out. Thanks for all the help and comments

sak0016_1-1599766383129.png

 

 

 

 

 

 

 

 

 

 

 

sak0016_3-1599766449190.png

 

 

 

0 Kudos
Message 1 of 11
(1,880 Views)

Out of curiosity, what does it do if you run it a third time.  My first thought is that this is the behavior of queues, to have 1 remaining data point after a queue is full.  That's not very helpful but maybe it could spark some ideas, or perhaps it could be misleading

----------------------------------------------------
Studying for CLA.
LabVIEW, inherit from social media habits!
0 Kudos
Message 2 of 11
(1,874 Views)

Thank you for your response. Actually all iterations beyond the first collect a single data point. The first iteration collects data in the correct way and every iteration after that collects only a single data point and saves it into an Excel file.

0 Kudos
Message 3 of 11
(1,852 Views)

How many time the loop which collect the data is executed when you collect a single data ?

It is possible that your boolean that stop the loop is not set up as "Latch when release" (It's not the default case for NXG stop button style) so after the first call, this control is still set to true and your loop stop at the first iteration.

0 Kudos
Message 4 of 11
(1,845 Views)

I would start by setting a breakpoint and probing the 3 stop conditions to figure out why the loop is stopping after one iteration.

Matt J | National Instruments | CLA
0 Kudos
Message 5 of 11
(1,838 Views)

The main VI allows for a user input for the amount of time that data collection should happen. That time goes as an input to the sub VI. Once the "collect data" button is pressed the "true" case structure  executes and the sub VI takes in the user input, collecting data for the prescribed amount of time. I'm hoping that without any stop buttons being pressed, the vi will save my data, change the case structure to "false" by reinitializing the stop button to it's default "false" position(skipping the data collection sub vi), and allow me to press it whenever I need to once again collect more data.  At least this is what I am expecting the program to do. Which Boolean are you referring to specifically?

0 Kudos
Message 6 of 11
(1,835 Views)
Solution
Accepted by topic author sak0016

I'm referring to the "Stop button".

 

I'm agree with Jacobson, you should check the state of the error, Stop button and elapsed time.

And, how many time your loop is executed after your first call to this subvi.

0 Kudos
Message 7 of 11
(1,830 Views)

Thank you for your input. I will check those points, and do a bit of debugging and get back with you. 

0 Kudos
Message 8 of 11
(1,825 Views)

There is no way to troubleshoot this by looking at a truncated picture of a small part of the diagram peppered with overlapping parts/wires and terminals without labels. Where (on what you describe as the "main VI") is the subVI located? 

 

Please get rid of the "reinit to default" and use the correct mechanical action (probably "latch when released").

 

None of your error wires have indicators, so how do you know what's going on? We probably can help better if you would attach a simplified version of your code. Try it!

0 Kudos
Message 9 of 11
(1,816 Views)

Ive checked the loop time as well as the state of the stop buttons and errors as you suggested. The stop buttons do not seem to be prematurely ending my VI and no errors are being thrown. I also looked at the timing of the loops, which are as follows:

1. I set my VI to collect data for one second. I click "collect data" and my subvi loops 370 times, at a speed of 3ms. Looking good upon the first call of the subvi it seems. Then I am able to save my data.

2. I leave my settings the same in the vi ( i.e., collect data for 1 second), click "collect data" again, and then it loops only once, and the loop timer shows about 24 seconds. Which I have figured out, is the time between my "collect data" button clicks. 

 

My VI continues this behavior for all subsequent "collect data" button clicks, showing 1 loop has been executed, and displaying the time between my clicks. 

 

I have used breakpoints to follow the code and probed all the values I can think of with no clue as to the problem. Do you have any additional ideas or suggestions? 

0 Kudos
Message 10 of 11
(1,730 Views)