From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timeout when using Modbus vi

Solved!
Go to solution

Hi,

 

I am developing a .vi that polls data from two seperate flowmeters and a D-A converter via Modbus.  The interface on the flowmeters are set at address 111 and cannot be changed so I cannot use the same master to get both flowmeters data.

 

Ive attached a picture of the code for reference. Ive only included the Modbus portion so as not to confuse the issue.  

 

The problem is, when I change the timing of the loop to 5 seconds, I get timeout error 61 from the modbus reads and the re-connect loops try but cannot re-connect them. When the timing is 3 seconds or quicker, they work perfectly.  At 4 seconds, I get intermittent errors and the re-connect case works fine.

 

3 seconds or less = works fine

4 seconds = occasional errors

5 seconds = no work.

 

I'm not an expert at Modbus for sure.  So please excuse my messy code.  I intend to clean it once I get it working correctly.

 

My flowmeters are RS-485, 38,400 baud, Modbus RTU.  They connect to ADAM 4017 modules that I use Modbus TCP to connect to.  The A/D converter is also Modbus RTU and its on the same circuit as the MMin meter and its address is 3.

 

Any help and/or guidance would be appreciated. I can attach the entire .vi if necessary.

0 Kudos
Message 1 of 3
(5,152 Views)
Solution
Accepted by topic author zener3

Firstly, I wanted to note that it looks like you're using a different API from the NI-supported Modbus API, so take my answers with a grain of salt.

 

As a complete shot in the dark, it's possible that the device you are communicating with requires some sort of communication within a timeout period otherwise it goes into some idle state after connecting. For example, if you make a Modbus TCP connection and then no communication happens for over 4 seconds, the slave goes into some idle state. This does not seem like a likely problem, but it's something to look in to. Due to the fact that I'm not familiar with the API you are using, I don't think there's much more I can recommend.

Message 2 of 3
(5,110 Views)
Solution
Accepted by topic author zener3

Found the issue!

 

The ADAM 4017 modules had a "Host Idle timeout" set at 4 seconds.  I increased this timeout to 10 and now I can poll at 5 second intervals just fine.

 

Your answer got me looking at the settings again on the Adam modules and thats where I discovered the solution.

 

Thanks!

0 Kudos
Message 3 of 3
(5,091 Views)