DMXkingのLeDMX4MAXを使ってsACNからSPIタイプのLEDを制御してみた その2

この記事は「DMXkingのLeDMX4MAXを使ってsACNからSPIタイプのLEDを制御してみた その1」の続きです。今回は、sACNを送ってLeDMX4MAXからSPI-LEDを点灯させてみます。

LeDMX4MAXでsACNを受信する設定

LeDMX4MAXでsACNを受信するには、Port Aのタブを選択します。

次に、Port Operation Modeから”DMX-IN sACN”にチェックを入れ、最後にUpdateのボタンを押します。

sACNを送るNode-REDフローを作成する

sACNを送るNode-REDフローを作成する方法については、「ENTTEC ODE MK2でNode-REDからsACNプロトコルでDMX機器を制御する」の記事を参照ください。

[{"id":"d3d92c7ed7c4d769","type":"sACN","z":"f7cccbb1879462ca","server":"2c7f22b08d940eed","universe":"","channel":"","transition":"instant","transitionRate":50,"transitionTime":1000,"name":"","x":560,"y":300,"wires":[]},{"id":"51da3c5fd5955d66","type":"function","z":"f7cccbb1879462ca","name":"sACNの値","func":"var value = msg.payload;\n\nmsg.payload = {\n    \"universe\":1,\n    \"channel\":1,\n    \"value\": value\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":180,"wires":[["d3d92c7ed7c4d769"]]},{"id":"c16a98672c203721","type":"inject","z":"f7cccbb1879462ca","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"255","payloadType":"num","x":210,"y":140,"wires":[["51da3c5fd5955d66"]]},{"id":"1fff2085c8f7f45a","type":"inject","z":"f7cccbb1879462ca","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":210,"y":240,"wires":[["51da3c5fd5955d66"]]},{"id":"2c7f22b08d940eed","type":"sacn-config","hostOrUniverse":"192.168.1.83","port":"5568"}]

まずはこのようなフローを作成します。

Injectノードは数字の255と0をpayloadで送信。

functionノードには、Universe1のChannel1にInjectノードの値を送るコードを書いています。

無事に1番目の赤のLEDが点灯しました。

LeDMX4MAXのSPIのPortのUniverseを変更する

初期設定ではPort1タブにあるPrimaryMappingのStartUniverseは1になっていますが、これを2に変更してUpdateします。

functionノードのuniverseを2にすると、sACNで送るDMXのUniverseが2になるので、この状態で送ると、赤色のLEDが点灯します。

今度は、Port1とPort2にそれぞれSPI-LEDを接続します。

Port1のUniverseは2

Port2のUniverseも2にして、先ほどのNode-REDのフローを使うと

Port1とPort2のSPI LEDの1番目の赤が点灯しました。

Port1をUniverse1,Port2をUniverse2にしてDimUp/Down

LeDMX4MAXのPort1をUniverse1,Port2をUniverse2にして、Universe1がDimUp-DownしたらUniverse2がDimUp-Downして、またUniverse1に戻るというフローを作成しました。

DimUpのfunctionノードです。topicのところにuniverse/channelという形式で”1/1″としています。

[{"id":"d3aa3a725d18cc90","type":"function","z":"f7cccbb1879462ca","name":"Dim UP","func":"var frameRate = 40;\nvar fadeTime = 2;\nvar fadeStep = frameRate * fadeTime;\n\nvar dimLevel = 255;\nvar dmxValue;\n\n\nfor (let i = 1; i < fadeStep; i++) {\n  \n  dmxValue = parseInt(dimLevel/fadeStep*i);\n  \n  node.send({ \n      topic : \"1/1\",    \n      payload : [dmxValue,dmxValue, dmxValue],\n      rate : 25\n  })\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":400,"wires":[["19f3ba3b4e76cb93"]]},{"id":"e32e4ed9e12da195","type":"inject","z":"f7cccbb1879462ca","name":"スタート","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":400,"wires":[["d3aa3a725d18cc90","2048ad0b887ec3c4"]]},{"id":"19f3ba3b4e76cb93","type":"delay","z":"f7cccbb1879462ca","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.01","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":true,"outputs":1,"x":770,"y":500,"wires":[["e3b011213ea85ae8"]]},{"id":"0d8dd7d0291052a9","type":"function","z":"f7cccbb1879462ca","name":"Dim DOWN","func":"var frameRate = 40;\nvar fadeTime = 2;\nvar fadeStep = frameRate * fadeTime;\n\nvar dimLevel = 255;\nvar dmxValue;\n\nfor (let i = 1; i < fadeStep; i++) {\n  \n  dmxValue = parseInt(dimLevel/fadeStep*i);\n  dmxValue = dimLevel - dmxValue;\n  \n  if (i == fadeStep-1) \n    {\n        dmxValue =0; \n    }\n  node.send({ \n      topic : \"1/1\",\n      payload : [dmxValue,dmxValue, dmxValue],\n      rate : 25\n  })\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":460,"wires":[["19f3ba3b4e76cb93"]]},{"id":"2048ad0b887ec3c4","type":"delay","z":"f7cccbb1879462ca","name":"遅延スタート","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":220,"y":460,"wires":[["0d8dd7d0291052a9","88ae94eeb7391c95"]]},{"id":"e3b011213ea85ae8","type":"sACN","z":"f7cccbb1879462ca","server":"2c7f22b08d940eed","universe":"","channel":"","transition":"rate","transitionRate":"25","transitionTime":1000,"name":"Device1","x":820,"y":560,"wires":[]},{"id":"88ae94eeb7391c95","type":"delay","z":"f7cccbb1879462ca","name":"遅延スタート","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":260,"y":520,"wires":[["60f06fa6ecf93e10","4ea70c6450c0890b"]]},{"id":"60f06fa6ecf93e10","type":"function","z":"f7cccbb1879462ca","name":"Dim UP","func":"var frameRate = 40;\nvar fadeTime = 2;\nvar fadeStep = frameRate * fadeTime;\n\nvar dimLevel = 255;\nvar dmxValue;\n\n\nfor (let i = 1; i < fadeStep; i++) {\n  \n  dmxValue = parseInt(dimLevel/fadeStep*i);\n  \n  node.send({ \n   topic : \"2/1\",    \n      payload : [dmxValue,dmxValue, dmxValue],\n      rate : 25\n  })\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":520,"wires":[["19f3ba3b4e76cb93"]]},{"id":"4ea70c6450c0890b","type":"delay","z":"f7cccbb1879462ca","name":"遅延スタート","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":300,"y":580,"wires":[["a1a36b321dda76b3","d2508c37834df6b0"]]},{"id":"a1a36b321dda76b3","type":"function","z":"f7cccbb1879462ca","name":"Dim DOWN","func":"var frameRate = 40;\nvar fadeTime = 2;\nvar fadeStep = frameRate * fadeTime;\n\nvar dimLevel = 255;\nvar dmxValue;\n\nfor (let i = 1; i < fadeStep; i++) {\n  \n  dmxValue = parseInt(dimLevel/fadeStep*i);\n  dmxValue = dimLevel - dmxValue;\n  \n  if (i == fadeStep-1) \n    {\n        dmxValue =0; \n    }\n  node.send({ \n      topic : \"2/1\",\n      payload : [dmxValue,dmxValue, dmxValue],\n      rate : 25\n  })\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":580,"wires":[["19f3ba3b4e76cb93"]]},{"id":"d2508c37834df6b0","type":"delay","z":"f7cccbb1879462ca","name":"遅延スタート","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":340,"y":640,"wires":[["d3aa3a725d18cc90","2048ad0b887ec3c4"]]},{"id":"2c7f22b08d940eed","type":"sacn-config","hostOrUniverse":"192.168.1.83","port":"5568"}]

まとめ

以上、「DMXkingのLeDMX4MAXを使ってsACNからSPIタイプのLEDを制御してみた」について、その1とその2で紹介させていただきました。

実はSPIは存在は知っていたものの、ほとんど触ったことがなかったので、今回の検証でかなり使い勝手がわかってきました。

ただ、5V DCは電圧降下の影響を受けやすく、プロジェクトで使用するにはちょっと注意が必要のようです。

今回の件で、友人の株式会社PASSIONEが24VタイプのSPI-LEDを扱っているこということだったので、近いうちに株式会社PASSIONEさんのSPI-LEDも検証してみたいと思います。