LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending String Array to and from Arduino

I want to send a string array from the arduino to labview.

I also want to be able to send the array back to the arduino.

Is there a way to send it as a packet rather than character by charactor?

CLD Certified 2014
0 Kudos
Message 1 of 46
(24,803 Views)

Hey ADrexelDragon,

If you use the Send/Receive VI you can package a lot of the characters together. This would be the easiest way I can think of to do it using the existing interface.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 46
(6,825 Views)

Thanks Kevin.

I was able to read the string array from the arduino to labview with the Send/Receive VI.

Could you show me an example of how to send a string array from labview to the arduino? I want to make the string array a constant within the arduino.

Thank you.

CLD Certified 2014
0 Kudos
Message 3 of 46
(6,825 Views)

Hey ADrexelDragon,

You should be able to use the same Send/Receive VI to send a string to the Arduino. If you are using the LIFA framework you could create a new case in the command structure that handles what to do with the string when it receives it.  Post back if you have any additional questions on this.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 4 of 46
(6,825 Views)

Hey Kevin,

I am working on the case at the moment.

Here is what I have so far:

  case 0x1E: //SerialRecieve

      for (int i=0; Serial.available() > 0; i++){

                    // read the incoming byte:

            incomingArray = Serial.read();

      }

     break;

Will I be able to use incomingArray in other cases that I call?

CLD Certified 2014
0 Kudos
Message 5 of 46
(6,825 Views)

Hey ADrexelDragon,

If you save the value to a variable on the Arduino then later cases would be able to use that data.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 6 of 46
(6,825 Views)

Hey Kevin,

If I have an array in LabVIEW and save the array in a txt file on the computer, can the arduino read the file?

This would save hassle of sending the arrray byte by byte from LabVIEW to the arduino.

Thanks for your help.

CLD Certified 2014
0 Kudos
Message 7 of 46
(6,825 Views)

Kevin,

After looking into the issue. I have noticed that the Arduino is not able to read txt files on the computer. I can open the txt file in labview and sent bytes at a time to the arduino. This is what I will have to do.

Would this code work to recieve the data in the arduino if I send the 30 (case 1E) and build the byte array from the txt file after that?

  case 0x1E: //SerialRecieve

      for (int i=0; Serial.available() > 0; i++){

                    // read the incoming byte:

            incomingArray = Serial.read();

      }

     break;

Thanks for your help.

CLD Certified 2014
0 Kudos
Message 8 of 46
(6,825 Views)

Hey ADrexelDragon,

You are correct in that you can't just use a read function to read .txt files from the computer. You need to transmit the data serially to the Arduino. If you are using the Send/Receive to send a command then the Arduino Interface will already process all the packets you send with the command into the command array.  To get data out of the command array you can just do standard array accesses.  You will have to know how many bytes you write into the command so you know how many to unpack on the Arduino side. Post back if you have questions.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 9 of 46
(6,825 Views)

Hey Kevin,

I am trying to send an array to the arduino.

Array = {100, 200, 300, 400, 500};

I am using the VISA write subvi and sending 100,200,300,400,500 one charactor at a time.

Then in the case of the arduino I am waiting for data using Serial.available() and build the array back up.

Number 1: It is not working.

Number 2:Is there a faster way?

I have also tried packaging the array into the send and recieve subvi

How to I work around the numbers 300,400,500 because of the byte overflow?

Instead of the arduino reading 300,400,500 it reads 44,144,244.

Thank you.

Message was edited by: ADrexelDragon

CLD Certified 2014
0 Kudos
Message 10 of 46
(6,825 Views)