ModBus RTU Broadcast to many slaves - Page 1
Forum section: electronics / projects

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 01, 2021, 10:10:35 am
content: Hello,I am currently looking into designing a RS485 multidrop network with many slaves.If the master is a commercial RTU device (PLC or some other commercial Modbus master), can I send a broadcast message to all slaves so the master does not expect a response, so really a simplex system, making it simple without the need for the slaves to have an address.The reason I ask this it that having many slaves that would need to respond to the master would require each slave having an address, which would mean that each node needs to be set (address) when its made and if all the slaves are the same they could be interchangeable without changing any settings resulting in no address clashes. I need all the nodes to be the same, so its easy to put a node on the network without having to set a slave address and without the need to tell the master system what the slaves are, or have to configure each node onto the network. Simply take it out of the box and plug it onto the network.Can a Modbus master send out a broadcast message to all slaves and not expect any response from them?The reason is that my slaves only need to set an option on power up from a master, and all the nodes would set the same one setting or option from the master. They do not need to send back data so this would make it easy to just take a slave out of the box and attach it to the network without any configuration.If the slave received corrupted data, or the CRC was incorrect etc then it would ignore it. To ensure that the slave received the correct packet or setting, the master could send out a repeat broadcast packet to all slaves perhaps once a minute or every 10 minutes etc.Is this something that a commercial Modbus RS484 master could do? Of course a master would be controlled by the main system.Thanks in advance for any comments.RegardsJohn

author: dave_k
author_rank: Frequent Contributor
timestamp: February 01, 2021, 10:19:07 am
content: Broadcast messages go to address 0, and slaves should not respond (i.e. it's write-only). Modbus RTU is a very well documented protocol, finding more information via a search engine should be easy.

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 01, 2021, 10:28:29 am
content: Hi Dave_KThanks for your reply. I did find loads of info, specs, and other official docs but there was so much of it. I have been just reading about this all weekend but found lots of conflicting info, so thought a post on here would solve it quickly.OK, your answer looks like what I was hoping for. I will see if I can find out how to put together what the packet could or should be. I only need to set one of four options to all the slaves. Once set that should stay the same until the next power down/up which should be every 12 hours or so.Thanks for you help.RegardsJohn

author: hooverphonique
author_rank: Contributor
timestamp: February 02, 2021, 10:34:25 am
content: Yes, what you're describing should work perfectly fine - when performing a modbus write to RTU address 0, the master does not expect a response (which also isn't possible as the slaves would be responding on top of each other).Note that if there's a Modbus (TCP) gateway between your master and the slaves, it may be configured to send a Modbus exception 11 ("gateway target device failed to respond") response back to the master in case of broadcast frames.

author: Renate
author_rank: Super Contributor
timestamp: February 02, 2021, 08:34:50 pm
content: If you're only broadcasting, why the Modbus?Are you sharing the bus with something existing already?Yeah, address #0 for broadcast works fine.If you are going your own way, heck, you could make #66 broadcast too. (That's completely non-standard.)Still, wouldn't it be nicer if it were half duplex so you could at least see if somebody pulled a cable and you lost half your network?If the nodes are in different places, but treated the same, why not give them addresses?So what if node #27 dies and you replace it with #47?At least this way you could scan the complete address space and see if the count of nodes jives with what you were expecting.I use Modbus on my home automation with a dozen nodes each with their own address.I want to know if my water heater node is no longer communicating.I broadcast on #0 once a second, but only the time (for clock displays).If something misses one broadcast, no problem.

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 03, 2021, 08:21:51 am
content: Hi,Thanks for your replies.I originally was just going to make up my own simple protocol (Start, Broadcast address, command, CRC (or LRC), end byte), which would be nice and easy as the master only needs to send one of four commands on power up. To be sure the slaves received it ok, the master could simply send the same command every 60 seconds, or 5 minutes for example, as timing for this is not critical, so hopefully the slaves should all receive the correct command at some point if the data got corrupted, and the speed would be as slow as possible, adding to the robustness?!It would be nice to give each slave an address and know that the command has been received ok or that the slaves are all present and as expected but as their will be many hundreds of slaves, maybe even up to 10 or 15 thousand!, I do not want to have to sort out a way to program or configure an address for each one. And also it means that if one slaves fails for some reason, a new slave out of the box can simply replace the faulty slave without any address or network configuration. At the moment I am thinking that each individual network will have no more than 64 slaves to each master, so when these are all installed, it does not matter which slaves go where. Each master will then be controlled by a central system, which will more than likely be some sort of commercial system that I will have no control over, from a hardware point of view.So, the reason why using ModBus may be a good idea is that the central system MAY be using Modbus (?), or maybe each master might be hooked up to a central system via a pc network. Its looking like that the commercial central system may be a PC network or Modbus RS485 network, connecting to all the commercial masters (PLC or something else??), each master will then hook up to my 64 slaves via RS485 (Modbus or own protocol) used to set one of four options on power up. That's it. No actual data is required back from the slaves.The whole system will consist of many masters and 100's or maybe thousands of slaves, but all broken down to 64 slaves on each 485 bus or network, going back to a single master, then each master on some sort of network (Not known as yet), going back to a central control system.Maybe I am missing something here, but if as you say node #27 dies and its replaced with #47, their may already be a #47 on the network? Or did you not mean that?With regard to scanning the whole address space, I assume that would simply be be starting at address 01 and seeing if I get a response? Then address 02 etc, with a short timeout period.The three main benefits and sort of a loose requirements are:1, No configuration or address setting required when the slaves are assembled or installed.2, Slaves can simply be taken out of the box and plugged on the bus without worrying about what goes where or address conflicts,3, If a slave fails its can simply be replaced with any other slave, either a new one or one taken from one of the other networks for example, without setting addresses or any other config.It would be nice to be able for the master or the central system to count the slaves to ensure they are all there on each bus segment of the overall system, but this is not a requirement and not essential, but would be nice.Does that all make some sort of sense or is all this a bad idea, or just do away with RS485 and use some other method to set the slaves on power up.One thing to add to this is that the environment these will be installed in, makes it very easy to diagnose any problems, as all the slaves are physically easily accessible so can be simply be unplugged or bypassed and can be individually tested or swapped out if needed.Thank again,John

