2021年10月2日 星期六

Node-Red ModBus Wite INT 16 bits , 32Bits , Float 16 bits , 32Bits , Read NT 16 bits , 32Bits , Float 16 bits , 32Bits

 Node-Red ModBus Wite INT 16 bits , 32Bits ,  Float 16 bits , 32Bits , Read NT 16 bits , 32Bits ,  Float 16 bits , 32Bits

FC=3  , FC=6 , 16 



Modbus 部分功能碼

中文名稱

寄存器 PLC 位址

位操作/字操作

運算元量

01

  數字量輸出

00001-09999

位操作bit

單個或多個

02

  數字量輸入

10001 -19999

位操作 bit

單個或多個

03

  模擬量輸出

40001-49999

字操作 16bits

單個或多個

04

  模擬量輸入

30001-39999

字操作16bits

單個或多個

 

 

 

 

 

05

  單個數位量輸出

00001-09999

位操作 bit

單個

06

  單個模擬量輸出

40001-49999

字操作16bits

單個

15

  多個數位量輸出

00001-09999

位操作 bit

多個

16

  多個模擬量輸出

40001-49999

字操作16bits

多個

 




















[{"id":"566e283f.320e58","type":"inject","z":"3693b3f5.4d71dc","name":"Read 32bit Float","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":320,"wires":[["99f00b0a.900d98"]]},{"id":"5d75ba7b.b2adf4","type":"modbus-flex-getter","z":"3693b3f5.4d71dc","name":"local getter","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"74ff149a.7f284c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":490,"y":60,"wires":[[],["8ed6b8d8.01b4f8"]]},{"id":"6ff5b8ca.6c6868","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":730,"y":360,"wires":[]},{"id":"b5f2874.b308078","type":"function","z":"3693b3f5.4d71dc","name":"16 Bit INT","func":"var fc=3;\nvar sa=40;\nvar addresses=1;\nvar slave_ip=msg.payload.slave_ip;\n//msg.slave_ip=\"192.168.1.31\";\nmsg.slave_ip=\"127.0.0.1\";\n\nmsg.payload={value: msg.payload, 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":60,"wires":[["5d75ba7b.b2adf4"]]},{"id":"6fdba017.722a5","type":"modbus-flex-write","z":"3693b3f5.4d71dc","name":"","showStatusActivities":false,"showErrors":false,"server":"74ff149a.7f284c","emptyMsgOnFail":false,"keepMsgProperties":false,"x":530,"y":980,"wires":[[],["cd12b0b4.fea65"]]},{"id":"55a1f062.f4f2c","type":"function","z":"3693b3f5.4d71dc","name":"Write-Float -16001.5","func":"\nvar fc=16;\nvar sa=70;\nvar addresses=2;\nvar value=16001.5;\nbuf=Buffer.alloc(4);\nbuf.writeFloatBE(value);\n//buf.writeFloatBE(16001.5);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n//msg.slave_ip=\"192.168.1.31\";\nmsg.slave_ip=\"127.0.0.1\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":980,"wires":[["6fdba017.722a5"]]},{"id":"5c386ccd.280ab4","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":750,"y":900,"wires":[]},{"id":"b926e361.c5cf4","type":"inject","z":"3693b3f5.4d71dc","name":"Read 16bit Integer","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":60,"wires":[["b5f2874.b308078"]]},{"id":"8ed6b8d8.01b4f8","type":"function","z":"3693b3f5.4d71dc","name":"","func":"const buf = Buffer.from(msg.payload.buffer);\nconst value = buf.readUInt16BE();\nmsg.value = value;\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":100,"wires":[["6aeb92f4.59865c"]]},{"id":"44dfb2e7.1b055c","type":"inject","z":"3693b3f5.4d71dc","name":"Write32Float","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":980,"wires":[["55a1f062.f4f2c"]]},{"id":"5795a73b.e1fa88","type":"inject","z":"3693b3f5.4d71dc","name":"Read 32bit Integer","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":180,"wires":[["90264b63.1f9e88"]]},{"id":"adb3097e.447718","type":"function","z":"3693b3f5.4d71dc","name":"","func":"const buf = Buffer.from(msg.payload.buffer);\nconst value = buf.readUInt32BE();\nmsg.value = value;\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":220,"wires":[["b2e526e1.578a88"]]},{"id":"8cc2b0ee.3c047","type":"modbus-flex-getter","z":"3693b3f5.4d71dc","name":"local getter","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"74ff149a.7f284c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":470,"y":180,"wires":[[],["adb3097e.447718"]]},{"id":"90264b63.1f9e88","type":"function","z":"3693b3f5.4d71dc","name":"32Bit INT","func":"var fc=3;\nvar sa=50;\nvar addresses=2;\nvar slave_ip=msg.payload.slave_ip;\nmsg.slave_ip=\"192.168.1.31\";\nmsg.payload={value: msg.payload, 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":180,"wires":[["8cc2b0ee.3c047"]]},{"id":"99f00b0a.900d98","type":"function","z":"3693b3f5.4d71dc","name":"32Bit Float ","func":"var fc=3;\nvar sa=70;\nvar addresses=2;\nvar slave_ip=msg.payload.slave_ip;\nmsg.slave_ip=\"192.168.1.31\";\nmsg.payload={value: msg.payload, 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":320,"wires":[["db3b009.be35a"]]},{"id":"db3b009.be35a","type":"modbus-flex-getter","z":"3693b3f5.4d71dc","name":"local getter","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"54dde46e.53267c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":450,"y":320,"wires":[[],["352e4543.a63a7a"]]},{"id":"352e4543.a63a7a","type":"function","z":"3693b3f5.4d71dc","name":"","func":"const buf = Buffer.from(msg.payload.buffer);\nconst value = buf.readFloatBE();\nmsg.value = value;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":360,"wires":[["6ff5b8ca.6c6868"]]},{"id":"ba4a6305.f4c9b","type":"inject","z":"3693b3f5.4d71dc","name":"Write32INT","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":860,"wires":[["1f426521.2cc78b"]]},{"id":"1f426521.2cc78b","type":"function","z":"3693b3f5.4d71dc","name":"write 68001-32 bit","func":"\nvar fc=16;\nvar sa=50;\nvar addresses=2;\nvar buf=Buffer.alloc(4);\nbuf.writeInt32BE(68001);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3]]\n//msg.slave_ip=\"192.168.1.76\";\nmsg.slave_ip=\"127.0.0.1\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":860,"wires":[["1cf7ff74.e25fa1","ee2c5d11.016e6"]]},{"id":"1cf7ff74.e25fa1","type":"modbus-flex-write","z":"3693b3f5.4d71dc","name":"","showStatusActivities":false,"showErrors":false,"server":"74ff149a.7f284c","emptyMsgOnFail":false,"keepMsgProperties":false,"x":530,"y":900,"wires":[[],["5c386ccd.280ab4"]]},{"id":"6cf968df.2ced38","type":"inject","z":"3693b3f5.4d71dc","name":"Write16INT","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":800,"wires":[["4618f66c.e69ab8"]]},{"id":"4618f66c.e69ab8","type":"function","z":"3693b3f5.4d71dc","name":"Write 16001-16bit","func":"\nvar fc=6;\nvar sa=40;\nvar addresses=1;\nvar value=16001;\n\n//msg.slave_ip=\"192.168.1.76\";\nmsg.slave_ip=\"127.0.0.1\";\nmsg.payload={\"value\":value , 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":800,"wires":[["9df48b6e.8c0ce8"]]},{"id":"9df48b6e.8c0ce8","type":"modbus-flex-write","z":"3693b3f5.4d71dc","name":"","showStatusActivities":false,"showErrors":true,"server":"74ff149a.7f284c","emptyMsgOnFail":false,"keepMsgProperties":false,"x":530,"y":800,"wires":[[],["534a393e.735368"]]},{"id":"dab7ec02.dd41b","type":"inject","z":"3693b3f5.4d71dc","name":"Buffer","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":90,"y":100,"wires":[["bee2bbf3.851b58"]]},{"id":"bee2bbf3.851b58","type":"function","z":"3693b3f5.4d71dc","name":"16 Bit INT 16001","func":"msg.payload={};\nvar buf=Buffer.alloc(2);\nbuf.writeInt16BE(16001);\nmsg.payload.buffer=buf;\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":100,"wires":[["8ed6b8d8.01b4f8"]]},{"id":"525ecc6c.c4f464","type":"function","z":"3693b3f5.4d71dc","name":"32 bit INT 68001","func":"msg.payload={};\nvar buf=Buffer.alloc(4);\nbuf.writeInt32BE(68001);\nmsg.payload.buffer=buf;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":220,"wires":[["adb3097e.447718"]]},{"id":"30fe7bb9.53f654","type":"inject","z":"3693b3f5.4d71dc","name":"Buffer","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":90,"y":220,"wires":[["525ecc6c.c4f464"]]},{"id":"7a67f832.149578","type":"function","z":"3693b3f5.4d71dc","name":"32Bit Float 16001.5","func":"msg.payload={};\nvar buf=Buffer.alloc(4);\nbuf.writeFloatBE(16001.5);\nmsg.payload.buffer=buf;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":360,"wires":[["352e4543.a63a7a"]]},{"id":"a6212bd9.caf8d8","type":"inject","z":"3693b3f5.4d71dc","name":"Buffer","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":90,"y":360,"wires":[["7a67f832.149578"]]},{"id":"302b0e6b.13c302","type":"inject","z":"3693b3f5.4d71dc","name":"Read 64bit Float","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":460,"wires":[["12f789b4.a58596"]]},{"id":"fb00dce6.ddb6e","type":"inject","z":"3693b3f5.4d71dc","name":"Buffer","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":90,"y":500,"wires":[["55e09f78.d99d"]]},{"id":"12f789b4.a58596","type":"function","z":"3693b3f5.4d71dc","name":"64Bit Float ","func":"var fc=3;\nvar sa=80;\nvar addresses=4;\nvar slave_ip=msg.payload.slave_ip;\nmsg.slave_ip=\"192.168.1.31\";\nmsg.payload={value: msg.payload, 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":460,"wires":[["97b3b3a1.b15a3"]]},{"id":"55e09f78.d99d","type":"function","z":"3693b3f5.4d71dc","name":"64Bit Float 16001.5","func":"msg.payload={};\nvar buf=Buffer.alloc(8);\nbuf.writeDoubleBE(16001.5);\nmsg.payload.buffer=buf;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":500,"wires":[["a47036cc.a285f8"]]},{"id":"97b3b3a1.b15a3","type":"modbus-flex-getter","z":"3693b3f5.4d71dc","name":"local getter","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"54dde46e.53267c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":450,"y":460,"wires":[[],["a47036cc.a285f8"]]},{"id":"a47036cc.a285f8","type":"function","z":"3693b3f5.4d71dc","name":"","func":"const buf = Buffer.from(msg.payload.buffer);\nconst value = buf.readDoubleBE();\nmsg.value = value;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":500,"wires":[["c7570896.089b28"]]},{"id":"40f68ee7.292df","type":"inject","z":"3693b3f5.4d71dc","name":"Write64Float","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":1060,"wires":[["b5bd6ca2.c1904"]]},{"id":"b5bd6ca2.c1904","type":"function","z":"3693b3f5.4d71dc","name":"Write-Float -16001.5","func":"\nvar fc=16;\nvar sa=80;\nvar addresses=4;\nvar value=16001.5;\nbuf=Buffer.alloc(8);\nbuf.writeDoubleBE(value);\n//buf.writeFloatBE(16001.5);\nvar values=[(buf[0]*256+buf[1]),(buf[2]*256)+buf[3],(buf[4]*256+buf[5]),(buf[6]*256)+buf[7]];\n\n//msg.slave_ip=\"192.168.1.76\";\nmsg.slave_ip=\"127.0.0.1\";\nmsg.payload={\"value\":values , 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":1060,"wires":[["82a332f0.4eb11"]]},{"id":"82a332f0.4eb11","type":"modbus-flex-write","z":"3693b3f5.4d71dc","name":"","showStatusActivities":false,"showErrors":false,"server":"74ff149a.7f284c","emptyMsgOnFail":false,"keepMsgProperties":false,"x":550,"y":1060,"wires":[[],["87dfa988.f29f18"]]},{"id":"6aeb92f4.59865c","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":730,"y":100,"wires":[]},{"id":"b2e526e1.578a88","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":730,"y":220,"wires":[]},{"id":"c7570896.089b28","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":730,"y":500,"wires":[]},{"id":"534a393e.735368","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":750,"y":800,"wires":[]},{"id":"87dfa988.f29f18","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":750,"y":1060,"wires":[]},{"id":"cd12b0b4.fea65","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":750,"y":980,"wires":[]},{"id":"ee2c5d11.016e6","type":"debug","z":"3693b3f5.4d71dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":860,"wires":[]},{"id":"3eea5b1a.418d54","type":"comment","z":"3693b3f5.4d71dc","name":"fc=6 sa=40;value=16001;","info":"var fc=6;\nvar sa=40;\nvar addresses=1;\nvar value=16001;","x":130,"y":760,"wires":[]},{"id":"fee9f534.7e8a08","type":"comment","z":"3693b3f5.4d71dc","name":"fc=3 sa=40;value=16001;","info":"var fc=3;\nvar sa=40;\nvar addresses=1;\nvar value=16001;","x":130,"y":20,"wires":[]},{"id":"31a601a8.e4017e","type":"comment","z":"3693b3f5.4d71dc","name":"fc=6 sa=50;value=68001","info":"var fc=6;\nvar sa=50;\nvar addresses=1;\nvar value=68001","x":130,"y":900,"wires":[]},{"id":"fe6d57f5.1890d8","type":"comment","z":"3693b3f5.4d71dc","name":"fc=3 sa=50;value=68001","info":"var fc=3;\nvar sa=50;\nvar addresses=1;\nvar value=68001","x":130,"y":140,"wires":[]},{"id":"7a84db63.45baf4","type":"comment","z":"3693b3f5.4d71dc","name":"fc=16; sa=70;  value=16001.5;","info":"var fc=16;\nvar sa=70;\nvar addresses=2;\nvar value=16001.5;","x":140,"y":1020,"wires":[]},{"id":"3d7d9c28.66baf4","type":"comment","z":"3693b3f5.4d71dc","name":"fc=16;  sa=80; value=16001.5;","info":"var fc=16;\nvar sa=80;\nvar addresses=4;\nvar value=16001.5;","x":140,"y":1100,"wires":[]},{"id":"5c4e.268bf3b2d8","type":"comment","z":"3693b3f5.4d71dc","name":"fc=3; sa=70;  value=16001.5;","info":"var fc=3;\nvar sa=70;\nvar addresses=2;\nvar value=16001.5;","x":140,"y":280,"wires":[]},{"id":"c4d73e85.175b1","type":"comment","z":"3693b3f5.4d71dc","name":"fc=3;  sa=80; value=16001.5;","info":"var fc=16;\nvar sa=80;\nvar addresses=4;\nvar value=16001.5;","x":140,"y":420,"wires":[]},{"id":"74ff149a.7f284c","type":"modbus-client","name":"local","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"54dde46e.53267c","type":"modbus-client","name":"local_3","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":3,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":false,"reconnectTimeout":2000,"parallelUnitIdsAllowed":false}]

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...