LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

visa read compare string value

Hi everyone, 

 

I'm writing a program where I use a stepper motor and a force gauge. In the initial case, I want to control the stepper motor by reading the force gauge simultaneously. (The force gauge is attached to the stepper motor). 

 

I use VISA read to read the values from the force gauge. So I want the stepper motor to move in down until force gauge shows a value 0.00, and then move up again until force gauge = 0.00. 

From VISA read it reads the buffer which is a string. I tried to compare the string and I also tried to convert it to a numeric, but when converting it I don't get the decimals (for example 5.67 converts to 6,00). Maybe it has to do that the string has a period and the numeric has a comma. But I couldn't figure out how to get around that. How should I do it? I've tried fract/exp string to number. 

0 Kudos
Message 1 of 2
(2,185 Views)

Hi pamy,

 

Maybe it has to do that the string has a period and the numeric has a comma.

Yes, sure!

This comes up very often and there are several solutions possible.

I usually recommend to set the point as decimal seperator in the system settings. You can also programmatically convert such numbers, there are format strings just for this purpose…

 

I've tried fract/exp string to number. 

Did you read the help? For all inputs of that function?

 

Keep in mind the common problems of comparing floating point values, you will find numerous threads on just this topic!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 2
(2,174 Views)