LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Overrun Error

Solved!
Go to solution

Hello all,

I am currently writing a basic program to read in results from an oxygen sensor that communicates via serial connection. In my current code, I keep getting an overrun error after a few times of running the program. Any suggestions as to how I can fix it? Thank you!serialError.png

0 Kudos
Message 1 of 12
(7,919 Views)

How fast is the device sending data?

 

Why are you using a timed while loop?

 

It is set to run once every second.  If your device is sending data faster than once were second, then eventually the buffer will fill up.  Use a regular while loop and don't put any timing functions in it as the communicating device will control the speed of the loop based on how fast it is sending data.

0 Kudos
Message 2 of 12
(7,915 Views)

Baud Rate: 38400

Data Bits: 8

Parity: None

Stop Bits: 1

Flow Control: None

 

The device sends an update every 10 seconds, I used a timed loop with a case structure so that it calls the Read vi every 11 loops (11 seconds, 1 extra second just to be safe), also, I have the timed loop set to 1 second so that it updates the counter gauge every seconds indicating how much longer until the next measurement.

0 Kudos
Message 3 of 12
(7,913 Views)

Also, replacing the timed loop with a while loop does nothing to help:

serialError.png

0 Kudos
Message 4 of 12
(7,912 Views)

Have you tried changing the structure of your program to a Producer/Consumer design? If not, check out Application Design Patterns: Producer/Consumer.

Hunter D.
Applications Engineer
0 Kudos
Message 5 of 12
(7,888 Views)

Your whole concept of VISA read is incorrect.  The VISA read will just sit there doing nothing until it either gets data or times out.  Don't try to control the timing of the while loop; just let the VISA read do it for you.  (Increase the timeout because I think it defaults to 10 seconds.)

 

Do you know what to expect from your equipment?  Do you know if the data ends with a termination character?  Knowing this will definitely influence the design choices that you make, and possibly even cause the error.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 12
(7,871 Views)

How much data is it sending?

 

How long does it run before the error pops up?

 

Put a Bytes at Port Property node in there with an indicator to see if the port is filling up.  Wire it up to a waveform chart to make it more obvious if it is growing in time.

 

Also, be sure you aren't using execution highlighting which artificially slows down the loop

 

I don't see how you would be getting a problem in the latest VI you posted a screenshot of unless that device is not communicating the way you think it is.

 

 

0 Kudos
Message 7 of 12
(7,861 Views)

@Gryffin wrote:

Also, replacing the timed loop with a while loop does nothing to help:

serialError.png


1) What do you see in the "read Buffer" string indicator?

2) my money is on either wrong baud rate OR garbage on the line.

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 12
(7,853 Views)

Just needed a Flush Buffer at the beginning, everything works fine now, thanks for the quick repliesfixed.png

0 Kudos
Message 9 of 12
(7,851 Views)

I think the real problem is that you never close the serial port.

 

If the serial port was closed, you wouldn't need a flush buffer because you are starting to read from it right after you configure and open it.

HOWEVER, you never close the port in your VI.  So if you stop the VI and restart it, the port will have remained open and the buffer accumulating bytes until it overflowed which you'll find out once you restart the VI.

 

You can leave the flush buffer in, but be sure to wire a VISA Close in before the VI ends.

0 Kudos
Message 10 of 12
(7,847 Views)