From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA READ wait for termination character not working

Solved!
Go to solution

We have something like mcduff's code in our libraries. We communicate with a device that doesn't really have a well defined protocol and we can get responses of varying unknown lengths. There fore we read a single character using our maximum data timeout (we don't use bytes at port) and once a character is received we read large blocks with a very short timeout. Once we get a timeout we assume we have received all of the data. It is not full proof but with a few tweaks over the years it has worked well for us. It would be nice if the device had a better protocol but this is what we have to work with.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 31 of 37
(553 Views)

Just in case someone ends up working with the Sutter MP-285 stage motion, here is what ended up working.

Here is generic send and receive:

emime_1-1624553981724.png

 

Here is the one that gets the current position:

emime_2-1624554043787.png

 

 

This is the move program that has a while loop to compare the current position with the desired final position :

emime_0-1624553894538.png

Here is the comparison Vi (you don't actually need the =0 check but I inverted the z axis for our specific purposes so I often get -0 which isn't equal to 0:

emime_3-1624554166529.png

 

I've attached all the actual code. I hope this saves someone a headache.

 

-Émilie

 

 

0 Kudos
Message 32 of 37
(532 Views)

It is never a good idea to test for equality when using floating point numbers. You should always compare against some tolerance. You could end up with two values such 1.000000 and 0.999999 which will always fail an equality test.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 33 of 37
(527 Views)

so I should substract one from the other and make sure it's absolute value is smaller than 0.5 or something?

0 Kudos
Message 34 of 37
(523 Views)

@emime wrote:

so I should substract one from the other and make sure it's absolute value is smaller than 0.5 or something?


Yes. You can also use the in range function and negate your tolerance.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 35 of 37
(514 Views)

You could also multiply both the number and the number to compare to by the 10^(decimal places to compare to), round them and do the comparison using the integer results.

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 36 of 37
(508 Views)

You can also greatly simplify some of your code if you use the Unflatten From String (when decoding the data) and the Flatten To String (when encoding the data).  Both of those functions have an input for Endianness.  Set those to be "Little Endian".  That will eliminate all of your Swap Bytes and Swap Words.


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 37 of 37
(489 Views)