LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sending of 2D arrays via serial

Hi there,

 

I've been using labview for about a year and i'm working on a project which is involving a lot of arrays. I have accumulated all the data however i now need to send the data via UART (Serial). There is 6 parts that are required to be sent, 4 being 2D array and 2  DBL values. What would be the best way to go about this?

 

The order in which they are sent to serial must be as follows: 

 

1 - DBL Value

2 - 2D Array

3 - 2D Array

4 - 2D Array 

5 - 2D Array

6 - DBL Value

 

I was going to send the DBL value first by converting it to decimal string but the main issue is the 2D arrays. I've tried changing the write into an array however the serial wont accept it (Write function to serial). I've tried splitting the arrays into sperate colums however i still have the issue of sending the array over via write. Any help would be appreciated. I'm using labview 2012 SP1.

 

Kind Regards

0 Kudos
Message 1 of 6
(3,776 Views)

I'm assuming you are able to control the Read and Write parsing on both ends of this serial communication. If not, please share the device information, or at least what the device will expect in terms of delimiters.

 

If you can control how you parse the data, why not just create your own set of rules/delimiters for writing and reading the data? You could send an "ArrayStart" string before you send an array and then used commas and semicolons to control rows and end-of-rows. If this works, then you can just convert your arrays to really long strings with the correct delimiters.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 6
(3,767 Views)

You could combine all your data into a single cluster, and then flatten to a string, or XML, or JSON, send the string, then take that string and convert it back to the cluster.

0 Kudos
Message 3 of 6
(3,748 Views)

^ This ^

 

Ignore my post above if both sides of your serial communication are LabVIEW.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 6
(3,739 Views)

I'm using labview to send the read write, however i'm sending data to a MSP430G2755 then it is returning data back through serial however this data is in ASCII.

 

Could i ask you to explain by what you mean your own set of rules? Right now i know from the code within the micro that if I send a certain character via serial, then the microchip is then expecting all these arrays and data to be sent along with it (To give a better understanding, I'm trying to convert a vb program to an automated labview program. I have managed to convert the rest of the code within the VB program, this is the last part.

 

The micro is expecting certain amounts of data and once its received them it then returns it. Here is a small snippet of the code in vb.

 

Pc to Micro:

 

For Loop_Count = 0 To 75            ' Send "unsigned int MSP_Heat".

                    Cal_SLong = MSP_Heat_Table(Loop_Count)

                    Buffer(Loop_Count * 2) = Cal_SLong And &HFF

                    Cal_SLong = Cal_SLong >> 8

                    Buffer(Loop_Count * 2 + 1) = Cal_SLong And &HFF

                Next Loop_Count

                SerialPort1.Write(Buffer, 0, 152)

 

Micro to PC:

for (Tx_Count = 0; Tx_Count < 76; Tx_Count = Tx_Count + 4) {

                     Send_UART_Message((unsigned int*) &MSP_Heat[Tx_Count], (unsigned int*) &VRef[Tx_Count + 2]);

 

By the input cluster do you mean something along the lines of the attached picture? I'm not very good when it comes to clusters so not sure if ive done that correctly, Test.PNG

 

Many thanks for your help

0 Kudos
Message 5 of 6
(3,673 Views)

Here is what I was thinking.  You may need to do some work with knowing when a transmission is complete, using terminating characters, or timing, with synchronous or asynchronous VISA settings.

 

Cluster String Example_BD.png

0 Kudos
Message 6 of 6
(3,637 Views)