LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

interfacing labview with arduino

Solved!
Go to solution

hi,

i am new in labview i am trying to send array from arduino and labview will read then after labview will increament the 0th index of array by 1 and send back to arduino i attatched my vi file there please tell me what i did wrong

0 Kudos
Message 1 of 20
(4,139 Views)

Hello nidhi11,

Not everyone has the privilege to use the latest version.

Kindly save the vi for the previous version like LV2017 or LV2016


CLD Using LabVIEW since 2013
0 Kudos
Message 2 of 20
(4,128 Views)

hi kartiknattar

i don't know to how to convert but when i click file one option is the convert in old version that i converted see is it correct or not

0 Kudos
Message 3 of 20
(4,112 Views)

Hi nidhi11,

You have converted the vi correctly.

You are incrementing the 0th element correctly. Kindly check if you are receiving the data from Arduino correctly (No. of bytes to read).


CLD Using LabVIEW since 2013
0 Kudos
Message 4 of 20
(4,104 Views)

this is the arduino code 


void setup() {
Serial.begin(9600);

}
int tbyte[5];
int rbyte[5];
void loop()
{
if(Serial.available()>0){
for(int i=0;i<5;i++)
{
Serial.write(tbyte[i]);
rbyte[i] =Serial.read()-'0';
Serial.println(rbyte[i]);

delay(500);
if(i>5)
break;
}

}
}

0 Kudos
Message 5 of 20
(4,094 Views)

what is the problem that you are facing?


CLD Using LabVIEW since 2013
0 Kudos
Message 6 of 20
(4,087 Views)

labview is not able to read the data and not sending also

0 Kudos
Message 7 of 20
(4,080 Views)

Hi nidhi,

 

labview is not able to read the data

Don't use BytesAtPort!

Your Arduino is using Println(), so just read the serial buffer "line by line"…

 

and not sending also

Your Arduino code is not receiving anything, it is just sending data…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 20
(4,071 Views)

but in arduino i and using serial.read() function for read the data then how it is  not recieving data

0 Kudos
Message 9 of 20
(4,064 Views)

Hi nidhi,

 

I'm sorry, I overlooked that Serial.Read() in your text above.

 

Can you verify in the Arduino IDE (and its debugger) you don't receive anything in the Arduino?

Do you get any errors in LabVIEW?

 

Serial.write(tbyte[i]);
rbyte[i] =Serial.read()-'0';
Serial.println(rbyte[i]);

Your Arduino is sending one byte (without TermChar), then it wants to read something from the serial buffer, then it sends another byte now with TermChar.

Your LabVIEW code is trying to read some bytes, waiting for a TermChar or your "Byte count" input. Then it sends several bytes - as much as are in your "array out" indicator.

There may be some deadlocks because of both devices waiting for input from the other communication partner.

 

Usually the scheme is different:

  1. LabVIEW is sending a command.
  2. Arduino is waiting for that command.
  3. After receiving the command the Arduino is sending some data, with TermChar appended.
  4. LabVIEW receives the full line of text.

 

What's the point of your "sending data back and forth"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 20
(4,060 Views)