ኮድ ይፈልጉ

አርዱኖ ኮድ እና ቪዲዮ፡ L293D የዲሲ ሞተር መቆጣጠሪያ (ያለ የፍጥነት መቆጣጠሪያ)

አርዱኖ ኮድ እና ቪዲዮ፡ L293D የዲሲ ሞተር መቆጣጠሪያ (ያለ የፍጥነት መቆጣጠሪያ)

ይህ መማሪያ ከአርዱኖ (Arduino) ጋር የL293D ሞተር መቆጣጠሪያን በመጠቀም የዲሲ ሞተርን እንዴት መቆጣጠር እንደሚቻል ይሸፍናል። L293D ሞተሩን በሰዓት አቅጣጫ እና በተቃራኒ ሰዓት አቅጣጫ ለማሽከርከር ያስችልዎታል። ይህን መመሪያ በመከተል ክፍሎቹን እንዴት ማገናኘት እና አርዱኖውን እንዴት ፕሮግራም ማድረግ እንደሚችሉ የሚፈለገውን የሞተር ቁጥጥር ለማሳካት ይማራሉ።

በዚህ ፕሮጀክት ውስጥ አንድ ነጠላ የዲሲ ሞተር ለመቆጣጠር L293D ሞተር ሾፌርን እንጠቀማለን። ሞተሩ በአርዱኖ ኮድ ውስጥ በተሰጡት ትዕዛዞች መሰረት አቅጣጫ መቀየር ይችላል። ስለ ቅንብሩ እና ኮዱ የበለጠ ግልጽ ግንዛቤ ለማግኘት ተያያዥውን ቪዲዮ መመልከት ጠቃሚ ነው (በቪዲዮው በ00:00)።

 

ሃርድዌር ተብራርቷል

L293D ሞተሮችን ለማሽከርከር የተነደፈ የተቀናጀ ወረዳ ነው። ሁለት የዲሲ ሞተሮችን በአንድ ጊዜ ወይም አንድ የእርምጃ ሞተር (stepper motor) መቆጣጠር ይችላል። ቺፑ በሞተሩ ላይ የሚደርሰውን የቮልቴጅ ፖላሪቲ በመቀየር አቅጣጫ ለመቆጣጠር የH-bridge ውቅር ይጠቀማል። ይህ ተለዋዋጭነት ለሮቦቲክስ እና አውቶሜሽን ፕሮጀክቶች በጣም ጥሩ ምርጫ ያደርገዋል።

ከL293D በተጨማሪ የቁጥጥር ምልክቶችን ወደ ሞተር ሾፌሩ ለመላክ የአርዱኖ ቦርድ እንጠቀማለን። አርዱኖው ሞተሩን ለማንቃት እና የመሽከርከር አቅጣጫውን ለመወሰን አስፈላጊዎቹን የሎጂክ ደረጃዎች ያመነጫል። ቅንብሩ እንዲሁም የዲሲ ሞተር እና ከሞተሩ የቮልቴጅ መስፈርቶች ጋር የሚስማማ የኃይል አቅርቦት ይፈልጋል።

የዳታሼት ዝርዝሮች

አምራች ቴክሳስ ኢንስትሩመንትስ
የክፍል ቁጥር L293D
የሎጂክ/IO ቮልቴጅ 5 ቪ
የአቅርቦት ቮልቴጅ 4.5 - 36 ቪ
የውጤት ጅረት (በአንድ ቻናል) 600 ሚኤ
ከፍተኛ ጅረት (በአንድ ቻናል) 1.2 ኤ
የPWM ድግግሞሽ መመሪያ 20 ኪሎሄርትዝ
የግቤት ሎጂክ ገደቦች 2.5 ቪ (በተለምዶ)
የቮልቴጅ ጠብታ / RDS(on) / ሳቹሬሽን 1.5 ቪ (ከፍተኛ)
የሙቀት ገደቦች 150 ዲግሪ ሴንቲግሬድ (ከፍተኛ)
ፓኬጅ 16-DIP
ማስታወሻዎች / ልዩነቶች ሁለት ሞተሮችን መቆጣጠር ይችላል

 

  • የአቅርቦት ቮልቴጅ ከ36 ቪ እንዳይበልጥ ያረጋግጡ።
  • በከፍተኛ ጅረት አካባቢ ሲሰሩ ተገቢውን የሙቀት መሙያ (heat-sink) ይጠቀሙ።
  • ሁልጊዜ የአርዱኖውን እና የሞተር ሾፌሩን መሬት (ground) ያገናኙ።
  • የተገላቢጦሽ ፖላሪቲ ግንኙነቶችን ለማስቀረት ሽቦውን ያረጋግጡ።
  • ወደፊት በሚደረጉ ፕሮጀክቶች ውስጥ ፍጥነትን ለመቆጣጠር ከተፈለገ የPWM ምልክቶችን ይጠቀሙ።