author: Renate
author_rank: Super Contributor
timestamp: February 03, 2021, 10:01:20 am
content: In a world where Amazon wants to know the exact time you turn a page in your Kindle book, you're going to deploy several hundred devices and get back no data from them?Maintaining hundreds of anything can be a problem.Automatic address assignment is not a feature of Modbus.You'd have to do something tricky like having a "mate" pushbutton on the unit that would set it to, say address #1The master would query address #1 for its 128 bit UUID, then assign it to an address that isn't #1.If you swap the node between networks you'd have to push the button again.

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 03, 2021, 10:17:56 am
content: Hi,Yes, that's is all very true, and in an ideal world that would be great. But time to develop this is tight and as it only needs one command on power up every 12 hours, I was hoping for a solution that would be quick to put together.But I do totally understand what you are saying and agree. Maybe I will have another think but really it needs to be as easy as possible during installation as it can be, so simply plug them in and walking away with not config would be great.How reliable would or should a RS485 network be with only 64 slaves, one command on power up and a very slow data rate, with a screened T/P cable, perhaps no more than few hundred metres of cable in total?Is that expecting to much from RS485 if the install is done carefully and not touched afterwards?Not sure what other options I have really, it also needs to be low cost (The added network or remote feature), but reliable???Uhmmm, I m starting to wonder now.CheersJohn

author: Renate
author_rank: Super Contributor
timestamp: February 03, 2021, 01:41:02 pm
content: Double check your transceiver specs to see that you can actually use 64 nodes.32 is more typical, 64 is special. Topography makes a difference too with so many nodes.A dozen nodes, 20 feet the longest run, eh, just connect it all together any way.Over the course of 5 years I did blow out a leg on one transceiver.The system worked fine except for a couple of transmission errors once a day.That was on a node that was polled every five seconds.But at least since I knew which node had problems I knew where to look.If you're not using the bus frequently how do you know that it died?Quote from: hobbyelectronics on February 03, 2021, 10:17:56 amIf this is a very linear bus I might even just put a random standard RTU on the end so that you have something to talk to for some sense of integrity.Heck, you could even just talk only to that node on its address and have your other nodes just "eavesdrop" instead of using broadcast.I'm not sure how I like that idea though.

author: Alti
author_rank: Frequent Contributor
timestamp: February 03, 2021, 02:17:13 pm
content: Quote from: hobbyelectronics on February 01, 2021, 10:10:35 amYes, you can but this must not be address #0 as this is an address a newly installed (off-the-shelf) node has to respond to. So maybe send broadcast to addrss #1 but take care that there are no nodes with such address.As for interpretation of what your nodes do when they receive message with #1 - it is up to you.Just make sure they won't do something stupid. If all hundreds of nodes switch on some load on #1 command simultaneously then power supply might get into trouble. Also, after you send #1 you must not assume this is a success and all nodes received the message correctly. This is not CAN.

