LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with data conversion

Solved!
Go to solution

Hi all,

 

I am trying to make an A-D conversion. Conversion table is given in the attachement, as well as the vi file. I am receiving three 8bit data over serial communication and joining them to form a 24bit number (I am mentioning this so there would be no questions why am I implementing input like this). As you can see in the conversion table no output number should be greater than Vref, however in this implementation I get an output of 2*Vref.

Can anybody please help me find the error.

 

Darko

Download All
0 Kudos
Message 1 of 4
(3,157 Views)
Solution
Accepted by topic author darko_36

The conversion formula is set up for bipolar data while your VI has U32. You cannot represent negative numbers with U32 (UNsigned integer).

 

Lynn

0 Kudos
Message 2 of 4
(3,128 Views)

Hi Lynn,

Thank you for replaying, you were right that is the solution.

I will put the working program in the attachement, if anybody else needs it.

 

Darko

0 Kudos
Message 3 of 4
(3,101 Views)

You code is overly complicated. if you join 4 bytes where one is zero, masking with FFFFFF makes no difference, you just get the input back.

Also, if you would pad the three real bytes with a zero byte at the end, you would not need to rotate.

What is the original form of the three bytes? Is it a binary string? Most likely it would be sufficient to pad and typecast it to I32 directly.

 

 

(Also, your 7FFFFFFF constant should be I32, not I64!)

 

You actually don't even have to pad the string, even with a 3-byte input of 8FFFFF (in hex format) it will get cast right-aligned, still giving the expected result. 😄 (Still it is typically not advisable to feed unmatched inputs to typecast)

0 Kudos
Message 4 of 4
(3,078 Views)