11-17-2012 11:04 AM
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
11-17-2012 11:24 AM
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.
11-17-2012 12:59 PM
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! 😮
Do you have an example VI with some typical data that you need to transform?
11-18-2012 03:19 AM
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
11-18-2012 10:38 AM
You get 3 bytes, but your example is U16, i.e. only 2 bytes. Where is the rest coming from?
11-18-2012 10:40 AM
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.
11-18-2012 10:49 AM
Claus, would it be better for you to explain it in danish?
11-18-2012 11:08 AM - edited 11-18-2012 11:08 AM
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.