Hi!
I have recently purchased an Adafruit Servo Controller Hat (https://www.adafruit.com/products/2327).
Being the noobie I am, I didn't get a full understanding of the python library reference in the learning section (https://learn.adafruit.com/adafruit-16- ... -reference).
I have not understood how to properly controll the servos as I don't even know what to google for.
Should I use some variation of what was in the test code (and if; then what?), or can I use the RPi.GPIO library (again, if; then how?)
This is for a high-school robotics project, so nothing too complicated is required.
Hasty responses are appreciated, thanks!
Python library help (Servo controller HAT)
Moderators: adafruit_support_bill, adafruit
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
- nicklas1162
- Posts: 3
- Joined: Fri Feb 05, 2016 7:03 pm
- drewfustini
- Posts: 944
- Joined: Sat Dec 26, 2015 1:19 pm
Re: Python library help (Servo controller HAT)
Could you please explain what your robotics project is?
It would be easier to give advice for how to accomplish specific tasks with that Python library.
To give you are few ideas, here's the Adafruit servo driver being used in a robot arm library:
https://github.com/RorschachUK/meArmPi
Here's an article with some examples:
Control servos with a Raspberry Pi
It would be easier to give advice for how to accomplish specific tasks with that Python library.
To give you are few ideas, here's the Adafruit servo driver being used in a robot arm library:
https://github.com/RorschachUK/meArmPi
Here's an article with some examples:
Control servos with a Raspberry Pi
- nicklas1162
- Posts: 3
- Joined: Fri Feb 05, 2016 7:03 pm
Re: Python library help (Servo controller HAT)
Thanks for the help!
I read the linuxuser article and it helped a lot. The only thing I don't quite understand is the servo frequency. The servo kind of "jittered" while controlling it (might be because I'm using putty to control it).
The project I'm working on is a Scientific data collection rover, i.e. a robot that collects data and samples. I will use continous rotaiton servos for the wheels, and normal servos for a robotic arm. I need help with the wheel controlling part especially.
I read the linuxuser article and it helped a lot. The only thing I don't quite understand is the servo frequency. The servo kind of "jittered" while controlling it (might be because I'm using putty to control it).
The project I'm working on is a Scientific data collection rover, i.e. a robot that collects data and samples. I will use continous rotaiton servos for the wheels, and normal servos for a robotic arm. I need help with the wheel controlling part especially.
- blro
- Posts: 74
- Joined: Wed Jun 10, 2015 10:11 pm
Re: Python library help (Servo controller HAT)
I have on my website a simple program for the control of servos using python. If you go to: http://www.usefulramblings.org/?page_id=5875 you can download the servo_min_max file. While it does some pythonTk stuff the code for the servo should give you an idea of how to control a servo. It can be installed on your pc and should run (this was done on a Linux box). There is also a video which shows what it will do.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Python library help (Servo controller HAT)
You can expect some amount of jitter from servos controlled by user-level software on a RasPi. It's a side effect of the operating system's preemptive multitasking.
The kernel gives each process about 10ms of CPU time, then suspends it and gives the other processes a turn. If the suspend signal occurs in the middle of a servo control pulse, you'll get a pulse that's longer than it should be, or a delay between pulses that's longer than it should be. That's one of the areas where microcontrollers have an advantage over computers with an OS.
The usual way to get smooth servo control is to hand the responsibility for timing off to an external device. That's what the Servo Hat does: https://www.adafruit.com/products/2327
The kernel gives each process about 10ms of CPU time, then suspends it and gives the other processes a turn. If the suspend signal occurs in the middle of a servo control pulse, you'll get a pulse that's longer than it should be, or a delay between pulses that's longer than it should be. That's one of the areas where microcontrollers have an advantage over computers with an OS.
The usual way to get smooth servo control is to hand the responsibility for timing off to an external device. That's what the Servo Hat does: https://www.adafruit.com/products/2327
- nicklas1162
- Posts: 3
- Joined: Fri Feb 05, 2016 7:03 pm
Re: Python library help (Servo controller HAT)
And how can I leave it up to the Servo Control HAT?adafruit_support_mike wrote:The usual way to get smooth servo control is to hand the responsibility for timing off to an external device. That's what the Servo Hat does: https://www.adafruit.com/products/2327
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Python library help (Servo controller HAT)
The Servo Hat is built around the PCA9685 PWM generator. You tell it the frequency and duty cycle you want, and it generates the signals that go to the servos.
The RasPi communicates with the PCA9685 through the I2C bus, and we have a Python module that handles all the chip-level communication.
The RasPi communicates with the PCA9685 through the I2C bus, and we have a Python module that handles all the chip-level communication.
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/