LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strings to 7-Bit binary

Hello

I've got a question if it is possible to create from string for each charakter a 7-Bit binary code?
If it is possible, can I put these 7 bit binary to 8 bit by shifting bit 1 from the next charakter to the empty bit of the charakter before?
If there are any questions, please let me know an I try to send an example.
Thanks for tipps 😉
0 Kudos
Message 1 of 13
(4,509 Views)
Hi Sebastian,
if I understood what you mean, you want to convert the ASCII code of each string character to binary number or boolean array.
If this is correct see this example.
(in the boolean array the leftmost boolean corresponds to the LSB).
Let me know if it is of any help,
Alberto
0 Kudos
Message 2 of 13
(4,509 Views)
Thanks a lot Alberto, now I know how to get the Binary ASCII values. But I have to put the 7-Bit values to 8-bit by shifting the first bit of the 2nd char to the empty 8th bit of the first value. Can you give me a tipp in that way?
0 Kudos
Message 3 of 13
(4,509 Views)
Give this a try. The code shows a short string that is converted first into an array of U8 values. This array is displayed in "array1". This array is then converted into a 2D array of boolean values. This array is shown in "array2". In this array each row equates to one character in the input string. Finally, "array3" shows the result of reshaping the 2D array into a 1D array. Here, the first 7 bits are the "H", the second 7 bits are the "i", the third 7-bits are the space, and so on to the end of the string.

BTW, what do you need this binary output for?

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 4 of 13
(4,509 Views)
Thank Mike

I need that 7-bit binary for creating PDU-Code. But I need to shift the 7-bit value to an eight bit (see answer above)

Sebastian
0 Kudos
Message 5 of 13
(4,509 Views)
Ok, I didn't understand what you meant. Try this.

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 6 of 13
(4,509 Views)
Thank yoi Mike, that was a very good tipp. But I recognized, that the alphabet-code that is used here in LabView doesn't match to the 7-Bit alphabet that is used for the PDU-code. For example an "H" is "0111000" or an "e" is "1100101" in binary. Can you give me a tipp how to convert this code-table into my programm?
0 Kudos
Message 7 of 13
(4,509 Views)
Create a lookup table consisting of an array of U8s. The array contains the PDU values for each character. For example, H has an ascii value of 72 (decimal) so make element 72 of the array equal to 56 (0111000 in decimal). In the same way, setup the lookup table array for all the values, and use the ascii values--the contents of array 1 in my example--to index into the loopup table array.

Alternately, you could also look to see if there is any sort of fixed mathematical relationships between the two charcter maps, like the PDU code is always 16 less than the ascii code. If there is you can do the calculations of the array of ascii codes.

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 8 of 13
(4,509 Views)
Thanks Mike! I think, I'll create a lookuptable with the binary values as string, because I need the shifting and this I think I can't do with integer values in that way I need it. With a binary string I can concatenate the strings and only build the HEX code.
Or is it possible to do the shifting with binary integer?
0 Kudos
Message 9 of 13
(4,509 Views)
It might be possible to do it with integers, but it would be really messy. Better to use binary arrays.

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 10 of 13
(4,509 Views)