05-29-2013 11:36 AM - edited 05-29-2013 11:42 AM
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
Solved! Go to Solution.
05-29-2013 12:55 PM
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.
05-29-2013 01:11 PM
why do you have an event structure outside the while loop? and could you not do this all in a state machine?
05-29-2013 01:36 PM
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.
05-29-2013 01:44 PM
@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
05-29-2013 01:49 PM
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.
05-29-2013 01:56 PM - edited 05-29-2013 02:06 PM
because in your pause state, you have defaulted "0" to your file...
add a shift register and build array and wire through all states, don't forget to initialize it
05-29-2013 02:16 PM
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.