LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to combine two 8 bit numbers to make a 16 bit number??

Hi

My electronics ADC ouputs the result of the conversion over two bytes because it is a 10 bit number. This is then fed into Labview via the serial port. I have the two bytes stored in the various elements of an unbundle block diagram.

My current vi has the two bytes stored seperately. HOw may I combine the two together??

So far I have

1st byte sent : (MSB)bit7/bit6/bit5/bit4/bit3/bit2/bit1/bit0(LSB)
2nd byte sent : (MSB)X/X/X/X/X/X/bit1/bit0(LSB)

I can send the two bytes from my electronics in either order, whichever suits labview the best.

At the present time, byte 1 max value is 255 and byte to is 3

I would like to combine these two arrays to form the following:

(MSB)X/X/X/X/X/X/bit9/bit8/bit7/bit6/bit5/bit4/bit3/bit2/bit1/bit0(LSB)

This way, the combined two bytes has a range up to 1048, a true representation of the ADC value. This value can then be converted and displayed on a dial.

If anybody has any ideas or help it would be appreciated. I can attach a vi to explain what I am doing if that helps/or my details above are unclear.

Thanks
0 Kudos
Message 1 of 11
(12,691 Views)
Hi

There's a function called "Join Numbers" in the Advanced>>Data Manipulation palette.

This function joins two numbers.

Just have a try.

Hope this helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 2 of 11
(12,686 Views)
Try the 'Join Numbers' function in Functions>Advanced>Data Manipulation palette.
=====================================================
Fading out. " ... J. Arthur Rank on gong."
0 Kudos
Message 3 of 11
(12,682 Views)
Brilliant. Thanks

Will try that and see if I can get it to work.
0 Kudos
Message 4 of 11
(12,675 Views)
"Join Numbers" will not work if bit1 of byte 2 is a sign bit. "Join Numbers" does not know that you have a 10 bit signed integer. In this case you need to make sign expansion on your own.

Use "join Numbers" to get the 16 bit representation. Then mask (0x0400) out bit 9 with an And. If the bit is set then set bit 10 to 15 by Oring with the right mask (0xFC00).
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 5 of 11
(12,650 Views)
Hello Waldemar,

can you send me your example code?

Regards, Stefan
0 Kudos
Message 6 of 11
(12,601 Views)
Since the resulting 10bit number has a range of 0 to 1023 (and that is what you want), you don't need to worry about sign bits. "Join numbers" will work just fine straight off the shelf. 🙂
0 Kudos
Message 7 of 11
(12,583 Views)
Sign extention of a 10 bit integer. Input two bytes, Output signextended 10 Bit. The output value will be in the range from -512 to 511. No check if Highbyte is greater than 3!
Code in LV 6.0.2
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 8 of 11
(12,562 Views)
Hi Waldemar,

I like your code very much!!!
I changed it a bit and made some comments.

Regards, Stefan
0 Kudos
Message 9 of 11
(12,480 Views)