የሽቦ መጫኛ መመሪያዎች

Arduino wiring for L293D motor driver with battery
Arduino wiring for L293D motor driver with battery
Arduino wiring for L293D motor driver
Arduino wiring for L293D motor driver

የL293D ሞተር መቆጣጠሪያን ከአርዱኖ ጋር ለማገናኘት በመጀመሪያ ኃይል እና መሬትን በማገናኘት ይጀምሩ። የL293Dን ፒን 4 እና ፒን 5 ከመሬት ጋር ያገናኙ። ከዚያም ፒን 1 (Vcc1) ከአርዱኖው 5 ቪ ውፅዓት ጋር ያገናኙ። ለVcc2 (ፒን 8) ከሞተሩ የቮልቴጅ መስፈርት ጋር የሚስማማ መሆኑን በማረጋገጥ ከውጭ የኃይል አቅርቦት ጋር ያገናኙት።

በመቀጠል የሞተሩን ኃይል ለመቆጣጠር የማንቃት ፒን (ፒን 1) ከአርዱኖው ፒን 8 ጋር ያገናኙ። ለሞተር ቁጥጥር ግቤቶች የL293Dን ፒን 2 (1A) ከአርዱኖው ፒን 2 እና ፒን 7 (2A) ከአርዱኖው ፒን 7 ጋር ያገናኙ። በመጨረሻም የሞተሩን ተርሚናሎች በL293D ላይ ካሉት ፒን 3 (1Y) እና ፒን 6 (2Y) ጋር ያገናኙ።

L293D breadboard pin 1
L293D የብሬድቦርድ ፒን 1
L293D_የብሬድቦርድ_ሽቦ_bb

የኮድ ምሳሌዎች እና ማብራሪያ

የሚከተለው ኮድ ፒኖቹን ያስጀምራል እና የሞተር ቁጥጥርን ያዘጋጃል። ጥቅም ላይ የዋሉት መለያዎች ለመጀመሪያው የሞተር ቁጥጥር ፒን P1A እና ለማንቃት ፒን EN12 ያካትታሉ። የሴትአፕ (setup) ተግባር ፒኖቹን እንደ ውፅዓት ያዋቅራል።

void setup() {
  Serial.begin(9600); // መረጃ ለማሳየት ሴሪያል ሞኒተርን ያዘጋጁ
  pinMode(P1A, OUTPUT); // ፒን ለP1A እንደ OUTPUT ይግለጹ
  pinMode(P2A, OUTPUT); // ፒን ለP2A እንደ OUTPUT ይግለጹ
  pinMode(EN12, OUTPUT); // ፒን ለ1,2EN ማንቃት እንደ OUTPUT ይግለጹ
}

በሉፕ (loop) ውስጥ ሞተሩ በመካከላቸው መዘግየቶች በሁለቱም አቅጣጫዎች እንዲሽከረከር ይታዘዛል። የሞተሩ ሁኔታ Serial.println በመጠቀም ወደ ሴሪያል ሞኒተር ይታተማል።

void loop() {
  Serial.println("በሰዓት አቅጣጫ በማሽከርከር ላይ");
  digitalWrite(EN12, HIGH); // 1A እና 2A አንቃ
  digitalWrite(P1A, HIGH); // ለP1A ከፍተኛ ምልክት ይላኩ
  digitalWrite(P2A, LOW); // ለP2A ዝቅተኛ ምልክት ይላኩ
  delay(3000); // ሞተሩ ለ3 ሰከንድ ይሰራል
  digitalWrite(EN12, LOW); // 1A እና 2A አጥፉ
}

ይህ ቅንጥብ ወደ P1A እና P2A የሚላኩትን የሎጂክ ደረጃዎች በመቀየር የሞተሩን የመሽከርከር አቅጣጫ እንዴት መቆጣጠር እንደሚቻል ያሳያል። ሞተሩ አቅጣጫ ከመቀየሩ በፊት ለ3 ሰከንድ ይሰራል ከዚያም ይቆማል።

L293D የግማሽ ድልድይ (half bridge) ሾፌሮች እንዴት እንደሚጠቀሙ እነሆ፡-

