多くのお客様が弊社のエンコーダを内蔵するステッピングモーターを使うロボットタンクカーと OSOYOOバランスカーを購入くださいました。その中に、エンコーダのプログラミング方法に興味があるため、ここで簡単なプログラムを提供いたして、Arduinoを使って、エンコーダが出力するパルス値が読み込めます。
接続:
ステッピングモーター | Arduino |
白線(V Power) | 5V |
黄線(G-GND) | GND |
S1( G の隣) | D6 |
S2( S1の隣) | D7 |
プログラム:
https://osoyoo.com/driver/encoder.zip
上記のをクリックしてコードをダウンロードできます。ダウンロードしたコードをArduino IDE に読み込んだら、右上のシリアルモニタを開いてください。
そして、1つのホイールをステッピングモーターに手でホイールを回転できるように取り付けた後、ホイールを360°回転して、シリアルモニタには下記のように表示します。
Position: 1
Position: 2
….
Position: 148
Position: 149
Position: 150
最後は Position 151
を表示します。1回転(360°)するのに、およそ、151パルス必要で、即ち150pulse/revということは分かりました。
DownLoad Url osoyoo.com
You must be logged in to post a comment.
I am able to upload this Encoder code into my MEGA Arduino. I connect the encoder wires as depicted. I cannot display anything on the serial monitor. I have verified the board and comm port in the TOOLS menu. I have set it up just like the video. I have tried all the motors. I have verified my hook up wires are good with a volt/ohm meter.
Could the problem be the Encoder.Zip?
Thank you
Jack
you need use install a wheel on the motor, use your hand to rotate the wheel. If your motor does not rotate, you can not see any Serial printing.