怎么通过modbus poll 注册码poll+Slave模拟modbus poll 注册码通信

博客访问: 230860
博文数量: 80
博客积分: 2003
博客等级: 大尉
技术积分: 815
注册时间:
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
Modbus Poll是一个非常好的调试Modbus通讯的工具。如果没有Slave端,可以使用Modbus Slave模拟多个Slave端。Modbus Poll提供了一些API,方便用户进行二次开发,但是开发工具只限于VB,当然还可以通过Excel控制也可以。
下面的文档来源于Modbus Poll的帮组文档,如果您对Modbus协议不熟悉,请阅读Modbus协议。
Automation Overview
Automation (formerly known as OLE Automation) makes it possible for one application to manipulate objects implemented in another application.An Automation client is an application that can manipulate exposed objects belonging to another application. This is also called an Automation controller.An Automation server is an application that exposes programmable objects to other applications. Modbus Poll is an automation serverThat means you can use any program that supports VBA (Visual Basic for Applications) such as Visual Basic, Excel etc. to interpret and show the modbus data according to your specific requirements.
The VBA links to the mbpoll.tlb file, (Type Library) which is installed in the directory where you installed Modbus Poll. If not registered automatic then use references in the tools menu in Visual Basic and browse for mbpoll.tlb.&Hint:You should enable the auto connection in the connection menu in order to establish a connection when Modbus Poll is started by a client.
Automation Setup Functions
Function CreateRequest(SlaveID As Long,
Function As Long,Address As Long,Length As Long, ScanRate As Long) As Long
Return ValueTrue if success. False if not success
ParametersSlaveID, The slave address 1 to 255. (247 is max according to Modbus specification)Function, 1, 2, 3 or 4Address, The data address (Base 0)Length, The number of data. 1 to 127 if registers. 1 to 256 if coilsPollRate, 50 to 10000ms&RemarksYou have to create a request before you can use properties to read
Sub ShowWindow()Call this function if you want the window to be shown in Modbus Poll. If ShowWindow is not called the Modbus Poll is not visible.
DisplayFormat As Long
Values0 = DISPLAY SIGNED1 = DISPLAY UNSIGNED,2 = DISPLAY HEX,3 = DISPLAY BINARY,4 = DISPLAY FLOAT,5 = DISPLAY FLOAT INVERSE,6 = DISPLAY DOUBLE,7 = DISPLAY DOUBLE INVERSE,8 = DISPLAY INT,9 = DISPLAY INT INVERSE
Property ReadResult As IntegerReturn ValueUse this property to check if communication established with CreateRequest is running successful.0 = SUCCESS1 = TIMEOUT_ERROR2 = CRC_ERROR3 = RESPONSE_ERROR (The response was not the expected slave id, function or address)
4 = WRITE_ERROR5 = READ_ERROR6 = PORTNOTOPEN_ERROR10 = DATA_UNINITIALIZED11 = BYTESMISSING_ERROR (Expected 81h = ILLEGAL FUNCTION82h = ILLEGAL DATA ADDRESS83h = ILLEGAL DATA VALUE84h = FAILURE IN ASSOCIATED DEVICE85h = ACKNOWLEDGE86h = BUSY, REJECTED MESSAGE87h = NAK-NEGATIVE ACKNOWLEDGMENT
Property WriteResult As IntegerDescriptionReturns a write result as integer.Use this function to check if a write was successful. The value is DATA_UNINITIALIZED until the result from the slave is available. See ReadResult for a list of possible values.
utomation Properties
The below properties are used to set or get values in the internal write/read arrays in Modbus Poll.Example 1:
m_svr1 is assumed created first. See Excel example.
m_svr1.Register(0) = 1m_svr1.Register(1) = 10m_svr1.Register(2) = 1234
status = m_svr1.PresetMultipleRegisters(1, 0, 3)& ?Write the 3 register stored in Modbus Poll&Example 2 with floating point values:
m_svr1.Float(0) = 1.3m_svr1. Float (1) = 10.5m_svr1. Float (2) = 1234.12status = m_svr1.PresetMultipleRegisters(1, 0, 6)& ?Write the 6 register stored in Modbus Poll
6 Registers are written as float is 32 bit wide.
Property Coil(Index As Integer) As IntegerDescriptionSets a coil in the write array structure or return a coil from the read arraySyntaxObject.Coil(Index) [=newvalue]
Property Register(Index As Integer) As IntegerDescriptionSets a register in the write array structure or return a register from the read arraySyntaxObject.Register (Index) [=newvalue]
Property Long(Index As Integer) As LongDescriptionSets a long in the write array structure or return a long from the read arraySyntaxObject.Long (Index) [=newvalue]
Property LongInv (Index As Integer) As LongDescriptionSets a long in the write array structure or return a long from the read arraySwap low and high order word.If display format is swapped, you should not use this function as they are swapped in advance.SyntaxObject.LongInv (Index) [=newvalue]
Property Float(Index As Integer) As SingleDescriptionSets a float in the write array structure or return a float from the read arraySyntaxObject.Float (Index) [=newvalue]
Property FloatInv (Index As Integer) As SingleDescriptionSets a float in the write array structure or return a float from the read arraySwap low and high order word.If display format is swapped, you should not use this function as they are swapped in advance.SyntaxObject.FloatIn (Index) [=newvalue]
Property Double(Index As Integer) As DoubleDescriptionSets a double in the write array structure or return a double from the read arraySyntaxObject.Double (Index) [=newvalue]
Property DoubleInv(Index As Integer) As DoubleDescriptionSets a double in the write array structure or return a double from the read arraySwap low and high order word.If display format is swapped, you should not use this function as they are swapped in advance.SyntaxObject. DoubleInv (Index) [=newvalue]
Automation Write Functions
Function ForceSingleCoil(SlaveID As Long, Address As Long) As BooleanReturn ValueTrue if write buffer is empty and the data are send. False if buffer not empty or error in parametersThe controlling application is responsible for verifying the write operation by reading back the value written.ParametersSlaveID, The slave address 0 to 247Address, The data address (Base 0)DescriptionWrite the first coil stored in the write array.Function 05 is used.
BOOL PresetSingleRegister (long SlaveID, long Address)Return ValueTrue if write buffer is empty and the data are send. False if buffer not empty or error in parametersThe controlling application is responsible for verifying the write operation by reading back the value written.ParametersSlaveID, The slave address 0 to 247Address, The data address (Base 0)DescriptionWrite the first register stored in the write array.Function 06 is used.
Function ForceMultipleCoils(SlaveID As Long, Address As Long, Length As Long) As Boolean
Return ValueTrue if write buffer is empty and the data are send. False if buffer not empty or error in parametersThe controlling application is responsible for verifying the write operation by reading back the value written.ParametersSlaveID, The slave address 0 to 247Address, The data address (Base 0)Length, The number of data. 1 to 256DescriptionWrite the first Length coils stored in the write array.Function 15 is used.
Function PresetMultipleRegisters(SlaveID As Long, Address As Long, Length As Long) As BooleanReturn ValueTrue if write buffer is empty and the data are send. False if buffer not empty or error in parametersThe controlling application is responsible for verifying the write operation by reading back the value written.ParametersSlaveID, The slave address 0 to 247Address, The data address (Base 0)Length, The number of data. 1 to 127DescriptionWrite the first registers stored in the write array.Function 16 is used.
在使用前,首先创建一个VB对象
Dim Server As Object
Server& = CreateObject("mbpoll.Document")
然后可以请求Polling服务。
需要注意一点:在写数据的时候,因为ModBus Poll要求只能写已经请求Polling的服务,所以在写以前,需要创建一个对应于写命令的读的Polling服务
下面是按照我的需要做的定义
Select Case Func
&&& Case 5
&&& &&&&&read = 4
&&& Case 6
&&& &&&&&read = 3
&&& Case 15
&&& &&&&&read = 4
&&& Case 16
&&& &&&&&read = 3
End Select
WriteServer.CreateRequest(ID, read, Adr, Len, 5)
If (Show.Checked = True) Then
WriteServer.ShowWindow()
下面是开发的界面,如果需要代码请回贴告诉我,告诉我你的信箱。
500)this.width=500;" border=0>
阅读(6065) | 评论(34) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
大神!能发一份用VB或者excel上的VB或者VC调用modbus&poll测到的数据的数据吗,我的邮箱,多谢了!另外希望能加你QQ,希望得到你的关于这个软件二次开发的指导
:太好了。。请发给我一份源码&&感谢不尽
最近在调一个变频器的MODBUS通信,用到了ModbusPoll&,看到它提供了Visual&Basic接口,还有例程序,但是看不太明白。能从网上找到,二次开发的例子,太好了!楼主给发一份过来吧,感谢! |
太好了。。请发给我一份源码&&感谢不尽
楼主,好样的,能否发我一份,对我来说,太有用了,发来参考参考,感谢!
我现在正在开发一个modbus软件.需您的代码作参考.希望您不吝赐教.邮箱:
请登录后评论。怎么通过ModBuspoll+Slave模拟modBus通信_百度知道怎么通过ModBuspoll+Slave模拟modBus通信_百度知道modbus_poll_快速入门到精通_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
modbus_poll_快速入门到精通
上传于||文档简介
&&m​o​d​b​u​s​_​p​o​l​l​_​快​速​入​门​到​精​通
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩6页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢}

我要回帖

更多关于 modbus poll 6 注册码 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信