Dim s1 As String
Dim s2 As String
Dim s22 As String
Dim s3 As String
Dim s4 As String
Timer1.Enabled = False
s2 = "010105000001"
s22 = LRC(s2)
s1 = ":" + s2 + s22 + Chr$(13) + Chr$(10)
MSComm1.Output = s1
s3 = MSComm1.Input
s4 = Mid$(s3, 6, 8)
If s4 = "0500FF00" Then
Text1.Text = "Y0为1"
Else
Text1.Text = "Y0为0"
Eed If
我想通过VB来读取台达PLC 输出Y0的状态,可运行显示的总是Y0为0,不管Y0是0还是1。VB也不报错,我想问下各位大哥大姐,问题出在哪里了?还有,如果要读取模拟量,它的地址应该是多少?采用哪个功能码?非常急,急盼各位高手的解答。在线等候!!!!!!!!
发送与接收中间做个延时。
写一条 text2.text=s3, 看一下 Mscomm1.input 数据对不对
欢迎来我的淘宝店逛逛,PLC、触摸屏编程电缆连接电缆
http://shop35903381.taobao.com