ይህ ትምህርት አካል ነው: ሰርቮ ሞተርስ
ከሰርቮ ሞተሮች ጋር የተያያዙ ሁሉም ቪዲዮዎች እዚህ ተዘርዝረዋል። ወደ ሌሎች ቪዲዮዎች የሚወስዱ አገናኞች ከዚህ ጽሑፍ በታች ይገኛሉ።
የ Arduino ኮድ እና ቪዲዮ ለ PCA9685 16-ቻናል 12-ቢት ሰርቮ መቆጣጠሪያ V1
በዚህ ትምህርት ውስጥ፣ ከNXP Semiconductor የሆነውን PCA9685 16-ሰርጥ 12-ቢት ሰርቮ መቆጣጠሪያን እንዴት መጠቀም እንደምንችል እንመረምራለን። ይህ ሞጁል እስከ 16 ሰርቮዎችን ለመቆጣጠር ወይም የLED ባንክን በ pulse width modulation (PWM) በመጠቀም በትክክል ለማደብዘዝ ያስችልዎታል። በዚህ ትምህርት መጨረሻ፣ ብዙ ሰርቮዎችን በተናጠል ወይም በአንድ ጊዜ መቆጣጠር የሚችል የሚሰራ ዝግጅት ይኖርዎታል።

የትምህርቱን ይዘት የበለጠ ለማብራራት፣ የዝግጅቱን እና የኮድ አጻጻፍ ሂደትን በእይታ ለማሳየት ተጓዳኝ ቪዲዮውን (በቪዲዮ 00:00) እንዲመለከቱ አበረታታለሁ።
ሃርድዌር ተብራርቷል
የPCA9685 ሞጁል በI2C ግንኙነት አማካኝነት ብዙ ሰርቮዎችን መቆጣጠር የሚችል የታመቀ ቦርድ ነው። 16 ሰርጦች ያሉት ሲሆን፣ እያንዳንዱም የራሱ የቁጥጥር ምልክት ያለው፣ እስከ 16 ሰርቮዎችን ለማገናኘት ያስችልዎታል። ሞጁሉ በ5V የኃይል አቅርቦት ይሰራል እና የሰርቮዎችን አቀማመጥ በትክክል ለመቆጣጠር አስፈላጊ የሆኑትን የPWM ምልክቶችን ለማስተናገድ የተነደፈ ነው።
ቦርዱ ለኃይል (VCC)፣ ለመሬት (GND) እና ለግንኙነት (SDA እና SCL) የተሰጡ ፒኖችን ያካትታል። የSDA ፒን ለውሂብ ማስተላለፊያ የሚያገለግል ሲሆን፣ የSCL ፒን ደግሞ የሰዓት ምልክት ነው፣ ሁለቱም ከአርዱኖው የአናሎግ ፒኖች A4 እና A5 ጋር ይገናኛሉ። ይህ ዝግጅት በአርዱኖ እና በPCA9685 ሞጁል መካከል አስተማማኝ ግንኙነትን ያረጋግጣል።
የዳታሼት ዝርዝሮች
| አምራች | NXP Semiconductor |
|---|---|
| የክፍል ቁጥር | PCA9685 |
| የሎጂክ/IO ቮልቴጅ | 3.3 V እስከ 5.5 V |
| የአቅርቦት ቮልቴጅ | 2.3 V እስከ 5.5 V |
| የውጤት ኤሌክትሪክ (በአንድ ሰርጥ) | 25 mA ከፍተኛ |
| ከፍተኛ ኤሌክትሪክ (በአንድ ሰርጥ) | 100 mA ከፍተኛ |
| የPWM ድግግሞሽ መመሪያ | 24 Hz እስከ 1.6 kHz |
| የግቤት ሎጂክ ገደቦች | 0.3 V (ዝቅተኛ) / 0.7 V (ከፍተኛ) |
| የቮልቴጅ ጠብታ / RDS(on) / ሙሌት | 0.5 V ከፍተኛ |
| የሙቀት ገደቦች | -40 °C እስከ 125 °C |
| ፓኬጅ | HTSSOP-28 |
| ማስታወሻዎች / ልዩነቶች | 16-ሰርጥ PWM መቆጣጠሪያ |
- በቂ ኤሌክትሪክ ያለው (1A ይመከራል) የ5V የኃይል አቅርቦት ያረጋግጡ።
- ጉዳት ለማስወገድ ሰርቮዎቹን በቀጥታ ከአርዱኖ አያብሩ።
- ትክክለኛዎቹን የI2C ፒኖች ይጠቀሙ፡ SDA ወደ A4 እና SCL ወደ A5።
- የ pulse width እሴቶችን እንደ ልዩ ሰርቮዎችዎ ያስተካክሉ።
- ለትክክለኛ የፖላሪቲ ግንኙነት ያረጋግጡ፡ GND፣ VCC እና ሲግናል።
- ለከፍተኛ ኤሌክትሪክ አፕሊኬሽኖች የሙቀት መስጫ (heat-sinking) ግምት ውስጥ ያስገቡ።
የወልና መመሪያዎች

