LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read error -1073807360 interface with Arduino

Hi,

 

I'm making a VI that reads data coming from Arduino UNO at 9600 bauds to color a graduated bar according to its value. However, I'm getting a -1073807360 error which I can't solve as I don't know the reason. I always get a 0.23 in the string output in VISA read function. I would also like to know if type cast "type" must have a value different from 0 or whatever. I don't understand why it shows "0" if I only want to cast string to single precision. 

 

Find attached the VI.

 

Thanks!

0 Kudos
Message 1 of 11
(963 Views)

a couple of things:

 

  1. Don't use a Timed Loop it is unnecessary and the Timed Loop is intended for use with LabVIEW PGA and Realtime targets.
    1. Use the VISA Time out for this.
  2. I do not see the VISA Configure Serial Port VI, how are you configuring the serial port? 
  3. Most Serial Communications issues can be solved by watching this video
    1. VIWeek 2020/Proper way to communicate over serial
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 11
(933 Views)

1. I used a timed loop because I want to control how many times it inputs data. The idea is to have a sampling frequency of 50 Hz.

2. I don't understand what you mean. I saw a tutorial and thought it was just open VISA->read VISA->close VISA. Are you talking about a block I have to add somewhere?

 

Thanks!

0 Kudos
Message 3 of 11
(928 Views)

@bitsandscience wrote:

1. I used a timed loop because I want to control how many times it inputs data. The idea is to have a sampling frequency of 50 Hz.

2. I don't understand what you mean. I saw a tutorial and thought it was just open VISA->read VISA->close VISA. Are you talking about a block I have to add somewhere?

 

Thanks!


1. Your Arduino is setting the sampling rate.  The VISA Read will sit there and wait up until the timeout or the termination character is read.  Therefore, the Arduino is what is actually setting the loop rate.  Timed Loops also bring in all kinds of other issues and overhead that you do not need.  Convert the Timed Loop to a normal While Loop.

 

2. Use the VISA Configure Serial Port instead of the VISA Open.  This way, you can make sure you are using the proper settings (baud rate, termination character, timeout, etc.).

 

3. Could you supply your Arduino code?  I question your messaging protocol.  Either your protocol needs a lot of tweaks or you are converting the data incorrectly on the LabVIEW side.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 11
(919 Views)

1. OK, I thought it was going to be slow without a timed loop, that's why I put it like that. I will change it, then.

2. OK.

3. Sure, here it is (can't attach it):

 

void setup() {
  Serial.begin(9600); //set bauds

}

void loop() {
  int sensor_val= analogRead(A1); //read input
  float volts_out=sensor_val*(5.0/1023.0); //convert input to volts
  //float milliamps=(volts_out/5.0)*1000.0; //IGNORE THIS LINE
  //Serial.println(milliamps, 3); //IGNORE THIS LINE
  Serial.println(volts_out);
  delay(20);
}

 

Thanks a lot!

0 Kudos
Message 5 of 11
(916 Views)

Nice and simple sketch.  Now the Serial.PrintLn converts your number into an ASCII format before transmitting.  So to interpret the data, you need to use Fract/Exp String To Number since it is designed interpret ASCII.

 

Here is how I would do your LabVIEW code in order to read the data as it comes in and properly interpret it.  As discussed earlier, use a While Loop instead of a Timed Loop.  Use Fract/Exp String To Number to convert the message to a number.  The Case Structure can accept integers and use ranges, making the coloring a lot easier to read.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
0 Kudos
Message 6 of 11
(846 Views)

Thanks for the advice, but I am still getting the same error out from VISA configure serial port, even from the design you attached. 

 

I also set this in Arduino:

 

Serial.setTimeout(10000);
 
in order to match the one that comes by default in LabView. I opened all the constants to see if they are the same as device manager says and they do. If I open VISA configure serial port I see that error is "property node (arg. 8)". What could be going wrong?
0 Kudos
Message 7 of 11
(839 Views)

Since the Arduino is not receiving anything, its timeout is not required.

 

You are getting an "Unknown System Error".  Do you have the port opened in another application, such as the Arduino interface?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 11
(832 Views)

Okay, so no timeout.

 

No, the serial monitor/serial plotter is closed every time I run labview VI. Even if I close the Arduino IDE, it gets same error.

0 Kudos
Message 9 of 11
(830 Views)

Okay, rebooting PC was the solution. 

 

Thanks a lot 😉

0 Kudos
Message 10 of 11
(790 Views)