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: 

How to read Serial Data from Arduino using labview VISA?

Solved!
Go to solution
Another identical post.
0 Kudos
Message 41 of 141
(4,865 Views)

HI this information is very helpful. but can you explain me the way with same codes I want to use 3 analoge values to read, lets say Pin 0, Pin 1 and Pin 2. How to i design and seprate strings in Labview and sample VI to demonstrate this example.

 

Thanks

 

 

0 Kudos
Message 42 of 141
(4,757 Views)

Hi,IMG-20140410-WA0005.jpg

 

 

My project is to control the speed of the dc motor(Hardware) using PID controller in LabVIEW. For interfacing Labview with dc motor, I am using Arduino Uno. For encoder, I am using Optocoupler and a schmitt trigger.

 

I have attached a vi and a pic of the encoder.

 

I tried to run the closed loop code using an encoder(Optocoupler and a schmitt trigger In the feedback path) to measure the speed of the dc motor. I am getting an error 5001 and in the error its mentioned pin 0 & 1 of arduino are reserved for communication with LabVIEW. But where do I connect those pins. On the arduino board, pin 0 & 1 are Rx & Tx pins. Also the moment I connect my USB cable to the laptop, my motor starts moving.

 

Please help me in this.

 

Thanks & Regards,

 

Neelam Punjabi

0 Kudos
Message 43 of 141
(4,464 Views)

i have used your vi to read the value from sensor. but then, may i know how to read value from many sensors?

0 Kudos
Message 44 of 141
(4,371 Views)

Hello, ABCPrograms,
I've been working on a project similar this one which you mentioned some explanations. I need to read the serial data from arduino on Labview interface.
Well, your post helped a lot, but I got another problem. It's pretty fast now; however, I cannot get stable data, I mean, it changes all the time between positive and negative values. So, the values on the screen blink all the time and it is not good to see the information on computer. 

Maybe, you can help somehow.

I thank you antway.

Diego

0 Kudos
Message 46 of 141
(4,161 Views)

In your code, you need to establish how many bytes you're transmitting and in LabVIEW how many you're receiving.  I've attached some code that I guarantee you will be very helpful if you look through it.  You'll want to check out the Arduino forum about sending data via serial Port if you're having any issues.  My code was meant to read VAC  on the analog channels and send the A/D values to LabVIEW via Serial and then have the data transposed into something readable and then from there into RMS.  LEast that's what I think.  It's been a year.

Message 47 of 141
(4,154 Views)

I saw what you did and I tried to do the same in my project. It worked close, but not enough. It can get the data from Arduino, but sometimes it loses the information and shows 0. Then, it gets the data again and shows the correct value. Do you think the problem is in the Arduino code? I think the Arduino that I have been using is not too fast to send data to computer. I dont know.

0 Kudos
Message 48 of 141
(4,131 Views)

It's possible your data is not being packaged correctly (very likely).

Below is the code I use to package.  Make sure you have your MSB and LSB being sent correctly and that LabVIEW is pulling the data correctly.  If LabVIEW pulls and interprets the LSB 16 bits of a 32 bit Variable, that value will probably be still correct (dependent on on the value of the variable of course) then it'll pull the next 16 bits of the 32 bit variable and that value is going to be 0.  Make sure that if you're trying to send a 32 bit variable that LabVIEW stores all 32 bits into one variable and that the MSB and LSB are in the correct place.

 

  if (BufferReady1) {                                      // Is Buffer1 ready for data transfer
    BufferReady1 = false;                                  // Set the flag to false because data will be sent
    for (int i = 0; i < DATA_SAMPLES; i++) {               // sample to be sent
      for (int j = 0; j < ADC_CHANNELS; j++) {             // channel to be sent
        for (int k = 1; k >= 0; k--) {                     // two bytes
          Serial.write(Vms1[j][i] >> (k*8));               // Send the bytes via the serial with MSB on "Left"
        }
        for (int k = 1; k >= 0; k--) {
          Serial.write((RMS(Vms1SquaredMean[j])) >> (k*8));
        }
      }
    }    
 }

 

Message 49 of 141
(4,125 Views)

Hi Guys!!! i think have a similar problem. i would like to read datas from a sensor pass them to arduino then to labview in a continuous process using the labview interface for arduino tool (LIFA). How deeply appreciate if someone could point  some VI'S to get started!! thanks a million 

0 Kudos
Message 50 of 141
(4,087 Views)