આ ટ્યુટોરિયલ આનો ભાગ છે: સર્વો મોટર્સ
સર્વો મોટર્સ સંબંધિત તમામ વિડિઓઝ અહીં સૂચિબદ્ધ છે. અન્ય વિડિઓઝની લિંક્સ આ લેખની નીચે છે.
આર્ડુઇનો કોડ અને વિડિઓ PCA9685 16-ચેનલ 12-બિટ સર્વો કંટ્રોલર V1 માટે
આ ટ્યુટોરિયલમાં, આપણે NXP સેમિકન્ડક્ટરના PCA9685 16-ચેનલ 12-બિટ સર્વો કંટ્રોલરનો ઉપયોગ કેવી રીતે કરવો તે શોધીશું. આ મોડ્યુલ તમને પલ્સ વિડ્થ મોડ્યુલેશન (PWM) નો ઉપયોગ કરીને 16 સર્વો સુધી નિયંત્રિત કરવા અથવા LED ના બેંકને ચોકસાઈ સાથે ઝાંખું કરવાની મંજૂરી આપે છે. આ ટ્યુટોરિયલના અંત સુધીમાં, તમારી પાસે એક કાર્યકારી સેટઅપ હશે જે બહુવિધ સર્વોને વ્યક્તિગત રીતે અથવા એકસાથે નિયંત્રિત કરી શકે છે.

ટ્યુટોરિયલ સામગ્રીને વધુ સ્પષ્ટ કરવા માટે, હું તમને સાથેની વિડિઓ (વિડિઓમાં 00:00 પર) જોવા પ્રોત્સાહિત કરું છું જે સેટઅપ અને કોડિંગ પ્રક્રિયાના દ્રશ્ય પ્રદર્શન માટે છે.
હાર્ડવેર સમજાવ્યું
PCA9685 મોડ્યુલ એક કોમ્પેક્ટ બોર્ડ છે જે I2C સંચાર દ્વારા બહુવિધ સર્વોને નિયંત્રિત કરી શકે છે. તેમાં 16 ચેનલો છે, જે તમને 16 સર્વો સુધી કનેક્ટ કરવાની મંજૂરી આપે છે, દરેકનો પોતાનો કંટ્રોલ સિગ્નલ હોય છે. મોડ્યુલ 5V પાવર સપ્લાય પર કાર્ય કરે છે અને PWM સિગ્નલોને હેન્ડલ કરવા માટે ડિઝાઇન કરવામાં આવ્યું છે, જે સર્વોની સ્થિતિને ચોકસાઈપૂર્વક નિયંત્રિત કરવા માટે આવશ્યક છે.
બોર્ડમાં પાવર (VCC), ગ્રાઉન્ડ (GND), અને સંચાર (SDA અને SCL) માટે સમર્પિત પિન શામેલ છે. SDA પિન ડેટા ટ્રાન્સમિશન માટે વપરાય છે, જ્યારે SCL પિન ક્લોક સિગ્નલ છે, જે બંને અનુક્રમે Arduino ના એનાલોગ પિન A4 અને A5 સાથે જોડાય છે. આ સેટઅપ Arduino અને PCA9685 મોડ્યુલ વચ્ચે વિશ્વસનીય સંચાર સુનિશ્ચિત કરે છે.
ડેટાશીટ વિગતો
| ઉત્પાદક | NXP સેમિકન્ડક્ટર |
|---|---|
| ભાગ નંબર | 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 કંટ્રોલર |
- પૂરતા કરંટ સાથે 5V પાવર સપ્લાય સુનિશ્ચિત કરો (1A ભલામણ કરેલ).
- નુકસાન ટાળવા માટે સર્વોને સીધા Arduino થી પાવર ન કરો.
- યોગ્ય I2C પિનનો ઉપયોગ કરો: SDA થી A4 અને SCL થી A5.
- તમારા ચોક્કસ સર્વો અનુસાર પલ્સ વિડ્થ મૂલ્યો ગોઠવો.
- યોગ્ય ધ્રુવીયતા માટે વાયરિંગ તપાસો: GND, VCC, અને સિગ્નલ.
- ઉચ્ચ-કરંટ એપ્લિકેશનો માટે હીટ-સિંકિંગ ધ્યાનમાં લો.
વાયરિંગ સૂચનાઓ

