12-23-2015 08:02 AM
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
Solved! Go to Solution.
12-23-2015 08:17 AM
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 ...
Bob Schor
12-23-2015 08:19 AM
The simple solution would be to just AND your U16 with 0x0FFF. That will force your upper nibble to all 0.
12-23-2015 08:25 AM
This is what happens when the complexity level goes through the roof....you forget the simple things. Thanks for the refresher on masking.
12-23-2015 08:55 AM
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. 🙂