Wa Koodu

Lilo 28BYJ-48 Stepper Motor pẹlu ULN2003 Driver ati Arduino

Lilo 28BYJ-48 Stepper Motor pẹlu ULN2003 Driver ati Arduino

Ninu ikẹkọ yii, a yoo kọ bi a ṣe le ṣakoso moto igbesẹ 28BYJ-48 nipa lilo awakọ ULN2003 pẹlu Arduino. Eto yii gba laaye iṣakoso deede ti ipo ati iyara moto naa. Ni ipari iṣẹ akanṣe yii, iwọ yoo ni anfani lati yiyi moto naa ni awọn itọsọna mejeeji ati ṣakoso awọn igbesẹ rẹ ni imunadoko.

A o ni lo 28BYJ-48 stepper motor, eyi ti o jẹ yiyan olokiki fun ọpọlọpọ awọn iṣẹ akanṣe roboti ati adaṣe nitori idiyele rẹ ti o din owo ati irọrun lilo. Iboju awakọ ULN2003 n so motor stepper pọ pẹlu Arduino, ti o fun wa laaye lati fi awọn ifihan igbesẹ ranṣẹ ti o n ṣakoso iṣipopada motor naa. Itọsọna yii yoo dari ọ nipasẹ awọn asopọ to ṣe pataki ati koodu lati jẹ ki motor rẹ yipo.

Fun alaye siwaju sii, jọwọ tọka si fidio ti o ni ibatan pẹlu ẹkọ yii (ni fidio ni 0:45).

Itumọ Ẹrọ

Awọn ẹya pataki ti iṣẹ akanṣe yii ni 28BYJ-48 stepper motor ati ULN2003 driver board. Stepper motor naa ni ọpọlọpọ awọn coils ti a le mu ṣiṣẹ ni ilana kan pato lati ṣẹda iyipo. ULN2003 driver naa ṣiṣẹ gẹgẹbi switch, ti o fun laaye Arduino lati ṣakoso agbara ti a fi ranṣẹ si ọkọọkan coil.

Olùdarí ULN2003 nlo àkópọ́ transistor Darlington láti ṣe àtẹ̀jáde àkúnya tó ga tó jẹ́ pé motor stepper nilo. Nígbà tí pin kan láti Arduino bá ń ṣe àtẹ̀jáde ìkìlọ̀ HIGH, ó jẹ́ kí àkúnya wọlé sí coil tó bá mu motor náà, tó ń fa kó rìn. Èyí ń jẹ́ kí a lè ṣàkóso pẹ̀lú ìtẹ́lọ́run lórí ìyípadà àngẹli àti iyara motor náà.

Alaye iwe data

OlùṣelọpọULN2003
Nọmba apakanULN2003
Iwọn folti logic/IO5 V
Iwọn folti ipese5-30 V (max)
Iwọn lọwọlọwọ (nipasẹ ikanni)500 mA to pọ julọ
Iwọn lọwọlọwọ to ga julọ (fun ikanni kọọkan)2 A max
Itọsọna igbohunsafẹfẹ PWMN/A
Iwọn aala logic input0.8 V (kekere), 2.4 V (giga)
Iwọn folti / RDS(on)saturation1.5 V max
Iwọn otutu to pọ julọ70 °C max
PàkàjìDIP-16
Akọsilẹ / awọn iyatọTi a maa n lo pẹlu awọn moto stepper 5V.

  • Rii daju pe awakọ le mu awọn ibeere lọwọlọwọ ti ọkọ ayọkẹlẹ rẹ.
  • Lo lo awọn heat sinks ti o ba jẹ dandan lati ṣakoso awọn ihamọ otutu.
  • Ṣayẹwo pé gbogbo asopọ jẹ́ ààbò láti yago fún àwọn ìkànsí tí ń fo.
  • Ṣe idanwo mọ́tò náà nipa ṣiṣe awọn igbesẹ irọrun ṣaaju ki o to darapọ mọ́ awọn iṣẹ akanṣe nla.
  • Rii daju pe o fun moto ni agbara pẹlu folti to peye.

