LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Intermittently empty values in visa read

Hi,

 

I have a small problem that I couldn't find good answer upon searching. In the attached file, in which I'm reading mass from a balance connected via serial port (COM1), I keep getting what appears to be empty (no values) from time to time (see attached screenshot). This only happens with the balance and not the other serial port (COM4). Any suggestions???

 

Thanks in advance.

Download All
0 Kudos
Message 1 of 15
(3,173 Views)

Hi Yazan,

 

Firstly, you need to ensure that you close all serial and file connections at the end of your program (after the while loop) otherwise you'll keep the ports/file open even though your program has finished! (also a bit of error handling wouldn't go amiss! Smiley Wink)

 

Secondly, are you sure you've got all of the settings for the serial port correct (I assume so, as you're reading data fine, but it's always best to check) 

 

Ok, if those are ok, then i'd suggest that the problem is in what the balance is sending. Have you looked at the balance data with another serial program (termite etc,)? If you still get the zeros/empty values then the balance must be sending them. Try and see if there are any settings for the balance which might solve this.

 

If you can't stop the balance sending empty data, your best bet is to ignore the "error" and only plot the non-zero (non-empty) data.

 

-CC 

 

 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 2 of 15
(3,159 Views)

Some balances will not return a numeric reading if it detects that the measurement is not stable due to motion or oscillation after a mass has been put on the platen.

 

Could this be the case with your balance?

 

Please 'weigh' in on this 🙂

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 3 of 15
(3,151 Views)

 


 

Please 'weigh' in on this 🙂

 

-AK2DM


*puts face in hands and groans* Smiley Very Happy

 

 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 4 of 15
(3,144 Views)

Thanks CC & AK2DM for the quick response and the tips. I will add a close block to the loop.

 

I doubt the problem is with balance reading as the problem is not there when the data is collected with another program (CPS Plus). My gut (specially after reading the manual) tells me it has to do with the data sent from the balance.

 

With the VISA testing tool, a read command return something like: 16.000\n\n (which is, according to the manual, is the result of “1234.567 g<CR><LF>”). However, my gut is not good in programming and I can't tell if this is the problem or not, or how I can solve it :).

 

If you have the time, I would appreciate if you can look at pages 26-28 of the manual http://www.adamequipment.co.uk/na/pdf/130.pdf and see if you can figure it out.

 

Thanks again,

Yazan

0 Kudos
Message 5 of 15
(3,134 Views)

Your code does not make any sense. You have the read termination character enabled but yet you use the VISA Bytes at Serial Port. Do one or the other. And, if the VISA Bytes at Serial Port returns 0, you still do a VISA Read. That could certainly account for your 0 readings. What do you think a blank string gets converted to?

 

Best fix is to get rid of those silly VISA Bytes at Serial Port and just use the term character to end the read when you specify some arbitrary number of bytes to read. The delay functions then also become redundant. Doing a flush buffer in every loop iteration is also silly.

Message 6 of 15
(3,133 Views)

The one with bytes and termchar is not making problems; the other one is. I'm sure this is not the best code, as I just know enough to manage my applications purposes, but it works fine. If you can make the changes your suggest and upload them here I will be very appreciative.

 

--Yazan

0 Kudos
Message 7 of 15
(3,127 Views)

and by the way, this is the output form the other serial program (notice the end characters):

zeros.JPG

0 Kudos
Message 8 of 15
(3,125 Views)

Why would I make the changes to your program? Wasn't my description adequate? Didn't you write the code in the first place?

0 Kudos
Message 9 of 15
(3,118 Views)

Hi,

 

As far as your graph goes, you could write a switch to skip a data point if it is exactly 0 ( or any number).    I know it is just avoiding the issue, but might be all you require.

 

As  Dennis said, if you are reading a blank reply you are getting a zero, cut that part out of the code.

-------
Mark Ramsdale
-------
0 Kudos
Message 10 of 15
(3,115 Views)