ni.com is currently experiencing slowness/issues due to ongoing maintenance.

Support teams are actively working on the soonest resolution.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ascii to Binary to Ascii

Hi all,
I am required to convert a data file from ascii to binary for transmission, then back to ascii at the destination point for analysis. Any ideas of how to do this as I have only been introduced to Labview in the last week and am unsure. I have seen the vi that converts ascii to binary but am unsure how to apply this and whether I need to save the converted data using the binary file vi, write to I16 or SGL file. Any help would be fantastic.
Thanks
0 Kudos
Message 1 of 5
(8,117 Views)
Hello,

use "String to byte array" VI that founds in "String"\"String/Path/Array conversion" palette.
This vi create Array of unsigned bytes from string, where each byte is number from 0-255 that represents ASCII code of corresponding letter in the string.
There is also VI-"write binary file" that just get this byte array. If you want read binary file use "Read binary file". You will get byte array. Use "Byte array to string" and you will get your ASCII data.
0 Kudos
Message 2 of 5
(8,117 Views)
You are not specific about the kind of transmission. In general, whether I see 8bits of data as a number or a character lies just in the eye of the beholder. So make sure nothing happens to these 8 bits (Labview does not yet know of 16 Bit characters) and there should be no problem.
Storing characters as SGL (floatingpoint numbers)makes no sense. Characters don't have of decimal points. Use U8 if you do not want to use a string right away.
Gabi
7.1 -- 2013
CLA
Message 3 of 5
(8,117 Views)
I have included a vi in LV 6.0 to show you what tools to use as explained by Nadav. And where i have shown the Byte array, i have changed the format to binary so you can see the 8 bits per ascii character. But, if you look at the saved data file it is in ascii format with spaces so this infact does not compress the data.

I have also included a string to binary string conversion which basically shows the binary code in string format rather than byte array. Although i would not use this to transmit data as each 0 or 1 in string format would be encoded by 8 bits itself!

I'm not quite sure why you need to convert the ascii file to binary and how you are going to transmit this data, but i hope this helps you.

Kim
Message 4 of 5
(8,117 Views)
Thanks to all of you for your help. Especially Kim and Nadav, I think by incorporating your vi with my ideas will get it working to a satisfactory level. I have used the write characters to file vi in the conversion back to ascii which eliminates the spaces.
I hope you can answer any questions I have in the future with the same thoroughness. Thanks again.
0 Kudos
Message 5 of 5
(8,117 Views)