Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Dumb scale behaviour

I'm working on the automation of a distillation column and we're using weighing scales to measure the mass flow rate into the column. We bought some radwag scales and they already have VIs written for them (with some bugs), but they're expensive and with unnecesary features for our application. So, we've now bought IBN scales from Mexico, which are cheaper, but have a couple of dumb design choices.

 

They transmit data in streaming mode. However the data they send is date and time in one line and then the weight in another. This is the VI I wrote to handle it:

 

imagen_2021-07-20_150538.png

 

It uses 3 reads because of the buffer clearance. As it's a big program, I use synchronization timers, but then the buffer quickly fills up and the readings become useless. So I then read once, discard the usually incomplete reading and read twice more for the time and weight and then discard the time string and extract the number and the units. Sometimes when starting the VI it has a "hiccup" and reads an empty string, thus the conditional.

 

But now we get to the behaviours which are causing me problems. First, it doesn't print the sign when the weight becomes negative. This is merely an inconvenience. But then when the weight becomes 0, it just stops the communication, which causes a timeout in the Visa read and an error in the scan from string. I tried using bytes at port at the beginning with a 100 ms wait, but if the communication stops between readings it still causes an error. Any suggestion on how I could handle this better? I think my code is still quite not good.

0 Kudos
Message 1 of 5
(190 Views)

My main issue with your code is that you are throwing away 1/3 of the data.  Unfortunately, I need more information in order to give any real suggestions here.  Do you have a full definition of the protocol?  This would include the format of the messages.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(165 Views)

Could you please share the manual of the scale that contains these commands?

 

Typically you should be able to get each packet properly using termination character, like CRLF. VISA already handles these by returning requested characters or until the termination character.

-Santhosh
Semiconductor Validation & Production Test
Soliton Technologies
NI CLD, CTD
LabVIEW + TestStand + TestStand Semiconductor Module (2013 - 2020)
NI STS for Mixed signal and RF
0 Kudos
Message 3 of 5
(161 Views)

Unfortunately the information provided is quite minimal and in spanish. It's a scale design to print tickets.

 

imagen_2021-07-21_114922.png

0 Kudos
Message 4 of 5
(129 Views)

Why not use the PRINT mode described? it will send data only when the PRINT button is pressed.

-Santhosh
Semiconductor Validation & Production Test
Soliton Technologies
NI CLD, CTD
LabVIEW + TestStand + TestStand Semiconductor Module (2013 - 2020)
NI STS for Mixed signal and RF
0 Kudos
Message 5 of 5
(114 Views)