在在工業(yè)場(chǎng)景中,經(jīng)常會(huì)使用到PLC進(jìn)行各種設(shè)備的數(shù)據(jù)采集和控制。本教程介紹使用海創(chuàng)-IIoT 可視化平臺(tái)配置s7-200 smart跑馬燈場(chǎng)景效果。
一、使用產(chǎn)品
海創(chuàng)Box智能采集網(wǎng)關(guān)
西門(mén)子PLC (ST20 S7-200)
帶自鎖急停開(kāi)關(guān)
LED聲光報(bào)警器
LED電源指示燈
二、產(chǎn)品連接方式
連接海創(chuàng)Box智能采集網(wǎng)關(guān)
連接接跑燈器材
三、產(chǎn)品配置
西門(mén)子PLC (ST20 S7-200) 基礎(chǔ)配置 請(qǐng)參考《西門(mén)子PLC》
西門(mén)子PLC (ST20 S7-200) 跑馬燈控制設(shè)計(jì)
總開(kāi)開(kāi)啟時(shí),接受平臺(tái)信號(hào)
總開(kāi)開(kāi)啟,響一聲;總開(kāi)關(guān)閉復(fù)位,信號(hào)響兩聲
四、項(xiàng)目部署調(diào)試
在桌面中打開(kāi)海創(chuàng)-IIoT可視化編輯工具,進(jìn)入可視化編輯器。本次教程需要用到如下節(jié)點(diǎn),在左側(cè)節(jié)點(diǎn)欄中拖拽出使用
定時(shí)器 周期性觸發(fā)輸入時(shí)間戳或者相應(yīng)的字符
S7ctrl 用于寫(xiě)入S7西門(mén)子通信協(xié)議的設(shè)備數(shù)據(jù)
function JavaScript函數(shù)塊,用于編寫(xiě)燈控邏輯代碼
配置相應(yīng)節(jié)點(diǎn)后配置界面如下:
節(jié)點(diǎn)配置:
定時(shí)器 設(shè)置成周期性觸發(fā),主要當(dāng)觸發(fā)流程使用,具體配置如下圖
S7ctrl 設(shè)置如下配置,配置PCL連接地址并定義PLC變量表
function 在右側(cè)調(diào)試窗口打開(kāi)代碼編碼窗口,向PLC的M區(qū)寫(xiě)入對(duì)應(yīng)的bool值從而控制對(duì)應(yīng)PLC輸出點(diǎn)的LED燈
部署調(diào)試:
按照以上教程配置好流程后,點(diǎn)擊部署,部署成功后程序開(kāi)始運(yùn)行,在實(shí)驗(yàn)板上觀(guān)看到跑馬燈效果,本案例效果可根據(jù)實(shí)際應(yīng)用,比如與具電表或濕濕度儀配置,讀取其狀態(tài)數(shù)據(jù),修改function代碼設(shè)定亮燈場(chǎng)景等。
五、示例
以上教程可以通過(guò)拷貝下面代碼實(shí)現(xiàn)快速?gòu)?fù)用,在新建的流程中點(diǎn)擊界面右側(cè) 菜單欄-導(dǎo)入-剪貼板,在文本框中粘貼下面代碼后點(diǎn)擊確定,即可快速?gòu)?fù)用
[
{
"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"
}
]