Ilana Asopọ.

Stepper 28BYJ-48 wiring battery
Stepper 28BYJ-48 wiring

Lati so 28BYJ-48 stepper motor pọ si ULN2003 driver ati Arduino, tẹle awọn igbesẹ wọnyi:

Ni akọkọ, so mọ́tò náà pọ̀ si awakọ ULN2003. Mọ́tò náà ní ẹ̀rọ mẹ́rin, tí a sábà máa n pe ni awọ̀ oríṣìíríṣìí gẹ́gẹ́ bí àwọ̀ àlùfáà, àwọ̀ ofeefee, àwọ̀ rózì, àti àwọ̀ buluu. So àwọn ẹ̀rọ wọ̀nyí pọ̀ si àwọn pin àtẹ̀jáde tó báamu lori awakọ ULN2003. Àwọn ìjápọ̀ náà ni:

  • Orangesopọ siOUT1
  • Yellowsopọ siOUT2
  • Pinksopọ siOUT3
  • Bluesopọ siOUT4

Nibi, so asopọ awakọ ULN2003 si Arduino. Awọn pinni input lori awakọ naa baamu si mẹrin awọn pin dijitalu lori Arduino. Fun apẹẹrẹ:

  • IN1siPin 10
  • IN2siPin 11
  • IN3siPin 12
  • IN4siPin 13

Nikẹhin, so awọn pin agbara ati ilẹ ti awakọ ULN2003 pọ si Arduino. So awọnVCCpin si si 5V ti Arduino atiGNDso pin si ilẹ Arduino. Rii daju pe gbogbo awọn asopọ jẹ aabo ṣaaju ki o to tan-an eto naa.

Àpẹẹrẹ Kóòdù & Irin-ajo

Ninu apakan iṣeto ti koodu Arduino, a ṣe alaye awọn pin ti o so pọ mọ awakọ ULN2003:

int Pin1 = 10; 
int Pin2 = 11; 
int Pin3 = 12; 
int Pin4 = 13; 

Nibi, a ṣe afihan mẹrin awọn oniyipada integer:Pin1,Pin2,Pin3, andPin4, ti o baamu si awọn pin oni-nọmba lori Arduino. Awọn pin wọnyi yoo ṣakoso iṣipopada motor stepper.

Ninusetup()iṣẹ, a ṣe eto awọn pin wọnyi gẹgẹbi awọn ẹka jade:

void setup() { 
 pinMode(Pin1, OUTPUT);  
 pinMode(Pin2, OUTPUT);  
 pinMode(Pin3, OUTPUT);  
 pinMode(Pin4, OUTPUT);  
} 

Iṣeto yii jẹ ki Arduino le fi awọn ifihanṣẹ ranṣẹ si awakọ ULN2003 lati ṣakoso moto.pinMode iṣẹ naa ṣeto ọkọọkan pin si ipo OUTPUT, n jẹ ki wọn le fi awọn ifihan ranṣẹ.

Nikẹhin, ninu iyipo pataki, a ṣẹda iyipada ọran lati ṣakoso awọn igbesẹ moto da lori oniyipada naa._step:

switch(_step){ 
   case 0: 
     digitalWrite(Pin1, LOW);  
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
     digitalWrite(Pin4, HIGH); 
   break;  
   // Additional cases follow
}

Ninu apakan yii, a lodigitalWritelati si HIGH tabi LOW si ọkọọkan pin da lori lọwọlọwọ_step. Eyi n ṣakoso awọn coils wo ni a mu ṣiṣẹ, ti o fun laaye motor lati yipo. Koodu kikun ti o dapọ awọn snippets wọnyi yoo wa ni ikojọpọ ni isalẹ akọsilẹ.

Iṣafihan / Kí ni láti retí

Ni gbogbo nkan ti wa ni asopọ ni deede ati pe koodu ti wa ni ikojọpọ, motor stepper yẹ ki o yipo ni idahun si awọn ifihan lati ọdọ Arduino. O le danwo motor naa nipa ṣiṣatunkọ idaduro ninu iyipo tabi yiyipada awọn igbesẹ lati wo bi o ṣe n ṣe. Ṣe akiyesi pe ti motor naa ko ba ni agbara ni deede, o le ma gbe tabi le ṣe ihuwasi ni airotẹlẹ.

