I noticed that when using Codesys as a Modbus Master there seem to be a problem when using function 23 (Read/Write Multiple Registers).
It seems that the offset for the write has to be set in number of bytes instead of number of registers like all the other functions. For the read, it is working fine.
For example, if my slave has 60 registers and from my master I want to write 10 registers starting at the 20th register, I would have to set the offset at 40 instead of 20.
I also noticed that if the slave has just enough registers, it does not work.
For example, if you take my previous example but the slave only has 40 registers it does not work. 50 registers does not work either. It needs at least 60 registers for the slave in the previous example for it to work.
I am testing it on Codesys 3.5 SP16 on a raspberry pi. Both my master and slave are in the same codesys project. I only tested it with modbus TCP. I don't know if it behaves the same with modbus RTU.
Regards.
Last edit: yannickasselin 2020-08-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I noticed that when using Codesys as a Modbus Master there seem to be a problem when using function 23 (Read/Write Multiple Registers).
It seems that the offset for the write has to be set in number of bytes instead of number of registers like all the other functions. For the read, it is working fine.
For example, if my slave has 60 registers and from my master I want to write 10 registers starting at the 20th register, I would have to set the offset at 40 instead of 20.
I also noticed that if the slave has just enough registers, it does not work.
For example, if you take my previous example but the slave only has 40 registers it does not work. 50 registers does not work either. It needs at least 60 registers for the slave in the previous example for it to work.
I am testing it on Codesys 3.5 SP16 on a raspberry pi. Both my master and slave are in the same codesys project. I only tested it with modbus TCP. I don't know if it behaves the same with modbus RTU.
Regards.
Last edit: yannickasselin 2020-08-12