PCA9685 PWM Driver

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
deshipu
Posts: 1365
Joined: Thu May 28, 2015 5:54 pm

Re: PCA9685 PWM Driver

Post by deshipu » Wed Apr 05, 2017 9:49 am

I would recommend that you reconsider the choice of your h-bridge. The LD298 was a fine piece of electronics back in the 70's when it was designed, and it works well with the 40V power that it was designed for. For hobby uses, though, its 5V voltage drop across the motor power lines makes it a pretty bad choice, especially when you plan to power the motors with a low-voltage battery. The bridge will eat half of the power just sitting there.

Why don't you use something more modern, like DRV8833 or the TB6612 that is also used in that Adafruit shield? They are not much more expensive, and much better suited for small hobby stuff.

pidou46
Posts: 76
Joined: Sat May 28, 2016 7:01 pm

Re: PCA9685 PWM Driver

Post by pidou46 » Sun Apr 09, 2017 4:10 am

Thanks for tour advice, I will look this way.
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

pidou46
Posts: 76
Joined: Sat May 28, 2016 7:01 pm

Re: PCA9685 PWM Driver

Post by pidou46 » Thu Apr 20, 2017 7:26 pm

Hello,

What about mixing dc motors + servos ?

It seems not possible because each kind work at different frequency. servo: 50Hz, dc_motor: 1600Hz

And it's a global property of the pca9685 class, so if I change it for servo, it will change for dc_motor and vise-versa...

Could you confirm my guess please ?

Thanks.
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

User avatar
deshipu
Posts: 1365
Joined: Thu May 28, 2015 5:54 pm

Re: PCA9685 PWM Driver

Post by deshipu » Thu Apr 20, 2017 10:00 pm

pidou46 wrote: Could you confirm my guess please ?
Yes, the PWM frequency is a global property of the chip.

DurkVell
Posts: 2
Joined: Mon Jun 01, 2020 5:24 am

Re: PCA9685 PWM Driver

Post by DurkVell » Mon Jul 27, 2020 4:06 pm

@deshipu

Hi, I'm new to MicroPython and find it very confusing how to get files running in general.

I would like to control a spider robot consisting of 12 micro servos 9G. I found these pages which made me very happy!

But ... I can't get it working.

I use a Mini D1 ESP32 module (with microPython on it), connected to the pca9685: I2C-SCL to GPIO 22 and I2C SDA to GPIO 21, connected V5 and gnd. I use an external power supply (5V 2A).

I managed to upload the two files: pca9685.py and servo.py to the ESP32-module and added a main.py file with this content:

Code: Select all

# This should move all servos to the central positions:
from machine import I2C, Pin
import servo

servos = servo.Servos(I2C(scl=Pin(22), sda=Pin(21))
for i in range(16):
    servos.position(i, us=1500
    )
Then I added a line to the boot.py file to load main.py.

Code: Select all

# This file is executed on every boot

import main

Can you please help me where I went wrong?


EDIT:

I found the problem. There was one ")" missing at the end of the line:
servos = servo.Servos(I2C(scl=Pin(22), sda=Pin(21))

Can you please add it in your example. For us newbees it's very confusing finding something that's on the internet already for quite some time and is not working properly because of a typo (?).

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: PCA9685 PWM Driver

Post by jimmo » Tue Jul 28, 2020 6:17 am

DurkVell wrote:
Mon Jul 27, 2020 4:06 pm
Then I added a line to the boot.py file to load main.py.
FYI - You don't need to do this -- main.py is always executed automatically after boot.py (regardless of what's in boot.py)

DurkVell
Posts: 2
Joined: Mon Jun 01, 2020 5:24 am

Re: PCA9685 PWM Driver

Post by DurkVell » Tue Jul 28, 2020 7:47 am

Thanks. I read that somewhere ....
;)

Post Reply