LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to easily convert Hex string to Binary string?

Solved!
Go to solution

Hi,

I want to write a microcontroller by using LabVIEW 2015. I need to convert a Hex string to a Binary string. In the attached vi, it does the job. However, I have to create a file. After the binary file is read, I have to delete the file. It slows down the process. I am just wondering whether there is a easy and fast way to do that? I am using LabVIEW 2015. An example hex file (Program Memory.bak) is attached. After running the attached vi, a binary file is created automatically.

Any help will be appreciated.

Steve

0 Kudos
Message 1 of 12
(236 Views)

Is it not really different to operate on a string in memory or from a string from a file. Not sure where you have problems.

 

(Also, none of your local variables are needed and could even give rise to race conditions. You can set the execution option to "clear indicators when called".)


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 2 of 12
(223 Views)

Thank you for the reply. I want to convert Hex string to Binary string directly to write to a microcontroller, instead of to create a binary file, read the binary file and in application program to delete the binary file after the binary file is read. All the other staff in the vi are just for troubleshooting the vi.

Regards,

Steve

 

0 Kudos
Message 3 of 12
(209 Views)

How do you communicate with the microcontroller?


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 4 of 12
(202 Views)

All the other staff in the vi are just for troubleshooting the vi temporarily.

0 Kudos
Message 5 of 12
(201 Views)

I write the binary file to the microcontroller by a RS232 port.

0 Kudos
Message 6 of 12
(199 Views)

@Shijie wrote:

I write the binary file to the microcontroller by a RS232 port.


But how? Using LabVIEW?

 

You seem to have a communication problem, not a conversion problem. Maybe you can have a moderator fix the subject line.


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 7 of 12
(192 Views)

I am sorry for the confusion. I only posted the Hex to Bin part, not the whole program.

Regards,

Steve

0 Kudos
Message 8 of 12
(183 Views)

The attached vi works. I am just wondering whether there is a easy and fast way to do it?

Regards,

Steve

0 Kudos
Message 9 of 12
(169 Views)
Solution
Accepted by topic author Shijie

Allow the FOR loop to build an array of U8 and then use Byte Array To String to convert to your string.  You should also use the "offset" on the Scan From String so you can avoid a lot of string memory allocations.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 10 of 12
(153 Views)