LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String Comparison

Solved!
Go to solution

Hello,

 

I want to add a start mark for the sensor signal. So I added a 'T' as the start mark. In my program, I will compare the string from the serial port with 'T' to judge, if the sensor data comes from the next measurement. But I have noticed, although the string from the serial port is 'T', the result of the comparison is 'false'. Could someone explain it?

 

Best regard

0 Kudos
Message 1 of 5
(3,497 Views)

Can you save the serial output so we can see what you are comparing? You can also try right-clicking the string control and changing to '/' Codes Display to see if you are also picking up the termination character.

Matt J | National Instruments | CLA
Message 2 of 5
(3,478 Views)

Hello Matt,

 

thanks for your replay. In this project, I will use LabVIEW to communicate with Arduino. The serial output from Serial Monitor and LabVIEW VISA is like:

T

1023

985

897

765

732

T

1024

988

898

765

732

...

 

It is like so, there is a 'T' as the start symbol for every five measurement data. In LabVIEW, I could read the start symbol "T" from the serial output of VISA, but when I compare this 'T' with another 'T', the result is false.

 

Best regard

0 Kudos
Message 3 of 5
(3,460 Views)
Solution
Accepted by topic author TUDarmstadtLLX

You likely still have the Carriage Return and/or Line Feed in your read string.  Try adding a Trim White Space before the comparison.

 

Another option would be to put all of your measurements into a single message.  You can separate your measurements with a comma and end the message with the Carriage Return and Line Feed.


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 5
(3,436 Views)

Hi,

 

thanks for your reply. Your idea sounds feasible, I will try it out.

 

Best regard

0 Kudos
Message 5 of 5
(3,428 Views)