From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read serial data from arduino uno using labview?

Hi, I am beginner of using labview and myrio..

I want to get reading from arduino to labview, but I cannot see any reading in labview..

My arduino code is

///////////////////////////////////////////////////////////////////////////

void setup() {
Serial.begin(115200);
}
int a = 0;
void loop() {
if (a == 0){
Serial.println("A");
a++;
delay(200);
}
if (a == 1){
Serial.println("B");
a++;
delay(200);
}
if (a == 2){
Serial.println("C");
a = 0;
delay(200);
}
delay(200);
}

//////////////////////////////////////////////////////////////////////////////

 

And I was also following through tutorial from youtube.

But it still does not work..

Any Idea how can I fix this problem?

 

0 Kudos
Message 1 of 2
(2,784 Views)

Are you sure you followed the you tube tutorial exactly?  Do you have a link to the video?  It might be a bad tutorial.  I've see many bad LabVIEW you tube videos created by people who've used LabVIEW for a week and then want to show the world that they are experts.

 

I see three things wrong in your VI.  First, you are using bytes at port and doing the VISA read.  That is the wrong way to do it 99% of the time.  Your arduino code shows it is sending a linefeed character (or perhaps carriage return) since it is using println.  So take advantage of that.  You have the termination character enabled by default on your serial configure.  So read a large number of bytes and you'll get a complete message whenever it comes in.

 

Second, your loop is running as fast as it can since it has no time delays in it.  So the vast majority of the time you'll have 0 bytes at port and read nothing, constantly overwriting your string display.  This in conjunction with #1 means you'll rarely see anything that you are actually getting.

 

Third, you are concatenating with an empty string from outside the loop.  Why?  Perhaps what you want is a shift register so you can continually build upon the data you've already collected.

0 Kudos
Message 2 of 2
(2,766 Views)