- Solder connections
- IMG_4207.jpg (829.95 KiB) Viewed 802 times
16 CHANNEL PWM SERVO DRIVER
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- sydeem
- Posts: 46
- Joined: Fri Oct 25, 2013 5:34 pm
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: 16 CHANNEL PWM SERVO DRIVER
It is hard to see where all the connections are going. But I don't see any common ground with the Arduino. (I don't see any power to the Arduino either).
- sydeem
- Posts: 46
- Joined: Fri Oct 25, 2013 5:34 pm
Re: 16 CHANNEL PWM SERVO DRIVER
You have a good eye! Didn't realize I disconnected the ground with the last breakdown. Arduino power for the test is from the USB and with the aforementioned ground attached it works. My bad and thanks for all your support.
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: 16 CHANNEL PWM SERVO DRIVER
Good to hear it is working for you. Thanks for the follow-up.
- davidsi
- Posts: 83
- Joined: Tue Oct 01, 2013 8:46 pm
Re: 16 CHANNEL PWM SERVO DRIVER
can you please explain a bit more about
I've been using the regular Servo library for Arduino up until now, and never needed to set a frequency. I'm not sure what value would be needed. This is for driving an ESC for a brushless motor.
thx
Code: Select all
pwm.setPWMFreq(40)
thx
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: 16 CHANNEL PWM SERVO DRIVER
Check the specs of your ESC. Most servos respond to pulse update rates in the 40-60Hz range. Some of the newer 'digital' servos will handle faster update rates. The not-quite-industry-standard is 50Hz.
- sydeem
- Posts: 46
- Joined: Fri Oct 25, 2013 5:34 pm
Re: 16 CHANNEL PWM SERVO DRIVER
I am trying to understand I2C as a beginner. I can write servo sequences but can not understand Adafruit’s language. Maybe a short command structure tutorial would be helpful to others also? I want to write commands to sweep servos in specific sequences to specific positions for 5 servos. I can handle this in Arduino with the Uno for 4 servos but to get to 5 servos I need your driver.
#include <Adafruit_PWMServoDriver.h> Including this gives access to different command structure so
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); replaces a term like #define module (0x2f);???
pwm.begine(); replaces wire.begin();???
pwm.setPWM(servonum, 0, pulselen);
Does this replace the Adarfuit specific library command for “write(position); ???
or does it replace
Wire.beginTransmission(pot_address);
Wire.write(real);
Wire.endTransmission()
#include <Adafruit_PWMServoDriver.h> Including this gives access to different command structure so
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); replaces a term like #define module (0x2f);???
pwm.begine(); replaces wire.begin();???
pwm.setPWM(servonum, 0, pulselen);
Does this replace the Adarfuit specific library command for “write(position); ???
or does it replace
Wire.beginTransmission(pot_address);
Wire.write(real);
Wire.endTransmission()
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: 16 CHANNEL PWM SERVO DRIVER
You don't need to understand i2c to use the library. The library takes care of the low-level i2c communication for you.I am trying to understand I2C as a beginner. I can write servo sequences but can not understand Adafruit’s language.
bUT If you really want to know how these commands map to i2c commands, you can look at the source code:
https://github.com/adafruit/Adafruit-PW ... Driver.cpp
- sydeem
- Posts: 46
- Joined: Fri Oct 25, 2013 5:34 pm
Re: 16 CHANNEL PWM SERVO DRIVER
Thanks again - but the cpp was over my head as you might expect but experimenting I have learned you need to define each servo with uint8_t and then use unit16_t in the for loop setting the servo number in the loop for example:
uint8_t jaw = 7;
uint8_t wrist = 9;
as
for (uint16_t pulselen = 420; pulselen > 300; pulselen--) {
pwm.setPWM(9, 0, pulselen);
delay(5);
}
or
for (uint16_t pulselen = 420; pulselen > 240; pulselen--) {
pwm.setPWM(7, 0, pulselen);
delay(5);
}
uint8_t jaw = 7;
uint8_t wrist = 9;
as
for (uint16_t pulselen = 420; pulselen > 300; pulselen--) {
pwm.setPWM(9, 0, pulselen);
delay(5);
}
or
for (uint16_t pulselen = 420; pulselen > 240; pulselen--) {
pwm.setPWM(7, 0, pulselen);
delay(5);
}
- davidsi
- Posts: 83
- Joined: Tue Oct 01, 2013 8:46 pm
Re: 16 CHANNEL PWM SERVO DRIVER
my servo wants values from 1100 to 1900 microseconds. From what I've read, a pulse length is the microseconds, so this value should be what is sent to .setPWM(). However that is not in the range 0..4095. How do I convert it?
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: 16 CHANNEL PWM SERVO DRIVER
The conversion depends on the PWM frequency you select. For 60 Hz as used in the example code. Each increment of the PWM period is: (1/60)/4096 seconds. or about 4 microseconds.
- davidsi
- Posts: 83
- Joined: Tue Oct 01, 2013 8:46 pm
Re: 16 CHANNEL PWM SERVO DRIVER
so lets say it is 60 Hz, and each value is an increment of 4 uS. I"m still not sure how that helps. That means that 1100 uS - the minimum my ESC wants would be a value of 275 and the maximum, 1900 would be a value of 475. This seems like an incredibly small range of values when the total range is 0..4095.
trying
didn't seem to give much better results either.
Oh, and every ESC I looked at failed to specify the Hz value, so I'm still not sure how to calculate it.
Help would be greatly appreciated.
trying
Code: Select all
map(degrees, 0, 180, 1100, 1900);
Oh, and every ESC I looked at failed to specify the Hz value, so I'm still not sure how to calculate it.
Help would be greatly appreciated.
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: 16 CHANNEL PWM SERVO DRIVER
That is because the servo control pulse is only 1-2ms out or a total cycle time of 16-20ms.This seems like an incredibly small range of values when the total range is 0..4095.
Not at all surprising since those numbers aren't even close to the calculated values.trying
CODE: SELECT ALL | TOGGLE FULL SIZE
map(degrees, 0, 180, 1100, 1900);
didn't seem to give much better results either.
Not sure why you would choose 0-180 as input values for an ESC. 0-100 would make more sense.
And the output range you calculated as 275 to 475. So 'map(0, 100, 275, 475);' would be a better place to start.
- davidsi
- Posts: 83
- Joined: Tue Oct 01, 2013 8:46 pm
Re: 16 CHANNEL PWM SERVO DRIVER
Yes, I realized after I posed it the degrees was not going to help.
The other part doesn't make sense to me. If the servo control pulse is only 1-2uS, how can changing it in increments of 4 uS work?
The other part doesn't make sense to me. If the servo control pulse is only 1-2uS, how can changing it in increments of 4 uS work?
- sydeem
- Posts: 46
- Joined: Fri Oct 25, 2013 5:34 pm
Re: 16 CHANNEL PWM SERVO DRIVER
They don't write manuals or instructions for dummies like me so I just guessed at angles from 0 to 180 by picking numbers between 150 and 600 - the min and max numbers in their demo code. After a few tries you get the hang of it.
Please be positive and constructive with your questions and comments.