PCA9865 16 servo controller board using I2C.

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Fri Mar 02, 2018 8:57 pm

@deshipu I don't own the ideas I just have them from time to time. I think it is fine for you to use anyone's idea that they share publicly.

I am at a loss why python would use radians as standards units for trig functions and not degree in the first place.

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

Re: PCA9865 16 servo controller board using I2C.

Post by deshipu » Sat Mar 03, 2018 11:06 am

Radians are the only units that make sense from the mathematical point of view. In fact, the definitions of trigonometric functions are such.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: PCA9865 16 servo controller board using I2C.

Post by pythoncoder » Sun Mar 04, 2018 8:06 am

Indeed, radians are exclusively used in science and engineering. Conversion is trivial using math.degrees(value_in_radians) and math.radians(value_in_degrees).
Peter Hinch
Index to my micropython libraries.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Sun Mar 04, 2018 9:12 am

I suppose I am showing my lack of education as before building this robot I had never heard of radians and neither has spell checker as it is highlighting then as wrong spelling.

Although it is a very easy code math.radians(value_in_degrees) to convert to radians it is another floating point maths to compute. This robot has 12 DOF (some of robots many more DOF) meaning lots of calculations to complete for 3D movement and to get smooth movement with speed control it involves moving each foot a mm at a time. i.e if moving a leg to a new position involves 1 servo moving 100 dregrees and another servo moving 10 degrees you can't do it in one calculated move because the 10 degrees servo will get to the new postion too quickly for the 100 degrees servo, instead you need lots of little steps so 1 servo moves 1 degree and the other moves 10 degrees.

ATM all the drivers calculate the duty from dregrees and just convert radians to degrees. I may rewrite my driver to calculate the duty from radians to reduce the extra conversion.

d4ß
Posts: 6
Joined: Thu Sep 28, 2017 10:19 am

Re: PCA9865 16 servo controller board using I2C.

Post by d4ß » Fri Mar 09, 2018 1:27 pm

Hello,

I got also an idea to use the PCA9865 shield with a ESP8266 to make a uPython Version of oTTo DIY.
Since I don't have a 3D printer or a Laser Cutter I used cardboard and tape (so it look very crappy - sorry for that).
While the libraries from adafruit are pretty helpful, I struggled to make my two robot legs move more than up an down.

Code: Select all

import machine
i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
import servo
import time
s = servo.Servos(i2c)

class Move: 

    def Jump(self):
        s.position(0, 30)
        s.position(1, 150)
        s.position(2, 90)
        s.position(3, 90)
        time.sleep(.4)
        s.position(0, 90)
        s.position(1, 90)
        s.position(2, 90)
        s.position(3, 90)
        time.sleep(.4)

    def Stop(self):
        s.position(0, 90)
        s.position(1, 90)
        s.position(2, 90)
        s.position(3, 90)
        
#########################        
move=Move()
move.Jump()
At oTTo DIY GitHub repository are some Ardurino codes, but I am not able to understand them good enough to turn them into uPython code (at which I am as well only a beginner). Especially the oscilloscope stuff is fare above my understanding.

Thank you in advance for any advises.

[And yes I used degrees instead of radians.]
Attachments
photo_2018-03-09_14-21-50.jpg
photo_2018-03-09_14-21-50.jpg (107.67 KiB) Viewed 29070 times
photo_2018-03-09_14-21-54.jpg
photo_2018-03-09_14-21-54.jpg (104.19 KiB) Viewed 29070 times

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Fri Mar 09, 2018 9:24 pm

Nice project :)

I make my kids build their projects out of card board first and if they can make therm work but discovering all their mistakes then I let them laser cut them. I get them to print out their designs on paper then stick the printer paper on card board and cut it out.

I clicked on the repository and there is quite a bit of code there. I would assume it has built up over time. It will also take you a fair bit of time to build up your MP code to do the same.

U have a couple of options: 1. try to port across the Arduino code. 2. write your own code by watching the videos to understand the needed behaviors and use the Ardunio code to give you ideas.

I personally like to do the second option, see something someone else created and use it to inspire me to make my own creation.

I do have it on my list to build a humanoid robot but am very busy with other projects ATM so it is likely to be a little while before I get to it. I say the otto and I also saw this https://www.youtube.com/watch?v=0R4U8iCmMJI and planned to make something somewhere between the 2.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Mon Mar 26, 2018 9:03 am

Today I sat down and wrote a very light weight and fast PCA9865 driver for Laboris port for my robot purposes. It uses 1Mhz I2C bus speed and also all servo positions and calculations are based upon radians so to be easy and fast(less floating point math) to integrate with Python trigonometry functions. All servo updates are staggered so that multiple servo current spikes don't happen simultaneously.

All feed back especially anything wrong or improvements welcome.

https://github.com/OutOfTheBots/ESP32_PCA9685

Morx97
Posts: 1
Joined: Mon Nov 23, 2020 2:25 pm

Re: PCA9865 16 servo controller board using I2C.

Post by Morx97 » Mon Nov 23, 2020 2:29 pm

gcarver wrote:
Thu Mar 01, 2018 3:17 pm
deshipu wrote:
Thu Mar 01, 2018 1:34 pm
What's wrong with https://github.com/adafruit/micropython ... it-pca9685 ?
Nothing, other than not knowing it existed. When I wrote this nothing popped up in google searches.
I just registered to the forum just to thank you for this library, it is all packed in just one file and I couldn't find libraries for PCA9865 anywhere else other than this topic.

Also I'd like to report the fact the board bootloops if started with PCA9865 VCC's plugged to the same source of ESP32 giving rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT) but connecting it after the board started gives no problems
I'm working on it and other than that everything works perfect, thanks!

User avatar
Werner_G
Posts: 17
Joined: Fri Sep 13, 2019 8:15 am
Location: Dortmund / Germany

Re: PCA9865 16 servo controller board using I2C.

Post by Werner_G » Tue Jul 26, 2022 3:17 pm

@ OutoftheBots: I am looking for an easy to use driver for ESP32 and PCA9685 and found this thread. When I run your demo, I always get this error message in the last line of the code: "name 'robot' isn't defined". What I am doing wrong?

And, is it possible to use Adafruit-drivers on non-Adafruit modules? Their files end up with 'mpy' instead on 'py'.

Post Reply