LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Scale Serial Connection

Hello,

 

I am working on a simple Labview program where I am connecting a Precisa BJ610 scale to a VI and reading/writing commands to the scale. I have attached this program below. I have no problem sending commands to the scale (T to tare, DTEST123 to set the display to "tESt 123"), however, I  have not been able to read any data from the scale. I have configured the VISA serial port to match the interface functions on the scale, and I'm certain that the commands are being processed correctly.

 

The PDT command is supposed to print the date and time, but the bytes at port shows 0 bytes reading. I'm not sure what might cause this issue. We're connected to the scale with an RJ45 - RS232 (from the scale) and an RS232 - USB (to the computer) cord daisy-chained together because those were the only components available. I'm thinking this might be an issue with the termination character or that connection, but I'm not sure. Any advice? 

 

I've attached the VI and the scale manual for reference. Thank you!

Download All
Message 1 of 8
(3,195 Views)

DON'T USE BYTES AT PORT!!!!!!   For the love of God, I wish somewhat would get rid of that example from NI and wipe away any trace of its existence.

 

You care checking bytes at port immediately after sending the command.  Guess what?  You haven't given the device enough time to read the command, process it, and return a response!

 

Delete "bytes at port".  Wire a constant into the VISA Read that is larger than the longest response you ever expect to get.  The manual on page 47 says it uses a termination character of Line Feed, so the defaults in the Serial Configure will work just fine.

0 Kudos
Message 2 of 8
(3,172 Views)

I second RavensFan's recommendation -- make your Reads 100 bytes without ever checking "Bytes at Port".  You do want to pay attention to the Error Line, as if you ask for data and the Balance isn't sending, after the (10-second) Timeout period, the Read will throw an Error (I forget the number, but it's a known VISA Error.

 

One small change I would make is in the VISA Settings.  I would set the Scale for the following RS232 parameters:  19200 Baud, N-8-1 parity, no handshake.  With modern USB/Serial communication, 19200 Baud is no trouble, and cable lengths are short enough that you should not need to worry about Parity.  The advantage of No Parity is that now the Bytes "make sense", i.e. if you read "ABC", and you happen to read it as U8s, they will be sequential, all having the high bytes set to 0 rather than having bit 8 flip from 0 to 1 in order to keep the parity Even or Odd.

 

Bob Schor

0 Kudos
Message 3 of 8
(3,162 Views)

Hello Bob,

 

I followed both your and RavensFan's advice and deleted the "Bytes at Port" and added a 100 byte count to my program, and now I've begun to receive the VISA error you described:

 

VISA: (Hex 0xBFFF0015) Timeout expired before operation completed.

 

There's still nothing showing for the read buffer. I tried setting a higher or lower byte count but still nothing happens and the same error appears. I also tried adding an actual time delay between the write/read blocks and still nothing shows up.

 

Strangely I noticed that when I adjusted my settings as you recommended to 19200 Baud, N-8-1 parity, no handshake, I wasn't able to send any commands either? Maybe this is a fluke as I might have adjusted a setting incorrectly, but the 9600 baud, E-7-1 setting I have still works.

 

Thank you,

Leon

0 Kudos
Message 4 of 8
(3,131 Views)

You'll have to change both the settings in the device and the VISA Configure if you want to use different baud rate and comm settings.

 

Do they provide any software?  If you used software they provided, can you get the data from the scale?  Do other commands work?  You said the Test display command worked.

0 Kudos
Message 5 of 8
(3,126 Views)

The manufacturer provides a (non-labview) weight transfer program which is supposed to be able to read the weights from the scale and put them in a text file, however whenever I try to use that program the I get a "runtime error 8005 port is already open", so I haven't been able to use that data to get information from the scale. The manufacturer also provides USB drivers, which I already have installed.

 

Every command I send to the scale which doesn't require a response (Tare, adjusting display, changing backlight, etc.) works, but I haven't been able to get any kind of response from the scale for any command which should be prompting a response (mainly the print commands).

0 Kudos
Message 6 of 8
(3,118 Views)

Make sure you aren't trying to run both things at the same time.  That is probably why you are getting the "port already open" error.

 

Close out LabVIEW or at least the serial port before you try to run their program.

 

If their program still doesn't work, and you can't get responses, then the problem is either with their device or the cables you are using.

0 Kudos
Message 7 of 8
(3,103 Views)

It looks like the outside program doesn't throw any errors when I have LabView closed, but I am still not receiving any information from the scale when I send commands through this program.

 

I'm contacting the manufacturer to see what the issue might be, since this is a new scale, but I'm frankly stumped.

0 Kudos
Message 8 of 8
(3,096 Views)