Jump to content

Recommended Posts

Posted

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!

  • MVP 2023
Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.