Modbus RTU协议主控实现 [英] Modbus RTU Protocol Master Implementation

查看:149
本文介绍了Modbus RTU协议主控实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的问题很奇怪,所以我为此道歉。



我将在名为DiGi Module Connect Me 9210的电子设备中实现Modbus RTU Master和Modbus TCP Master。从这个设备我将要求PIC的一些数据,如节点和温度等数据和一些其他数据。我只想在我的设备中实现FC 04/03/16。



Digi模块是一个电子设备,为此我将创建C#GUI从PIC请求数据使用GUI通过DiGi模块,因为Digi将使用Modbus RTU协议与PIC连接。在使用Digi获取数据后,我们将使用Modbus TCP在云上发送数据。



从GUI到DIgI我将拥有TCP / IP,从DIGI到PIC I将拥有Modbus RTU以及Cloud和DiGi之间我将拥有Modbus TCP。



我想在C#中删除我的数据,所以我只需要从GUI发送请求PIC通过DIGI(因此我的DIGI将成为GUI和PIC之间的桥梁)来配置节点或从PIC获取节点数据。我必须使用80请求或其他东西一次读取近9999个寄存器以从3X / 4X寄存器获取数据。现在的问题是。


$ b $b☺如何在C#中删除我的数据。?


$ b $b☺如何在设备或系统中同时实现Modbus RTU / TCP。?


$ b $b☺如何通过GUI读取所有9999寄存器,因为我可能想要全部读取来自3X寄存器的RunTime数据。?


$ b $b☺如何写/读所有4X寄存器。?



我们也在实现分页技术,这意味着第0页将有9999个寄存器,然后第1页将有9999个寄存器。因此,如果我想读取温度,我必须转到第0页并读取寄存器,如果我想读取速度值,我必须转到第1页并检查所有寄存器。?



GUI看起来像某样东西



用户将添加节点编号然后添加温度并提交请求。



谢谢

Muhammad Azym

Hi,

My question would be weird so I do apologize for that.

I am going to implement Modbus RTU Master and Modbus TCP Master in an electronic device Called "DiGi Module Connect Me 9210". From this device I will request some data from PIC, data like Nodes and Temperatures and Some other data. I just want to Implement FC 04/03/16 in my device.

The Digi Module is an electronic device so for this purpose I am going to create C# GUI to request data from the PIC Using GUI via DiGi Module because Digi will be connected with PIC using Modbus RTU Protocol. And after getting the data in Digi we will send that data on cloud using Modbus TCP.

From GUI to DIgI I will have TCP/IP and from DIGI to PIC I will have Modbus RTU and between Cloud and DiGi I will have Modbus TCP.

I want to strip out my data in C# so I will just send request from the GUI to PIC via DIGI (so my DIGI would a bridge between GUI and PIC) to configure the node or get node data from PIC. I have to read almost 9999 registers in one go using 80 request or something else to get the data from 3X / 4X registers. Now the questions are.

☺ How can I strip my data in C#.?

☺ How to implement Modbus RTU/TCP same time in a device or a system.?

☺ How can I read all the 9999 registers via GUI because I might want to read all the RunTime data from the 3X registers.?

☺ How can I write/Read all the 4X registers as well.?

We are also implementing the paging technique so it means that page 0 will have 9999 registers and then page 1 will have 9999 registers. So if I want to read temperatures I have to go to page 0 and read the registers and if I want to read Speed values I have to go to page 1 and check all the registers.?

The GUI would look like some thing

User will add Node Number and then Temperature and Submit the request.

Thanks
Muhammad Azym

推荐答案

使用 NModbus [ ^ ]

请参阅: http ://www.mesta-automation.com/modbus-with-c-sharp-libraries-examples/ [ ^ ]。



但你需要看清楚:Modbus / TCP通过TCP / IP工作,Modbus / RTU可以通过RS232和RS485等串行协议工作。你不能只是混合它们。如果digi模块不是modbus网关,它将无法工作。正如我所见,Digi模块可以编程为网关,但你真的想要这个吗?

如果PC软件将轮询PIC,则需要在PIC上实现Digi Modbus / TCP从站(非主站)+ Modbus / RTU主站和Modbus / RTU从站。

但是,使用现成的设备可能会更便宜。像这样: http://www.moxa.com/product/MGate_MB3180_3280_3480.htm [ ^ ]。甚至更便宜: http://www.shjelectronic.com/EthernetModules.htm [ ^ ]

即使Digi拥有自己的网关:http://www.digi.com/products/serial-servers/industrial-hardened-serial- servers / digioneia [ ^ ]



当然,如果这是你的愿望,继续,并编程Digi。您可以在其上实现Modbus / RTU和Modbus / TCP堆栈。由于设备可以托管嵌入式Linux ...你可以从这个开始: http://mbus.sourceforge.net/ [< a href =http://mbus.sourceforge.net/target =_ blanktitle =New Window> ^ ],但可能是其他人准备好了。



从协议的角度来看,如果需要,您可以一次读取所有寄存器。不要试图重新发明轮子,因为Modbus是一个相当古老和广泛使用的行业标准包。很多东西都支持它,但如果你试图添加你自己的花哨的东西,它将不再符合,你将来会挣扎。



For测试你可以使用标准 Modscan32 [ ^ ] - 但这不值得付出代价(对不起朋友) - 更好的方法是使用NModbus实现。



另一方面,您根本不需要Modbus / TCP,因为您可以在以太网端实现更高级别的服务。如果您严格需要工业标准,请实施OPC UA。如果没有,请放置REST API。如果目标是非通用数据采集,则更容易实现和适应。
Use NModbus[^]
See: http://www.mesta-automation.com/modbus-with-c-sharp-libraries-examples/[^].

But you need to see something clear: Modbus/TCP works over TCP/IP, Modbus/RTU works over serial protocols like RS232 and RS485. You can't just mix them. If the digi module is no modbus gateway, it won't work. As I see, the Digi module could be programmed to be a gateway, but do you really want this?
You need to implement on the Digi Modbus/TCP Slave (not master) + Modbus/RTU Master, and Modbus/RTU slave on the PIC - if the PC software will poll the PIC.
However, you could end up much cheaper with a ready-made device. Like this one: http://www.moxa.com/product/MGate_MB3180_3280_3480.htm[^]. Or even cheaper with these: http://www.shjelectronic.com/EthernetModules.htm[^]
Even Digi has it's own gateway: http://www.digi.com/products/serial-servers/industrial-hardened-serial-servers/digioneia[^]

Of course, if this is your desire, go on, and program the Digi. You can implement both Modbus/RTU and Modbus/TCP stacks on it. As the device can host Embedded linux... you could start from this one: http://mbus.sourceforge.net/[^], but could be others out there ready to run.

From protocol's point of view you can read all registers at once, if you want. Don't try to reinvent the wheel, as Modbus is a quite old and widely used industry standard pack. Many things are supporting it, but if you try to add your own fancy things, it won't be compliant anymore, and you will struggle in the future.

For testing you can use the "standard" Modscan32[^] - but it's not worth the price (sorry folks) -, better simply implement your with NModbus.

On the other hand, you don't need Modbus/TCP at all, because you can implement higher level services on the ethernet side. If you strictly need industrial standards, implement OPC UA. If not, put a REST API in place. Far simpler to implement, and to adapt - if the goal is non generic data acquisition.


这篇关于Modbus RTU协议主控实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