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: 

How to convert a string to binary?

Hello!

We wonder if there is a VI for converting from a string to a binary number?

Best regards!
0 Kudos
Message 1 of 12
(4,808 Views)
In the String palette there is a Num/String conversion sub-palette.
Use the decimal string to number VI.
Right click the indicator you get from this VI, and select Format & Presicion.
Select Binary on the left.
If you want to get a boolean array, there is the number to boolean array VI in the boolean palette.

___________________
Try to take over the world!
0 Kudos
Message 2 of 12
(4,797 Views)
Hi,

Within the string palette is a string to U8 array.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 3 of 12
(4,797 Views)
Hello!

Thank you for your answer. Now we wonder how to be able to use this binary number in VI-s that comes after this? Cause when we do as you suggest we only have an indicator. Then one can´t pick out the numbers. We want to pick out bit number 0 and 1 for example from the binary number we get in the indicator.
Thank´s for your kindness 🙂
0 Kudos
Message 4 of 12
(4,790 Views)
As I suggested earlier, use the number to boolean array VI.

___________________
Try to take over the world!
0 Kudos
Message 5 of 12
(4,787 Views)
By the way, Ray's suggestion is for converting an ASCII character into a number. Mine was for converting a "1101001010..." string into a number. In both cases, after you get the number, you can use the number to boolean array VI and you'll get a 1D boolean array in which each element is a bit.

___________________
Try to take over the world!
0 Kudos
Message 6 of 12
(4,783 Views)
I'm sorry, I seem to be having tremendous difficulty with my lifestyle.
I guess I'm a bit sick, almost everything I wrote until now was pure rubbish.
To compensate, I wrote a small VI to do what you asked, but with the way I'm feeling, I'm probably going to find out that there's a better way to do this.
Anyway, Here's the VI.

___________________
Try to take over the world!
0 Kudos
Message 7 of 12
(4,774 Views)
Or like the attached.
0 Kudos
Message 8 of 12
(4,772 Views)
Hello!

We are very greatful for your help. We might come back 🙂

Best regards!
0 Kudos
Message 9 of 12
(4,745 Views)
Hello again 🙂

Your VI-s has helped us a bit but now we need answer to another thing. We explain the whole problem for you and if anyone would like to give any tip we are greatful.

Here we go: For example we have a string (ASCII-format) that is 1A (two bytes and hexadecimal) that we want to convert to binary. Then we have another string that is for example 1B. This one we want to convert to binary and then pick out two of the bits and put together with the 8 bits we get from the first cinversion. Then we have a ten bits binary number that we want to convert to a decimal number. Is this possible to do? We got a little help of your VI-s that convert to boolean but we have a string that is as we explained now. Have anyone got a tip for us? 🙂 Thank you.
Best regards
0 Kudos
Message 10 of 12
(4,735 Views)