09-03-2019 10:28 AM
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
Solved! Go to Solution.
09-03-2019 10:40 AM
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".)
09-03-2019 10:53 AM
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
09-03-2019 10:56 AM
How do you communicate with the microcontroller?
09-03-2019 10:58 AM
All the other staff in the vi are just for troubleshooting the vi temporarily.
09-03-2019 11:00 AM
I write the binary file to the microcontroller by a RS232 port.
09-03-2019 11:04 AM
@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.
09-03-2019 11:11 AM
I am sorry for the confusion. I only posted the Hex to Bin part, not the whole program.
Regards,
Steve
09-03-2019 11:20 AM
The attached vi works. I am just wondering whether there is a easy and fast way to do it?
Regards,
Steve
09-03-2019 11:40 AM - edited 09-03-2019 11:41 AM
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.