06-29-2015 02:37 PM
Hello,
I am interested in sending an array of various data types over a serial connection. I currently have what the bit structure of the data message is supposed to look like and now need to implement it in Labview. Any help would be greatly appreciated.
06-29-2015 02:40 PM - edited 06-29-2015 02:41 PM
You want to use NI-VISA to do the serial communication. VISA communication is via strings, so you need to convert to/from strings in order to transfer data.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-29-2015 03:56 PM
06-30-2015 07:15 AM
Hello,
Thank you for your reply. Here is an example of what my byte structure looks like:
Data Type Byte Number
Numeric 0
Numeric 1 - 4
Numeric 5- 8
Boolean 9 - 12
Enum 13 - 16
This goes on for approximately 256 bytes. I need to send them in the order they are listed over a Serial connection. I will also need to read from an external non-National Instruments device through serial, which will have a different byte structure with the same Data Types.
Each variable is 4 bytes long, with there being a few status bytes at the very beginning being 1 byte.
Any help is appreciated.
Thank you.
06-30-2015 07:24 AM
If the byte order is always the same, I would just make a cluster with all of the data and then use Flatten To String. You can then send that string using the VISA Write.
For the read, I would do the same thing except read with the VISA Read and then Unflatten From String.
06-30-2015 12:39 PM
Ok thank you. I am going to go with the flatten to String method. I have another question. I need to run a for loop that performs certain operations depending on the value of N, but after it runs an N number of times, I need it to reset the N to 0 and repeat this process. I think shift registers are the method I should use but I am not entirely sure of the syntax.
06-30-2015 12:45 PM
@Scaz wrote:
Ok thank you. I am going to go with the flatten to String method. I have another question. I need to run a for loop that performs certain operations depending on the value of N, but after it runs an N number of times, I need it to reset the N to 0 and repeat this process. I think shift registers are the method I should use but I am not entirely sure of the syntax.
A For loop inside of a While loop? Specific operations based on the value of N would be a Case Structure with N wired to the selector. I think that's what you're getting at, but I can't be sure because your sentence structure could mean N different operations, or a single operation based on the value of N.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-30-2015 12:53 PM
It would be a single operation based on the value of N.
06-30-2015 12:59 PM - edited 06-30-2015 12:59 PM
@Scaz wrote:
It would be a single operation based on the value of N.
Specific operations based on the value of N would be a Case Structure with N wired to the selector, all inside of a While loop. Use a shift register if you need the previous loop's values.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-30-2015 01:06 PM
Ok, thank you. I understand that part. My question is, how do I continuously run this loop N number of times, resetting it back to 0 after each N times. I need to repeatly send data over a serial connection that sets certain fields to certain values depending on this N value. Each iteration is one message and after N number of times, it resets and repeats the process. Hopefully this clarifies.