Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

Modbus TCP timeout issues with S7-1500 - driving me insane

Last updated on 2 days ago
K
KevinVeteran Member
Posted 2 days ago
Reply by veteran_plc_tech | 1 day ago

Not to be that guy but have you confirmed the flow meter actually supports Modbus TCP or is it Modbus RTU over TCP? Some vendors lie about this in their datasheets and it'll cause exactly the symptoms you're describing. Also check if there's a firmware update for the flow meter, I know you said the vendor claims it's fine but I've seen so many devices with buggy Modbus stacks that get fixed in updates. Last resort - put a Moxa gateway between the PLC and the flow meter to handle the Modbus translation, sometimes that's easier than fighting with the direct connection. Those things are bulletproof in my experience.
K
KevinVeteran Member
Posted 2 days ago
Reply by SiemensProgrammer_Kate | 2 days ago

500ms should be totally fine unless the device is garbage tier. One more thing to check - in TIA Portal under your Ethernet interface settings, make sure you don't have any weird security settings enabled like "block external access" or funky firewall rules. I've seen that cause random drops before. Also double check your MB_CLIENT configuration, specifically make sure you're using the right function code - if you're trying to read holding registers make sure you're using FC3 not FC4. And honestly if the Wireshark captures are too much, just capture for like 30 seconds right when it fails, filter by the flow meter IP address and look for TCP retransmissions or RST packets. Those will tell you exactly where things are breaking down.
K
KevinVeteran Member
Posted 2 days ago
Reply by frustrated_controls_guy | 3 days ago

Kate I'm calling it in a cyclic interrupt at 500ms which I thought would be fine but maybe that's still too fast? The vendor doc says it supports 10 requests per second but who knows if that's actually true. Jason I haven't tried the disconnect mode, that's a really good call - I'll test that tomorrow. Pedro we're using a Stratix 5700 managed switch and yeah IGMP snooping is enabled, didn't even think about that. Gonna check those settings. I did try Wireshark yesterday but honestly the captures are so massive I couldn't make sense of them, might need to filter better. This is for a water treatment plant so downtime is a huge deal, management is breathing down my neck hard.
K
KevinVeteran Member
Posted 2 days ago
Reply by network_guy_pedro | 3 days ago

I'm gonna go a different direction here - this smells like a network infrastructure problem not a PLC or Modbus problem. Random timeouts that require a power cycle scream ARP cache issues or switch port problems to me. What kind of industrial switch are you using? Is it managed or unmanaged? I've seen unmanaged switches cause this exact behavior when they get confused about MAC addresses. Also check if you have any kind of IGMP snooping or spanning tree enabled on your switch, those can cause intermittent drops on Modbus TCP. Try putting the PLC and flow meter on a completely isolated switch, just those two devices, and see if the problem goes away.
K
KevinVeteran Member
Posted 2 days ago
Reply by ModbusDebugger_Jason | 4 days ago

Kate's questions are good but I'm betting money this is a keep-alive or TCP connection management issue. A lot of these cheaper Modbus devices don't handle persistent connections well and they expect the connection to close between requests. Try setting the connection mode to disconnect after each transaction instead of keeping it open - there's a parameter for that in MB_CLIENT. Also use Wireshark to actually see what's happening on the wire, you might be sending malformed requests or the device might be sending back garbage that's not getting caught. I spent 2 weeks once chasing a similar issue and it turned out the flow meter was expecting big-endian byte order and we were sending little-endian, drove me absolutely bonkers.
K
KevinVeteran Member
Posted 2 days ago
Reply by SiemensProgrammer_Kate | 4 days ago

Okay so first off, take a breath because Modbus TCP issues are literally the worst to troubleshoot lol. Few questions - are you calling MB_CLIENT cyclically or just on demand? If you're calling it every scan cycle that could be overwhelming the flow meter, I'd put it on a timed interrupt or at least add some logic to space out the requests. Also 5 seconds seems really long for a timeout, we usually use 1-2 seconds max. What's the scan time on your PLC? And this might sound dumb but have you checked if there's any other device on the network trying to poll that same flow meter? I've seen building automation systems randomly trying to talk to field devices and causing all kinds of weird conflicts.
K
KevinVeteran Member
Posted 2 days ago
Posted by frustrated_controls_guy | 5 days ago

Alright I'm about ready to throw my laptop across the room here. I've got an S7-1500 (CPU 1515-2 PN) trying to communicate with a third-party flow meter over Modbus TCP and I keep getting random timeouts every few hours. The connection works fine for a while, then just drops and won't reconnect until I power cycle the flow meter. I've checked the IP addresses like 50 times, subnet masks are correct, I can ping the device consistently with no packet loss. Using MB_CLIENT in TIA Portal V17, timeout set to 5 seconds. The flow meter vendor swears their device is fine and "works with everyone else." Anyone dealt with this nightmare before or do I just need to find a new career?
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?
Users Online Now
Guests Online 11
Members Online 0

Total Members: 21
Newest Member: brijamohanjha