LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read Data loss

Solved!
Go to solution

Hello guys,

 

I am reading force values in real time from a MP2F (manufacturer AEP transducers) load-cell though virtual com port.

The MP2F is returning the values in 6 bytes, something similar to the IEEE754 standard, so the output is random characters.

 

I have successfully made a program to decrypt these output values and it works fine.

 

But I have noticed that I am not receiving all the data in VISA read at certain loads, nevertheless I've set 12 bytes to read.

 

Normally the output is like shown in attachment "OK-Output".

But like I said, at certain loads (for example @ -2.56 N) I only receive 2, 3 or 4 bytes, shown in "NOK-Output".

 

I highly doubt, but is this due to some unknown character?

Something wrong in my code?

 

Please help.

0 Kudos
Message 1 of 5
(970 Views)
Solution
Accepted by topic author Jakob_Pin

The default behavior for VISA Configure Serial Port is to enable line termination for reads using the linefeed character (0x0A).  You need to explicitly *disable* line termination with a binary protocol like yours.  Wire a False constant to the corresponding boolean input up at the top of the vi. 

 

Keep in mind that it'll still be up to you to figure out how to establish proper framing of your 6-byte packets so you don't happen to start your decode from, say, the 3rd byte from one packet through the 2nd byte of the next one.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 5
(954 Views)

@Kevin_Price wrote:

The default behavior for VISA Configure Serial Port is to enable line termination for reads using the linefeed character (0x0A).  You need to explicitly *disable* line termination with a binary protocol like yours.  Wire a False constant to the corresponding boolean input up at the top of the vi. 

 

Keep in mind that it'll still be up to you to figure out how to establish proper framing of your 6-byte packets so you don't happen to start your decode from, say, the 3rd byte from one packet through the 2nd byte of the next one.

 

 

-Kevin P


Just to expand a tiny bit on Kevin's post:

The reason for disabling the termination character for a binary read is that the data may very well contain the byte value reserved as the termination character and trigger VISA Read to stop reading before all the data has arrived.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 5
(923 Views)

Hello Kevin!

Thank you for the answer and solution. It worked without any problem 🙂

 


@Kevin_Price wrote:

Keep in mind that it'll still be up to you to figure out how to establish proper framing of your 6-byte packets so you don't happen to start your decode from, say, the 3rd byte from one packet through the 2nd byte of the next one.


Yes, that part I have already predicted. That is why I am reading 12-bytes, this way I always receive one complete 6-byte package. Value is actually stored in 4-bytes, another two bytes is a separator.

 

BR,

Jakob

0 Kudos
Message 4 of 5
(886 Views)

@Jakob_Pin wrote:

@Kevin_Price wrote:

Keep in mind that it'll still be up to you to figure out how to establish proper framing of your 6-byte packets so you don't happen to start your decode from, say, the 3rd byte from one packet through the 2nd byte of the next one.


Yes, that part I have already predicted. That is why I am reading 12-bytes, this way I always receive one complete 6-byte package. Value is actually stored in 4-bytes, another two bytes is a separator.


Please expand on this.  We can help you a lot more if you give more exact details on this 6-byte package, most likely making it so that you can get all of your data instead of every 2-3 samples.


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 5 of 5
(880 Views)