LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary Conversion 16bit to 8bit

Solved!
Go to solution

Im having a little trouble making a labview VI for this process, where var1send and var2send are signed 16-bit integers

 

int8_t var1low = var1send & 0xff;
int8_t var1high = (var1send >> 8);
int8_t var2low = var2send & 0xff;
int8_t var2high = (var2send >> 8);

 

Any help would be awesome!

0 Kudos
Message 1 of 17
(10,162 Views)

Hi sout,

 

does the "split number" VI do that for you? It splits a 16 bit number into two 8 bit numbers. You can find it under Programming >> Numeric >> Data Manipulation.

 

 



Remember Cunningham's Law
0 Kudos
Message 2 of 17
(10,142 Views)
First, there's an issue with problem definition. You say the inputs are 16 bit but they are being anded with an 8 bit value. If the point is to isolate the least significant byte, just do that by splitting the 16 bit number.

Next you are shifting the original input by 8 bits (which will still result in a 16 bit value) and you are trying to assign it to an 8 bit value.

Frankly, it looks like the intent might be to assign the low byte of the input to the low byte of the output, and the high byte of the input to the high byte of the output. Or if the outputs are 4, 8 bit values all you need to do is split the input integer.

What is it exactly that you are trying to do?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 17
(10,131 Views)

I think your right, thanks for the help. The split number function should work.

 

Just one other thing, is there a function to convert a decimal into a signed 16-bit integer?

0 Kudos
Message 4 of 17
(10,112 Views)

Yes, there is.

 

BTW, there also is a ton of tutorials available online that help you with these things:

3 Hour Introduction
6 Hour Introduction
LabVEW Basics
Self Paced training for students

The Function you're looking for is called "To Word Integer"

Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
Learning NI
Getting Started with NI Products

 



Remember Cunningham's Law
0 Kudos
Message 5 of 17
(10,108 Views)

Sorry my mistake, i meant to say from a decimal to binary 16bit signed

0 Kudos
Message 6 of 17
(10,096 Views)

Do you mean a boolean array of the Value? And number to boolean doesn't work?



Remember Cunningham's Law
0 Kudos
Message 7 of 17
(10,088 Views)

Everything i try, doesnt seem to work.

 

Basically, I can't seem to figure out how to convert a signed 16 bit decimal number into a signed 16bit binary number and then split that

0 Kudos
Message 8 of 17
(10,084 Views)

Decimal and Binary just two representations of the same number. Right click on the Element >> Visible Items >> Radix; then click on the radix and select.

Splitting should work as described above.

 

If you still have questions, please include an example, as it's hard to guess what does work, when we don't know what you already tried.



Remember Cunningham's Law
0 Kudos
Message 9 of 17
(10,069 Views)

Ok, so this is basically what I want, i dont want to enter the number in as a binary number. Ive tried to use format into string to convert to binary, but I am not able to split the string into 2 seperate 8-bit bytes.

 

Not sure what other functions i can use to convert from decimal to binary except not in a string.

 

 

binary split.PNG

 

 

0 Kudos
Message 10 of 17
(10,052 Views)