LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Saving Correct Data

Hi all,

 

I am writing this VI to take temperature data from an apparatus I designed to put acoustic transducers in liquid nitrogen.

 

There will be 4 RTDs on the body of the apparatus and 1 RTD in the liquid nitrogen reservoir. The temperature from the single RTD in the liquid nitrogen reservoir is all I am interested in saving, along with the elapsed time for that measurement since the experiment has started.

 

My while loop checks to see when the RTD in the reservoir reaches the final temperature and will stop the experiment. Inside the while loop, I am reading in the doubles from the RTDs and plotting them on XY graphs.

 

The problem I am having is saving only the data I am interested in. I have an array that saves all the data from the liquid nitrogen RTD to display, but I only want to save a certain amount of those. I made an initial value in the array very low so that the first measurement by the liquid nitrogen RTD will always be above it and save the first time it loops through; however, my data comes out looking like the picture shown. It is saving both the elapsed time and the temperature measurement in the same column. It also looks like my condition of when to save the data is not working correctly because each entry for the temperature has not changed beyond the threshold I set.

 

I am also trying to call another VI when I am ready to save a temperature entry. Can I output the measurement from that VI into the file I am saving for the temperature? It would be extremely helpful to have the temperature measured at a certain elapsed time along with the additional transducer measurement on the same file. 

 

Thanks you! 

Best,

icewind26 

 

 

Download All
0 Kudos
Message 1 of 6
(2,071 Views)

There are a number of things possibly/probably "wrong" in your code.  First, "threshold" -- it is difficult to figure out what you are really doing (too many lines running all over the place and not always straight nor visible), but there seems to be a single Threshold, and you seem to be only saving temperatures > threshold, rather than "all temperatures once one crosses threshold".

 

To implement a threshold, I'd suggest two sequential loops -- one samples and "does nothing" (= "throws away") the data until you exceed threshold, at which point you exit the loop.  The following loop "samples and saves", until you decide to stop.  [I know, you've just thrown away the first point, but you can probably figure out how to "fix that"].

 

I'm not sure why your data looks as it does, but I strongly suspect it is because you "told it to do that".  I tend to stay away from Express VIs for doing File I/O, as they do "what they want to do", not necessarily what I want them to do.  LabVIEW's File I/O is not that difficult -- spend a little time with a Tutorial or find a colleague/mentor to help you.

 

Bob Schor

Message 2 of 6
(2,015 Views)

I urge you to get each code segment working the way it should before throwing them all together. For instance, have you tested that Transducers1.vi runs and acquires the expected temperature data 20000 samples at 1 MHz? writes that to TDMS file? Does that code produce any errors?

 

Why do you call Transducers1.vi by reference?

Acquire High-Speed Temperature snippet.png

Try replacing this code by dropping Transducers1 directly into ColdTest.vi block diagram.

 

Also, this is an interesting pattern:

 

Append Append.png

First, you put time and temperature data into the same array. The build array on the left appends new time and temperature data to the previous time and temperature data.

 

Then, the conversion to dynamic datatype bullet is configured:

dsbNI_0-1629080058118.png

 

1D array array of scalars - single channel this is where you are telling LV that you only have a single channel (column) of data.

 

Lastly, the Express VI is configured to append data to file. If this works without error (you should connect the error out), I expect you would get a file with the following data stored as a single channel:
time0

temp0

time0

temp0

time1

temp1

time0

temp0

time1

temp1

time2

temp2

...

 

Bob Schor's suggestion to use LabVIEW File I/O directly rather than use Express VIs would allow you to have more control over the data that actually gets written to file. In any case, test each code segment before adding more functionality.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
Message 3 of 6
(1,946 Views)

Hi Bob,

 

The idea for the "threshold" was to see if the difference between the current temperature and the last saved temperature has increased beyond that "threshold." 

 

Thank you for the suggestion of two sequential loops. I would like to now update the "threshold" value to whatever the newest temperature is that I have saved, and I believe I know how to do that in the second loop.

0 Kudos
Message 4 of 6
(1,920 Views)

Hi Doug,

 

I am very surprised my brain went straight to trying to combine all the different pieces immediately after writing them, so thank you for the reminder that working on individual pieces until they work is a faster way of getting my code written and working.

 

Thank you for the suggestion on dropping in the referenced VI. I think that will fit better with what I am trying to do.

 

I also appreciate you finding out what was wrong with my saving procedure. It helps to see why I was making those errors. I will definitely implement the LabVIEW File I/O instead of the express VIs once I watch some more tutorials. Thank you!

0 Kudos
Message 5 of 6
(1,919 Views)

Hi there,

 

I have a main VI (ColdTest.vi) that reads in temperature data from 5 RTDs with one of them being dipped in a liquid nitrogen reservoir. This RTD is what I use to trigger the events in the main VI.

 

As it is written, the VI takes in the temperature from the RTDs and plots them versus the elapsed time since the "Sampling Loop" began. It then checks if the RTD in liquid nitrogen has seen a higher temperature than "Threshold Temp." If it is higher, it takes the temperature data from all the RTDs and saves it to a file. The first measurement will always be taken because the default value of "Threshold Temp" is set very low. It then increases the "Threshold Temp" by the amount "Temp Increase" to make sure the temperature has risen by at least a certain amount since the last measurement. I have tested this part and it works as I would like; however, the next addition causes problems. 

 

When the RTD in liquid nitrogen has seen its temperature increase higher than the threshold there is a sub VI inside the True case structure called "Transducers_ColdTest" that takes a 5 second acoustic sample from acoustic transducers that are inside the liquid nitrogen reservoir. On its own, this sub VI takes the sample and can save it to a file to be viewed without error.

 

When I tried to add this feature to the main VI, I find that the code gets stuck at trying to save a file that includes both the temperature data and the sample from the acoustic transducers because it will run once time and buffer. For "Transducers_ColdTest", my sampling rate and number of samples is 1 MHz and 5M. Since this sub VI takes a while to run, is this the reason for my saving problems? Do I need to save the data from the sub VI and return the file to the main VI? Or is there something else I am missing?

 

I would also like to be able to view the data from all the RTDs as a function of the total elapsed time since the code began, not just since the "Sampling Loop" restarted. My thought is to use the DAQ assistant to just read this data and display it in real time. Would this work or is there a better way to implement this?

 

Best,

icewind26

Download All
0 Kudos
Message 6 of 6
(1,943 Views)