赞
踩
- //TK6071IQ
- //自由协议
- macro_command main()
- char command[32]
- short address, checksum
- FILL(command[0], 0, 32) // 初始化命令
- Command[0] = 0x1 // 站号
- Command[1] = 0x5 // 功能码 : 写单个位
- address = 0
- HIBYTE(address, command[2])
- LOBYTE(address, command[3])
- Command[4] = 0xff // 使该bit设置为ON
- Command[5] = 0
- CRC(command[0], checksum, 6)
-
- LOBYTE(checksum, command[6])
- HIBYTE(checksum, command[7])
- // 将命令通过串行发送出去
- OUTPORT(command[0], "Free Protocol", 8)
-
-
- end macro_command
-
- macro_command main()
- short data[4]
- short page
- unsigned char buf[10]
- bool a
- int data32
-
-
-
-
- GetData(a,"Local HMI", LB, 0, 1)//读LB 0 地址到a
- SetData(a,"Local HMI", LB, 5, 1)
- a=false
- SetData(a,"Local HMI", LB, 0, 1)//清原来数据
- //判断密码
- //GetData(data32,"Local HMI", LW, 0, 2)
-
- GetData(buf[0],"Local HMI", LW, 0, 4)
- SetData(buf[0],"Local HMI", LW, 2, 4)//测试正确
-
- SetData(buf[0],"Local HMI", LW, 20, 1)//0xd2 原输入数据:1234567890 0x499602d2 下面是高地址存高位
- SetData(buf[1],"Local HMI", LW, 22, 1)//0x02
- SetData(buf[2],"Local HMI", LW, 24, 1)//0x96
- SetData(buf[3],"Local HMI", LW, 26, 1)//0x49
-
- //GetData(data[0],"Local HMI", LW, 0, 2)
- //SetData(data[0],"Local HMI", LW, 6, 2)//测试也正确
-
- //data32=data[0]<<16|data[1]
- //SetData(data32,"Local HMI", LW, 16, 1)//此处转换出现错误,原值为0x499602d2 而此处显示为0x02d24996
-
-
- //data32=buf[0]<<24|buf[1]<<16|buf[2]<<8|buf[3]
-
- //page=11
- //SetData(page,"Local HMI", LW, 10, 1)//切换到11页,因为plc控制器里增加
- //FILL(data[0],0,2)
- //SetData(data[0],"Local HMI", LW, 0, 2)//清原输入密码
-
- end macro_command
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。