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

TOPIC: Modbus-TCP and S7-1200

Modbus-TCP and S7-1200 5 years 10 months ago #9705

Hello All,
I built a simple pymodbus test reader for a system using the S7-1200 in preparation for my Proview work.
I discovered that all of the system values were placed into the 40000 memory block, and the S7 will not correctly read any values unless they are handled by Function Code 3 (Read Holding Registers).

This means that for bits, I have to fetch the register, split it into bits, and then grab the right bit to work with it.

I've read everything I can find on this, and the Maba.dk Wiki seems authoritative.

Am I correct that, even if I use FC3 (Read Holding Registers), I can still access the bits as ChanDi's, and I don't have to write some code to convert a UINT into bits?


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

Modbus-TCP and S7-1200 5 years 10 months ago #9706

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

Yes, that is correct. For HoldingRegisters, the incoming values are Int16, but you can choose how to interpret them by using ChanAi, ChanIi, ChanDi or ChanBi. For ChanDi set representation to Bit16 and the bit number in ChanDi.Number from 0 to 15. Only ChanDi for bit that are used have to be present, but Number 0 should always be there to indicate the start of a new word.

/Claes
The administrator has disabled public write access.
The following user(s) said Thank You: MattBerglund, N4WR3

Modbus-TCP and S7-1200 5 years 10 months ago #9708

Thanks and solved!
-Matt
The administrator has disabled public write access.

Modbus-TCP and S7-1200 5 years 8 months ago #9769

  • N4WR3
  • N4WR3's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
Number 0 should always be there to indicate the start of a new word
Thank you very much Claes. I was having a hard time reading coils state with modbus TCP and Bit8 ChanDi.
I was using ChanDi.Number = 1 to read my first coil instead of ChanDi.Number = 0.
Now it's working perfectly! B)
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 8.172 seconds