当前位置:   article > 正文

威纶通宏指令_威纶通宏指令一览表

威纶通宏指令一览表
  1. //TK6071IQ
  2. //自由协议
  3. macro_command main()
  4. char command[32]
  5. short address, checksum
  6. FILL(command[0], 0, 32) // 初始化命令
  7. Command[0] = 0x1 // 站号
  8. Command[1] = 0x5 // 功能码 : 写单个位
  9. address = 0
  10. HIBYTE(address, command[2])
  11. LOBYTE(address, command[3])
  12. Command[4] = 0xff // 使该bit设置为ON
  13. Command[5] = 0
  14. CRC(command[0], checksum, 6)
  15. LOBYTE(checksum, command[6])
  16. HIBYTE(checksum, command[7])
  17. // 将命令通过串行发送出去
  18. OUTPORT(command[0], "Free Protocol", 8)
  19. end macro_command

 

  1. macro_command main()
  2. short data[4]
  3. short page
  4. unsigned char buf[10]
  5. bool a
  6. int data32
  7. GetData(a,"Local HMI", LB, 0, 1)//读LB 0 地址到a
  8. SetData(a,"Local HMI", LB, 5, 1)
  9. a=false
  10. SetData(a,"Local HMI", LB, 0, 1)//清原来数据
  11. //判断密码
  12. //GetData(data32,"Local HMI", LW, 0, 2)
  13. GetData(buf[0],"Local HMI", LW, 0, 4)
  14. SetData(buf[0],"Local HMI", LW, 2, 4)//测试正确
  15. SetData(buf[0],"Local HMI", LW, 20, 1)//0xd2 原输入数据:1234567890 0x499602d2 下面是高地址存高位
  16. SetData(buf[1],"Local HMI", LW, 22, 1)//0x02
  17. SetData(buf[2],"Local HMI", LW, 24, 1)//0x96
  18. SetData(buf[3],"Local HMI", LW, 26, 1)//0x49
  19. //GetData(data[0],"Local HMI", LW, 0, 2)
  20. //SetData(data[0],"Local HMI", LW, 6, 2)//测试也正确
  21. //data32=data[0]<<16|data[1]
  22. //SetData(data32,"Local HMI", LW, 16, 1)//此处转换出现错误,原值为0x499602d2 而此处显示为0x02d24996
  23. //data32=buf[0]<<24|buf[1]<<16|buf[2]<<8|buf[3]
  24. //page=11
  25. //SetData(page,"Local HMI", LW, 10, 1)//切换到11页,因为plc控制器里增加
  26. //FILL(data[0],0,2)
  27. //SetData(data[0],"Local HMI", LW, 0, 2)//清原输入密码
  28. end macro_command

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/112330
推荐阅读
相关标签
  

闽ICP备14008679号