モータードライバ
PCA9685 16Channel 12bit PWM サーボドライバー
Amazon より adafruit互換品を購入。 1980円。
使い方のURLが箱に書いてあった。 これ
追加購入、Amazon 300円
VCC 3~5V V+ 6V MAX
さっそくライブラリをダウンロードして使ってみた。 Adaflruitのサイトからライブラリをダウンロード。
I2Cアドレスはデフォルト0x40。I2Cアドレス設定ジャンパーのA0をショートすると0x41となる。
ダウンロード | ライブラリをコピーしてスケッチの例を実行 |
---|
2相ステッピングモータTS3692N
ステップ角 1.8°200ステップ 定格3.5Vデジットより購入 500円 青=>青、赤=>橙、橙=>白、緑=>黄
L9110S Hブリッジ ステッピングモータドライバ
Amazonより購入 170円 データシート
ステッピングモーターTS3692を回してみた。
//TS3692N65 3V //カタログ通り励磁 動作確認済 // #define A1 3 #define A2 5 #define B1 6 #define B2 9 #define st 200 const int ledpin = 13; const int RA1 =3; //int pin[4]={A1,A2,B1,B2}; int pin[4]={A1,B1,A2,B2}; //int cw_R[] ={1,0,0,1, 1,0,1,0, 0,1,1,0, 0,1,0,1}; // int cw_R[] ={1,0,0,1, 1,1,0,0, 0,1,1,0, 0,0,1,1}; // int ccw_R[] ={0,1,0,1, 0,1,1,1, 1,0,1,0, 1,0,0,1}; // void setup() { pinMode(A1,OUTPUT); pinMode(A2,OUTPUT); pinMode(B1,OUTPUT); pinMode(B2,OUTPUT); reijiS(); delay(1000); Serial.begin(9600); } void loop() { if(Serial.available() > 0){ switch(Serial.read()) { case 'f': for(int i=0;i<50;i++)motor_cw(); //reijiS(); break; case 'b': for(int i=0;i<50;i++)motor_ccw(); //reijiS(); break; case 'c': for(int i=0;i<1000;i++)motor_cw(); //reijiS(); break; case 'a': step_1(); break; default: reijiS(); break; } } }// end loop void step_1(){ while(1){ motor_cw(); delay(1000); } } void motor_cw(){ int j=0; while(j<16){ for(int i=0;i<4;i++){ digitalWrite(pin[i],cw_R[j]); j++; delayMicroseconds(st); } } } void motor_ccw(){ int j=0; while(j<16){ for(int i=0;i<4;i++){ digitalWrite(pin[i],ccw_R[j]); j++; delayMicroseconds(st); } } } void reijiT(){ digitalWrite(pin[0],LOW); digitalWrite(pin[1],LOW); digitalWrite(pin[2],LOW); digitalWrite(pin[3],LOW); } void reijiS(){ digitalWrite(pin[0],HIGH); digitalWrite(pin[1],HIGH); digitalWrite(pin[2],HIGH); digitalWrite(pin[3],HIGH); } |
---|
8BYJ48 5V ステッピングモーター / ULN2003 ドライバーを試す
[GPG] 28BYJ48 5V ステッピングモーター / ULN2003 ドライバー基盤 2組セット Arduino等の電子工作用 Amazonより購入 1480円// このサンプルコードは28BYJ-48の時計回り・逆回りを行うデモです。 // ULN2003 インターフェースボードを使用。つまりただのトランジスタアレイで駆動するだけ // 28BYJ-48モーターは4相、8ビートモーター。 // 減速ギア非68倍。 1バイポーラ巻線。ステップ角は5.625/64。 // 動作周波数100PPS。電流92mA。 //////////////////////////////////////////////// //Base Code // 4tronix Arduino http://www.4tronix.co.uk/arduino/Stepper-Motors.php int motorPin1 = 8; // Blue - 28BYJ48 pin 1 int motorPin2 = 9; // Pink - 28BYJ48 pin 2 int motorPin3 = 10; // Yellow - 28BYJ48 pin 3 int motorPin4 = 11; // Orange - 28BYJ48 pin 4 // Red - 28BYJ48 pin 5 (VCC) int motorSpeed = 1200; //速度。数値が小さいほど速くなる。800以下は脱調して動かない int count = 0; // count of steps made int countsperrev = 512; // number of steps per full revolution int lookup[9] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001,B00000}; ////////////////////////////////////////////////////////////////////////////// void setup() { //declare the motor pins as outputs pinMode(motorPin1, OUTPUT); pinMode(motorPin2, OUTPUT); pinMode(motorPin3, OUTPUT); pinMode(motorPin4, OUTPUT); Serial.begin(115200); } ////////////////////////////////////////////////////////////////////////////// void loop(){ if(count < countsperrev ) clockwise(); else if (count == countsperrev * 2) count = 0; else anticlockwise(); count++; } ////////////////////////////////////////////////////////////////////////////// void anticlockwise() //反時計回り { for(int i = 0; i < 8; i++) { setOutput(i); delayMicroseconds(motorSpeed); } } void clockwise() //時計回り { for(int i = 7; i >= 0; i--) { setOutput(i); delayMicroseconds(motorSpeed); } } void setOutput(int out) { digitalWrite(motorPin1, bitRead(lookup[out], 0)); digitalWrite(motorPin2, bitRead(lookup[out], 1)); digitalWrite(motorPin3, bitRead(lookup[out], 2)); digitalWrite(motorPin4, bitRead(lookup[out], 3)); } |
---|