LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert two U8 to single 12-bit hex

Solved!
Go to solution

This should be really simple, but for some reason I'm struggling to find a solution.    I have some 12-bit Temperature sensor data embedded into two U8's.   I need to strip-out 4-bits from the MSB U8, and add them to the LSB U8 to get a temperature reading in HEX.  

 

I have attached a simple snippett VI which emulates the incoming data.   The MSB U8 is typically 04h, 14h, 84h, or 94h, depending on which sensor the FPGA is reading.   Currently, the reading goes bonkers when the  the MSB U8 switches from 04h to 14h, to read the second sensor.

 

Thanks

 

0 Kudos
Message 1 of 5
(3,218 Views)
Solution
Accepted by topic author SparkyOne

If I understand your problem correctly, you want to take an 8-bit number representing the high byte of a 12-bit quantity and basically keep the lower 4 bits.  In other words, you want to mask out (or clear) the top four bits.  Boolean functions are your Friends, here ...

Low 4 bits.png

 

Bob Schor

Message 2 of 5
(3,209 Views)

The simple solution would be to just AND your U16 with 0x0FFF.  That will force your upper nibble to all 0.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 5
(3,200 Views)

This is what happens when the complexity level goes through the roof....you forget the simple things.    Thanks for the refresher on masking.

0 Kudos
Message 4 of 5
(3,192 Views)

I actually went with crossrulz's suggestion, but accepted Bob_Schor's as the solution, since my forgetfullness of & masking was the problem.    Much appreciated.  🙂

0 Kudos
Message 5 of 5
(3,177 Views)