(no subject)
akrawczyk
wiki
(Thread)
Last updated: 2025-08-11
Post by akrawczyk on Dynamically enabling/disabling Modbus slave devices in runtime (performance issue with timeouts)
CODESYS Forge
talk
(Post)
Hi everyone, I'm working on a CODESYS-based project running on a Weintek cMT2078X HMI with a built-in CODESYS runtime. The system communicates with multiple Modbus RTU slave devices, arranged in a cascade. The number of connected units can vary between 2 and 8, depending on the installation. Each slave has 17 Modbus channels, which are polled cyclically every 5 seconds. The issue is that when fewer devices are physically connected (e.g. only 3 out of 8), the Modbus master still attempts to communicate with all configured slaves. This leads to massive delays due to timeouts (currently 200ms per channel). For one disconnected device, that’s: 17 × 200ms = 3.4 seconds of delay per polling cycle, and this quickly multiplies with each additional missing slave. This behavior significantly degrades the system's performance and responsiveness. We attempted a workaround where we tried to trigger polling based on a variable in the PLC program, but this caused instability and even led to hardware hangs/freezes on the cMT2078X – likely due to clashes in how the Modbus polling engine and program logic interact at runtime. My main questions are: Is there a way in CODESYS to dynamically enable/disable Modbus slave devices at runtime, using a BOOL or INT variable (e.g. indicating number of active slaves)? Can devices or channels be conditionally polled or temporarily disabled without removing them from the device tree? Are there any best practices or examples for handling variable numbers of Modbus slaves in scalable systems like this? Would splitting communication across tasks or interfaces help reduce the impact of timeouts? Any advice, documentation references, or architectural suggestions would be extremely helpful. I'm looking for a robust way to dynamically scale slave polling without degrading system stability or performance. Thanks in advance!
Last updated: 2025-08-11
Home (version 1) discussion
gonzalo
wiki
(Thread)
Home (version 1) discussion
Last updated: 2025-08-11
Home (version 1) discussion
naci30
wiki
(Thread)
Home (version 1) discussion
Last updated: 2025-08-11
Home
akrawczyk
wiki
(WikiPage)
Project Members: akrawczyk (admin)
Last updated: 2025-08-11
Post by rajatdas2005 on Codesys Virtual control SL
CODESYS Forge
talk
(Post)
Thank you. Its working now.
Last updated: 2025-08-11
Codesys Virtual control SL
CODESYS Forge
talk
(Thread)
Codesys Virtual control SL
Last updated: 2025-08-11
wiki Discussion
lahsen55
wiki
(Discussion)
Forum for wiki comments
Last updated: 2025-08-12
blog Discussion
lahsen55
blog
(Discussion)
Forum for blog comments
Last updated: 2025-08-12
(no subject)
lahsen55
wiki
(Thread)
Last updated: 2025-08-12
Home (version 1) discussion
edme
wiki
(Thread)
Home (version 1) discussion
Last updated: 2025-08-12
Home
lahsen55
wiki
(WikiPage)
Project Members: lahsen55 (admin)
Last updated: 2025-08-12
Home (version 1) discussion
phryniszak
wiki
(Thread)
Home (version 1) discussion
Last updated: 2025-08-12
Home (version 1) discussion
akrawczyk
wiki
(Thread)
Home (version 1) discussion
Last updated: 2025-08-12
Post by tommchris on EThercat Dynamic configuration
CODESYS Forge
talk
(Post)
If you tell me which EtherCAT master stack you’re using Sprunki (Beckhoff TwinCAT, SOEM, IgH, Acontis, etc.), I can give you step-by-step dynamic configuration code for your environment.
Last updated: 2025-08-12
Post by jonhmoafa on Problem trying Net Base Services 3.5.15.0 TCP connection
CODESYS Forge
talk
(Post)
When the client disconnects (by setting ClientConnect := FALSE), the server still holds an active connection handle (hConnection), which causes the server to reject or mishandle new incoming connections from the same client Geometry Dash Lite IP and port. The key issue: You are not cleaning up the old connection on the server side. So when you try to reconnect from the client side: A new TCP handshake is attempted. But the server might still have the previous session open (from the OS/socket library's view), and so it gets confused or fails to accept it properly. This leads to client timeouts.
Last updated: 2025-08-12
Post by yannickasselin on Dynamically enabling/disabling Modbus slave devices in runtime (performance issue with timeouts)
CODESYS Forge
talk
(Post)
I would definitely try using the "Reconfigure" function block from "CAA Device Diagnosis@ library. https://content.helpme-codesys.com/en/libs/CAA%20Device%20Diagnosis/3.5.17.0/CAA-Device-Diagnosis/Function-Blocks/Reconfigure/Reconfigure.html#:~:text=This%20function%20block%20reads%20and,take%20effect. Although I have not tried it with Modbus, I had great success with EtherNet/IP, Profinet and EtherCAT. You can also have a look at the other functions in this library. There are useful functions to help iterate through all the nodes under a master node.
Last updated: 2025-08-12
Post by dkugler on Erreur bibliothèque WagoSysKbusTerminalControl et WagoSysKbusServices pour la gestion de la carte 750-671
CODESYS Forge
talk
(Post)
Hi naci, because this is a english forum it increases the chance to get help a lot if you translate your questions into english before posting :-) happy coding!
Last updated: 2025-08-12
Post by ph0010421 on Dynamically enabling/disabling Modbus slave devices in runtime (performance issue with timeouts)
CODESYS Forge
talk
(Post)
Hello If you uncheck 'Auto restart Communication', it will try once and never again. You can manually reset the slave if needed : Slave.xReset (or something similar) Or I have a ModbusRTU library if you want to try it.
Last updated: 2025-08-12
Post by dkugler on Cursor to move to a control
CODESYS Forge
talk
(Post)
this example may be a hint, how to solve this: https://content.helpme-codesys.com/en/CODESYS%20Examples/_ex_visu_selection.html
Last updated: 2025-08-12
Erreur bibliothèque WagoSysKbusTerminalControl et WagoSysKbusServices pour la gestion de la carte 750-671
CODESYS Forge
talk
(Thread)
Erreur bibliothèque WagoSysKbusTerminalControl et WagoSysKbusServices pour la gestion de la carte 750-671
Last updated: 2025-08-12
Cursor to move to a control
CODESYS Forge
talk
(Thread)
Cursor to move to a control
Last updated: 2025-08-12
blog Discussion
eksheep
blog
(Discussion)
Forum for blog comments
Last updated: 2025-08-12
Post by eksheep on Discussion for Home page
Applied Design Patterns
home
(Post)
This is a great resource, thank you.
Last updated: 2025-08-12
(no subject)
Applied Design Patterns
home
(Thread)
Last updated: 2025-08-12