SE M221 Modbus addressing as Slave

min111

Member
Join Date
Apr 2022
Location
singapore
Posts
2
Hi,

I am doing PLC using M221 as a slave device and communication via modbus.

The PLC has been completed and i am required to provide Modbus address for other devices to read information from the M221 device.

I have read in many sources that you can only R/W to %M or %MW addresses. And the address are 0xxxx, 1xxxx, 3xxxx or 4xxxx.

I have also read that %M0 = 000001. However, I am unable to find proper documentation on this, thus unable to confirm.

It is also mentioned in SE support the following:
Supported Modbus
Function Code Supported Sub-
Function Code Description
1 (0x01) - Read multiple internal bits %M
2 (0x02) - Read multiple internal bits %M
3 (0x03) - Read multiple internal registers %MW
4 (0x04) - Read multiple internal registers %MW

So my other question is if i want to read %M0, should the address be 00001 or 100001?

Also, another question is, is it true that there is no addresses assigned to %i and %Q? the only solution is to map it to %M or %MW?
 
It is also mentioned in SE support the following:
Supported Modbus
Function Code Supported Sub-
Function Code Description
1 (0x01) - Read multiple internal bits %M
2 (0x02) - Read multiple internal bits %M
3 (0x03) - Read multiple internal registers %MW
4 (0x04) - Read multiple internal registers %MW

So my other question is if i want to read %M0, should the address be 00001 or 100001?


The Siemens help file I have (which should still apply) gives it as this:


00001-09999 = Output coils, function codes 01, 05 and 15. Read/write
10001-19999 = Input coils, function code 02. Read only.
30001-39999 = Internal Registers, function code 04. Read only.
40001-49999 = Holding registers, function codes 03, 06 and 16. Read/write


So my other question is if i want to read %M0, should the address be 00001 or 100001?


Address 1 would be 10002.
I downloaded a trial from this website, which has some pretty good tools for simulating coms.
https://www.modbustools.com/index.html


Also, another question is, is it true that there is no addresses assigned to %i and %Q? the only solution is to map it to %M or %MW?


Not worked with Schneider stuff myself, but yes this is true. You're not using any I/O, just whatever coms module you're using for your modbus interface.
 
Hello! Thank you very much for your reply and help!

Unfortunately, i do not have the PLC now to connect it to.

Address 1 would be 10002.
I downloaded a trial from this website, which has some pretty good tools for simulating coms.
https://www.modbustools.com/index.html

Can i check that you mean %M1 (internal bits) = 10002? and this is for read only.

if i would allow the master to also write, then the address will be %M1 = 00002?

Not worked with Schneider stuff myself, but yes this is true. You're not using any I/O, just whatever coms module you're using for your modbus interface.

i will need to send the inputs and outputs status to the master device. Which means i will need to Map each input to a internal memory itself?

eg. %I0.0 = %M0 (10001), %Q0.3 = %M3 (10004)



The Siemens help file I have (which should still apply) gives it as this:


00001-09999 = Output coils, function codes 01, 05 and 15. Read/write
10001-19999 = Input coils, function code 02. Read only.
30001-39999 = Internal Registers, function code 04. Read only.
40001-49999 = Holding registers, function codes 03, 06 and 16. Read/write

Thanks!! this helped alot!
What confused me is SE stated 0x01 and 0x02 as read multiple internal bits %M. Does the function codes only required by the master device?
I am currently acting as a slave. So these function codes does not matter?

i am so sorry! I am new to modbus systems...
 
i am so sorry! I am new to modbus systems...

In Modbus there are two addressing models: Data Model Addressing; PDU* Addressing. Cf. Section 4.4 at this link and Figure 8 at this link; yes I know that is as clear as mud and does not help much.

* PDU = Protocol Data Unit

Data Model Addressing uses ordinal numbers starting at one, so 1 through 65536.

Protocol (from PDU) is what goes "over the wire" (TCP/IP or serial), and only two bytes are ever used for an address, which obviously** limits the range of possible addresses to 0 through 65535. So if you want the first element of a particular data type (Data Model Address 1) then a 0 would be the address in the PDU, and if you want the tenth element of a particular data type (Data Model Address = 10) the you use 9 as the address in the PDU.

** If this is not obvious to the reader, I apologize, but I am not going to go into the reasons here.

So Modbus addresses are limited to five decimal digits, with a lower limit of 0 or 1, and and an upper limit of 65535 or 65536, depending on the data model being referred to. That is decimal; in hexadecimal, which would only apply to the PDU Model, the lower and upper limits are 0x0000 and 0xFFFF (i.e. 0 and 65535 decimal).

There is also the commonly-used convention, not part of Modbus proper***, that couples the concepts of "Modbus Object Type" coupled with Access, in the Data Model, into a decimal prefix to the Data Model Address; cf. the Modbus wiki this link, and highlighted in bold magenta below.

