From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bit representation

Hi Guys!

 

How do I take the two last bit in byte 1 and put these two bit as the two first bit in byte 2?

 

Hope someone can help me! I've tried a lot.

 

 - Clausny

0 Kudos
Message 1 of 8
(2,885 Views)

Are you trying to copy those two bits, or move them?  If you're trying to move them, use the Logical Shift function.  The input will need to be at least a 16-bit (2-byte) integer.

0 Kudos
Message 2 of 8
(2,882 Views)

clausny wrote:

How do I take the two last bit in byte 1 and put these two bit as the two first bit in byte 2?


Before "trying a lot", you need to first define the problem. With only the given information, we cannot help! 😮

 

  • Which side is "last" and which side is "first"? (LSB or MSB?)
  • Which side is byte 1? (byte order)
  • What is the data type and how many bytes are there?
  • What is the definition of "put"? Overwrite the existing bits in the target location or shift them out of the way first?

Do you have an example VI with some typical data that you need to transform?

0 Kudos
Message 3 of 8
(2,873 Views)

Okay, of course. I will try to explain better 🙂

 

I am getting 3 bytes pr. sec from a bluetooth connection as input. The first byte is a status byte, the second byte is Heart Rate and the third byte is oximetry. But bit 1 and 0 in the status byte includes values form the heart rate byte. So therefore,

 

I want the last two bits representation form byte 1 (that is bit 1 and 0) to form bits 8 and 7 in the second byte which is the heart rate byte. 

 

I am not good at thes bits and bytes talk and in general 🙂 I hope this made my problem clear.

I have attached a VI but I don't think it explains a lot. I have tried to spilt byte 1 and then maybe thought I could insert the to bits in byte 2. 

 

 - Clausny

0 Kudos
Message 4 of 8
(2,849 Views)

You get 3 bytes, but your example is U16, i.e. only 2 bytes. Where is the rest coming from?

0 Kudos
Message 5 of 8
(2,832 Views)

Can you attach documentation explaining the data format?  It is still not clear how your data is formatted.  Are you trying to overwrite bits 7 and 8 in the second byte with bits 0 and 1 from the first byte, or are you trying to add two bits to the second byte in order to get a 10-bit value?  You should be clear about whether you're using 0 indexing or 1 indexing, since a byte that has bit 0 does not also have a bit 8.

 

Even if you could just put some text showing the bit arrangement of the input, and the format you want for the output, that would be helpful.

0 Kudos
Message 6 of 8
(2,831 Views)

Claus, would it be better for you to explain it in danish?

0 Kudos
Message 7 of 8
(2,827 Views)

clausny wrote:

I want the last two bits representation form byte 1 (that is bit 1 and 0) to form bits 8 and 7 in the second byte which is the heart rate byte.


Here's a quick example assuming that the heart rate is a 10 bit value. i.e.

 

We have 24 bits. The first 6 bits are status, then 10 bits of HR, then 8 bits of Oxymetry.

 

Modify as needed.

 

Download All
0 Kudos
Message 8 of 8
(2,824 Views)