取消
显示结果 
搜索替代 
您的意思是: 

Serial Overrun Error

已解决!
转到解答

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 项奖励
1 条消息(共 12 条)
11,545 次查看

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 项奖励
2 条消息(共 12 条)
11,541 次查看

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 项奖励
3 条消息(共 12 条)
11,539 次查看

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

serialError.png

0 项奖励
4 条消息(共 12 条)
11,538 次查看

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 项奖励
5 条消息(共 12 条)
11,514 次查看

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 项奖励
6 条消息(共 12 条)
11,497 次查看

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 项奖励
7 条消息(共 12 条)
11,487 次查看

@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 项奖励
8 条消息(共 12 条)
11,479 次查看

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

0 项奖励
9 条消息(共 12 条)
11,477 次查看

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 项奖励
10 条消息(共 12 条)
11,473 次查看