PCA9685 ને તમારા Arduino સાથે વાયર કરવા માટે, પાવર અને ગ્રાઉન્ડ કનેક્ટ કરીને શરૂ કરો. PCA9685 પરનો VCC પિન Arduino પરના 5V આઉટપુટ સાથે કનેક્ટ કરો. પછી PCA9685 પરનો GND પિન Arduino પરના GND સાથે કનેક્ટ કરો. આગળ, PCA9685 પરનો SDA પિન Arduino પરના પિન A4 સાથે અને SCL પિન A5 સાથે કનેક્ટ કરો.
સર્વો માટે, સિગ્નલ વાયરને PCA9685 પરના અનુરૂપ ચેનલ સાથે કનેક્ટ કરો (દા.ત., પ્રથમ સર્વો માટે CH0), પાવર વાયરને અલગ પાવર સપ્લાય સાથે (કારણ કે સર્વોને Arduino પ્રદાન કરી શકે તેના કરતાં વધુ કરંટની જરૂર પડી શકે છે), અને ગ્રાઉન્ડ વાયરને PCA9685 સાથે શેર કરેલા સામાન્ય ગ્રાઉન્ડ સાથે કનેક્ટ કરો. ખાતરી કરો કે સિગ્નલ, પાવર અને ગ્રાઉન્ડ વાયર યોગ્ય રીતે ગોઠવાયેલા છે જેથી તમારા ઘટકોને નુકસાન ન થાય.
કોડ ઉદાહરણો અને વોકથ્રુ
કોડના સેટઅપ વિભાગમાં, આપણે pwm.begin() સાથે PCA9685 મોડ્યુલ શરૂ કરીએ છીએ અને pwm.setPWMFreq(60); સાથે PWM આવૃત્તિ સેટ કરીએ છીએ. આ સર્વો માટે સંચાર આવૃત્તિ સેટ કરે છે.
void setup() {
Serial.begin(9600);
Serial.println("16 ચેનલ સર્વો ટેસ્ટ!");
pwm.begin();
pwm.setPWMFreq(60); // એનાલોગ સર્વો ~60 Hz અપડેટ પર ચાલે છે
}
લૂપની અંદર, આપણે ઇચ્છિત ખૂણાઓને અનુરૂપ PWM મૂલ્યો સેટ કરીને સર્વોને નિયંત્રિત કરીએ છીએ. ફંક્શન angleToPulse(int ang) ખૂણાને યોગ્ય પલ્સ વિડ્થ સાથે મેપ કરે છે, જે ચોક્કસ સર્વો સ્થિતિ માટે આવશ્યક છે.
void loop() {
for( int angle =0; angle<181; angle +=20){
delay(500);
pwm.setPWM(0, 0, angleToPulse(angle) );
}
}
છેલ્લે, ફંક્શન angleToPulse(int ang) વ્યાખ્યાયિત લઘુત્તમ અને મહત્તમ પલ્સ લંબાઈનો ઉપયોગ કરીને ખૂણાને પલ્સ વિડ્થમાં રૂપાંતરિત કરે છે. આ તમને તમે પ્રાપ્ત કરવા માંગતા ખૂણાના આધારે સર્વોની સ્થિતિ સરળતાથી નિયંત્રિત કરવાની મંજૂરી આપે છે.
int angleToPulse(int ang){
int pulse = map(ang,0, 180, SERVOMIN,SERVOMAX);
Serial.print("ખૂણો: ");Serial.print(ang);
Serial.print(" પલ્સ: ");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);
}
તમને જોઈતી વસ્તુઓ
-
AmazonPurchase PCA9685 from Amazonamzn.to
-
eBayPurchase PCA9685 from eBayebay.us
-
AliExpressPurchase PCA9685 from AliExpresss.click.aliexpress.com
-
BanggoodPurchase PCA9685 from Banggoodbanggood.com
સંસાધનો અને સંદર્ભો
હજી સુધી કોઈ સંસાધનો નથી.
ફાઇલો📁
Arduino લાઇબ્રેરીઓ (zip)
-
Adafruit-PWM-Servo-Driver-Library-master
Adafruit-PWM-Servo-Driver-Library-master.zip0.02 MB
અન્ય ફાઇલો
-
PCA9685 Datasheet
robojax_PCA9685.pdf0.39 MB -
PCA9685 Adafruit Library
robojax_PCA9685-Adafruit-Library.zip0.01 MB