威纶通官方论坛

数值修改后发送问题

[复制链接]
发表于 2014-2-19 08:43:59 | 显示全部楼层 |阅读模式
本帖最后由 guwang1971 于 2014-2-19 10:14 编辑

//数值改变后写入数据到仪表

//发送子程序
sub unsigned short SJX(unsigned short A, unsigned short  B)
unsigned char command[32],response[32]
unsigned short address, checksum,result
  short return_value

FILL(command[0], 0, 32) // 初始化command[0]~command[31] to 0
FILL(response[0], 0, 32)

command[0] = 0x01 // 站号
command[1] = 0x10 //写寄存器 (功能码是 0x10)

address = A// 起始地址是A
HIBYTE(address, command[2])
LOBYTE(address, command[3])

HIBYTE(B, command[4])
LOBYTE(B, command[5])

CRC(command[0], checksum, 6)// CRC校验计算
LOBYTE(checksum, command[6])
HIBYTE(checksum, command[7])

OUTPORT(command[0], "SB194E", 8)// 发送写命令
INPORT(response[0], "SB194E", 8, return_value)// 读取回复的命令
return result
end sub

//如果两次(间隔)的数值不一样,则调用子程序发送修改后的数值
macro_command main()
unsigned short X,B
GetData(X, "Local HMI", LW, 1, 1)
DELAY(1)
GetData(B, "Local HMI", LW, 1, 1)
if X<>B then
unsigned short A=1
SJX(A, B)
end if
end macro_command

以上程序数值修改后不能发送(没反应),错在哪里,该怎么改,麻烦师傅解答
另数值修改后发送有何办法,
OUTPORT和INPORT只能用在PLC类型为Free Protocol中吗,谢谢
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2025-5-13 04:17

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

快速回复 返回顶部 返回列表