plc 上位机程序
答案:2 悬赏:70
解决时间 2021-02-08 10:52
- 提问者网友:前事回音
- 2021-02-07 10:06
plc 上位机程序
最佳答案
- 二级知识专家网友:年轻没有失败
- 2021-02-07 11:26
这可能是他们自己编写的一个DLL,你到安装包里面看看有没有这个DLL,然后手动注册就OK了,到网上搜索注册方法,很简单,再没有产家要
全部回答
- 1楼网友:有钳、任性
- 2021-02-07 12:40
'窗体上添加一个mscomm,一个按钮,然后粘贴如下代码,点一下按钮,然后plc发送数据,如果程序收到了,会给出确认消息
private const startflag = &ha0
private const endflag = &h23
private sub command1_click()
static db() as byte
dim t() as byte
dim i as long, j as long
command1.enabled = false
mscomm1.commport = 1
mscomm1.settings = "9600,n,8,1"
mscomm1.inputlen = 0
mscomm1.inputmode = cominputmodebinary
mscomm1.portopen = true
redim db(0 to 0) as byte
dim found as long
do
doevents
t = mscomm1.input
if ubound(t) >= 0 then
redim preserve db(lbound(db) to ubound(db) + ubound(t) - lbound(t) + 1) as byte
j = ubound(t)
for i = ubound(db) to lbound(db) step -1
db(i) = t(j)
debug.print t(j)
j = j - 1
if j < lbound(t) then exit for
next i
found = -1
for i = lbound(db) to ubound(db)
if db(i) = startflag then
found = i
end if
if db(i) = endflag and found <> -1 then
exit for
end if
next i
if i <= ubound(db) then
dim s as string
for j = found to i
s = s & hex(db(j)) & " "
next j
msgbox s
exit do
end if
end if
loop
command1.enabled = true
mscomm1.portopen = false
end sub
不明白的请百度hi
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