#54 4ch非絶縁ドライ接点入力
Tibbitの配置
Tibbit #54を挿入します。
ノードの配置
リレーの制御のために、functionノードを使用します。
以下のようにフローを配置します。
functionノードの編集を開き、コードに以下を記述します。
値を取得したいラインを指定します。
1 2 |
msg.payload = [{line: 'A'}]; return msg; |
ラインを複数取りたい場合は、以下のように指定ができます。
1 2 |
msg.payload = [{line: 'A'},{line: 'B'},{line: 'C'},{line: 'D'}]; return msg; |
ノードの設定を開き、スロットを選択します。
Node-REDデプロイ後、injectノードをクリックすると値を取得ですることができます。
Outputsは指定したライン分、配列で取得できます。
サンプルフロー
1 |
[{"id":"556386c9.df42c","type":"inject","z":"55785919.c3dbf8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":680,"wires":[["4eac3f09.1c2688"]]},{"id":"83aa131.5ddfd7","type":"debug","z":"55785919.c3dbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":740,"wires":[]},{"id":"4eac3f09.1c2688","type":"function","z":"55785919.c3dbf8","name":"ライン指定","func":"msg.payload = [{line: 'A'}]\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":680,"wires":[["f2058fd.3e32c7"]]},{"id":"f2058fd.3e32c7","type":"Tibbit-#54","z":"55785919.c3dbf8","name":"","tpSlot":"S01","communication":"GPIO","pinA":"IN","pinB":"IN","pinC":"IN","pinD":"IN","connectedStatus":"start","host":"","x":420,"y":740,"wires":[["83aa131.5ddfd7"]]}] |
Edgeの取得
INのEdgeを取得したい場合は、inノードを使用し以下のようにフローを配置します。
OutputsはラインとHIGH/LOWが出力されます。
サンプルフロー
1 |
[{"id":"4cffd36a.b7735c","type":"debug","z":"55785919.c3dbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":390,"y":900,"wires":[]},{"id":"4098395c.9b5d58","type":"Tibbit-#54 in","z":"55785919.c3dbf8","name":"","tpSlot":"S01","outputOnly":true,"communication":"GPIO","pinA":"IN_Edge","pinB":"IN_Edge","pinC":"IN_Edge","pinD":"IN_Edge","connectedStatus":"start","host":"","x":200,"y":860,"wires":[["4cffd36a.b7735c"]]}] |