LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I convert 16 bit Binary to ASCII text

Hmm, so what needs to be done???

So far we know how the data is represented. What kind of input do you have and what kind of output do you want?

(Better just give us an example VI with typical data as default in a control of the desired type and a description on how the output should look like).

0 Kudos
Message 11 of 23
(2,566 Views)

Output is a +/- DBL value.

Input are two hex decimal words.

The two words need to be converted to binary (10010......) and concatenated to form a 32 bit binary number. If the first bit is a one, the bits must be flipped add a one etc. prior to performing the 2's complmentary math to arrive at a number that is then negated. If the first bit is zero, easy, just use the remaining 15 bits to perform the 2's comp math. Hope this helps

Thanks

 

0 Kudos
Message 12 of 23
(2,560 Views)
Can't you just typecast it into a I32, then convert to DBL and scale to +/- 0.5?
0 Kudos
Message 13 of 23
(2,552 Views)

I don't know?

What would your solution be for

word 1 = 624

word 2 = 2448

Max/Min Value +/- 1.0240E+03

resolution 3.8147E-06

MSB = 2^12

LSB = 2^-18

Full scale of the data 8.1920E+03

0 Kudos
Message 14 of 23
(2,547 Views)
Your problem is way overdetermined, the only thing you need is log2(MSB) (-18 in this case), which gives the resolution.
 
(I don't know why you need the "min/max" and "full scale" and all that. Do you need some additional scaling?)
 
Anyway, the attached (LabVIEW 7.1) is one possibility. You should really check it with some inputs that yield a negative number, though.
 
 
My result for your sample inputs (624,2448) is about 156.

Message Edited by altenbach on 06-21-2006 02:02 PM

Download All
Message 15 of 23
(2,530 Views)


@altenbach wrote:
... log2(MSB) (-18 in this case)...

Log2(LSB) of course. Sorry for the typo. 😉
0 Kudos
Message 16 of 23
(2,510 Views)

altenbach,

You VI is simple and works with negative numbers. More importantly, your VI provides verification for my VI.

Thank you

Where can I send your 2 - JDAM product patches?

0 Kudos
Message 17 of 23
(2,501 Views)
Jdam,
 
My services here are freely volunteered. 😄 I am glad to help!
(Of course stars are always appreciated, so don't forget to rate my contributions if you have not done so already ;))
 
(Somehow, I doubt that I have any personal use of any jdam products in the near future. 🐵
0 Kudos
Message 18 of 23
(2,490 Views)

Altenbach - You are five stars in my book.

I came accross a new problem that I was wondering if you could assist to simplify?

Same type data 16 bit word

Field name    Bit No   Description

Integer             -00- S     Sign Bit

                        -01- N     MSB

                        -02- ..... -10- N

                        -11- N   LSB

Exponent         -12- E   MSB

                         -13-....-14-

                         -15- E   LSB

Integer    Resolution 1    MSB 2^10    LSB 2^0

Exponent  Resolution 1  MSB 2^3      LSB 2^0

Is there a simple way of handling this problem?  

 

0 Kudos
Message 19 of 23
(2,478 Views)
Since the LSB of the mantissa is 1 and the exponent is always positive, the result is always an integer and will fit into an I32.
 
I also assume that the exponent is meant to be base 2, i.e. the desired result is (mantissa x 2^exponent). If the definition is different, modify accordingly.
 
Here is a simple possibility to convert to I32 according to the given rules, see if it gives the right answer for you. Sorry, I cannot test this. No guarantee that its right. 😉
 
 
 
 
 

Message Edited by altenbach on 06-22-2006 03:52 PM

Download All
Message 20 of 23
(2,472 Views)