S7-1200 Modbus TCP - How to read/write memory bits?

horvatmiha

Member
Join Date
Jan 2019
Location
MS
Posts
14
Hello!

I am using S7-1200 PLC 1212C AC/DC with configured Modbus TCP Server. I can already read/write Inputs/Outputs (Coils) and Memory Words. However I'd like to read/write Memory BITS. Is it possible? If so, how? What addresses should I use in TIA portal? And which function codes on client side?

Thanks in advance!
 
I don't think you can read only bits of Memory Words. But, after you read the word, you can quite simply address the bits of that word. For example, if you read the Modbus register word in to "Data_Block"."MyWord", you can reference bit 0 as "Data_Block".MyWord.%X0
 
I can read/write next addresses in PLC:

- I0.0, I0.1, I0.2 ...
- Q0.0, Q0.1, Q0.2 ...
- MW0, MW2, MW4 ...

Is it possible to read/write for example M0.0 or M2.0 or M2.4 ... ???

Thanks in advance!
 
Memory Words ?

Modbus addressing defines four areas:

Coils : bit, Read/Write
Discrete Inputs: bit, Read Only
Input Registers: 16bit word, Read Only
Holding Registers: 16bit word, Read/Write

Modbus doesn't define how to read or write single bits from 16bit word, neither how to read/write double word types like float, or 32bit integer, or read integers as signed or unsigned. If you see a plc or hmi or scada capable of doing that, it is an add-on from the programmer of that driver.
 
Last edited:
Yes, this is correct. I was talking about Memory Words in TIA portal. Also addresses I defined in my post are meant as addresses in TIA portal, in S7-1200 program. I just want to know if possible and how to read/write single bit which is in S7-1200 addresses like M2.0 for example.
 

Similar Topics

can i send and recieve data using my yokogawa UT35A controller with my siemens s7 1200 plc using profinet communication without using gsd file
Replies
1
Views
355
Hello All I have a modbus tcp device(Julabo magio) with an DB9 pin assignment. Pin3=B and Pin8=A. I would like to connect it on the secondary...
Replies
4
Views
1,544
Hi All, I have a closed loop stepper motor (Nanotec make), https://en.nanotec.com/products/2512-pd4-e601l42-e-65-4. This uses MODBUS TCP for...
Replies
4
Views
3,698
Hello; i'm having some troubles with a com test i'm handling. i have another end for it, but for now i would like to have : M241 in io_scanning...
Replies
4
Views
3,439
Hi, I currently have a s7-1200 enabled as modbus tcp slave for customers master to connect to freely. Now my customer want to add a new modbus...
Replies
8
Views
4,567
Back
Top Bottom