L293D as halft bridge CW
L293D እንደ ግማሽ ድልድይ በሰዓት አቅጣጫ
L293D as halft bridge CCW
L293D እንደ ግማሽ ድልድይ በተቃራኒ ሰዓት አቅጣጫ

ማሳያ / ምን እንደሚጠበቅ

ሲትዘጋጅ እና ኮዱ ሲሰቀል፣ ሞተሩ ለ3 ሰከንድ ወደ አንድ አቅጣጫ ሲሽከረከር፣ ለ2 ሰከንድ ሲቆም፣ ከዚያም ለሌላ 3 ሰከንድ ወደ ተቃራኒው አቅጣጫ ሲሽከረከር ማየት ይኖርብዎታል። የሞተሩ ሁኔታ በተከታታይ መቆጣጠሪያ (ሰሪያል ሞኒተር) ላይ ይታተማል፣ ይህም ድርጊቶቹን ያረጋግጣል (በቪዲዮ በ12፡00)።

የተለመዱ ችግሮች ለሞተሩ ትክክለኛውን የቮልቴጅ አቅርቦት ማረጋገጥ እና የሞተር ግንኙነቶች ትክክል መሆናቸውን መፈተሽ ያካትታሉ። ሞተሩ ምላሽ ካልሰጠ፣ የሽቦ አያያዙን እና የኃይል አቅርቦት ግንኙነቶችን በድጋሚ ያረጋግጡ።

የቪዲዮ ጊዜ ምልክቶች

  • 00፡00 - መግቢያ
  • 02፡30 - የሽቦ አያያዝ ማብራሪያ
  • 05፡00 - የኮድ ግምገማ
  • 10፡00 - የሞተር ቁጥጥር ማሳያ

ምስሎች

L293D breadboard pin 1
L293D breadboard pin 1
L293D_breadboard_wiring_bb
L293D_breadboard_wiring_bb
L293D as halft bridge CCW
L293D as halft bridge CCW
L293D as halft bridge CW
L293D as halft bridge CW
Arduino wiring for L293D motor driver with battery
Arduino wiring for L293D motor driver with battery
Arduino wiring for L293D motor driver
Arduino wiring for L293D motor driver
79-Arduino code L293 DC motor driver (Advanced).
ቋንቋ: C++
++
/*
 * This is the Arduino code L293 DC motor driver (Advanced).
 Using this code you can control a motor to rotate in both directions: clockwise (CW) 
 and counter-clockwise (CCW).

 *  * 
 // Written by Ahmad S. for Robojax.com on 
// February 25, 2018 at 18:30 in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purposes only.
 * 

 * watch L293 video for details https://youtu.be/jAmDliHcTJ0
 * Code is available at http://robojax.com/learn/arduino

 * 

*/
// DC motor 1 control
#define P1A 2 // define pin 2 as for P1A
#define P2A 7 // define pin 7 as for P2A
#define EN12 8 // define pin 8 as for 1,2EN enable



// DC motor 2 control 
#define P3A 10 // define pin 10 as for P3A
#define P4A 13 // define pin 13 as for P4A
#define EN34 9 // define pin 9 as for EN3 and EN4 enable

/*
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purposes only.
 * 
 */

void setup() {
  // L293 Motor Control Code by Robojax.com 2018025
  Serial.begin(9600);// setup Serial Monitor to display information
  pinMode(P1A, OUTPUT);// define pin as OUTPUT for P1A
  pinMode(P2A, OUTPUT);// define pin as OUTPUT for P2A
  pinMode(EN12, OUTPUT);// define pin as OUTPUT for 1,2EN
   
  pinMode(P3A, OUTPUT);// define pin as OUTPUT for P3A
  pinMode(P4A, OUTPUT);// define pin as OUTPUT for P4A
  pinMode(EN34, OUTPUT);// define pin as OUTPUT for 3,4EN   
  // L293 Motor Control Code by Robojax.com 2018025   
}

