02-17-2020 01:15 AM
Hi guys,
I am struck with my project. I hope you guys can help me resolving it.
I am reading a excel file which has numerical data in it and i am making some calculation with it. I want to convert the numerical data into 8-bit binary format and i want that binary number to be sent to one of my serial port in my laptop so that i can read it with a microcontroller.
So i am using NI-VISA WRITE function to write the data to one of my Serial COM port. NI-VISA WRITE function can send only string format to the COM port. All i need is 8-bit binary numer on the output(Serial COM port).my VI
Solved! Go to Solution.
02-17-2020 02:19 AM - edited 02-17-2020 02:26 AM
You can either build a U8 array, then Type Cast or Flatten it to a string.
With Type Cast, only binary data are converted to the string; with Flatten to String, an I32 header may be added (and it is by default) meaning the number of array elements. Also, with Flatten to string you can select the byte order.
In the picture below, the string content in hex format is shown (two characters per byte).
If you send data continuously, you may need to add some control character (a start byte sequence, for example), to help the receiver to separate subsequent packets.
02-17-2020 05:43 AM
@pincpanter wrote:
If you send data continuously, you may need to add some control character (a start byte sequence, for example), to help the receiver to separate subsequent packets.
If we are actually sending raw/binary/hex values over the serial port, then a typical method is to have a start byte (0x02 is common) followed by a message ID and/or a message length, the the data and finally a checksum of some type. This allows the receiver to find where the message actually starts and validate the message was properly received.