Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

not getting bytes from serial port

Hello friends,

 

I have a force measuring instrument connected to CPU using RS-232 cable. I use the labview program made using VISA write and read. I get correct force readings. But my problem is that I get higher values of "bytes at port" reading. The instrument sends maximum 16 bytes but I see 4065 or something greater than 16byte. I can even see the COM port in MAX. Why is that happeneing? How to solve this?

 

force measurement.PNG

 

Thanks

Ashnu

0 Kudos
Message 1 of 7
(5,275 Views)

That sounds like the instrument is streaming the data, meaning it is just constantly sending measurments to you.  And with that delay in there, you can get some really large number of bytes in the buffer.

 

What is the instrument you are using?  What is its command structure?  Most instruments will send and End Of Line character or something like that to tell the reciever that the message is done.  That is called a termination character.  You may want to enable the termination character and not use the Bytes At Port at all.  Instead, just set the number of bytes to read for the VISA Read to something like 20 bytes (since the maximum message is 16 bytes).


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
Message 2 of 7
(5,269 Views)

Hey 

 

0 Kudos
Message 3 of 7
(5,252 Views)

ashnu wrote: 

The numeric outpuf of the VISA Read is the number of bytes read with that read, no how many bytes are actually available.  So if every message is 16 bytes, then that output will always be 16.


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
Message 4 of 7
(5,238 Views)
Section 11 says it transmits 16 bytes so all would appear correct. You can use the String to Byte Array function to get individual bytes. I don't see any details in the manual, though, on how to interpret the bytes.
0 Kudos
Message 5 of 7
(5,236 Views)

Thanks guys!

Please clear me one more doubt. 

I am getting an output as say 7.7 so am i not suppose to get 3 bytes as output instead of 16 bytes from VISA read?? 

Else, does the 16 bytes mean, the instrument is sending 16 digits or character but I am not able to see all those values (i.e. I am missing few digits)?

 

Thanks a lot for your patience. 🙂 

0 Kudos
Message 6 of 7
(5,225 Views)
No, you get 16 bytes with each transmission as the manual clearly states. Only some of the bytes represent the value, again as the manual states. As I already said, I don't see anyplace in the manual that said how the data bytes are supposed to be converted. Each byte could be represented as an ascii character or a hex value that needs to be converted to a floating point number. You can set the string indicator to hex display and post what you receive along with what the instrument is actually displaying at the time. That might help someone explain to what you need to do for the conversion.
0 Kudos
Message 7 of 7
(5,209 Views)