LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Losing data while writing to spreadsheet

Solved!
Go to solution

I've been working on a VI to acquire data from two instruments and write them to a spreadsheet. For this, I wrote two sub-VIs to acquire the data -- one for a scale, and another for a conductivity and temperature meter. Independently, each sub-VI works fine; however, the conductivity meter sometimes writes a 0 value to the spreadsheet in the main VI. I thought it might have been a problem with the sub-VI, so I wrote a little section to catch and eliminate any 0 results it produces (I have it set up to collect an array of results and get the mean to reduce noise). This didn't work and every 5 or so points of data it writes NaN or a strange value. I think there's some data loss in the main VI caused by one of a couple things:

 

- The response time of the scale is on the order of milliseconds, but the response time of the conductivity meter only sends a signal every 5 seconds. Could this difference cause a loss in data?

 

- Within the main VI, the scale read sub-VI is set to run a for loop to generate the array within the main VI. On the conductivity sub-VI, I have it set up to run the for loop within the sub-VI. Would this difference cause a loss?

 

I've attached some photos of the block diagram to help.

 

Thanks for the help, guys!

-----------------------
Anything worth doing is worth over-doing.

LabVIEW Junkie
Download All
0 Kudos
Message 1 of 7
(2,450 Views)

So, what is the question?

 

(It is difficult to debug pictures. Why don't you attach some real VIs instead?)

Message 2 of 7
(2,435 Views)

Sure thing!

 

My question is why does the main VI print odd values to the spreadsheet when the sub-VIs generate values without issue independently?

-----------------------
Anything worth doing is worth over-doing.

LabVIEW Junkie
Download All
0 Kudos
Message 3 of 7
(2,432 Views)

I've also attached the Scale Read sub-VI here to compare it with the conductivity sub-VI.

-----------------------
Anything worth doing is worth over-doing.

LabVIEW Junkie
0 Kudos
Message 4 of 7
(2,425 Views)
Solution
Accepted by topic author will.nevis

I figured it out. By running the for loop inside the sub-VI rather than in the main VI, it was losing some data as it came out (?). In any case, once I set it up similar to the Read Scale VI, everything worked fine. I think, anyway. It might not look like you guys did anything, but forcing myself to put the problems on paper helped out tremendously. Thanks!

-----------------------
Anything worth doing is worth over-doing.

LabVIEW Junkie
0 Kudos
Message 5 of 7
(2,421 Views)

Why are you constantly flushing the IO?

 

Well, in the lower loop you are doing parallel I/O on a single serial port (COM3). Most likely you get a race condition because the execution order of the two calls varies.

0 Kudos
Message 6 of 7
(2,414 Views)

Yeah, that's kind of silly. It was originally configured to take data from two different scales -- one increasing, one decreasing. Those are on different serial ports. I just switched it temporarily since our current tests only use one scale and I didn't want to re-write half the VI.

 

As for flushing the IO, the signals that get sent to the computer by the scale and meter are sometimes a little glitchy -- they'll occasionally read halfway through a signal, and because it comes in ASCII, it can scramble the interpreter I have written. It's just easier to make sure that I have a full string of data to work with. Are there memory benefits to constantly flushing the buffer?

-----------------------
Anything worth doing is worth over-doing.

LabVIEW Junkie
0 Kudos
Message 7 of 7
(2,410 Views)