author: Renate
author_rank: Super Contributor
timestamp: February 03, 2021, 03:38:25 pm
content: Quote from: Alti on February 03, 2021, 02:17:13 pmWhat? I didn't think that broadcast on address #0 had any official stated purpose/format/address space map.Do you have a specification for it? It's not in "Application Protocol" or "Modbus over Serial".

author: Alti
author_rank: Frequent Contributor
timestamp: February 03, 2021, 04:28:16 pm
content: Quote from: Renate on February 03, 2021, 03:38:25 pmLink to Modbus over Serial LineQuote from: Modbus specEDIT: You are right - #0 is not an official way of addressing newly attached Modbus nodes.

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 05, 2021, 08:43:51 am
content: Hi,On an electrical front, looking at the doc that you linked to states that a ground (Common) wire is also required for ModBus. I was under the impression that for normal RS485 no ground was needed as it was a differential bus. Maybe a common ground will reduce common mode noise perhaps? Looks like I need to do more reading,Would Linking all the DC transceiver grounds together not cause ground potential problems. Especially if the slaves are on a different AC supply?Any thoughts on this?ThanksJohn

author: Renate
author_rank: Super Contributor
timestamp: February 05, 2021, 02:33:30 pm
content: Everything connected to an RS485 bus must be referenced to ground, you can't just float.This keeps the line voltages within the common mode spec.If you're feeding a wire powered, isolated thingy, obviously the ground and power go with it.If you're feeding across two systems with a potential for ground currents then you don't carry through the ground.Still, you need to make sure that the difference in the two grounds is not large.

author: Alti
author_rank: Frequent Contributor
timestamp: February 05, 2021, 05:30:50 pm
content: Quote from: hobbyelectronics on February 05, 2021, 08:43:51 amI hope the supply is not tied to Modbus GND in any way.Technically speaking you should connect this Modbus GND to PE in one place only, otherwise an L-PE short is going to fry transceivers. Most RS485 transceivers have common mode voltage -7: +12 and can be damaged if you exceed -10:+15 (with respect to pin #5, not some remote PE).

author: WattsThat
author_rank: Frequent Contributor
timestamp: February 06, 2021, 03:17:28 am
content: ANSI X3.28 is another simple protocol that can do a broadcast to all slaves. It’s easy to implement without all the message variants of Modbus.With respect to RS-485, to expand on what has been discussed, every device needs an isolated from earth power supply and you absolutely need a common wire running between the nodes that is absolutely not going to earth anywhere. Anything else and you will absolutely blow up transceiver chips on a fairly regular basis especially when devices are on different electrical distributions where there can be slight differences in ground potential.True life story: Had an industrial I/O system running at 200kb on 8051 cores with 75176 transceivers which are 2 wire 485. Didn’t have a common and in some systems, the data errors were a problem. So, we used the shield in the two wire cable as the common which fixed things in the shop. In the field, we started blowing up transceivers.It wasn’t until there was a big enough ground disturbance to blow the data traces off a board that I realized we had ground loops. Once we knew what was going on, it was easy to find the problem. Mistakenly, my cable house did not insulate the shield wires in the cables that I had used as the common and in some of the cables, the shield wires ended up going to earth by way of a metal connector housing. Ground disturbances created enough differential between the devices with enough energy it could blow the epoxy off the tops of the 8031 and 75176 packages.

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 06, 2021, 08:42:28 am
content: HI,Thanks for all your replies. I understand everyone's comments and it now makes me think that all though doable, this now needs to be a longer term project with plenty of testing and adding all of the safety features and protection features that have been mentioned.This is really where I wanted to get to before committing to any hardware design or prototypes, which in the time given may not be achievable, but certainly perhaps the best option in the coming months.So, this now leads on to my next question, but unrelated to Modbus so may need to be a separate post perhaps.I have existing boards that takes readings from inputs (ADC's, Comparator, Digial I/O etc) and then controls a few other things, which works well in a large installation of many thousands of units. I now need to add some method of adding a 1 of 4 option to the boards on some sort of low cost network that can be controlled remotely. The 1 of 4 options only needs to be made once during power up. Power will be cycled once every 12 hours. The existing board has a MCU in place already with spare I/O.So, if RS485 / Modbus is not a quick option at the moment what about perhaps having two digital inputs (Giving 1 of 4 options) like what a PLC input would be?I have been looking at the ISO1211 or ISO1212 chip which provides an isolated digital input up to 60V. So my thinking is based around using one of these devices where the network would simply be a 4 wire cable with 0 & 24V and 0 & 24V which would be selected by the main control box some hundreds of metres away. The MCU on each slave could then simply read the 2 inputs to make the selection.If anyone has any views on using these types of isolated digital input chips, which seem very low cost, it would be good to hear your what you think. The 24V cable would run the length of the installation but tapped off to each slave. The master control box would simply need to provide two 24V outputs giving the 1 of 4 options.The question I have is, if when one of the 24V lines is off the line or input is not selected, will then have either 0 volts (If switched back to 0v) or left off (Floating), how would that effect many of these devices sitting on this cable over hundreds of metres?Please see he image attached from the data sheet showing sort of what I mean. So the bus or cable would simply have two 24V lines giving 4 options, with all the slaves sitting on this cable like a multidrop bus. Each slave would have two of these devices (ISO1211), picking up the two 24V inputs from the cable. Does that make any sense?. The central control may be a PLC with 24V or dry contact outputs.Thanks again for your thoughts & time regarding this.John

