Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Modbus and S7...

Modbus and S7... 5 years 10 months ago #9715

Hello all,

The server, an S7-1200, is setup for a block of 86 bytes (of bits and floats) starting from 40001 (address 0). The first two words/addresses (32 bits, 2 16-bit words) are all bits or spares.

I have the following in Proview under Nodes-IO
Modbus_Master(standard options)
->Modbus_Slave(ip=my device, Port=502, standard options)
-->Modbus_Module(FC=ReadHoldingRegisters, Address=0, UnitId=1, standard options)
--->Multiple ChanDi(Number=0...32,Bit16, standard options)

This works for only the first word. After the first word, things just don't work (no output).
If I break this into two(2) Modules such that ModuleA(Address=0 aka 40001), ModuleB(Address=1 aka 40002) then Module B doesn't read the 1st address. It read the zeroth, which seems really, really odd.

I would normally (and may YET) blame this on Siemens. But... my pymodbus code yields the correct output.
HR 40001, Address 0
result1 = client.read_holding_registers(0, 1, unit=1)
decoded = BinaryPayloadDecoder.fromRegisters(result1.registers, endian=Endian.Big)
output = "{0:016b}".format(decoded.decode_16bit_unit())
play with output...
HR 40002, Address 1
result2 = client.read_holding_registers(1, 1, unit=1)
decoded = BinaryPayloadDecoder.fromRegisters(result2.registers, endian=Endian.Big)
output = "{0:016b}".format(decoded.decode_16bit_unit())
play with output...

I've been trying to sort this out for a couple of days, now, and I'm seriously stumped.


Thanks,
Matt
Last Edit: 5 years 10 months ago by MattBerglund.
The administrator has disabled public write access.

Modbus and S7... 5 years 10 months ago #9717

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3175
  • Thank you received: 501
  • Karma: 133
Hi Matt,

Thre are two types of addresses i Modbus, the PDU address that starts counting from 0, and the register address that starts counting from 1. Proview uses the PDU address so I guess your start addess should be 40000.

A Modbus register is two bytes and can be read with representation Bit16 and Number 0..15. Bit32 with Number 0..31 and Bit8 with Number 0..7 can also be used although I'm not sure the byte ordering will be correct in all cases. Proview will swap all 4 bytes for Bit32 and no bytes for Bit8.

/Claes
The administrator has disabled public write access.

Modbus and S7... 5 years 10 months ago #9720

Claes,
Thanks for the response. That part I had correct.

I figured out what one problem was.

The biggest issue was that I didn't realize (until reading this post Proview youtube channel for beginners) that the *order* of the ChanDi,Li,Ai,etc. matter.
I had my channel objects scattered as I wrote them up, not realizing that they *must* be organized linearly in chunks.


An additional issue seems to be that I can only have one Modbus Module for read and write per Slave.
So the memory area is broken up like so

40001[Readable Bits]
40002[Readable Bits]
40003-40018[Readable Float32]
40019[Writeable Bits]
40020-40043[Writable Float32]
40044[4 Readable bits]
40044[6 Writable bits]
40045-40050[Readable Float32]

I currently have partly working:
->Modbus_Slave(ip=my device, Port=502, standard options)
-->Modbus_Module(FC=ReadHoldingRegisters, Address=0, UnitId=1, standard options)
--->Multiple ChanDi(Number=0..16,0..16,Bit16, standard options) This works
--->Multiple ChanAi(Number=2..17,float32 This works
-->Modbus_Module(FC=WriteMultipleRegisters, Address=18, UnitId=1, standard options)
--->Multiple ChanDo(Number=0..16,Bit16, standard options) This works
-->Modbus_Module(FC=ReadHoldingRegisters, Address=43, UnitId=1, standard options)
--->Multiple ChanDi(Number=0..4,Bit16, standard options) This DOES NOT work


1. Is it possible to have multiple Reads and Writes attached to the same connection?
2. If so, do the Modules need to be in memory order AND complete, meaning no empty gaps between addresses like I have above?

Thanks for all your hard work Claes, and everyone else here that posts.

Thanks again,
Matt
Last Edit: 5 years 10 months ago by MattBerglund.
The administrator has disabled public write access.

Modbus and S7... 5 years 9 months ago #9721

As others have said before... the best part of writing things up on this board is that you figure out your problem an hour later.

So, it seems that my questions go as follows:
1. Is it possible to have multiple Reads and Writes attached to the same connection?
Yes, but it looks like (until I'm told otherwise) that you must do what I suggest in the next question.

2. If so, do the Modules need to be in memory order AND complete, meaning no empty gaps between addresses like I have above?
This seems to be the case for this gear, at least. Can anyone confirm this S7-1200/1500? I would think that the addressing would take care of that, but...

Now to figure out how to correctly setup the Engineering values...

Thanks,
Matt
Last Edit: 5 years 9 months ago by MattBerglund. Reason: forgot to mark it answered...
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 8.253 seconds