Code:
  [U][B]Object type[/B][/U]       [U][B]Access[/B][/U]      [U][B]Size[/B][/U]     [U][B]Address Space[/B][/U]
  Coil****          Read-write  1 bit    [COLOR=Magenta][B]0[/B][/COLOR]0001 – [COLOR=magenta][B]0[/B][/COLOR]9999
  Discrete input    Read-only   1 bit    [B][COLOR=magenta]1[/COLOR][/B]0001 – [COLOR=magenta][B]1[/B][/COLOR]9999
  Input register    Read-only   16 bits  [COLOR=magenta][B]3[/B][/COLOR]0001 – [COLOR=magenta][B]3[/B][/COLOR]9999
  Holding register  Read-write  16 bits  [COLOR=magenta][B]4[/B][/COLOR]0001 – [COLOR=magenta][B]4[/B][/COLOR]9999
N.B. there are only four digits shown in each Object Type's address space there, they should all be X00001 - X65535.

*** AFAICT
**** Coil = a physical Discrete Output usually, but it can also refer to an internal bit that is both readable and writable.

That prefix means nothing in Data Model Addressing; and of course it is impossible to even implement in the two bytes of an address in a PDU on the wire. It is, as far as I can tell, a convention that allows abbreviating the verbosity of "Discrete input xxxx" with the more concise "1xxxx" e.g. in a user interfaces. Also note that these prefixes are redundant with the Function Code in any Modbus PDU e.g. Function codes 01, 05 and 15 (decimal) all refer to an Object Type of Coil (prefix 0 above). To make it even more confusing, there is no, and if anything anti-, correlation between the PDU function Codes and the prefixes e.g. PDU Function Codes 03 and 04 read Holding Registers and Input Registers, respectively, which Holding (Function Code 03) and Input (Function Code 04) registers have "common" prefixes of 4 and 3, respectively.

That said, the prefix may show up in a user interface (e.g. popup or dialog window) for configuring a Modbus transaction. E.g. some vendors' Modbus Client configuration interfaces might expect to see the prefix prepended the user-supplied address in order to determine which Function Code to use. So to execute a PDU with a Function Code of 03 (Read Holding Register) and a Data Model address of 16, the user interface might require the user to configure options

  • "Read" as the data transfer direction, and
  • "400016" as the address,
which options the interface would convert to a Function Code of 03 and a PDU address of 15 (0x000F) on the wire.

Again, whether the user needs to supply the Data Model (1-65536) or the PDU Address (0-65535), with or without the "Object Type" prefix, to a configuration menu interface is vendor specific, and often the quickest way to sort it all out is to poke around and try different things; there are only a dozen or so possibilities, so an empirical session of half an hour or so should be enough to get it sussed. Some vendors' Modbus server's implementations conveniently place a fixed value, e.g. a 32-bit floating point value (e.g. -1234.0) at a documented, but otherwise-unused, Holding Register address, which supports empirically characterizing the menu interface's options, the protocol, the byte order, etc.

It is only ones and zeros; it cannot be hard - Jouni Ryno

-
 
Last edited:
Code:
  [U][B]Object type[/B][/U]       [U][B]Access[/B][/U]      [U][B]Size[/B][/U]     [U][B]Address Space[/B][/U]
  Coil****          Read-write  1 bit    [COLOR=Magenta][B]0[/B][/COLOR]0001 – [COLOR=magenta][B]0[/B][/COLOR]9999
  Discrete input    Read-only   1 bit    [B][COLOR=magenta]1[/COLOR][/B]0001 – [COLOR=magenta][B]1[/B][/COLOR]9999
  Input register    Read-only   16 bits  [COLOR=magenta][B]3[/B][/COLOR]0001 – [COLOR=magenta][B]3[/B][/COLOR]9999
  Holding register  Read-write  16 bits  [COLOR=magenta][B]4[/B][/COLOR]0001 – [COLOR=magenta][B]4[/B][/COLOR]9999

Didn't know the bit about the bits, I've learned something today now.

It is only ones and zeros; it cannot be hard - Jouni Ryno

Jouni Ryno needs a poke in the eye.
 

Similar Topics

Hello, I need to access the bits from the fire system control panel through RS-485. So, I used Read Var block to read from the panel...
Replies
0
Views
199
disclaimer- 1,no one in their right mind would pick this configuration but I want to try and get it working. 2, my MB knowledge is sketchy at...
Replies
5
Views
1,145
Hi, I am trying to setup comms between my computers rs232 port and a schneider M221 PLC. (ultimatly with the intention of setting up PLC ->...
Replies
6
Views
1,564
Hi all, I've been trying to develop modbus rtu program between uv balasts and plc ı'have 6 slave balast.I am reading fault run voltages etc...
Replies
0
Views
1,199
Hello new user here seeking some guidance. I have been given the task of polling data from a modbus slave (Thermo 43i Analyzer) using RS-232...
Replies
2
Views
1,687
Back
Top Bottom