#02 RS232/422/485マルチトランシーバ
Tibbitの配置
Tibbit #02とTibbit #19を挿入します。
使用できるスロットは、1,3,7,9です。
シリアルの設定
シリアル設定の登録方法は、#01 RS232トランシーバのチュートリアルの「シリアルの設定」を参考にしてください。
ノードの配置
このTibbitブロックは、各モード(RS232/422/485)を切り替えて使用することができます。
モードによって、TibbitブロックのLEDが以下のように変わります。
Mode | FD/-HD | -232/422-485 |
RS232 | HIGH | LOW |
RS422 | HIGH | HIGH |
RS485 | LOW | HIGH |
RS232
シリアルのIN
以下のようにフローを配置します。
ノードの設定を開き、スロットとシリアル設定とRS232を選択し、Node-REDをデプロイします。
このノードには2つOutputsがありますが、以下のようになっております。
1. 機器から受信したデータを出力
2. LINE H(DSR)のINのEdge
サンプルフロー
1 |
[{"id":"c13742db.742868","type":"debug","z":"d0a8e665.0b3038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":1140,"wires":[]},{"id":"ba6c1647.61ba8","type":"debug","z":"d0a8e665.0b3038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":1060,"wires":[]},{"id":"66d2da00.945f18","type":"Tibbit-#02 in","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","outputOnly":true,"serialConf":"21e4a251.3b34a6","connectedStatus":"start","host":"","_mode":"RS232","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"other"},"pinD":{"value":"other"}},{"tpSlot":{"value":"plus1"},"outputOnly":{"value":true},"communication":{"value":"GPIO"},"pinA":{"value":"other"},"pinB":{"value":"other"},"pinC":{"value":"other"},"pinD":{"value":"IN_Edge"}}],"x":780,"y":1100,"wires":[["ba6c1647.61ba8"],["c13742db.742868"]]},{"id":"21e4a251.3b34a6","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\r","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |
シリアルのOUT
送信するデータをセットするため、functionノードを使用します。
以下のようにフローを配置します。
functionノードの編集を開き、コードに以下を記述します。
「test」の部分が送信されるデータになりますので、適宜変更してください。
→文字列以外にもbytesなどでも可能。
1 2 |
msg.payload = Buffer.from("test"); return msg; |
ノードの設定を開き、スロットとシリアル設定とモードを選択します。
Node-REDデプロイ後、injectノードをクリックすると機器へデータを送信することができます。
サンプルフロー
1 |
[{"id":"e5fa7e4d.30fe58","type":"inject","z":"d0a8e665.0b3038","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":900,"y":1040,"wires":[["c2397381.bd275"]]},{"id":"c2397381.bd275","type":"function","z":"d0a8e665.0b3038","name":"シリアル送信データ","func":"msg.payload = Buffer.from(\"test\");\nreturn msg;","outputs":1,"noerr":0,"x":1040,"y":1080,"wires":[["b85c01da.3595f8"]]},{"id":"b85c01da.3595f8","type":"Tibbit-#02","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","serialConf":"c790b305.a63b8","connectedStatus":"start","host":"","_mode":"RS232","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"OUT_OD"},"pinD":{"value":"IN"}}],"x":1160,"y":1120,"wires":[[]]},{"id":"c790b305.a63b8","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\n","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |
LINE G(DTR)
LINE G(DTR)にLOW/HIGHを設定することが可能です。
以下のようにフローを配置します。
functionノードの編集を開き、コードに以下を記述します。
1 2 |
msg.payload = {act: 'dtr', v: 0}; return msg; |
1 2 |
msg.payload = {act: 'dtr', v: 1}; return msg; |
ノードの設定を開き、スロットとシリアル設定とモードを選択します。
Node-REDデプロイ後、各injectノードをクリックするとHIGH/LOWの設定を行うことができます。
サンプルフロー
1 |
[{"id":"3f30523d.ad9926","type":"inject","z":"d0a8e665.0b3038","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":820,"y":1080,"wires":[["22b2a027.217898"]]},{"id":"22b2a027.217898","type":"function","z":"d0a8e665.0b3038","name":"DTR(HIGH)","func":"msg.payload = {act: 'dtr', v: 1};\nreturn msg;","outputs":1,"noerr":0,"x":970,"y":1080,"wires":[["23de699.d74d996"]]},{"id":"23de699.d74d996","type":"Tibbit-#02","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","serialConf":"21e4a251.3b34a6","connectedStatus":"start","host":"","_mode":"RS232","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"OUT_OD"},"pinD":{"value":"IN"}}],"x":1160,"y":1060,"wires":[[]]},{"id":"8c99f9e3.0c9528","type":"function","z":"d0a8e665.0b3038","name":"DTR(LOW)","func":"msg.payload = {act: 'dtr', v: 0};\nreturn msg;","outputs":1,"noerr":0,"x":970,"y":1040,"wires":[["23de699.d74d996"]]},{"id":"f883a1ec.af844","type":"inject","z":"d0a8e665.0b3038","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":820,"y":1040,"wires":[["8c99f9e3.0c9528"]]},{"id":"21e4a251.3b34a6","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\r","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |
LINE H(DSR)
LINE H(DSR)のINの値を取得することが可能です。
以下のようにフローを配置します。
functionノードの編集を開き、コードに以下を記述します。
1 2 |
msg.payload = {act: 'dsr'}; return msg; |
ノードの設定を開き、スロットとシリアル設定とモードを選択します。
Node-REDデプロイ後、injectノードをクリックすると値を取得することができます。
サンプルフロー
1 |
[{"id":"55932d19.71520c","type":"inject","z":"d0a8e665.0b3038","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":820,"y":1080,"wires":[["4e7eddd2.755f34"]]},{"id":"4e7eddd2.755f34","type":"function","z":"d0a8e665.0b3038","name":"DSR取得","func":"msg.payload = {act: 'dsr'};\nreturn msg;","outputs":1,"noerr":0,"x":960,"y":1080,"wires":[["88b3d85d.ababf"]]},{"id":"88b3d85d.ababf","type":"Tibbit-#02","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","serialConf":"21e4a251.3b34a6","connectedStatus":"start","host":"","_mode":"RS232","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"OUT_OD"},"pinD":{"value":"IN"}}],"x":1000,"y":1120,"wires":[["71ff8c2d.c2488c"]]},{"id":"71ff8c2d.c2488c","type":"debug","z":"d0a8e665.0b3038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1110,"y":1160,"wires":[]},{"id":"21e4a251.3b34a6","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\r","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |
すべてを一つのノードに対して行っても問題ありません。
RS422
シリアルのIN
以下のようにフローを配置します。
ノードの設定を開き、スロットとシリアル設定とRS422を選択し、Node-REDをデプロイします。
このノードには2つOutputsがありますが、以下のようになっております。
1. 機器から受信したデータを出力
2. 使用しない
サンプルフロー
1 |
[{"id":"ba6c1647.61ba8","type":"debug","z":"d0a8e665.0b3038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1170,"y":1320,"wires":[]},{"id":"66d2da00.945f18","type":"Tibbit-#02 in","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","outputOnly":true,"serialConf":"21e4a251.3b34a6","connectedStatus":"start","host":"","_mode":"RS422","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"other"},"pinD":{"value":"other"}},{"tpSlot":{"value":"plus1"},"outputOnly":{"value":true},"communication":{"value":"GPIO"},"pinA":{"value":"other"},"pinB":{"value":"other"},"pinC":{"value":"other"},"pinD":{"value":"IN_Edge"}}],"x":980,"y":1280,"wires":[["ba6c1647.61ba8"],[]]},{"id":"21e4a251.3b34a6","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\r","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |
シリアルのOUT
送信するデータをセットするため、functionノードを使用します。
以下のようにフローを配置します。
functionノードの編集を開き、コードに以下を記述します。
「test」の部分が送信されるデータになりますので、適宜変更してください。
→文字列以外にもbytesなどでも可能。
1 2 |
msg.payload = Buffer.from("test"); return msg; |
ノードの設定を開き、スロットとシリアル設定とモードを選択します。
Node-REDデプロイ後、injectノードをクリックすると機器へデータを送信することができます。
サンプルフロー
1 |
[{"id":"55932d19.71520c","type":"inject","z":"d0a8e665.0b3038","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":820,"y":1080,"wires":[["4e7eddd2.755f34"]]},{"id":"4e7eddd2.755f34","type":"function","z":"d0a8e665.0b3038","name":"シリアルデータ送信","func":"msg.payload = Buffer.from(\"test\"); \nreturn msg;","outputs":1,"noerr":0,"x":1000,"y":1080,"wires":[["88b3d85d.ababf"]]},{"id":"88b3d85d.ababf","type":"Tibbit-#02","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","serialConf":"21e4a251.3b34a6","connectedStatus":"start","host":"","_mode":"RS422","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"OUT_OD"},"pinD":{"value":"IN"}}],"x":1160,"y":1120,"wires":[[]]},{"id":"21e4a251.3b34a6","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\r","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |
RS485
送受信切り替え
RS485モードでは、送受信の切り替えを行う必要があります。
以下のようにフローを配置します。
functionノードの編集を開き、コードに以下を記述します。
1 2 |
msg.payload = {act: 'io', v: 1}; return msg; |
1 2 |
msg.payload = {act: 'io', v: 0}; return msg; |
ノードの設定を開き、スロットとシリアル設定とモードを選択します。
Node-REDデプロイ後、各injectノードをクリックするとOutput/Inputを切り替えることができます。
サンプルフロー
1 |
[{"id":"253bfc76.2b4014","type":"inject","z":"d0a8e665.0b3038","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":800,"y":1000,"wires":[["bf1d4bcd.4c7278"]]},{"id":"a6e29004.968258","type":"inject","z":"d0a8e665.0b3038","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":800,"y":1040,"wires":[["e584ab6.3713fd8"]]},{"id":"bf1d4bcd.4c7278","type":"function","z":"d0a8e665.0b3038","name":"Output","func":"msg.payload = {act: 'io', v: 1};\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":1000,"wires":[["29998ea0.3b9faa"]]},{"id":"e584ab6.3713fd8","type":"function","z":"d0a8e665.0b3038","name":"Input","func":"msg.payload = {act: 'io', v: 0};\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":1040,"wires":[["29998ea0.3b9faa"]]},{"id":"29998ea0.3b9faa","type":"Tibbit-#02","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","serialConf":"21e4a251.3b34a6","connectedStatus":"start","host":"","_mode":"RS485","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"OUT_OD"},"pinD":{"value":"IN"}},{"tmp_mode":"RS485","outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"other"},"pinB":{"value":"other"},"pinC":{"value":"OUT"},"pinD":{"value":"other"}}],"x":1120,"y":1020,"wires":[[]]},{"id":"21e4a251.3b34a6","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\r","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |
シリアルのIN
以下のようにフローを配置します。
ノードの設定を開き、スロットとシリアル設定とRS485を選択し、Node-REDをデプロイします。
RS485モードでは、シリアル設定でのハードウェアフローは使用できません。
このノードには2つOutputsがありますが、以下のようになっております。
1. 機器から受信したデータを出力
2. 使用しない
サンプルフロー
1 |
[{"id":"ba6c1647.61ba8","type":"debug","z":"d0a8e665.0b3038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1170,"y":1320,"wires":[]},{"id":"66d2da00.945f18","type":"Tibbit-#02 in","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","outputOnly":true,"serialConf":"21e4a251.3b34a6","connectedStatus":"start","host":"","_mode":"RS485","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"other"},"pinD":{"value":"other"}},{"tpSlot":{"value":"plus1"},"outputOnly":{"value":true},"communication":{"value":"GPIO"},"pinA":{"value":"other"},"pinB":{"value":"other"},"pinC":{"value":"other"},"pinD":{"value":"IN_Edge"}},{"tmp_mode":"RS485","outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"other"},"pinB":{"value":"other"},"pinC":{"value":"OUT"},"pinD":{"value":"other"}}],"x":1000,"y":1280,"wires":[["ba6c1647.61ba8"],[]]},{"id":"21e4a251.3b34a6","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\r","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |
シリアルのOUT
送信するデータをセットするため、functionノードを使用します。
以下のようにフローを配置します。
functionノードの編集を開き、コードに以下を記述します。
「test」の部分が送信されるデータになりますので、適宜変更してください。
→文字列以外にもbytesなどでも可能。
1 2 |
msg.payload = Buffer.from("test"); return msg; |
ノードの設定を開き、スロットとシリアル設定とモードを選択します。
Node-REDデプロイ後、injectノードをクリックすると機器へデータを送信することができます。
RS485モードでは、シリアル設定でのハードウェアフローは使用できません。
サンプルフロー
1 |
[{"id":"55932d19.71520c","type":"inject","z":"d0a8e665.0b3038","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":840,"y":1120,"wires":[["4e7eddd2.755f34"]]},{"id":"4e7eddd2.755f34","type":"function","z":"d0a8e665.0b3038","name":"シリアルデータ送信","func":"msg.payload = Buffer.from(\"test\"); \nreturn msg;","outputs":1,"noerr":0,"x":1020,"y":1120,"wires":[["88b3d85d.ababf"]]},{"id":"88b3d85d.ababf","type":"Tibbit-#02","z":"d0a8e665.0b3038","name":"","tpSlot":"S01","communication":"Serial","serialConf":"21e4a251.3b34a6","connectedStatus":"start","host":"","_mode":"RS485","moreDefaults":[{"tpSlot":{"value":"plus1"},"outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"OUT"},"pinB":{"value":"OUT"},"pinC":{"value":"OUT_OD"},"pinD":{"value":"IN"}},{"tmp_mode":"RS485","outputOnly":{"value":false},"communication":{"value":"GPIO"},"pinA":{"value":"other"},"pinB":{"value":"other"},"pinC":{"value":"OUT"},"pinD":{"value":"other"}}],"x":1180,"y":1160,"wires":[[]]},{"id":"21e4a251.3b34a6","type":"tp-config-serial","z":"","serialName":"シリアル1","hardwareFlow":"off","seriBaudRate":"9600","seriDataBits":"8","seriParity":"none","seriStartBits":"1","seriStopBits":"1","seriSplitInput":"1","seriOnTheCharactor":"\\r","seriAfterATimeoutOf":"0","seriIntoFixedLengthOf":"0"}] |