Iwe akọsilẹ

  • Ifáhàn - 0:00
  • Hardware ti a ṣalaye - 1:30
  • Itọsọna Wiring - 3:15
  • Àpẹẹrẹ Kóòdù & Irin-ajo - 5:00
  • Iṣafihan / Ohun ti a nireti - 7:45

Aworan

Stepper 28BYJ-48 wiring battery
Stepper 28BYJ-48 wiring battery
Stepper 28BYJ-48 poles
Stepper 28BYJ-48 poles
Stepper 28BYJ-48 waveform actual
Stepper 28BYJ-48 waveform actual
Stepper 28BYJ-48 waveform inverted
Stepper 28BYJ-48 waveform inverted
Stepper 28BYJ-48 wiring
Stepper 28BYJ-48 wiring
6-The source code for stepper motor 28BYJ-48 with ULN2003 for Arduino
Ede: C++
// Original source is http://www.geeetech.com/wiki/index.php/Stepper_Motor_5V_4-Phase_5-Wire_%26_ULN2003_Driver_Board_for_Arduino
// Update by Ahmad Shamshiri for RoboJax.com
// Published on March 27, 2017 in Ajax, ON, Canada.
/*
 * 
  Need wiring diagram from this code:  https://youtu.be/0glBk917HPg
  Purchase My Arduino course on Udemy.com http://robojax.com/L/?id=62
 * 

 * Get this code and other Arduino codes from RoboJax.com
Learn Arduino step by step in a structured course with all material, wiring diagrams, and libraries
all in one place. Purchase My course on Udemy.com http://robojax.com/L/?id=62

If you found this tutorial helpful, please support me so I can continue creating 
content like this. 

or make a donation using PayPal http://robojax.com/L/?id=64

 *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been downloaded from RoboJax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


int Pin1 = 10; 
int Pin2 = 11; 
int Pin3 = 12; 
int Pin4 = 13; 
int _step = 0; 
boolean dir = true;// false=clockwise, true=counter clockwise
int count=0;
void setup() 
{ 
 pinMode(Pin1, OUTPUT);  
 pinMode(Pin2, OUTPUT);  
 pinMode(Pin3, OUTPUT);  
 pinMode(Pin4, OUTPUT);  
} 
 void loop() 
{ 
 switch(_step){ 
   case 0: 
     digitalWrite(Pin1, LOW);  
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
     digitalWrite(Pin4, HIGH); 
   break;  
   case 1: 
     digitalWrite(Pin1, LOW);  
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, HIGH); 
     digitalWrite(Pin4, HIGH); 
   break;  
   case 2: 
     digitalWrite(Pin1, LOW);  
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, HIGH); 
     digitalWrite(Pin4, LOW); 
   break;  
   case 3: 
     digitalWrite(Pin1, LOW);  
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, HIGH); 
     digitalWrite(Pin4, LOW); 
   break;  
   case 4: 
     digitalWrite(Pin1, LOW);  
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, LOW); 
     digitalWrite(Pin4, LOW); 
   break;  
   case 5: 
     digitalWrite(Pin1, HIGH);  
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, LOW); 
     digitalWrite(Pin4, LOW); 
   break;  
     case 6: 
     digitalWrite(Pin1, HIGH);  
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
     digitalWrite(Pin4, LOW); 
   break;  
   case 7: 
     digitalWrite(Pin1, HIGH);  
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
     digitalWrite(Pin4, HIGH); 
   break;  
   default: 
     digitalWrite(Pin1, LOW);  
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
     digitalWrite(Pin4, LOW); 
   break;  
 } 
 if(dir){ 
   _step++; 
 }else{ 
   _step--; 
 } 
 if(_step>7){ 
   _step=0; 
 } 
 if(_step<0){ 
   _step=7; 
 } 
 delay(1); 

}

Fáìlìs📁

Ko si awọn faili ti o wa.