11-12-2021 08:02 AM
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.
Solved! Go to Solution.
11-12-2021 08:51 AM
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
11-12-2021 11:21 AM
@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.
11-16-2021 05:00 PM
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
11-16-2021 07:49 PM
@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.