请高手指点:用VB编写向PLC发送数据的方法,最好能给写一个实例

来源:百度知道 编辑:UC知道 时间:2024/06/07 10:57:48
我想用上位机来控制PLC

具体要看协议,实例只能帮助你使用语句,最终要理解协议,这才是关键
我的邮箱:vbediter@126.com

a(0) = &H68
a(1) = &H99
a(2) = &H99
a(3) = &H99
a(4) = &H99
a(5) = &H99
a(6) = &H99
a(7) = &H68
a(8) = &HA
a(9) = &H8
a(10) = &H34
a(11) = &H34

temp(0) = "&h" & Mid(Text3.Text, 11, 2) '表号
temp(1) = "&h" & Mid(Text3.Text, 9, 2) '表号
temp(2) = "&h" & Mid(Text3.Text, 7, 2) '表号
temp(3) = "&h" & Mid(Text3.Text, 5, 2) '表号
temp(4) = "&h" & Mid(Text3.Text, 3, 2) '表号
temp(5) = "&h" & Mid(Text3.Text, 1, 2) '表号

a(12) = add_33h(temp(0))
a(13) = add_33h(temp(1))
a(14) = add_33h(temp(2))
a(15) = add_33h(temp(3))
a(16) = add_33h(temp(4))
a(17) = add_33h(temp(5))

a(18) = sum_my(a, 17)
a(19) = &H16

MSComm1.InputLen = 0
If MSComm1.PortOpen = False Then
MSComm1.CommPort =