author: Renate
author_rank: Super Contributor
timestamp: February 06, 2021, 12:42:01 pm
content: I'm still scratching my head on this whole project.You say that your nodes have an MCU on it.I don't understand what they can be doing if they don't measure anything, it doesn't matter which one is which and they only have four modes (which is the same for all nodes on one sub-bus).Does this thing flash light bulbs or what?Can this be done without an MCU?I just think that if you have hundreds of nodes, hundreds of meters of cable you really need some sort of duplex communication.Maintaining hundreds of anything is a pain.

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 07, 2021, 12:03:17 pm
content: Hi Renate,(Attached is a basic idea of what is required).Each node currently has an MCU which takes readings form onboard sensors and processes the data, in turn it controls other outputs on the board depending on the various sensor readings. This is done constantly, and refreshed every few seconds or so (Timing is not critical here). Each node currently works very well in a real installation of 2,000+ units, each of which are currently independent of each other. The only thing in common is the 3 phase supply being fed to each one. I think every 8 devices are fed from a different power distribution point or breaker. The nodes are installed over a large area, maybe hundreds of metres in every direction. Now my requirement is to simply set 1 of 4 options to every node on power up of the whole system. The 1 of 4 selection needs to be set the same for every node, but the setting needs to happen from one central point. This central point currently has a number of output options, which are feed from a commercial device, may be a PLC or something like that (Not yet known exactly), but it can offer outputs based on RS485, Modbus, Ethernet, PLC dry contacts, Switched 24V O/P and also maybe a 1 to 10V offering.So, I need a simple, low cost reliable way to be able to ensure that the 1 of 4 selection is sent to all the nodes when the system is powered up. This then will stay in that state until the powered is cycled, about once every 12 hours or so.However, due to only having a few months to find a solution that can be added to the existing design, it cannot be too time consuming or require a vast amount of testing. I like the idea of adding an isolated Modbus (RS485) port to each unit, where the master control can simply send out the selected option to all nodes so they can be set. But this maybe something for the future as time allows. A way of having two inputs on each node would be good, perhaps even something as crude as two relays, but then the bus would need a couple of amps to operate the 2x relays per node. Using a isolated digital input IC (ISO1211 or 1212 for example), where each input would only draw a couple of mA may be an option, maybe with a TVS on each input as well.So, basically I just need a way of being able to set a one of for option to all nodes. Once a day on power up. The main control system can be broken down into smaller chunks, perhaps with as little as 8 nodes on each output (PLC etc), all though maybe 32 or even 64 would be a benefit as their would need to be less control output modules in total.The whole installation of 2,000 nodes can be broken down into smaller segments, each being fed by an output module, PLC or other commercial system. Each output module will then be liked back to a central system, so when the 1 of 4 option is selected is propagates to all the nodes, via the PLCs or output modules.Please see the attached doc which may explain this better.I only need to work on the node or slave units and provide a input method to select the required option.Does that all make more sense or just confuse things even more with my rambling on.....ThanksJohn

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 07, 2021, 01:53:01 pm
content: Hello,Looking at this problem again, I think that a simple low cost easy solution could be the use of two MAX22191 ICs, which simply provide a binary digital input from a -60 to +60 volt input.Data sheet attached.Any thoughts?ThanksJohn

