Mastering Servo Control: PCA9685 PWM Driver with Arduino Tutorial and Demo

Sdílet
Vložit
  • čas přidán 6. 09. 2024

Komentáře • 53

  • @vishalradhakrishnan1424
    @vishalradhakrishnan1424 Před 6 měsíci +4

    Thank you for the video.
    For the 5V 10A power supply, what battery are you using?
    Normally the amperage rating is much lower than the voltage rating, so I'm curious what source you used here.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 6 měsíci

      You can use a 12v to 5v converter that is rated for 10amp if you need a portable supply. This one has good reviews on Amazon. www.amazon.com/12v-5v-Converter-Regulator-Transformer/dp/B08PP6LMM1?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A3M3YMPQTI06AD For most projects with high current requirements I will use a larger 24v/20a power supply and dial in the voltage I need.

  • @hankb7725
    @hankb7725 Před 5 měsíci +2

    what if you are running very beefy servos that need more power? will it still work? if not what do I have to do?

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 5 měsíci

      hey there! The PCA9685 PWM driver operates at a voltage range between 2.3V and 5.5V for its VCC pin. The v+ terminal is 6v max However, it can still be used to control higher voltage servos by using an external power supply for the servos. Since the servo motor draws current to move, it's best to isolate the power for the servos from the power for the PCA9685 controller board.

  • @LivingRoomRobotics
    @LivingRoomRobotics Před 2 měsíci +1

    Do you know if you can control the servos using potentiometers? I haven’t had much luck controlling them while using the servo driver.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 2 měsíci

      hey there! You can manually turn the potentiometers to control the movement of the servos when using the PCA9685 PWM Driver or you can connect the potentiometers to the Arduino directly and control them that way.
      Just curious, what kind of issues are you having with the driver?

  • @sanganibhargavteja6045
    @sanganibhargavteja6045 Před měsícem +1

    Hey can we control each servo differently like one in clockwise and another one in anticlock wise at the same time

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před měsícem

      sure! You're loop would look something like this:
      //servo1 moves clockwise and servo2 counterclockwise
      for (int pos = 0; pos = 0; pos -= 1) {
      servo1.write(pos);
      servo2.write(180 - pos);
      delay(15);
      }
      You may need to adjust it according to your project, but that's the idea. 👍👍

  • @lutzwunderlich2003
    @lutzwunderlich2003 Před 2 měsíci +1

    hi there, impressive video how to drive the servos with the pca9685. I only have one question regarding the baud rate. As I know the Mega requires a baud rate of 115200 to communicate while the 9600 is for the Uno. Did this have an impact on the control or is this not important with the PCA 9685? Thank you and keep making such kind of videos for us to help with problems.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 2 měsíci +2

      Hey there! Thank you for the kind comment. It's great to get feedback on videos to improve future content.
      The baud rate settings in this video are primarily for serial communication between the Arduino board and my computer. In this instance, Arduino uses serial communication to send and receive data between the board and the computer. The baud rate specifies the data transfer speed in bits per second and the baud rate uploaded to the Arduino needs to match the baud rate set in your serial monitor. The PCA9685 PWM driver communicates with the Arduino via the I2C protocol, which is not affected by the serial baud rate settings. So no, baud rate doe not impact control of the servos.
      Thank you for asking and I hope you enjoy building your Arduino project! 👍💪

    • @lutzwunderlich2003
      @lutzwunderlich2003 Před 2 měsíci

      @@BMonsterLaboratory Thank you for your explanation. Now I understand the difference using the baud rate for communication between units in the Arduino world.

  • @Mind-to-made-26
    @Mind-to-made-26 Před 7 měsíci +1

    sorry about that apprently you have to divide your pw by your boards bit rate so mine being a 12 bit had to be divided by 4.07 to get the correct values

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 7 měsíci

      hey there! great question. Do you have a link for this? I was under the impression that the PCA9685 takes care of generating the PWM signals for all the channels based on the frequency you've set and the specified pulse widths. It does this simultaneously, so you can control multiple servos independently without needing to manually calculate or divide pulse widths.

    • @Mind-to-made-26
      @Mind-to-made-26 Před 7 měsíci

      aye man sorry found it on a random form somewhere and it worked

    • @Mind-to-made-26
      @Mind-to-made-26 Před 7 měsíci

      but what i did was take my 2500 and 500 and divided it by 4.07 which gave me pretty much the same numbers as in your code

  • @ivyvo8333
    @ivyvo8333 Před 4 měsíci +1

    hi there, thank you so much for your video, really helpful. quick question in term of power supply, im using 6 MG996R at the moment at 5V 15A seems to be too much for them, do you suggest particular lower A for the power supply?

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 4 měsíci

      Hello! If the 5v 15A supply is working for you, stick with it. You want to be sure to have plenty of overhead current to handle the servos when they are all drawing the most current at 5v and the motors will only draw the current they need. Check data sheets and test to ensure there's no over heating or erratic behavior of the motors based on your project. But, I would keep the 5v 15A supply for 6 servos. I hope this helps!

  • @leonesilvestre4974
    @leonesilvestre4974 Před 6 měsíci +1

    Hello my friend. Excellent video. I compiled the video code on Arduino Uno and it worked perfectly. I wanted to ask you how do I increase the servo speed? I wish it moved faster.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 6 měsíci +1

      Hi.. thank you! 👍
      I don't have access to the code at the moment but it's posted on face book.
      try decreasing the delay. Should look something like this...
      MyServo.write(0);
      delay(1000); //decrease this number to increase speed

    • @leonesilvestre4974
      @leonesilvestre4974 Před 6 měsíci +1

      Thanks. I managed to find it and change the speed.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 6 měsíci

      Great

  • @mlemmi
    @mlemmi Před 7 měsíci +1

    Good job! Thanks for explain very well about powering only the chip.
    Where can I find this code to test my board? I couldn't find this one in your Facebook page... There's tons of projects there!

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 7 měsíci +1

      Hey, thanks! I will post it at 4pm EST
      sorry about the delay.

  • @Mind-to-made-26
    @Mind-to-made-26 Před 7 měsíci +1

    Hi I have hooked up my servos to my board. They say they have a pw of 500 to 2500 yet they seem to only move a few degrees when I plug in my values to replace the ones u entered . Any thoughts on this would be appreciated.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 7 měsíci

      just curious....what board and servos are you using? Thanks for sharing this 👍

  • @chill_music_lyrics0614
    @chill_music_lyrics0614 Před 6 měsíci +1

    Hello sir i need help with my thesis project im already done with the wirings and programming its all good but why is that my servo motors are not functioning?? Im using PCA9685 with 3 MG996R and 3 MG995. With a 5v 2amps power source

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 6 měsíci +1

      Those 2 servo motors are 6v servos that can draw up to, and maybe a little over, 1amp of current each depending on peak load and speed. I am assuming your issues is the lack of current to power these motors. For 3 of each, and a total of 6 servos, I would use 5v-6v at 8-10amps. The motors will only draw the current they need so having a little overhead would be good. You may find a stand alone variable power supply or a step down converter to be useful. Perhaps you could test the motors and board by removing all but 1 servo and testing it at each servo position.

  • @basitwassil6244
    @basitwassil6244 Před 3 měsíci +1

    Hey, What is the max output current for PCA9685?

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 3 měsíci

      Hey there! Sorry for late reply, been traveling the past few days.
      I have a 5v10a supply connected. If you need more current for a lot of servos, try using an external power source and just connect ground and servo signal wires to the driver board for pwm control. I would not put more than 10amp supply on v+ to power the board. I believe this is the safest approach. I hope it helps

  • @KOAlleyCat
    @KOAlleyCat Před 6 měsíci +1

    I’m getting really annoyed with my boards. I have five micro servos (specifically MG90S) connected to this and my Arduino. I have a portable battery to power the Arduino and a Tenergy 6V NiMh battery (for RC cars) powering the servos (connected to the terminal block).
    It was working fine for a few days, then magically didn’t. I thought it was the battery so I bought a Tenergy balance charger and charged the battery. Multimeter checked the battery and it seemed fine.
    Definitely frustrating. I’m not *new* new but I’m still fairly inexperienced. Arduino forums weren’t much of a help, since the only questions that needed answering were in regards to bad wiring diagrams lol
    Any suggestions would be much appreciated. 🙏

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 6 měsíci +1

      hey there! if it was working and now it doesn't, i'm wondering about the battery. It sounds like the wiring is fine but I'm happy to help where I can. what is the mAh of you 6v battery? If your 6V battery capacity is 1600mAh, its continuous discharge rate might not be high enough to handle 4.5A and could overheat or be damaged but it also depends on usage duration and servo load. It's recommended to choose a battery with a higher capacity than the minimum required. Consider a 2000mAh or 2500mAh battery to provide a safety margin and potentially longer runtime.... just my initial thoughts.

    • @KOAlleyCat
      @KOAlleyCat Před 6 měsíci +1

      @@BMonsterLaboratory Thank you for your quick reply! The battery I’m using is 2000mAh. If I need one go up to 2500 I can try ordering one of those too

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 6 měsíci +1

      @@KOAlleyCat can you send me a picture or diagram of your connections? Facebook or email is fine. Perhaps you don't need a new battery

    • @KOAlleyCat
      @KOAlleyCat Před 6 měsíci

      @@BMonsterLaboratory You’re amazing. I’ll send you what I have over FB Messenger. I’ll try to show as much as possible as well as what I’ve already tried. I appreciate you and your time so much. I’m teaching a class of kids next weekend on how I built my last one (community leader asked if I’d help and I love to help kids so I said yes lol) and introduce them to the basics of Arduino programming. But the last one I made I had the servos directly wired to the Arduino. This time I wanted to use a servo driver and it’s been a pain in my rear!

  • @martinsvoboda1237
    @martinsvoboda1237 Před 7 měsíci +1

    Hello, could i ask you i have 7,4V 2S lipo bat. and I use it to power the servos I have 12 servo motors and each one takes about 3A under load. The question is… is it possible to use this driver pca9685?

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 7 měsíci

      Hey there! This board cannot directly drive a 7.4v servo. The PCA9685 operates with a supply voltage range of 2.3 V to 5.5 V. However, you can connect your servos to a 7.4v power source and use the PCA9685 board to send control signals to the servo via its PWM control input (assuming your servo has a 5v signal pin). You may also want to check out high voltage servo drivers. This one is a stand alone servo controller - www.adafruit.com/product/5437?gad_source=1&gclid=CjwKCAiAt5euBhB9EiwAdkXWO9AbfugiJgUH6CyWzK35_XNwNcthAU-gfVnBhwZ7Tj0AlACuxN4CvxoCmvoQAvD_BwE -It supports high voltage servos, up to 11V. I have never used it but i'm sure there are some good demo videos out there.
      You're going to need a lot of current. Consider integrating fuses into your design to protect against short circuits or overcurrent. A fuse rated slightly above your expected maximum current will help prevent damage to your components.
      hope I answered your question. good luck to you!

    • @martinsvoboda1237
      @martinsvoboda1237 Před 7 měsíci +1

      @@BMonsterLaboratory I tried connecting the servos and it worked fine even at 7.4V. I'm just worried that the pca9685 will be ruined for long term use.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 7 měsíci

      @@martinsvoboda1237 I agree.

  • @solutionreplays6622
    @solutionreplays6622 Před 4 měsíci

    Can you have the servos doing different operations at the same time or can they only do the same action across them all

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 4 měsíci

      hi, yes... you should be able to. sorry for the late response. If you're using the code I posted on Facebook, you would have something similar to this:
      for (int pos = SERVO_MIN; pos

  • @kyanoo2392
    @kyanoo2392 Před 4 měsíci +1

    What power supply do you recommend for 15 Servos?

    • @kyanoo2392
      @kyanoo2392 Před 4 měsíci

      And what can I use to make it portable

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 4 měsíci

      hey there! It depends on the servos you're using. The MG995 servos can have current at maximum load: 1200mA according to components101.com/motors/mg995-servo-motor You want enough current to accommodate all 15 servos. Current load for 15 servos could be around 18A (15 * 1200mA = 18000mA = 18A) It's advisable to choose a battery with a higher current rating than you need to ensure reliable and stable performance, taking into account factors like battery efficiency, voltage drops, and safety margins. Be sure to do our research and make sure you look over data sheets for the servos and other components you're going to use. I, personally, haven't used more than 6 servos on this driver. If you're using 15 MG995, I'd be interested in what you think of the performance. 👍

  • @ardaa2607
    @ardaa2607 Před 7 měsíci

    Hello. Even though I have completed the connections and library installation you explained in the video, exit status 1
    Compilation error for Arduino Uno board. I'm getting the error. But when I load another code, I do not encounter this error. Can you help me, thank you in advance.

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 7 měsíci +1

      so, it's probably a syntax error or board selection error... Did you copy and paste code from Facebook post?
      If not, try this.
      #include
      #include
      Adafruit_PWMServoDriver pwm;
      #define NUM_SERVOS 5
      #define SERVO_MIN 100
      #define SERVO_MAX 600
      #define SERVO_DELAY 1000 // Delay in milliseconds
      int servoPins[NUM_SERVOS] = {0, 1, 2, 3, 4};
      void setup() {
      Serial.begin(9600);
      Serial.println("Alternate Servo Test");
      pwm.begin();
      pwm.setPWMFreq(50); // Set the PWM frequency for the PCA9685
      // Initialize all servos to their minimum positions during setup
      for (int i = 0; i < NUM_SERVOS; i++) {
      pwm.setPWM(servoPins[i], 0, SERVO_MIN);
      }
      }
      void loop() {
      // Rotate all servos to one extreme position
      for (int pos = SERVO_MIN; pos = SERVO_MIN; pos -= 1) {
      for (int i = 0; i < NUM_SERVOS; i++) {
      pwm.setPWM(servoPins[i], 0, pos);
      }
      delay(15);
      }
      delay(SERVO_DELAY);
      }

    • @ardaa2607
      @ardaa2607 Před 7 měsíci +1

      @@BMonsterLaboratory I made a mistake while installing the library🤦‍♂ Thank you very much for your help. I subscribed to your channel :)

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 7 měsíci +1

      @@ardaa2607 ​great! thank you. I hope you find more videos that are helpful. If you have any questions just leave a message here, on facebook, or send an email. 👍

  • @hyperplayeryt8426
    @hyperplayeryt8426 Před 5 měsíci +1

    Can i turn it off and on

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 5 měsíci

      hey there! you could set the PWM to a certain duty cycle. For example, setting it to 50% duty cycle means the channel will be on half the time and off the other half. To turn a channel off, set its PWM value to 0, resulting in no signal being outputted.
      Here's what that might look like:
      #include
      #include
      // Create PCA9685 object
      Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
      void setup() {
      Serial.begin(9600);
      pwm.begin();
      pwm.setPWMFreq(1000); // Set the frequency to 1000 Hz
      }
      void loop() {
      // Turn channel 0 fully on (100% duty cycle)
      pwm.setPWM(0, 4096, 0);
      delay(1000); //on for 1 second
      // Turn channel 0 off
      pwm.setPWM(0, 0, 4096);
      delay(1000); //off for 1 second
      }

  • @kaushlendrapandey5404
    @kaushlendrapandey5404 Před 3 měsíci +1

    Can u guide me for a project ??

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 3 měsíci +1

      Hey there! I am happy to assistance however I can. Not sure about guiding through every step.
      Tell me the goal of your project, components you are using, and your experience level.
      I am currently traveling but will be available next week. 👍

    • @kaushlendrapandey5404
      @kaushlendrapandey5404 Před 2 měsíci +2

      @@BMonsterLaboratory cool, that will be really helpful. Where can I connect with u??

    • @BMonsterLaboratory
      @BMonsterLaboratory  Před 2 měsíci

      @@kaushlendrapandey5404 Facebook mssg has worked well for me facebook.com/BMonster-Laboratory-101410418059806/
      I usually check it at night. Feel free to send a message if you have a question.