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: 450
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: 1334
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: 3126
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

OutoftheBOTS_
Posts: 450
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: 4
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 626 times
photo_2018-03-09_14-21-54.jpg
photo_2018-03-09_14-21-54.jpg (104.19 KiB) Viewed 626 times

OutoftheBOTS_
Posts: 450
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: 450
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

Post Reply