author: Renate
author_rank: Super Contributor
timestamp: February 07, 2021, 02:25:40 pm
content: Well, what about starting this out, like you said, Modbus RS-485, broadcast only.There's no need to make it broadcast only once every 12 hours.If you have a cable disconnected for that split second your day (ok, half a day) is ruined.Why not every 10 seconds?In the future you could transition to units with addresses and readback of data with just a software update.C'mon, everybody wants data.Besides, if you have thousands of these things already how do you know they are all working?

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 07, 2021, 07:11:30 pm
content: Hi Renate,Yeah, my original thought was to send the broadcast message once every 60 seconds just in case one of the slaves did not get it or even repeat the broadcast every few seconds for 5 or ten minutes at power up then stop.Or even give the last slave on the bus an address so which will respond. That way I know that the bus is intact and all the slaves must have heard the broadcast, as they will just be listening only.Its what the modules actually do with its sensor data and its other outputs that is important. If one of the modules stops, it will be picked up through one of its other outputs to another system, so will be very easy to tell.All the RS485 Modbus stuff is perfect with addresses and sending data back, but that can come later in another version when I have enough time to develop it properly, both hardware and software.I like the look of a PLC style digital input using either the ISO1211 or the MAX22192. I like the MAX222191 because it can be isolated without needing to have a isolated local supply as it can take parasitic power from the 'bus' and will only draw a few mAJust need to find out if having 32 all on the same 0/24V wire will cause a problem.Need to read up on this Level 1, 2 & 3 input spec that PLC's have.Looks interesting though.....Thanks

author: Renate
author_rank: Super Contributor
timestamp: February 08, 2021, 11:50:27 am
content: If you adopt some voltage signalling thing you're stuck with it.If you go with Modbus broadcast only initially, the hardware and wiring is the same as for duplex operation.You would be able to upgrade to full addressable a single node at a time.With a bootloader and preassigned address you could upgrade the whole system without even going around to every spot.With a laptop and a RS485 adapter you could write a new address for replacement nodes.Heck, with an Android phone and a RS485 adapter you could.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: February 10, 2021, 11:28:48 am
content: The idea of collecting information from multiple devices anonymously is unclear. After all, you will not know from whom the data is received. Or is it enough for you to know about some event, for example, a light bulb burning out, without specifying where this event occurred, without knowing which light bulb burned out?I use two of these switches to specify the address:https://lcsc.com/product-detail/Coded-Rotary-Switches_Nidec-Copal-Elec-SA-7010B_C132915.htmlUnfortunately, RS-485 does not provide any ways to identify the device on the bus. You can install two RS-485 ports in each device: input and output, then you will have to broadcast someone else's traffic, but you will be able to uniquely identify the devices by the order of connection. I once used an RS-422 in which all the master transmitter and slave receivers were permanently connected, and the slaves transmitters in the string. Each device could intercept the traffic and not allow the next one to respond, if it decided to respond itself. It was very easy to distribute the addresses.

author: Renate
author_rank: Super Contributor
timestamp: February 10, 2021, 01:03:44 pm
content: Quote from: S. Petrukhin on February 10, 2021, 11:28:48 amApparently they don't want to collectanydata.

author: hobbyelectronics
author_rank: Regular Contributor
timestamp: February 14, 2021, 10:27:57 am
content: Hi,Just to confirm, I do not need to collect any data from the slaves or nodes, just simply set 1 of 4 options to ALL slaves on power up or just after. I do not need to set (Or want to) a network address for each slave, just because I do not need to communicate with any slave on an individual basis. But all this needs to be robust without any issues caused by noise, volt drops, coms errors etc. And that is it, nothing more.The option needs to be set from a remote point with as many slaves as possible on one length of cable which could be a good few hundred metre in length.If it turns out only 32 slaves max then that is fine. If I can get 200+ slaves that's better, but as long as it works, so I can simply set one single option to all 2,000 slaves when they power up.The solution can be basic and cheap or much more complex but as long as its achievable within a few months.#At the moment I simply like the idea of have two MAX22191 devices on each slave board with a long 3 core cable, 0V, +24V (A), +24V (B), this will give me electrical isolation for each slave on the cable and also by simply applying a 24V or 0v on the two wire (A & B) will give me the one of the four options to all slaves directly into the MCU from the opto attached to the MAX22191.Or any other easy solution would be good, and maybe ModBus over RS485 (Isolated) for the next revision when I have more time available for testing etcThanks for everyone's inputs......

author: Renate
author_rank: Super Contributor
timestamp: February 14, 2021, 03:57:37 pm
content: I made my point before, but I'll persist...Don't put in a 24 V thing, please.That's a dead end.When, (not if) this thing wants to get upgraded you'll have to run another set of cables for something that doesn't signal on 24 V.You won't be able to piecemeal update a single bus.You'll probably end up with lots of blown modules from somebody putting a "new" module on an "old" bus.I never liked the Modbus broadcast option, but can't you implement that?You don't even need to make it robust, no CRCs, just accept 1 of 4 preset broadcast messages.I don't understand your viewpoint on this whole thing unless you can sit at your desk and issue a email for some grunt to swap a few hundred modules or pull a whole new load of cable.