void loop() {
  // L293 Motor Control Code by Robojax.com 2018025


    Serial.println("Rotating CW");
    digitalWrite(EN12 ,HIGH);// Enable 1A and 2A 
    digitalWrite(P1A,HIGH);// send + or HIGH signal to P1A
    digitalWrite(P2A,LOW);// send - or LOW signal to P2A       
    delay(3000);// motor runs for 3 seconds
    digitalWrite(EN12 ,LOW);// Disable 1A and 2A
    delay(2000);// motor stop for 3 seconds 
    Serial.println("Motor Stopped"); 

  // L293 Motor Control Code by Robojax.com 2018025
    // now changing the direction of rotation of motor
    Serial.println("Rotating CCW");
    digitalWrite(EN12 ,HIGH);// Enable 1A and 2A     
    digitalWrite(P1A,LOW);// send + or HIGH signal to P1A
    digitalWrite(P2A,HIGH);// send - or LOW signal to P2A  
    delay(3000);// motor runs for 3 seconds
    digitalWrite(EN12 ,LOW);// Disable 1A and 2A
    delay(2000);// motor stop for 3 seconds    
    Serial.println("Motor Stopped");   
     

  Serial.println("=========== Loop done"); 
  delay(500);
  // L293 Motor Control Code by Robojax.com 2018025 
}
80-Arduino code: L293 DC motor driver (Advanced)
ቋንቋ: C++
/*


 * This is the Arduino code L293 DC motor driver (Advanced).
Using this code you can control a motor to rotate in both directions: clockwise (CW) 
and counter-clockwise (CCW).

 *  * 
 // Written by Ahmad S. for Robojax.com on 
// February 25, 2018 at 18:30 in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purposes only.
 * 

* Watch L293 video for details: https://youtu.be/jAmDliHcTJ0
 * Code is available at: http://robojax.com/learn/arduino

 * 

*/
// DC motor 1 control
#define P1A 2 // define pin 2 as for P1A
#define P2A 7 // define pin 7 as for P2A
#define EN12 8 // define pin 8 as for 1,2EN enable


// DC motor 2 control 
#define P3A 10 // define pin 10 as for P3A
#define P4A 13 // define pin 13 as for P4A
#define EN34 9 // define pin 9 as for EN3 and EN4 enable

/*
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purposes only.
 * 
 */

void setup() {
  // L293 Motor Contro Code by Robojax.com 2018025
  Serial.begin(9600);// setup Serial Monitor to display information
  pinMode(P1A, OUTPUT);// define pin as OUTPUT for P1A
  pinMode(P2A, OUTPUT);// define pin as OUTPUT for P2A
  pinMode(EN12, OUTPUT);// define pin as OUTPUT for 1,2EN
   
  pinMode(P3A, OUTPUT);// define pin as OUTPUT for P3A
  pinMode(P4A, OUTPUT);// define pin as OUTPUT for P4A
  pinMode(EN34, OUTPUT);// define pin as OUTPUT for 3,4EN 

  // L293 Motor Contro Code by Robojax.com 2018025   
}

void loop() {

 if(value == 45){
  rotateMA("CW",HIGH); // start motor in CW
 }
  delay(3000); 
  rotateMA("CW",LOW); // stop motor
  delay(2000);

  rotateMA("CCW",HIGH); // start motor in CCW
  delay(3000); 
  rotateMA("CW",LOW); /// stop motor
  delay(2000);  
  
  // L293 Motor Contro Code by Robojax.com 2018025 
}// loop ends


/**
 * function: rotateMA(String di,int action)
 * Sends power to motor A
 * di is a string and can be "CW" or "CCW"
 * to use: 
 * rotateMA("CW",HIGH);// to rotate motor  CW
 * rotateMA("CCW",HIGH);// to rotate motor CCW
 *  to stop the motor:
 * rotateMA("CW",LOW);// to stop motor 
 */
void rotateMA(String di,int endis)
{
    // L293 Motor Contro Code by Robojax.com 2018025
 if(di =="CW"){
    Serial.println(" Rotating CW");
    digitalWrite(EN12 ,endis);// Enable 1A and 2A 
    digitalWrite(P1A,HIGH);// send + or HIGH signal to P1A
    digitalWrite(P2A,LOW);// send - or LOW signal to P2A       
  

 }else{
  // L293 Motor Contro Code by Robojax.com 2018025
    // now changing the direction of rotation of motor
    Serial.println(" Rotating CCW");
    digitalWrite(EN12 ,endis);// Enable 1A and 2A  
    digitalWrite(P1A,LOW);// send + or HIGH signal to P1A
    digitalWrite(P2A,HIGH);// send - or LOW signal to P2A  

 }   
   // L293 Motor Contro Code by Robojax.com 2018025
}//rotateMA ends here

እንደሚያስፈልግዎት ይችላል

ምንጮች እና ምንጮች

አሁን ምንም ምንጮች የለም።

ፋይሎች📁

የዳታ ማዕከል (pdf)