node-red-contrib-keiganmotor 0.3.0

Keigan Motor node-red node.

npm install node-red-contrib-keiganmotor

KeiganMotorをNode-REDから操作するノード

sc_1

概要

BLEアダプタ又はUSBを搭載したデバイス上のNode-REDで動作します。

v0.3.0 USBに対応

KeiganMotorは以下のデバイスで動作検証してます。 + Raspberry Pi 3 Model B + MacBook

インストール (npmからインストール)

Node-REDのROOT(.node-red)ディレクトリで以下を実行

 $npm install node-red-contrib-keiganmotor

実行権限の付与 (Raspberry Pi 3)

raspberry piでBLEを実行する場合、スーパーユーザー権限が必要です。 通常のユーザーとしてNode-Redを実行している場合、BLEを実行するためのアクセス許可を与える必要があります。

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

依存関係

サンプル

/sample/motor_demo.jsonの中身をNode-REDのクリップボードに貼り付けるか
以下のフローをNode-REDのクリップボードに貼り付けます。

単体動作テスト

[{"id":"f69f7b2d.ea0648","type":"tab","label":"smple","disabled":false,"info":""},{"id":"ce28fdcd.39533","type":"inject","z":"f69f7b2d.ea0648","name":"Scan 20sec 1Motor","topic":"","payload":"20,1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":140,"wires":[["f8723f7f.a836"]]},{"id":"81d8d99.d0efd28","type":"km-motor","z":"f69f7b2d.ea0648","name":"","allowConnectMotor":"","x":793.7500152587891,"y":1346.2500133514404,"wires":[["9134badd.804f98","e164e22e.c5575"],["826ace6f.01a2c"],["ea702513.1201b8"],["f3ef7737.f76178"]]},{"id":"47dc8904.8b5808","type":"inject","z":"f69f7b2d.ea0648","name":"{\"cmd\":\"cmdLed\",\"arg\":\"1,200,0,0\"}","topic":" ","payload":"{\"cmd\":\"cmdLed\",\"arg\":\"1,200,0,0\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":253.75001525878906,"y":1446.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"587ef430.272f8c","type":"inject","z":"f69f7b2d.ea0648","name":"{\"cmd\":\"cmdLed\",\"arg\":[1,200,200,0]}","topic":"cmdLed","payload":"{\"cmd\":\"cmdLed\",\"arg\":[1,200,200,0]}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":263.75001525878906,"y":1486.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"dc129b87.85c038","type":"comment","z":"f69f7b2d.ea0648","name":"接続例1) BLE 最初に発見したモーターに即座に接続する","info":"※注意 別のノードで既に接続されているモーターは接続されません。一旦接続を切って下さい\n\n### ●Scan injectノードにScan時間,検出モーター数を設定する。  \nex)モーターは1つタイムアウトは20秒(20000ms)\n","x":250,"y":100,"wires":[]},{"id":"dde1aab3.3d2c88","type":"debug","z":"f69f7b2d.ea0648","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1010,"y":180,"wires":[]},{"id":"3fb8947d.57926c","type":"inject","z":"f69f7b2d.ea0648","name":"1) 原点を初期化、10rpmで180度回転","topic":"","payload":"[{\"cmd\":\"cmdPresetPosition\"},{\"cmd\":\"cmdSpeed_rpm\",\"arg\":10},{\"cmd\":\"cmdMoveToPosition\",\"arg\":3.1415}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":843.7500152587891,"y":1606.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"854d04ce.a34938","type":"inject","z":"f69f7b2d.ea0648","name":"","topic":"","payload":"{\"cmd\":\"cmdEnable\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":213.75001525878906,"y":1806.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"71af7997.43b978","type":"inject","z":"f69f7b2d.ea0648","name":"","topic":"","payload":"{\"cmd\":\"cmdDisable\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":213.75001525878906,"y":1846.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"e76dda27.384c48","type":"inject","z":"f69f7b2d.ea0648","name":"5) 原点に戻る","topic":"","payload":"[{\"cmd\":\"cmdSpeed_rpm\",\"arg\":50},{\"cmd\":\"cmdMoveToPosition\",\"arg\":0}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":763.7500152587891,"y":1766.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"d6214081.f12f9","type":"debug","z":"f69f7b2d.ea0648","name":"motorMeasurement1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1060,"y":220,"wires":[]},{"id":"3cf8521c.2ca7fe","type":"inject","z":"f69f7b2d.ea0648","name":"{\"cmd\":\"cmdReadRegister\",\"arg\":[29,30]}","topic":"","payload":"{\"cmd\":\"cmdReadRegister\",\"arg\":[29,30]}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":273.75001525878906,"y":1946.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"30c02bb5.01d864","type":"inject","z":"f69f7b2d.ea0648","name":"{\"cmd\":\"disConnect\"}","topic":"","payload":"{\"cmd\":\"disConnect\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":213.75001525878906,"y":1306.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"b3f8497f.cc7538","type":"km-motor","z":"f69f7b2d.ea0648","name":"","allowConnectMotor":"","x":780,"y":200,"wires":[["dde1aab3.3d2c88"],["d6214081.f12f9"],[],[]]},{"id":"84274e0e.bab39","type":"comment","z":"f69f7b2d.ea0648","name":"接続例2) BLE 全てのモータを検出し、指定した2つのモーターに自動接続する","info":"※注意 別のノードで既に接続されているモーターは接続されません。一旦接続を切って下さい\n\n### ●Scan injectノードにScan時間を設定する。  \nあまり短いとモーターが検出されません、推奨は20秒(20000ms)\n\n### ●Keigan Motorに接続するモーター名を設定する \n(モーター名はScan終了時にスキャナーの下部に表示されます)\n\n\n### ●スキャン終了後にスキャン中に発見したモータを接続する場合。\nKeigan MotorをKeigan BLE scannerの出力に接続\n","x":303.7500305175781,"y":567.5000076293945,"wires":[]},{"id":"b55c8105.51def","type":"inject","z":"f69f7b2d.ea0648","name":"","topic":"","payload":"{\"cmd\":\"disConnect\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":240,"wires":[["b3f8497f.cc7538"]]},{"id":"fbe65195.3f25c","type":"inject","z":"f69f7b2d.ea0648","name":"Scan 20sec","topic":"","payload":"20","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":183.75001907348633,"y":625.0000152587891,"wires":[["d2697e67.66cd9"]]},{"id":"3bd1a9b.0c1db56","type":"km-motor","z":"f69f7b2d.ea0648","name":"","allowConnectMotor":"KM-1 CIRU","x":773.7500190734863,"y":685.0000152587891,"wires":[["248a6283.62c00e"],["3b5c3786.d2a508"],[],[]]},{"id":"3b5c3786.d2a508","type":"debug","z":"f69f7b2d.ea0648","name":"motorMeasurement","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1043.7500190734863,"y":685.0000152587891,"wires":[]},{"id":"5e95c2cd.8b518c","type":"inject","z":"f69f7b2d.ea0648","name":"","topic":"","payload":"{\"cmd\":\"disConnect\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":433.7500190734863,"y":725.0000152587891,"wires":[["3bd1a9b.0c1db56","ace455ae.4aad68"]]},{"id":"248a6283.62c00e","type":"debug","z":"f69f7b2d.ea0648","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1023.7500190734863,"y":645.0000152587891,"wires":[]},{"id":"ace455ae.4aad68","type":"km-motor","z":"f69f7b2d.ea0648","name":"","allowConnectMotor":"KM-1 175D","x":773.7500190734863,"y":785.0000152587891,"wires":[["e4f8c904.88f628"],["ca2a5884.be2d08"],[],[]]},{"id":"ca2a5884.be2d08","type":"debug","z":"f69f7b2d.ea0648","name":"motorMeasurement","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1043.7500190734863,"y":785.0000152587891,"wires":[]},{"id":"e4f8c904.88f628","type":"debug","z":"f69f7b2d.ea0648","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1023.7500190734863,"y":745.0000152587891,"wires":[]},{"id":"a27bb719.afe7d8","type":"comment","z":"f69f7b2d.ea0648","name":"制御例1) BLE モーターの制御","info":"※注意 別のノードで既に接続されているモーターは接続されません。一旦接続を切って下さい。 \n\n+ モータの制御コマンド書式は全て\"cmd\"で始まります。 \n  (connect disConnect以外)  \n\n+ 制御出来る全てのコマンドは以下を参照下さい。 \n\n[モーターコマンド](https://document.keigan-motor.com/apiDocument/kmconnector-js/KMMotorOneBLE.html#connect__anchor)\n\n","x":153.75001525878906,"y":1106.2500133514404,"wires":[]},{"id":"544c7026.4a0e3","type":"debug","z":"f69f7b2d.ea0648","name":"discoverMotor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":753.7500152587891,"y":1146.2500133514404,"wires":[]},{"id":"e164e22e.c5575","type":"debug","z":"f69f7b2d.ea0648","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1063.750015258789,"y":1326.2500133514404,"wires":[]},{"id":"826ace6f.01a2c","type":"debug","z":"f69f7b2d.ea0648","name":"motorMeasurement2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1113.750015258789,"y":1366.2500133514404,"wires":[]},{"id":"ea702513.1201b8","type":"debug","z":"f69f7b2d.ea0648","name":"imuMeasurement","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1103.750015258789,"y":1406.2500133514404,"wires":[]},{"id":"f3ef7737.f76178","type":"debug","z":"f69f7b2d.ea0648","name":"setting","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1063.750015258789,"y":1446.2500133514404,"wires":[]},{"id":"8d27d529.e3f018","type":"comment","z":"f69f7b2d.ea0648","name":"例) モーターの無限回転","info":"\n","x":193.75001525878906,"y":1546.2500133514404,"wires":[]},{"id":"729bd219.3402ac","type":"trigger","z":"f69f7b2d.ea0648","op1":"{\"cmd\":\"cmdEnable\"}","op2":"0","op1type":"json","op2type":"str","duration":"10","extend":false,"units":"ms","reset":"","bytopic":"topic","name":"{\"cmd\":\"cmdEnable\"}","x":873.7500152587891,"y":1246.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"9134badd.804f98","type":"switch","z":"f69f7b2d.ea0648","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"connect","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":683.7500152587891,"y":1246.2500133514404,"wires":[["729bd219.3402ac"]]},{"id":"ac230e9f.6c0c4","type":"comment","z":"f69f7b2d.ea0648","name":"※安全装置 モーターを最初に制御する為に必要","info":"","x":833.7500152587891,"y":1206.2500133514404,"wires":[]},{"id":"3c962603.c6839a","type":"inject","z":"f69f7b2d.ea0648","name":"LED、10rpm、正回転","topic":"","payload":"[{\"cmd\":\"cmdLed\",\"arg\":\"1,200,0,0\"},{\"cmd\":\"cmdSpeed_rpm\",\"arg\":10},{\"cmd\":\"cmdRunForward\"}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":213.75001525878906,"y":1586.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"1c58d23.e01642e","type":"inject","z":"f69f7b2d.ea0648","name":"LED、40rpm、逆回転","topic":"","payload":"[{\"cmd\":\"cmdLed\",\"arg\":\"1,100,0,100\"},{\"cmd\":\"cmdSpeed_rpm\",\"arg\":40},{\"cmd\":\"cmdRunReverse\"}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":213.75001525878906,"y":1626.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"a7298735.4d3be8","type":"inject","z":"f69f7b2d.ea0648","name":"{\"cmd\":\"connect\"}","topic":"","payload":"{\"cmd\":\"connect\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":203.75001525878906,"y":1346.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"e4dce484.7c9ea8","type":"comment","z":"f69f7b2d.ea0648","name":"例) モーターの切断・手動接続","info":"+ 手動で接続する場合はスキャナーで認識されているモーター名を指定して下さい。  \nex)`{\"cmd\":\"connect\",\"arg\":\"KM-1 175D\"}`\n+ スキャナーで認識されていないモータは接続出来ません。","x":213.75001525878906,"y":1266.2500133514404,"wires":[]},{"id":"eac68d52.7cd7b","type":"comment","z":"f69f7b2d.ea0648","name":"例) モーターのLED変更","info":"\n","x":193.75001525878906,"y":1406.2500133514404,"wires":[]},{"id":"ed81b5c7.4a3488","type":"comment","z":"f69f7b2d.ea0648","name":"例) モーターの有効無効(安全装置)","info":"+ モーター接続時は常に無効(cmdDisable)です。 \n\n+ 最初に有効(cmdEnable)にしない限りモーターは動作しません。\n","x":233.75001525878906,"y":1766.2500133514404,"wires":[]},{"id":"6bb35ada.7d1044","type":"comment","z":"f69f7b2d.ea0648","name":"例) モーターの設定値の取得","info":"+ レジスタ番号で指定した設定値をモーターから取得します。 \n\n+ 取得した値はモーターの出力4(settingデバッグノード)に出力されます。  \n\n+ レジスタ番号は下記のリンクを参考に10進数で指定して下さい。  \n\n[レジスター一覧](https://document.keigan-motor.com/apiDocument/kmconnector-js/KMMotorCommandKMOne.html#.cmdReadRegister_COMMAND__anchor)","x":213.75001525878906,"y":1906.2500133514404,"wires":[]},{"id":"f0d23aed.d05ba8","type":"comment","z":"f69f7b2d.ea0648","name":"例) モーターの回転 座標指定","info":"電源投入時のモータの座標は0です。  \n\n+ 座標(原点)の初期化はcmdPresetPositionで行えます。  \n\n+ 現在のモーターの座標は、モーターノード.出力2.msg.posionで取得出来ます。  \n\n+ 座標の単位はradian(360度=2π=3.1415*2=6.283)\n\n+ 速度は以前に設定した速度が維持されます。\n\n","x":793.7500152587891,"y":1566.2500133514404,"wires":[]},{"id":"e307e7f3.777b58","type":"inject","z":"f69f7b2d.ea0648","name":"3) 現在位置から90度回転","topic":"","payload":"[{\"cmd\":\"cmdMoveByDistance\",\"arg\":1.57}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":803.7500152587891,"y":1686.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"4faf2ce1.6654b4","type":"inject","z":"f69f7b2d.ea0648","name":"2) 速度を40rpmに変更","topic":"","payload":"[{\"cmd\":\"cmdSpeed_rpm\",\"arg\":40}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":793.7500152587891,"y":1646.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"6b086d8f.d6d944","type":"inject","z":"f69f7b2d.ea0648","name":"4) 現在位置から-90度回転","topic":"","payload":"[{\"cmd\":\"cmdMoveByDistance\",\"arg\":-1.57}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":803.7500152587891,"y":1726.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"29c4661b.9ca60a","type":"inject","z":"f69f7b2d.ea0648","name":"Scan Stop","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":200,"wires":[["f8723f7f.a836"]]},{"id":"90455da5.82a95","type":"inject","z":"f69f7b2d.ea0648","name":"","topic":"","payload":"{\"cmd\":\"connect\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":423.7500190734863,"y":825.0000152587891,"wires":[["3bd1a9b.0c1db56","ace455ae.4aad68"]]},{"id":"90f11853.500cf8","type":"comment","z":"f69f7b2d.ea0648","name":"スキャン終了後にモーターを自動接続","info":"### ●スキャン終了後にスキャン中に発見したモータを接続。\nRaspberryPi3のBLEデバイスではスキャン中に接続を行うと、  \n接続に失敗したりBLE動作が不安定になる為、BLE scannerのスキャン終了後に接続します。","x":790,"y":140,"wires":[]},{"id":"564d8cae.9d44b4","type":"comment","z":"f69f7b2d.ea0648","name":"前回接続のモーターに再接続","info":"‘{\"cmd\":\"connect\",arg:\"モーター名\"}‘\n\n指定したモーターに接続する。  \n\n引数argを省略すると、前回接続したモータに接続します。","x":413.7500190734863,"y":785.0000152587891,"wires":[]},{"id":"5fa05d32.d9b4a4","type":"comment","z":"f69f7b2d.ea0648","name":"接続を許可するモーター名を指定","info":"スキャナーのタイムアウト時には、検出されたモーター全てが一括で出力されます。\n\n従って、モーターノードの \"Allow Connect Motor\"に接続許可するモーター名を指定する事で、個々のモーターノードに指定したモーターのみを接続させます。\n","x":783.7500190734863,"y":625.0000152587891,"wires":[]},{"id":"6dc962c8.dba5fc","type":"inject","z":"f69f7b2d.ea0648","name":"Scan Stop","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":173.75001907348633,"y":665.0000152587891,"wires":[["d2697e67.66cd9"]]},{"id":"5e25e2d9.3b622c","type":"inject","z":"f69f7b2d.ea0648","name":"Scan 20sec 1Motor","topic":"","payload":"20,1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":203.75001525878906,"y":1166.2500133514404,"wires":[["3f8b7c2b.e0c494"]]},{"id":"1987aa55.bcdf96","type":"inject","z":"f69f7b2d.ea0648","name":"Scan Stop","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":173.75001525878906,"y":1206.2500133514404,"wires":[["3f8b7c2b.e0c494"]]},{"id":"f8723f7f.a836","type":"km-BLEscan","z":"f69f7b2d.ea0648","name":"","x":480,"y":140,"wires":[["b3f8497f.cc7538"]]},{"id":"d2697e67.66cd9","type":"km-BLEscan","z":"f69f7b2d.ea0648","name":"","x":413.7500190734863,"y":625.0000152587891,"wires":[["3bd1a9b.0c1db56","ace455ae.4aad68"]]},{"id":"3f8b7c2b.e0c494","type":"km-BLEscan","z":"f69f7b2d.ea0648","name":"","x":433.75001525878906,"y":1186.2500133514404,"wires":[["81d8d99.d0efd28","544c7026.4a0e3"]]},{"id":"ef188406.06c8d8","type":"inject","z":"f69f7b2d.ea0648","name":"減速停止","topic":"","payload":"{\"cmd\":\"cmdStop\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":173.75001525878906,"y":1666.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"7b080f57.bc36","type":"inject","z":"f69f7b2d.ea0648","name":"強制停止","topic":"","payload":"{\"cmd\":\"cmdFree\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":173.75001525878906,"y":1706.2500133514404,"wires":[["81d8d99.d0efd28"]]},{"id":"91303e0a.b0ce5","type":"comment","z":"f69f7b2d.ea0648","name":"接続例3) BLE 指定したモータに手動で接続する","info":"※注意 別のノードで既に接続されているモーターは接続されません。一旦接続を切って下さい\n\n","x":213.75001907348633,"y":905.0000152587891,"wires":[]},{"id":"b9e93aa7.e91448","type":"inject","z":"f69f7b2d.ea0648","name":"Scan 20sec","topic":"","payload":"20","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":183.75001907348633,"y":985.0000152587891,"wires":[["81041b58.af8448"]]},{"id":"d1410df3.5ef92","type":"debug","z":"f69f7b2d.ea0648","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1348.0357856750488,"y":965.0000114440918,"wires":[]},{"id":"5ad4cc65.9ec9d4","type":"debug","z":"f69f7b2d.ea0648","name":"motorMeasurement1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1398.0357856750488,"y":1005.0000114440918,"wires":[]},{"id":"39dedd65.5cd372","type":"km-motor","z":"f69f7b2d.ea0648","name":"","allowConnectMotor":"","x":1178.0357856750488,"y":985.0000114440918,"wires":[["d1410df3.5ef92"],["5ad4cc65.9ec9d4"],[],[]]},{"id":"ae558f9b.11089","type":"inject","z":"f69f7b2d.ea0648","name":"","topic":"","payload":"{\"cmd\":\"disConnect\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":753.7500190734863,"y":1045.000015258789,"wires":[["39dedd65.5cd372"]]},{"id":"ff77dad1.fa0fa8","type":"inject","z":"f69f7b2d.ea0648","name":"Scan Stop","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":173.75001907348633,"y":1025.000015258789,"wires":[["81041b58.af8448"]]},{"id":"d26b9306.c1723","type":"comment","z":"f69f7b2d.ea0648","name":"スキャン終了(停止)後にモーターを手動接続","info":"###スキャナーを停止後、発見したモータ名を指定して接続。\n+ \"KM-1 175D\"の部分は実際に検出したモータ名に変更して下さい。\n+ モーター名はScan終了時にスキャナーの下部に表示されます。\n+ RaspberryPi3のBLEデバイスではスキャン中に接続を行うと、接続に失敗したりBLE動作が不安定になる為、BLE scannerのスキャン終了後に接続します。","x":783.7500190734863,"y":945.0000152587891,"wires":[]},{"id":"81041b58.af8448","type":"km-BLEscan","z":"f69f7b2d.ea0648","name":"","x":473.7500190734863,"y":985.0000152587891,"wires":[[]]},{"id":"4f4ffa38.f167e4","type":"inject","z":"f69f7b2d.ea0648","name":"{\"cmd\":\"connect\", arg:\"KM-1 175D\"}","topic":"","payload":"{\"cmd\":\"connect\", \"arg\":\"KM-1 175D\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":803.7500190734863,"y":985.0000152587891,"wires":[["39dedd65.5cd372"]]},{"id":"ba6b4e0c.8af5f","type":"comment","z":"f69f7b2d.ea0648","name":"接続例1-2) USB 最初に発見したモーターに即座に接続する","info":"※注意 別のノードで既に接続されているモーターは接続されません。一旦接続を切って下さい\n\n","x":250,"y":320,"wires":[]},{"id":"c647e161.2be64","type":"inject","z":"f69f7b2d.ea0648","name":"Scan","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":380,"wires":[["aef9f66c.390968"]]},{"id":"aef9f66c.390968","type":"km-USBscan","z":"f69f7b2d.ea0648","name":"","x":380,"y":380,"wires":[["161254fe.42dcab"]]},{"id":"161254fe.42dcab","type":"km-motor-usb","z":"f69f7b2d.ea0648","name":"","allowConnectMotor":"","x":770,"y":400,"wires":[["31ca7bc2.be5294"],["2254bf21.b2fe5"],[],[]]},{"id":"2254bf21.b2fe5","type":"debug","z":"f69f7b2d.ea0648","name":"motorMeasurement1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1160,"y":420,"wires":[]},{"id":"31ca7bc2.be5294","type":"debug","z":"f69f7b2d.ea0648","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1110,"y":380,"wires":[]},{"id":"5e6beee1.68408","type":"inject","z":"f69f7b2d.ea0648","name":"{\"cmd\":\"disConnect\"}","topic":"","payload":"{\"cmd\":\"disConnect\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":440,"wires":[["161254fe.42dcab"]]},{"id":"6ae85026.2ac","type":"comment","z":"f69f7b2d.ea0648","name":"制御例1-2) USB モーターの制御","info":"※注意 別のノードで既に接続されているモーターは接続されません。一旦接続を切って下さい\n\n","x":170,"y":2020,"wires":[]},{"id":"e75f3956.d58738","type":"inject","z":"f69f7b2d.ea0648","name":"接続","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":2080,"wires":[["7725cbf5.aea2f4"]]},{"id":"7725cbf5.aea2f4","type":"km-USBscan","z":"f69f7b2d.ea0648","name":"","x":380,"y":2080,"wires":[["a0ebb461.813208"]]},{"id":"a0ebb461.813208","type":"km-motor-usb","z":"f69f7b2d.ea0648","name":"","allowConnectMotor":"","x":770,"y":2240,"wires":[["7977b080.98161","a6338b62.5a4a78"],["9994de9d.1c00a"],[],[]]},{"id":"9994de9d.1c00a","type":"debug","z":"f69f7b2d.ea0648","name":"motorMeasurement1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1180,"y":2200,"wires":[]},{"id":"7977b080.98161","type":"debug","z":"f69f7b2d.ea0648","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1130,"y":2140,"wires":[]},{"id":"ae6db89d.6ee018","type":"inject","z":"f69f7b2d.ea0648","name":"{\"cmd\":\"disConnect\"}","topic":"","payload":"{\"cmd\":\"disConnect\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":2160,"wires":[["a0ebb461.813208"]]},{"id":"a6338b62.5a4a78","type":"switch","z":"f69f7b2d.ea0648","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"connect","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":2120,"wires":[["54c345f8.e1b72c"]]},{"id":"54c345f8.e1b72c","type":"trigger","z":"f69f7b2d.ea0648","op1":"{\"cmd\":\"cmdEnable\"}","op2":"0","op1type":"json","op2type":"str","duration":"10","extend":false,"units":"ms","reset":"","bytopic":"topic","name":"{\"cmd\":\"cmdEnable\"}","x":840,"y":2120,"wires":[["a0ebb461.813208"]]},{"id":"a3fd20a2.77318","type":"inject","z":"f69f7b2d.ea0648","name":"LED、10rpm、正回転","topic":"","payload":"[{\"cmd\":\"cmdLed\",\"arg\":\"1,200,0,0\"},{\"cmd\":\"cmdSpeed_rpm\",\"arg\":10},{\"cmd\":\"cmdRunForward\"}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":2260,"wires":[["a0ebb461.813208"]]},{"id":"7f82be2.8471e4","type":"inject","z":"f69f7b2d.ea0648","name":"減速停止","topic":"","payload":"{\"cmd\":\"cmdStop\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":360,"y":2300,"wires":[["a0ebb461.813208"]]},{"id":"16b8dfa1.4334f","type":"comment","z":"f69f7b2d.ea0648","name":"※安全装置 モーターを最初に制御する為に必要","info":"","x":760,"y":2040,"wires":[]}]

その他のモーターコマンド

モーターのコマンドは以下のJSON形式で記述します。

 {"cmd":"コマンド名","arg":[引数1,引数2,,]}

コマンドの種類はJavascriptAPIドキュメントに準拠します。以下のドキュメントを参照下さい。

JavascriptAPIドキュメント

Author

Keigan Inc.

License

MIT

Node Info

Version: 0.3.0
Updated 5 months, 3 weeks ago
License: MIT
Rating: 5.0
(1 )

Downloads

1 in the last day
14 in the last week
72 in the last month

Nodes

  • km-BLEscan
  • km-USBscan
  • km-motor
  • km-motor-usb

Keywords

  • node-red
  • motor
  • keigan

Maintainers

  • keigan-motor