Jump to content

Recommended Posts

Good day, everybody!

I have a question about ModBus RTU: how about ModBus RTU connection - is there any way to keep it "alive"? I mean if we have master-slave connection and for example one of them (due to some reasons: power failure, system error or else) goes "offline", how this connection establishes? This happens automatically when we reset unit (bring it to normal state) or do we need to use some program function to establish connection? Thank you!

Link to comment
Share on other sites

  • MVP 2023

Have you watched the Modbus Webinars featured on the main page of the forum? If you haven't, take 45 minutes to give them a look and see if you can answer your own question.

My opinion is doing any kind of serial communication with a PLC is not a beginner-level project. You have to write your own port handler using the functions available, and you have to understand the timing and the back and forth one-block-at-a-time nature of a serial port. I've seen lots of instances where someone sets up Modbus polling logic and then can't figure out why their write blocks don't work. It's almost always caused by not turning the polling off. A program using the serial port can be compared to a large ballroom dance; you've got to structure your code so all the dancers keep moving but don't crash into each other. Putting together a program flowchart before you start is invaluable.

Generally, you don't keep a master-slave setup "alive" - you check for read/write errors on the master side. If you find that it's possible for the slave to go into some kind of brain-dead mode where it won't communicate, then you set up a heartbeat bit in the slave that the master turns on and off on some periodic basis. You then write logic in the slave to monitor the change of this bit, and write more logic to handle the situation if the heartbeat stops.

Joe T.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...