ni.com checkout is currently experiencing issues.

Support teams are actively working on the resolution.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with sending some values from arduino to labview using VISA

Hello,

I'm having a problem with sending some values from Labview to Arduino.

Arduino read ASCII code instead of the value, so I convert it in Arduino and display the value in Labview.

It's doing fine for 3digit input. But not with 2digit or 1digit.

For 2digit value,i nstead of just sending 99, Labview send 990 to Arduino. For 1digit, it send 900 instead of just 9.

Download All
0 Kudos
Message 1 of 8
(4,231 Views)

Have you tried just using LIFA (LabVIEW Interfce for Arduino) for which this section is named?  It might make life easier once you set it up.

Otherwise, this should work:

void loop()
{
     if(Serial.available()>0)
     {
          value = Serial.read();
     }
     setLed(0,value);
     delay(500);
}

and

send_single_byte.png

0 Kudos
Message 2 of 8
(3,214 Views)

Hello Nathan,

I've tried your suggestion, but the output comeout wrong,

It supposed to be linear from 255 to 0.

Please help me.

0 Kudos
Message 3 of 8
(3,215 Views)

I've also tried to use the old Arduino code, the output is Linear, but still wrong.

0 Kudos
Message 4 of 8
(3,215 Views)

The way that you have your code implemented in LabVIEW, you will never get the correct output from the Arduino.  Having said this, the image you have named as Untitled.jpg is what I would expect to see (or something similar).  It is because you are reading single bytes in LabVIEW when you are trying to send multiple byte representing one number from Arduino.

Does the LED act correctly with my code?

0 Kudos
Message 5 of 8
(3,216 Views)

It works as it displayed in LabView.

I've tried it again, and for the first loop, the output is inconsistent, then the second loop is less incosistent, in the third loop, the output finally right.

But when I've tried it again, it won't come out right till the 4th loop.

Then, what should I do?

Download All
0 Kudos
Message 6 of 8
(3,216 Views)

You are pulling random bytes from the serial stream when you try to read from the Arduino inot LabVIEW.  This is why you are seeing random behavior.

I don't really understand why you are sending back the exact same information that you just sent to the Arduino.  If you could explain your actual end goal for the project instead of your intermmediate goals then we might be able to better understand what you are doing.

0 Kudos
Message 7 of 8
(3,216 Views)

Actually, I'm trying to send the data from Labview to digital potentiometer.

I connect the digital potentiometer with Photovoltaic Cell, the actual data that i need is the voltage in that circuit when the resistance is changed.

But I found out later that the Arduino didn't read the value right, so the digital potentiometer didn't work like what i expected to be. But the data voltage which appeared in Labview is the same as what i measured using Multimeter,

So without using photovoltaic, i tried to read the output directly from digital potentiometer and it shown as it is now.

That's when I conclude that Labview didn't send the data llike I what expected it to be.

0 Kudos
Message 8 of 8
(3,216 Views)