28BYJ-48 ステッピングモーターとULN2003とArduino Nano

◆実動作

64*32=2048 STEP順方向回転したのち500msecディレイの処理に入って逆回転するデモ

◆ソース
https://github.com/setapolo/arduino_sample_28BYJ-48/blob/master/28BYJ-48.ino


#include <Stepper.h>
//sample souce code for 28BYJ-48 (ULN2003) HALFMODE
const int NUMBER_OF_STEPS =64;//一周(360°)にかかるステップ数
const float GEAR_RATIO = 63.68395; //ギア比
int current_steps = 0;
int cw=1;
Stepper stepper(NUMBER_OF_STEPS, 8, 10, 9, 11);//コンストラクタ
void setup() {
 stepper.setSpeed(300);//RPM
}
void loop() {
 stepper.step(cw);//1ループで動かすステップ数 1または-1としている
 current_steps++;
 if (current_steps > (NUMBER_OF_STEPS * (GEAR_RATIO/2))){
 delay(500);
  current_steps = 0;
  cw = cw * -1; //逆方向にしている
 }
}
下記の情報ふまえ上記の動作確認ソースとした

◆配線
配線はこちらのサイトを参考にさせていただいた
https://iot.keicode.com/arduino/arduino-stepper-28byj-48.php


◆28BYJ-48のデータシート(英語)
http://robocraft.ru/files/datasheet/28BYJ-48.pdf
Speed Variation Ratio 1/64
Stride Angle 5.625° /64  

◆28BYJ-48のデータシートの読み方解説(英語)
https://42bots.com/tutorials/28byj-48-stepper-motor-with-uln2003-driver-and-arduino-uno/

こちらの解説にHalf mode(8step) で1ステップの角度が5.625° x 64 step で360°一周というモードと、full mode(4step)で1ステップの角度が11.25 x 32ステップという解説があった。(Half-step mode: 8 step control signal sequence (recommended) 5.625 degrees per step / 64 steps per one revolution of the internal motor shaftFull Step mode: 4 step control signal sequence 11.25 degrees per step / 32 steps per one revolution of the internal motor shaft

◆ギア比(Speed Variation Ratio) 1/64についての詳細な解説と議論
https://forum.arduino.cc/index.php?topic=71964.15
解説においてギア比が厳密には63.68395:1というコメント。

◆Arduinoが出しているStepperライブラリ情報(英語)
https://www.arduino.cc/en/Reference/Stepper
https://garretlab.web.fc2.com/arduino_reference/libraries/standard_libraries/Stepper/index.html (表紙だけ日本語)

◆Stepperコンストラクタでのstep引数の考え方
https://www.arduino.cc/en/Reference/StepperConstructor
stepの定義は一回転するときのステップ数を指定する仕様・モーターのステップあたりの角度が分かれば360をその角度で割った数となっているため、上述のHALF FULLに割り当てると
HALF = 360/5.625 = 64 STEP
FULL = 360/11.25 = 32 STEP
という考え方で良いはず
"steps: the number of steps in one revolution of your motor. If your motor gives the number of degrees per step, divide that number into 360 to get the number of steps (e.g. 360 / 3.6 gives 100 steps). (int)"

◆stepメソッドでのstep数に関しての考え方
https://www.arduino.cc/en/Reference/StepperStep
コンストラクタで指定したステップ数(ここでは64または32)で一周する想定で、どの程度の角度回転させるかを指定できる理解。
処理が"Blocking"同期処理で行われる説明が書かれており、一般的にこの場合、指定したSTEP数を回転し終えるまで処理が戻ってこない(固まる、動かなくなる)と想定。このため、一周分などを指定するとRPM分他に何もできなくなってしまうため、「なるべく速いRPMにして小刻みに処理を書く」(keep the speed high and only go a few steps with each call to step())ように注記されている。
This function is blocking; that is, it will wait until the motor has finished moving to pass control to the next line in your sketch. For example, if you set the speed to, say, 1 RPM and called step(100) on a 100-step motor, this function would take a full minute to run. For better control, keep the speed high and only go a few steps with each call to step()."

◆実際のSTEP数の指定 = ギア比を考慮
1/64のギア比となるため、実際のステップ数は64倍して指定する。(こちらを参考にすると正確な比は63.68395のよう)

◆ArduinoのStepperライブラリの解説(日本語)
http://www.musashinodenpa.com/arduino/ref/index.php?f=1&pos=259

◆Stepperライブラリのソース
https://github.com/arduino-libraries/Stepper/blob/master/src/Stepper.cpp

◆ソースコード付きのマニュアルらしきもの(ULN2003)(英語)
http://eeshop.unl.edu/pdf/Stepper+Driver.pdf

◆Stepperライブラリが前提としているユニポーラステッパモニターの配線図
https://www.arduino.cc/en/Reference/StepperUnipolarCircuit

◆ご購入
※購入は自己責任でよろしくお願いしたい。(合計\2343)


中国でエアコンのルーバーに使うステッピングモーターが大量に流通しているのでホビー用に使いたいとご要望を頂き販売開始いたしました」とのことですのでもともとはエアコンに利用されているようです。

◆参考にさせていただいたリンク
https://iot.keicode.com/arduino/arduino-stepper-28byj-48.php
https://stupiddog.jp/note/archives/1235
https://kokensha.xyz/arduino/arduino-step-motor-28byj-48/
https://sites.google.com/site/memorandumjavaandalgorithm/arduino-jiang-zuo-suteppingumota-28byj-48
https://www.nakarobo.com/entry/2019/02/08/000000
https://qiita.com/kudo453/items/30d9322cacb71f4a1e1f
https://42bots.com/tutorials/28byj-48-stepper-motor-with-uln2003-driver-and-arduino-uno/

◆よりいけてるドライバがあるらしい情報
https://www.denshi.club/cookbook/output/motor/stepping/stepper1.html

Comments

Popular posts from this blog

SG92RサーボモータとArduino Nano

ARLISSのロケットデザインについて ARLISS-M Design Guide ブースター