LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview random serial port Error -1073807339 VISA Read Timeout ARDUINO communication

Hi Kevin,


@Kevin_Price wrote:

You're attaching timestamps to each serial line as you receive it in LabVIEW.  Any clues available from the time intervals, or any suspicious-looking serial text?  


indeed in the first lines there often seems to be a random sign (like a chines character or a greek character). In the standalone version that happens within some of the first lines of the file. In the subVI version that happens in the first line between the timestamp and the first value and sometimes some lines dont have any values (jusrt the labview timestamp) and sometimes they have double. It looks like as it would skip the linefeed sometimes or read only the middle of a massage so its shorter.

 

___________________________

 

EDIT: [I added a delay(5) of 5ms after the Serial.flush(). The standalone version runs fine. The subVI version shows a max of 43 bytes at serial but the normal is at 0 bytes at serial. Loop execution is now around 10ms but varies a bit. It seems to run fine now for much longer, then the bytes at serial go up to around 800 and the timeout error occurs (refer to SerialFlush_subVIversion_withdelay_5ms.png]

0 Kudos
Message 11 of 16
(860 Views)

Can you try setting the Read to be synchronous?

 


@perry_tiff wrote:

In the subVI version that happens in the first line between the timestamp and the first value and sometimes some lines dont have any values (jusrt the labview timestamp) and sometimes they have double. It looks like as it would skip the linefeed sometimes or read only the middle of a massage so its shorter.

 


This looks pretty suspicious to me - I'm not sure what would cause this but it seems like bits of your messages are being interleaved or reordered. Beyond competition for the VISA library or something (not sure if that's a reasonable idea) I can't see why running as a subVI would cause a problem.

 

You also mentioned earlier that several VISA devices are opened with ports specified by an ini file. Are you sure that no other ports/subVIs are misconfigured as COM4 by accident/previous configuration?


GCentral
0 Kudos
Message 12 of 16
(847 Views)

So your NI I/O Trace screenshot shows that you're also doing DAQ simultaneous with serial in your "subvi" runs.  It strikes me that perhaps the DAQ operations are somehow interfering with serial.  Don't know exactly how, and it's not normally a problem to run both at once, but we *are* in grasping-at-straws territory.

 

By any chance are you using a cheap generic USB-to-serial converter as well as a USB-based DAQ device?  Do they share a common USB hub?   

 

Many many years ago I had a problem with a cheap USB-to-serial converter.  It would operate fine for long stretches, but once in a while there'd be a brief time where just a few of the ASCII characters would look like gibberish, seemingly because I was getting stuff in the 128-255 extended character set.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 13 of 16
(843 Views)

Hi all,

 

apologies for the late reply. I didnt have access to the application the last couple of days.

 

I changed the Arduino code slightly to avoid the buffer from filling up. Now the Arduino loop always waits for input from Labview (while (Serial.available() <=0){} ). But it still crashed randomely

 

So apparentaly it was a problem with a subVi using DAQmx. Its a digital output., and I have four lines and I created four seperate/indepenent tasks (I did that in very beginning when I did notr knew a lot of LabVIEW and itr worked fine). Anyway, now I merged all these seperate task on a single one.... and "Voila" 🙂 the VISA read doesnt crash anymore 🙂

 

But I dont know whats the connection between these things. I use all seperate USB ports on my PC and quite new, high quality USB cables.... Maybe you guys can think of something???

 

Thank you very for all the help though and I learned a lot through this!

 

0 Kudos
Message 14 of 16
(828 Views)

Ok ... Update 2 ... I was a bit over optimistic. The Arduino SubVI version crashed after 3 hours. I let the stabndalone Arduino VI run for 24 hours and it did not crash.

 

It really seems to be something is inferring if I use the CDAQ and the Arduino at the same time. What could that be?

0 Kudos
Message 15 of 16
(815 Views)

I only have a couple possible theories and I don't feel particularly strongly about either one.

 

1. There's some issue on the USB bus with corruption / contention / power savings that only shows up when you place more demand on the bandwidth & traffic with the addition of a cDAQ system.

   Maybe you can *sorta* investigate this by running a standalone Arduino vi and then also running a standalone cDAQ vi at the same time.

   You mentioned getting occasional odd characters or empty strings when data was expected.  Those are probably some good clues.  Nothing in the code you've shown would explain such a symptom, and that's why I start wondering about weird stuff like bits getting mangled due to corruption in the USB driver or something.

 

2. The execution timing of your code changes when you're doing additional things like servicing cDAQ tasks.  I would have expected a different error than a VISA timeout, but perhaps the timeout is a symptom due to an earlier root-cause error that isn't being reported out for some reason.

   The first thing I'd be investigating is whether the Arduino itself might be sending data faster than your LabVIEW app can keep up with (because perhaps your VISA loop rate slows down when you also run cDAQ code).  And then further, perhaps this overflow of data coming in puts the serial port into a failure state that isn't directly reported as an error code, but the next attempt to *use* the serial port during VISA Read will fail with a timeout error?

 

Very speculative shaky stuff, but it's all I can come up with.

 

 

-Kevin P

   

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 16 of 16
(795 Views)