下面要給大家介紹的是如何使用海創(chuàng)-IIoT平臺快速的采集歐姆龍PLC的數(shù)據,我們使用的是CP1E-N20DR-A型號的PLC,采用HOSTLINK協(xié)議。
一.選擇產品
1、CP1E-N20DR-ACP1E
2、海創(chuàng)Box智能采集網關
3、串口服務器
二.設置PLC串口通訊
在歐姆龍PLC編程軟件CX-Programmer里面設置PLC的串口通訊的波特率、數(shù)據位、校驗位、停止位、單元號和采集協(xié)議。
下圖為寄存器地址
三.采集數(shù)據
在桌面中打開海創(chuàng)-IIoT可視化編輯工具,進入可視化編輯器。本次教程需要用到如下節(jié)點,在左側節(jié)點欄中拖拽出使用
1、’定時器周期性觸發(fā)輸入時間戳或者相應的字符
2、HostLink歐姆龍HostLink采集協(xié)議
下圖為本案例HostLink歐姆龍控件的配置內容
下圖為服務器配置內容
3、調試用于調試節(jié)點輸出
把三個控件用線連接起來組成一個流,點擊部署最后的效果如下圖所示
四.代碼示例
以上教程可以通過拷貝下面代碼實現(xiàn)快速復用,在新建的流程中點擊界面右側菜單欄-導入-剪貼板,在文本框中粘貼下面代碼后點擊確定,即可快速復用
[
{
"id": "47bba1db.0ca98",
"type": "inject",
"z": "aac35e85.a1cec",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 235,
"y": 240,
"wires": [
[
"bb8b0e84.34dc9"
]
]
},
{
"id": "bb8b0e84.34dc9",
"type": "iot-hostlink",
"z": "aac35e85.a1cec",
"name": "",
"server": "a9ca7528.fe2da8",
"columns": [
{
"Key": "D0000",
"Lable": "D區(qū)第0位",
"Area": "D",
"Address": "0000",
"Number": "1",
"ValueType": "Int16BE",
"Arithmetic": ""
},
{
"Key": "D0001",
"Lable": "D區(qū)第1位",
"Area": "D",
"Address": "0001",
"Number": "1",
"ValueType": "UInt16BE",
"Arithmetic": ""
}
],
"x": 350,
"y": 240,
"wires": [
[
"ec2ebc2f.77bd5"
]
]
},
{
"id": "ec2ebc2f.77bd5",
"type": "debug",
"z": "aac35e85.a1cec",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 535,
"y": 240,
"wires": []
},
{
"id": "a9ca7528.fe2da8",
"type": "iot-hostlink-client",
"z": "",
"name": "",
"communicate": "Serial",
"host": "COM1",
"post": "502",
"baudrate": "115200",
"databits": "7",
"stopbits": "2",
"parity": "Even",
"expand": {
"UnitId": "0"
}
}
]