07-26-2012 10:29 AM
Has anyone made a VI that can concatenate bit arrangements of irregular sizes (like 5 bits) together to form a byte array?
I have three 5 bit numbers that I want to put into two bytes in little endian order. Is there a a way to automatically split up the bits to just fit into the array?
What happens to the bit that is not accounted for within the 15 bits?
07-26-2012 10:38 AM
How do you currently have the 5-bit numbers stored? U8? Boolean Array? String?
07-26-2012 11:42 AM
U8 representation. Display format is binary, but not sure if that matters.
07-26-2012 12:18 PM - edited 07-26-2012 12:22 PM
You can build an array of binary values, then do "Boolean Array to Number." If you already have 3 5-element arrays, just append them. The output is a 32-bit value with all the unused bits set to 0, so you can convert that to a U16 which will have your data in the low 15 bits and a 0 in the highest-order bit.
EDIT: Alternatively you can just do some bit math such as shown in this image:
07-26-2012 12:42 PM
I was trying to come up with something more generic, but it looks like nathand might have the best solution for your particular problem. His code there will give you a U16. If you need a btye array, you can use the split number and build array.