Can RTU and ASCII slaves be on the same network

S

Thread Starter

stherriault

Hi,

I'm designing a modbus master firmware that needs to support any kind of devices connected to it. I've never worked with modbus before and I was wondering if only one protocol can be used at once? What I mean is, does the Master need to support RTU devices and ASCII devices at the same time? Would my master controller need to know how to communicate with each slave?

Thank you very much
 
P

Patrick Lansdorf

I would say that one normally do not mix protocols on RS485, however I cannot see why it would not work, so I do not agree with Rob.

When sending a Modbus command, only the slave with the corresponding slave Id will/should reply and if a different (ASCII) command is sent, it should not effect the Modbus slaves. The master does not need to support RTU and ASCII at the same time.

Just my 2 cents

Patrick Lansdorf
 
S
Ok, thanks for the tip :)

Is it that complicated to write a modbus master "stack"? I saw that some companies sell it. There's even a free one but I think it's only for the slave side...

One more thing, is it possible for a master to query what protocol the slaves are using dynamically? My master firmware must be able to support any kind of devices. All of them could/would be on the same protocol ( RTU or ASCII ) but in one situation, all of them could be RTU and in another situation, all of them could be ASCII. Would that be possible to detect this during initialization and use the good protocol afterwards?

Thanks!
 
Patrick is correct - you could make this work if you really have to. But you are adding layers of complexity. More complexity = More code = more work = more bugs. Its up to you to decide if you really cannot live without this functionality or if your target users can live without it.

Personally I would KISS (Keep It Simple Stupid)
 
L

Lynn August Linse

> One more thing, is it possible for a
> master to query what protocol the slaves
> are using dynamically?

I suppose you can, but the question is "What percentage of the time will the Master FAIL to correctly detect and ignore a valid slave?" 1%? 5% 25%?

Sending an ASCII message to an RTU stave will result in no response ... same as if the slave is not there. If the user must configure that slave #1 exists, they might as well add if it is ASCII or RTU.

In general, Modbus is NOT a 'browse-auto-config' system. Users expect to manually define what is true. Auto-detect is likely not required to sell a product; likely not to be used by most customers; likely to cause tech-support calls by the few % who actually try it and fail to gain 100% satisfaction.

- LynnL, of Digi.com
 
S
> Its up to you to decide if you really cannot live without this
> functionality or if your target users can live without it.

> Personally I would KISS (Keep It Simple Stupid)

I agree with you. I want to keep it simple but the thing is this embedded system must be deployable anywhere and be scalable the most it can. I don't know what will be hooked to it. I just know I need to support to be a Modbus master and have some slaves hooked to me. I'll receive my instructions from ethernet. For now, I think I will need to support both, ASCII and RTU but not necessarily at the same time. Is the ASCII protocol used a lot in the industry?

Thanks
 
Please, give this a try and report back to us on the details of how it works.

Remember that Modbus RTU uses 8 data bits and that Modbus ASCII uses 7 data bits, so be sure to change the data word format on the serial line depending on whether it's an ASCII or RTU transaction and hold that format until the master times out so that slave's response can be recognized. I know word format is usually a one-time comm setting, but if you're writing your own multi-combo-one-size-fits-all master then have a go at it.

Oh, and make sure your serial UART can handle the format changes on the fly and in a reasonable time so throughput isn't compromised.
 
I too would be cautious when mixing Modbus in RTU and ASCII modules. The Modbus over Serial spec states in section 2.5 of ver 1.0, that the transmission mode MUST be the same for all devices on a Modbus serial line.

This makes sense because when the master is speaking RTU, all ASCII devices will be trying to decode the frame with the wrong byte structure (10 bit instead of 11) and will see nothing but framing errors. Likewise for the RTU slave when the master is speaking ASCII.

I recommend you do not mix the two modes on the same network. You do not know what unintended results you might get when a slave receives a message in the wrong mode. Like Rob said, "More complexity = More code = more work = more bugs."
 
Top