在在工業(yè)場景中,經(jīng)常會使用到PLC進行各種設(shè)備的數(shù)據(jù)采集和控制。本教程介紹使用海創(chuàng)-IIoT 可視化平臺配置s7-200 smart跑馬燈場景效果。
一、使用產(chǎn)品
海創(chuàng)Box智能采集網(wǎng)關(guān)
西門子PLC (ST20 S7-200)
帶自鎖急停開關(guān)
LED聲光報警器
LED電源指示燈
二、產(chǎn)品連接方式
連接海創(chuàng)Box智能采集網(wǎng)關(guān)
連接接跑燈器材
三、產(chǎn)品配置
西門子PLC (ST20 S7-200) 基礎(chǔ)配置 請參考《西門子PLC》
西門子PLC (ST20 S7-200) 跑馬燈控制設(shè)計
總開開啟時,接受平臺信號
總開開啟,響一聲;總開關(guān)閉復位,信號響兩聲
四、項目部署調(diào)試
在桌面中打開海創(chuàng)-IIoT可視化編輯工具,進入可視化編輯器。本次教程需要用到如下節(jié)點,在左側(cè)節(jié)點欄中拖拽出使用
定時器 周期性觸發(fā)輸入時間戳或者相應(yīng)的字符
S7ctrl 用于寫入S7西門子通信協(xié)議的設(shè)備數(shù)據(jù)
function JavaScript函數(shù)塊,用于編寫燈控邏輯代碼
配置相應(yīng)節(jié)點后配置界面如下:
節(jié)點配置:
定時器 設(shè)置成周期性觸發(fā),主要當觸發(fā)流程使用,具體配置如下圖
S7ctrl 設(shè)置如下配置,配置PCL連接地址并定義PLC變量表
function 在右側(cè)調(diào)試窗口打開代碼編碼窗口,向PLC的M區(qū)寫入對應(yīng)的bool值從而控制對應(yīng)PLC輸出點的LED燈
部署調(diào)試:
按照以上教程配置好流程后,點擊部署,部署成功后程序開始運行,在實驗板上觀看到跑馬燈效果,本案例效果可根據(jù)實際應(yīng)用,比如與具電表或濕濕度儀配置,讀取其狀態(tài)數(shù)據(jù),修改function代碼設(shè)定亮燈場景等。
五、示例
以上教程可以通過拷貝下面代碼實現(xiàn)快速復用,在新建的流程中點擊界面右側(cè) 菜單欄-導入-剪貼板,在文本框中粘貼下面代碼后點擊確定,即可快速復用
[
{
"id": "934346d0.9ab7c8",
"type": "iot-s7ctrl",
"z": "cbf428b2.2a3ac8",
"name": "",
"server": "b8104a0c.03ed08",
"columns": [
{
"Key": "M0.0",
"Label": "M0.0",
"Address": "M0.0",
"Ctrlvalue": "0",
"ValueType": "bool"
},
{
"Key": "M0.1",
"Label": "M0.1",
"Address": "M0.1",
"Ctrlvalue": "yes",
"ValueType": "bool"
},
{
"Key": "M0.2",
"Label": "M0.2",
"Address": "M0.2",
"Ctrlvalue": "0",
"ValueType": "bool"
},
{
"Key": "M0.3",
"Label": "M0.3",
"Address": "M0.3",
"Ctrlvalue": "0",
"ValueType": "bool"
},
{
"Key": "M0.4",
"Label": "M0.4",
"Address": "M0.4",
"Ctrlvalue": "0",
"ValueType": "bool"
},
{
"Key": "M0.5",
"Label": "M0.5",
"Address": "M0.5",
"Ctrlvalue": "0",
"ValueType": "bool"
},
{
"Key": "MR2",
"Label": "MR2",
"Address": "MR2",
"Ctrlvalue": "11.22",
"ValueType": "numerical "
},
{
"Key": "MD1",
"Label": "MD1",
"Address": "MD1",
"Ctrlvalue": "444",
"ValueType": "numerical "
}
],
"x": 655,
"y": 340,
"wires": [
[]
]
},
{
"id": "b8104a0c.03ed08",
"type": "iot-s7ctrl-client",
"z": "",
"name": "",
"communicate": "TCP",
"host": "192.168.7.163",
"post": "102",
"baudrate": "9600",
"databits": "8",
"stopbits": "1",
"parity": "None",
"expand": {},
"connmode": "tsap",
"rack": "0",
"slot": "2",
"localtsaphi": "10",
"localtsaplo": "00",
"remotetsaphi": "03",
"remotetsaplo": "00",
"verbose": "default"
}
]