Hello!
We are EA Elektro-Automatik company from Germany, a big power supply manufacturer. We use ModBus RTU and TCP in our devices for years now,
but have been pointed by customers to the fact that our devices are not fully compatible to the ModBus specification. Reviewing the specs we think we know where we did wrong, but are not sure. Maybe someone here can help.
Read Coils (RC): the specs say that there can be up to 2000 coils, but it doesn't say that a device must support to read 2000 coils, whether they are all used or not, or if the limit can be lower. Let's say we would define to have 16 coils in use we would define that the user can read up to 16 coils and when trying to read more, there will be error 03. Next problem: if we define 16 coils as maximum, the specification doesn't say that the device must also support to read 1-15 coils. So far we defined that the user must always read 16 coils in order to get 16 in return. Reading less than 16 would also return error 03.
Write Single Coil (WSC): This is actually a paradox for me, because with RC one coil corresponds to one bit, but with WSC 16 bits are written (0xFF00, 0x0000) for one coil. That's why we defined that if some one wants to read what has been written to a WSC register he would have to use RC with 1 coils and so the register would return 0xFF00 or 0x0000. This is where we went wrong. But it seems logical to me, because the specs also don't define that a register which I can write with WSC can't be read with RC. However, it turns out that reading 1 coil with RC and returning 0xFF00 is considered as actually reading 16 bits (or 9-16), so that a stock software would return an error. The coils to read with RC are put in the memory at some address, let's say 0x0000. 2000 coils are 250 bytes (0xFA) which corresponds to 125 ModBus registers. But with WSC I could not address all of these 2000 single coils because every addressable coil register already contains 16 coils. Means with WSC I can eventually address 125 coils by writing 0xFF00 or 0x0000, but would have to read 16 to have the logical state (TRUE/FALSE) back. Confusing.
Conclusion: thinking through all of this I get the feeling that ModBus isn't made to read a coil that has been written with WSC. Am I right? That's a weird approach, but it seems to be the root problem.
We are EA Elektro-Automatik company from Germany, a big power supply manufacturer. We use ModBus RTU and TCP in our devices for years now,
but have been pointed by customers to the fact that our devices are not fully compatible to the ModBus specification. Reviewing the specs we think we know where we did wrong, but are not sure. Maybe someone here can help.
Read Coils (RC): the specs say that there can be up to 2000 coils, but it doesn't say that a device must support to read 2000 coils, whether they are all used or not, or if the limit can be lower. Let's say we would define to have 16 coils in use we would define that the user can read up to 16 coils and when trying to read more, there will be error 03. Next problem: if we define 16 coils as maximum, the specification doesn't say that the device must also support to read 1-15 coils. So far we defined that the user must always read 16 coils in order to get 16 in return. Reading less than 16 would also return error 03.
Write Single Coil (WSC): This is actually a paradox for me, because with RC one coil corresponds to one bit, but with WSC 16 bits are written (0xFF00, 0x0000) for one coil. That's why we defined that if some one wants to read what has been written to a WSC register he would have to use RC with 1 coils and so the register would return 0xFF00 or 0x0000. This is where we went wrong. But it seems logical to me, because the specs also don't define that a register which I can write with WSC can't be read with RC. However, it turns out that reading 1 coil with RC and returning 0xFF00 is considered as actually reading 16 bits (or 9-16), so that a stock software would return an error. The coils to read with RC are put in the memory at some address, let's say 0x0000. 2000 coils are 250 bytes (0xFA) which corresponds to 125 ModBus registers. But with WSC I could not address all of these 2000 single coils because every addressable coil register already contains 16 coils. Means with WSC I can eventually address 125 coils by writing 0xFF00 or 0x0000, but would have to read 16 to have the logical state (TRUE/FALSE) back. Confusing.
Conclusion: thinking through all of this I get the feeling that ModBus isn't made to read a coil that has been written with WSC. Am I right? That's a weird approach, but it seems to be the root problem.