LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading data from force gauge rounding off decimals

Hello everyone.  I am new to Labview and this is my first posting on the forum.  I am currently writing a program to record pull tests on crimps using a force gauge.  Everything is going fairly well for it being my first project except when the data I am reading from the force gauge is rounding off the decimals.  I am sure it is where I am using the absolute value and conversion functions but I am unsure the correct way I should be doing this.  Thanks in advance for any advice.  Also, I tried searching on this but did not come up with anything so I apologize if this is a redundant topic. 

 

 

 

data_read.png

0 Kudos
Message 1 of 14
(4,354 Views)

The reason you are losing your decimals is because of the data type you are using.

If you notice, your indicator is blue, indicating it is "I8" (an 8-bit integer).

Since it is an integer, by definitiion it has no decimal precision.

 

After you read in the data string, try converting it to SGL (single precision float, 32-bit) or DBL (double precision float, 64-bit)

Conversion.png

Cory K
0 Kudos
Message 2 of 14
(4,341 Views)

How is the decimal part being encoded in the HEX string that is returned by the force gauge.

Not knowing anything about the force gauge you might have to convert the HEX string to a float by some multiplier. Like maybe 0.001 or something.

 

The Hex String to Number returns an I32 which does not have any decimal part.

I do not think the absolute value is the cause.

Omar
0 Kudos
Message 3 of 14
(4,338 Views)

I am starting to understand.  So my problem lies in the Hexidecimal string to number command.  Could you point me to the correct command I should be using to collect the data from the string?  Thanks.

0 Kudos
Message 4 of 14
(4,326 Views)

Hi tfuller,

 

You should read the manual of the gauge!

There it should be mentioned how to interprete the bytes from the serial port.

 

0 Kudos
Message 5 of 14
(4,322 Views)

Can you post a copy of EXACTLY what the STRING is that is returned?

Including every thing like line feeds and returns.

Omar
0 Kudos
Message 6 of 14
(4,316 Views)

As I was saying I am completely new to this so I apreciate the help guys.  I realize I am probably bothersome with what is a simple problem.  When I place an indicator directly at the read buffer I get -015.55 which is actually what I am wanting other than it being displayed as negative.  data_read.png

0 Kudos
Message 7 of 14
(4,309 Views)

Give this a shot

 

Format String.png

 

The function is called "scan from string".

Here's a breakdown of the format used:
-%.2f :

"-" means its negative

"%" is used immediatley preceding a data type

".2" means use two digits of precision

"f" means use DBL precision float

Cory K
0 Kudos
Message 8 of 14
(4,304 Views)

You need the "Fract/Exp String To Number" which is two to the right of the Hex string to number you were using.

Omar
0 Kudos
Message 9 of 14
(4,303 Views)

gauge.png

Omar
0 Kudos
Message 10 of 14
(4,299 Views)