LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading data on an Electronic scale via RS-232

Hello, I have an electronic scale with an RS-232 output, and I would like to print the data on my screen using the LabVIEW program. The device's manual is in Chinese, so all the information I have is in Chinese.

I translated the manual into English using Google Lens.

 

IMAGE_1.jpgIMAGE_2.jpgIMAGE_3.jpgIMAGE_4.jpg

 

Can you help me create a simple design to display the scale's measurements on the screen?

 

Thanks!

 

0 Kudos
Message 1 of 9
(493 Views)

Start with watching this video VIWeek 2020/Proper way to communicate over serial

 

Try a few things out, then if you need more help come back and show us what you tried and the issues you are having.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 9
(460 Views)
I followed some tutorials and made an example of how to communicate using the serial port.
image_5.png
I saw the manual
IMAGE_1.jpgIMAGE_2.jpg
but I don't know what I should write in the box I have circled to request the data from the scale.
0 Kudos
Message 3 of 9
(430 Views)

Hi Thanos,

 


@Thanos_9456 wrote:
I followed some tutorials and made an example of how to communicate using the serial port.

But you didn't follow the suggestions/recommendations given in the video, linked to in the message before…

(This REALLY is a great tutorial video!)

 

  • Don't use BytesAtPort in this case.
  • Set a suitable TermChar (like 0x0d) and use it to read full messages!
  • Close the COM port after the loop.
  • Only define/set non-default values at ConfigureSerialPort call…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(420 Views)

Several additional points to what Gerd said:

 

- How did you decide that 7 data bits, 1 stop bit, and even parity matches with the explanation in your data sheet about 10 bits (one start bit, 8 data bits and one stop bit) and no parity?

 

- The datasheet specifies continous output, this usually means there is no command to request anything from the device, it simply keeps spewing data at an unknown rate until you switch it off. 

That means that there is nothing you should write to the device and simply wait for a response and then go back to wait for the next response.

 

- The data format is terminated with two 0xD characters. So you should configure the port to use this character as termination character. But since they decided to use two termination characters you will have to read first the data frame and then again to read the second termination character before relooping. You should basically NEVER use the Bytes at Serial Port. Another approach is to always try to read 19 characters but that is less reliable.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 9
(410 Views)

Thank you all very much for the immediate help.

Sorry for asking so many things, I'm just using labview for the first time!

 

Is it better now?

image_5.png


I have set the termination character to the number 13 which corresponds to 0x0d

0 Kudos
Message 6 of 9
(379 Views)

Still many things not quite right.

 

1) Just setting the Term Char alone is not enough. The Serial Port Init function from before was not wrong, you just had wired several of the values wrong. And it should be before the loop as before, not inside the loop as you did now with the Open function.

 

2) The VISA Write is almost certainly superfluous, and potentially problematic. Continuous output mode means that the device simply talks and talks and talks and talks, without having to be prompted to do so with any command. Even if it would need a command, chances that that would be *IDN? are abut -100%.

 

3) Make the number to read at least 19, rather than 10. Each message contains 19 characters. And add a second Read after that to read the second 0x0D character. VISA Read if set to terminate on termination character will terminate on the first occurence of that character. But your message contains two of them, so you need to do another read to get that from the input buffer.

 

4) Also put the Close function outside the loop after your loop stops.

 

5) That Delay of 1000 ms is going to be possibly problematic. If the device produces more than one measurement per second, your loop will lag more and more behind the data send by the device. You can leave that out, since the VISA Read will simply wait until a message frame has arrived and that will synchronize your loop with the speed of the device.

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 9
(368 Views)

I finally managed to read the output from the scale, but I didn’t want to do just that.
I also want to read the temperature from a thermocouple, which I’ve connected to an Arduino.
In the image below,

 

Thanos_9456_0-1744634654171.png

 

you can see that I have a while loop for each serial connection, and it works without any problems. However, I can’t display the data on an XY plot.
But when I remove the two inner while loops and use just one common while loop, then I can’t get data from the scale. It shows data infrequently, as if it’s getting stuck somewhere.
How can this be solved?

0 Kudos
Message 8 of 9
(137 Views)

Any suggestion?

 

Thanks!

0 Kudos
Message 9 of 9
(73 Views)