电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

VBMODBUS实现源码VIP免费

VBMODBUS实现源码_第1页
1/17
VBMODBUS实现源码_第2页
2/17
VBMODBUS实现源码_第3页
3/17
Option Explicit Public bln_busy As Boolean Public bln_success As Boolean Public bln_readword As Boolean Public Declare Function timeGetTime Lib "winmm.dll" () As Long Public Sub tran_modbus_order(ByVal byt_slv_id As Byte, ByVal byt_func As Byte, ByVal addr As Long, byt_data() As Byte) Dim trans_byte() As Byte Dim i As Integer Dim j As Integer Dim k As Integer Dim Index As Integer Dim CRC() As Byte Dim temp As Integer Dim lenth As Integer Dim lenth1 As Integer Select Case byt_func Case 1 ReDim trans_byte(7) As Byte trans_byte(0) = byt_slv_id trans_byte(1) = 1 trans_byte(2) = (addr - 1) \ 256 trans_byte(3) = (addr - 1) Mod 256 trans_byte(4) = 0 trans_byte(5) = byt_data(0) CRC = CRC16(trans_byte) trans_byte(6) = CRC(0) trans_byte(7) = CRC(1) Case 3 ReDim trans_byte(7) As Byte trans_byte(0) = byt_slv_id trans_byte(1) = 3 trans_byte(2) = (addr - 1) \ 256 trans_byte(3) = (addr - 1) Mod 256 trans_byte(4) = 0 trans_byte(5) = byt_data(0) CRC = CRC16(trans_byte) trans_byte(6) = CRC(0) trans_byte(7) = CRC(1) Case 6 ReDim trans_by te(7) As By te trans_by te(0) = by t_slv _id trans_by te(1) = 6 trans_by te(2) = (addr - 1) \ 256 trans_by te(3) = (addr - 1) Mod 256 trans_by te(4) = by t_data(0) trans_by te(5) = by t_data(1) CRC = CRC16(trans_by te) trans_by te(6) = CRC(0) trans_by te(7) = CRC(1) Case 15 lenth = UBou nd(by t_data) + 1 lenth1 = (lenth - 1) \ 8 + 1 ReDim trans_by te(8 + lenth1) trans_by te(0) = by t_slv _id trans_by te(1) = &HF trans_by te(2) = (addr - 1) \ 256 trans_by te(3) = (addr - 1) Mod 256 trans_by te(4) = 0 trans_by te(5) = lenth trans_by te(6) = lenth1 k = 0 Index = 7 temp = 0 For i = 1 To lenth temp = temp + by t_data(i - 1) * (2 ^ k) If (i Mod 8 = 0...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

VBMODBUS实现源码

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部