You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by "zhy1378 (via GitHub)" <gi...@apache.org> on 2024/01/09 17:50:14 UTC

[D] How do I configure the PLC memory address to start at 0 instead of 1 when using PLC4j Modbus-TCP?

GitHub user zhy1378 created a discussion: How do I configure the PLC memory address to start at 0 instead of 1 when using PLC4j Modbus-TCP?

I'm using PLC4j's Modbus-TCP implementation to communicate with a Siemens S7-200 PLC. The PLC addresses memory locations starting at 0, but PLC4j requires addresses to start at 1 when adding register items. This prevents me from reading address 0 in the PLC.

While other PLC brands may start addressing at 1, Siemens PLCs start at 0. So I believe the address checking in the addItem() method is not appropriate in this case.

Is there a way to configure PLC4j to allow starting register addresses at 0 instead of 1? Or alternatively, is there a way to disable the address validation check so I can specify address 0? I need to be able to read the full range of PLC memory including location 0.

GitHub link: https://github.com/apache/plc4x/discussions/1330

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] How do I configure the PLC memory address to start at 0 instead of 1 when using PLC4j Modbus-TCP?

Posted by "zhy1378 (via GitHub)" <gi...@apache.org>.
GitHub user zhy1378 added a comment to the discussion: How do I configure the PLC memory address to start at 0 instead of 1 when using PLC4j Modbus-TCP?

Hi, thanks for your answer.

Your suggestion is what I am doing right now - using address 1 as the starting address instead of 0.

Arrays and lists begin at 0, not 1, in most programming languages. I have been programming for over 10 years before using PLCs and Modbus-TCP, and having addresses start at 0 aligns better with my experience.

Even though the Modbus specification defines 1 as the starting address, stopping the check for non-zero addresses would likely work better in this situation and provide more compatibility. Do you agree?

While the Modbus standard specifies starting at 1, allowing a starting address of 0 seems more intuitive for those with a programming background. Disabling the address validation would enable full compatibility with PLCs like Siemens that start addressing memory at 0. Given my background, starting addresses at 0 feels more natural as well. What are your thoughts on disabling the address check?

GitHub link: https://github.com/apache/plc4x/discussions/1330#discussioncomment-8074254

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] How do I configure the PLC memory address to start at 0 instead of 1 when using PLC4j Modbus-TCP?

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
GitHub user chrisdutz added a comment to the discussion: How do I configure the PLC memory address to start at 0 instead of 1 when using PLC4j Modbus-TCP?

I agree, c that this seems odd for us IT folks. However what do you think would happen, if we removed that check? We'd be sending -1 on the wire.
We could add a config option to the connection string to start at 0, but that's I guess the only way to solve this. 

GitHub link: https://github.com/apache/plc4x/discussions/1330#discussioncomment-8075894

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] How do I configure the PLC memory address to start at 0 instead of 1 when using PLC4j Modbus-TCP?

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
GitHub user chrisdutz added a comment to the discussion: How do I configure the PLC memory address to start at 0 instead of 1 when using PLC4j Modbus-TCP?

Hi,

According to the Modbus spec there technically is no Register 0 or coil 0 ... however many vendors don't implement their protocol-stack correcly according to this spec. 

If you read Coil 1, all addresses are sent over the wire as x-1 ... so 1 becomes 0 ... please try if simply adding 1 to all your addresses gives you the results you're looking for.

GitHub link: https://github.com/apache/plc4x/discussions/1330#discussioncomment-8070157

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org