VB 控件Mscomm 控件与PLC 进行RS485(Modbus)通讯源码 本人用的是Modbus RTU 通讯模式,通过计算机串口转RS485 与外围设备通行通讯,读写外围设备指定地址里的数据,从而达到自动化控制远端设备
Dim HiByte As Byte Dim LoByte As Byte Dim CRC16Lo As Byte Dim CRC16Hi As Byte Dim ReturnData(1) As Byte Dim K As Integer Dim CmdLenth As Integer Private Sub Command1_Click() K = Text9
Text '写6 个字节 Text13
Text = "" '=========== 数组赋值输入代码 ======================================================================================= '> Dim WriteStr() As Byte Dim u As Integer ReDim WriteStr(K + 2) For u = 0 To K WriteStr(u) = Val("&H" & Text1(u)
Text) Next '> Dim CRC_2() As Byte Dim v As Integer ReDim CRC_2(K) For v = 0 To K CRC_2(v) = Val("&H" & Text1(v)
Text) Next '==================================================================================================