LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

New User: Pausing data collection results in unwanted zeros.

Solved!
Go to solution

Hello NI forums. I was hired by my university to do summer research and started using labVIEW 2010 last week. I have had some success so far but have run into a few bugs I don't know how to fix. 

 

My front panel has user input boxes for the initial experimental settings. When the program runs it changes the current running through a circuit by a certain step current, and the other three devices read various data. The data is graphed as it is collected and written to a file at the end. My professor has asked that we be able to pause the program to change this step current while it is running. I was able to create a pause/resume routine by using an event structure inside my loop. This event structure changes the timeout of an interior event structure to -1 on pause, and to 1 on resume. 

 

Bug 1: While the pause and resume works, it is hanging. I have to change tabs in windows and the program immediately starts to work again. Perhaps this is a temporary issue or something to do with the lab computer. I don't know.

 

Bug 2: After analyzing the data I noticed that everywhere I paused the program a number of rows of zeroes appeared in my text file. So I will have my 4 mA reading, my 5 mA reading, five 0 mA readings, followed by the expected 10mA reading. 

 

It would be nice to remove these bugs completely, but I am open to workarounds. For instance. A method to stop the program from writing a row of zeroes after the initial zero reading. 

 

I have included my vi and an example data file below. (keep in mind, I just started using labVIEW last week, so things are very messy. 

 

Thanks for your time!

 

Nukem

Download All
0 Kudos
Message 1 of 8
(2,455 Views)

UPDATE: I moved the command to set pause to -1 outside the pause event structure, which has fixed the hanging issue. The pause and resume both work. However, I am now getting a small glitch where the pause works the first time, but may need a few pressess on the second or third time to activate. 

0 Kudos
Message 2 of 8
(2,429 Views)

why do you have an event structure outside the while loop? and could you not do this all in a state machine?

0 Kudos
Message 3 of 8
(2,422 Views)

The outermost event structure was created so the user could enter the inital conditions before starting evaluation. Also, being new to Labview i didn't know whether it was okay just to run from the above menu, so I avoided it. 

Coming from a C++ background the concept of a state machine is new to me. I looked it up and yes, in theory there is an initial stage, a data collection stage, and a write to file stage. 

0 Kudos
Message 4 of 8
(2,415 Views)

@Nukem wrote:

The outermost event structure was created so the user could enter the inital conditions before starting evaluation. Also, being new to Labview i didn't know whether it was okay just to run from the above menu, so I avoided it. 

Coming from a C++ background the concept of a state machine is new to me. I looked it up and yes, in theory there is an initial stage, a data collection stage, and a write to file stage. 


yes, that's it.....have a look at these videos under state machines
0 Kudos
Message 5 of 8
(2,403 Views)

That will certainly help clean things up, I guess. But that doesn't really address the main issues here. Primarily the fact that when I pause my program it writes zeros into the data file. I can live with having to carefully double click my pause button if it doesn't work the first time, but when my data file doubles in size due to zeros, that is a problem... 

I will probably convert my program to a state machine after I have it working in this clearly rudimentary method. 

0 Kudos
Message 6 of 8
(2,398 Views)
Solution
Accepted by topic author Nukem

because in your pause state, you have defaulted "0" to your file...

Pause%20stop%20reutine%20start[1].png

 

add a shift register and build array and wire through all states, don't forget to initialize it

 

Spoiler
Pause%20stop%20reutine%20start[1].png

 

Message 7 of 8
(2,394 Views)

Thank you. I was aware that the wire was leading to nothing in those states, but I thought it needed input to do anything. I was expecting it to only read from the states that were connected not knowing the default setting issue existed. Your solution worked perfectly. We will see what my professor can cook up to trip me up next. 

0 Kudos
Message 8 of 8
(2,377 Views)