如何查看CODESYS中MODBUS TCP/IP保持寄存器的原始内存地址

huangapple go评论50阅读模式
英文:

How do I view raw memory addreses of MODBUS TCP/IP holding registers in CODESYS

问题

为了一个工作项目,我需要读取一个使用CODESYS 3.5编程的IFM CR1203 PLC的一堆保持寄存器。

PLC将运行一个从设备实例,读取保持寄存器的设备将是一个运行自定义Javascript应用程序的PC,该应用程序被编程为客户端。我已经为自定义应用程序编程了MODBUS TCP/IP功能,经过测试可用(对于之前的一个项目,我必须为使用不同平台编程的不同PLC执行相同的操作)。

我的当前问题是,我需要原始存储器地址的第一个保持寄存器,但我在CODESYS IDE上找不到它。CODESYS使用一个寻址系统,使不同基于CODESYS的设备之间的通信变得容易。以下是一个解释它如何工作的链接:CODESYS MODBUS寄存器位置指南

唯一看起来可行的是来自上面的链接:

<memory position> : <number> ( .<number> )* // 取决于目标系统

但我不完全理解这一切的含义。

我也找不到有关PLC或CODESYS的任何详细解释这个主题的文档。以下是用于测试的虚拟代码片段,显示了CODESYS地址:

如何查看CODESYS中MODBUS TCP/IP保持寄存器的原始内存地址

请问有人可以解释一下如何将值%IW0转换为原始存储器地址,例如0xFFFF吗?

英文:

For a work project, I have to read a bunch of holding registers from an IFM CR1203 PLC that is programmed using CODESYS 3.5.

The PLC will be running a slave instance and the device reading the holding registers will be a PC running a custom application programmed in Javascript to be a client. I have already programmed MODBUS TCP/IP functions for the custom application that is tested and works (For a previous project I had to do the same for a different PLC programmed using a different platform).

My current issue is that I need the raw memory address of the first holding register to do this, but I can't find it on the CODESYS IDE. CODESYS uses an addressing system that makes it easy for different CODESYS-based devices to communicate. Here is a link that explains how it works: CODESYS MODBUS register location guide

The only thing that looks like it can work is from the link above:

&lt;memory position&gt; : &lt;number&gt; ( .&lt;number&gt; )* // Depends on the target system

But I don't fully understand what all that means.

I also can't find any documentation on the PLC or CODESYS that explains this topic in enough detail. Here is a snippet of dummy code used for testing that shows the CODESYS addresses:

如何查看CODESYS中MODBUS TCP/IP保持寄存器的原始内存地址

Can someone please explain to me how I can convert the value %IW0 to a raw memory address, for example, 0xFFFF?

答案1

得分: 1

在他们的文档中写道:

从主视角来看,I/O 被映射到 Modbus 寄存器,如下所示:

  • %IWs 从寄存器 0 映射到 n-1,并且是可读/写的(n = 保持寄存器数量,每个 %IW 寄存器占用 2 个字节)。
  • %QWs 从寄存器 n 映射到 n+m-1,只读(m = 输入寄存器数量,每个 %QW 寄存器占用 2 个字节)。

所以在您的示例中,它们应该是地址 0 和 1。

英文:

I use Machine Expert (Codesys 3.5.16) and in their documentation says:

> The I/Os are mapped to Modbus registers from the master perspective as follows:
>
> - %IWs are mapped from register 0 to n-1 and are R/W (n = Holding register quantity, each %IW register is 2 bytes).
>
> - %QWs are mapped from register n to n+m -1 and are read only (m = Input registers quantity, each %QW register is 2 bytes).

So in your example they should be address 0 and 1.

huangapple
  • 本文由 发表于 2023年2月16日 17:00:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75469877.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定