PCA9685ን ከአርዱኖዎ ጋር ለማገናኘት፣ በመጀመሪያ ኃይልን እና መሬትን በማገናኘት ይጀምሩ። በPCA9685 ላይ ያለውን የVCC ፒን በአርዱኖ ላይ ካለው የ5V ውጤት ጋር ያገናኙ። ከዚያም በPCA9685 ላይ ያለውን የGND ፒን በአርዱኖ ላይ ካለው GND ጋር ያገናኙ። በመቀጠል፣ በPCA9685 ላይ ያለውን የSDA ፒን በአርዱኖ ላይ ካለው ፒን A4 ጋር፣ እና የSCL ፒንን ደግሞ ከA5 ጋር ያገናኙ።
ለሰርቮዎቹ፣ የሲግናል ሽቦውን በPCA9685 ላይ ካለው ተጓዳኝ ሰርጥ ጋር (ለምሳሌ፣ ለመጀመሪያው ሰርቮ CH0)፣ የኃይል ሽቦውን ወደ ተለየ የኃይል አቅርቦት (ሰርቮዎቹ ከአርዱኖ ሊሰጠው ከሚችለው በላይ ኤሌክትሪክ ሊፈልጉ ስለሚችሉ)፣ እና የመሬት ሽቦውን ደግሞ ከPCA9685 ጋር ከሚጋራው የጋራ መሬት ጋር ያገናኙ። ክፍሎችዎን ላለማበላሸት የሲግናል፣ የኃይል እና የመሬት ሽቦዎች በትክክል መደረደራቸውን ያረጋግጡ።
የኮድ ምሳሌዎች እና ማብራሪያ
በኮዱ የማዋቀሪያ ክፍል ውስጥ፣ የPCA9685 ሞጁሉን በpwm.begin() እንጀምራለን እና የPWM ድግግሞሹን በpwm.setPWMFreq(60); እናዘጋጃለን። ይህ ለሰርቮዎቹ የግንኙነት ድግግሞሽን ያዘጋጃል።
void setup() {
Serial.begin(9600);
Serial.println("16 channel Servo test!");
pwm.begin();
pwm.setPWMFreq(60); // አናሎግ ሰርቮዎች በ~60 Hz ዝማኔዎች ይሰራሉ
}
በሉፕ ውስጥ፣ ከተፈለጉት ማዕዘኖች ጋር የሚዛመዱ የPWM እሴቶችን በማዘጋጀት ሰርቮዎቹን እንቆጣጠራለን። ተግባሩ angleToPulse(int ang) ማዕዘኑን ወደ ተገቢው የ pulse width ይቀይረዋል፣ ይህም ለትክክለኛ የሰርቮ አቀማመጥ አስፈላጊ ነው።
void loop() {
for( int angle =0; angle<181; angle +=20){
delay(500);
pwm.setPWM(0, 0, angleToPulse(angle) );
}
}
በመጨረሻም፣ ተግባሩ angleToPulse(int ang) የተገለጹትን ዝቅተኛ እና ከፍተኛ የ pulse ርዝመቶችን በመጠቀም ማዕዘኑን ወደ pulse width ይቀይረዋል። ይህ ሊያሳኩት በሚፈልጉት ማዕዘን ላይ በመመስረት የሰርቮውን አቀማመጥ በቀላሉ እንዲቆጣጠሩ ያስችልዎታል።
int angleToPulse(int ang){
int pulse = map(ang,0, 180, SERVOMIN,SERVOMAX);
Serial.print("Angle: ");Serial.print(ang);
Serial.print(" pulse: ");Serial.println(pulse);
return pulse;
}
ማሳያ / ምን እንደሚጠበቅ
ሁሉም ነገር በትክክል ከተገናኘ እና ኮዱ ከተጫነ በኋላ፣ ሰርቮው በ20 ዲግሪ ጭማሪዎች በተገለጹት ማዕዘኖች ሲንቀሳቀስ ማየት ይኖርብዎታል። ሰርቮው እንደተጠበቀው ባይሰራ፣ ግንኙነቶቹ ትክክለኛ መሆናቸውን ለማረጋገጥ የወልናውን ያረጋግጡ እና የኃይል አቅርቦቱ በቂ መሆኑን ያረጋግጡ (በቪዲዮ 12:30)።
የቪዲዮ ጊዜ አመልካቾች
- 00:00 - ለPCA9685 መግቢያ
- 02:30 - የወልና መመሪያዎች
- 05:00 - የኮድ ማብራሪያ
- 10:15 - የሰርቮ ቁጥጥር ማሳያ
- 12:30 - የተለመዱ ችግሮችን መፍታት
ይህ ትምህርት አካል ነው: ሰርቮ ሞተርስ
- አርዱኖን በመጠቀም ሰርቮን በግፊት አዝራሮች መቆጣጠር
- Control a Servo Motor with a Push Button: Move Servo and Return SPB-1
- Control a Servo Motor with a Push Button: Move Servo in One Direction SPB-2
- Controlling a Servo Motor with a Push Button: Move Servo While Button Is Pressed (SPB-3)
- ፖቴንሺዮሜትር በመጠቀም ሰርቮን ከአርዱኖ ጋር መቆጣጠር
- ፖቴንሺዮሜትር እና LCD1602 በመጠቀም ሰርቮን ከአርዱኖ ጋር መቆጣጠር
- አርዱኖን በመጠቀም የኢንፍራሬድ ሪሞት ኮንትሮል በመጠቀም የሰርቮ ሞተሮችን መቆጣጠር
- የአርዱኖ ሰርቮ ሞተር ቁጥጥር በፖቴንሺዮሜትር በመጠቀም
- የሰርቮ አቀማመጥን በእጅ ምልክቶች መቆጣጠር ለአርዱኖ
- Controlling Two or More Servos with Potentiometers Using an Arduino
- How to Control a 360° Servo with Three Push-Button Switches
- የተከታታይ 360° ሰርቮን ከአርዱኖ ጋር እንዴት መጠቀም እንደሚቻል
- አርዱኖ ሰርቮ ቶግል ስዊች በፑሽ ቁልፍ ይገንቡ
/*
* Original source: https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library
* This is the Arduino code for the PCA9685 16-channel servo controller.
* Watch the video for details and demo: http://youtu.be/y8X9X10Tn1k
* get code and wiring diagram from http://robojax.com/RTJ27
* Watch the video for this code:
*
* Related Videos:
V5 video of PCA9685 32 Servo with ESP32 with WiFi: https://youtu.be/bvqfv-FrrLM
V4 video of PCA9685 32 Servo with ESP32 (no WiFi): https://youtu.be/JFdXB8Za5Os
V3 video of PCA9685: how to control 32 servo motors: https://youtu.be/6P21wG7N6t4
V2 Video of PCA9685: 3 different ways to control servo motors: https://youtu.be/bal2STaoQ1M
V1 Video introduction to PCA9685 to control 16 servos: https://youtu.be/y8X9X10Tn1k
* Written by Ahmad Shamshiri for Robojax Video channel: www.Robojax.com
* Date: December 16, 2017, 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.
* This code has been downloaded from https://robojax.com
*
*/
/***************************************************
This is an example for our Adafruit 16-channel PWM & Servo driver.
Servo test - this will drive 16 servos, one after the other.
Pick one up today in the Adafruit shop!
------> http://www.adafruit.com/products/815
These displays use I2C to communicate; 2 pins are required to
interface. For Arduino UNOs, that's SCL -> Analog 5, SDA -> Analog 4.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution.
****************************************************/
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// Depending on your servo make, the pulse width min and max may vary; you
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN 125 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 575 // this is the 'maximum' pulse length count (out of 4096)
// our servo # counter
uint8_t servonum = 0;
void setup() {
Serial.begin(9600);
Serial.println("16 channel Servo test!");
pwm.begin();
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
//yield();
}
// the code inside loop() has been updated by Robojax
void loop() {
for( int angle =0; angle<181; angle +=20){
delay(500);
pwm.setPWM(0, 0, angleToPulse(angle) );
}
delay(1000);
}
/*
* angleToPulse(int ang)
* gets angle in degrees and returns the pulse width.
* Also prints the value on the serial monitor.
* Written by Ahmad Shamshiri for Robojax, Robojax.com
*/
int angleToPulse(int ang){
int pulse = map(ang,0, 180, SERVOMIN,SERVOMAX);// map angle of 0 to 180 to Servo min and Servo max
Serial.print("Angle: ");Serial.print(ang);
Serial.print(" pulse: ");Serial.println(pulse);
return pulse;
}
/*
* Original source: https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library
* This is the Arduino code for the PCA9685 16-channel servo controller.
we have simple code with mapping PWM for simplicity explained in the video at 18:27
* Watch the video for details and demo: http://youtu.be/y8X9X10Tn1k
get this code and wiring from for this video: http://robojax.com/RJT27
* Written by Ahmad Nejrabi for Robojax Video channel: www.Robojax.com
* Date: December 15, 2017, 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.
*
*/
/***************************************************
This is an example for our Adafruit 16-channel PWM & Servo driver.
Servo test - this will drive 16 servos, one after the other.
Pick one up today in the Adafruit shop!
------> http://www.adafruit.com/products/815
These displays use I2C to communicate; 2 pins are required to
interface. For Arduino UNOs, that's SCL -> Analog 5, SDA -> Analog 4.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// Depending on your servo make, the pulse width min and max may vary; you
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN 125 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 575 // this is the 'maximum' pulse length count (out of 4096)
// our servo # counter
uint8_t servonum = 0;
void setup() {
Serial.begin(9600);
Serial.println("16 channel Servo test!");
pwm.begin();
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
//yield();
}
// the code inside loop() has been updated by Robojax
void loop() {
pwm.setPWM(0, 0, 125 );
delay(500);
pwm.setPWM(0, 0, 255 );
delay(500);
pwm.setPWM(0, 0, 450 );
delay(500);
pwm.setPWM(0, 0, 575 );
delay(500);
}
እንደሚያስፈልግዎት ይችላል
-
አማዞንPurchase PCA9685 from Amazonamzn.to
-
ኢቤይPurchase PCA9685 from eBayebay.us
-
አሊኤክስፕሬስPurchase PCA9685 from AliExpresss.click.aliexpress.com
-
ባንጉድPurchase PCA9685 from Banggoodbanggood.com
ምንጮች እና ምንጮች
አሁን ምንም ምንጮች የለም።
ፋይሎች📁
Arduino ቤተ መዝገቦች (zip)
-
Adafruit-PWM-Servo-Driver-Library-master
Adafruit-PWM-Servo-Driver-Library-master.zip0.02 MB
ሌላ ፋይሎች
-
PCA9685 ዳታስሄት
robojax_PCA9685.pdf0.39 MB -
PCA9685 Adafruit ቤተ መዋቅር
robojax_PCA9685-Adafruit-Library.zip0.01 MB