0

Adafruit 16-Channel PWM / Servo HAT Coding
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit 16-Channel PWM / Servo HAT Coding

by Perugini on Tue Mar 15, 2016 1:37 pm

Hello;

Regarding the Adafruit 16-Channel PWM / Servo HAT. I would like to talk to it via C, not python. Do you have the C libraries I can address?

Greg

Perugini
 
Posts: 3
Joined: Tue Mar 15, 2016 1:34 pm

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by franklin97355 on Wed Mar 16, 2016 12:44 am

Sorry, no. But you should be able to look at the Python code and write code to control it.

franklin97355
 
Posts: 21217
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by Perugini on Wed Mar 16, 2016 12:26 pm

Seriously? we don't want to use python to talk to this board. All our code is in C to the Raspberry PI. We need real-time and very quick control. To go through python will slow us down.


Greg Perugini

Perugini
 
Posts: 3
Joined: Tue Mar 15, 2016 1:34 pm

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by adafruit_support_bill on Wed Mar 16, 2016 12:41 pm

What Franklin is saying is to use the Python code as a reference. i2c coding is not that complex. Just writing command bytes and reading data bytes. It should be fairly straightforward to translate to use your C library for i2c.

adafruit_support_bill
 
Posts: 74659
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by Perugini on Wed Mar 16, 2016 12:51 pm

So this i2c. are those the libraries that I would call to, using my C code? Do they call directly to the HAT? Are they C libraries?

Perugini
 
Posts: 3
Joined: Tue Mar 15, 2016 1:34 pm

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by adafruit_support_bill on Wed Mar 16, 2016 1:07 pm

The HAT is controlled via the Raspberry Pi i2c bus. Many other devices use this bus also. The Pi Foundation provides an excellent i2c library in Python. I don't know about the C you are using, but it should have i2c support if it wants to work with any of the thousands of sensors and other i2c devices out there.

https://learn.adafruit.com/adafruits-ra ... guring-i2c

adafruit_support_bill
 
Posts: 74659
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by franklin97355 on Wed Mar 16, 2016 3:35 pm

And here is the datasheet with the registers to write/read https://www.adafruit.com/datasheets/PCA9685.pdf

franklin97355
 
Posts: 21217
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by mclemens7 on Sat May 14, 2016 8:47 pm

Hey i just hooked up my board and its not working. Im using a mega arduino board and i did all the steps like put sla in pwm sla .etc. please help me i dont understand why its not working witht the code they game me and my arduino is plugged in to 0 and im new at this

Here is the page i looked at to do it
https://learn.adafruit.com/16-channel-p ... king-it-up

mclemens7
 
Posts: 13
Joined: Sat May 14, 2016 8:29 pm

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by franklin97355 on Sat May 14, 2016 9:08 pm

What code did "they" give you and what are your actual connections (there is no SLA on the breakout). Post a picture of your board and the connections you have so we can take a look.

franklin97355
 
Posts: 21217
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by mclemens7 on Sun May 15, 2016 9:15 am

So they gave me the servo code on the adafruit library. And here are the pictures. If you look at the direction u can see why I put my wires where they are. The connections is
SCL - analog in 5
SDA - analog in 4
Ground - power, ground
VCC - 5v
Attachments
IMG_1982 (1).JPG
IMG_1982 (1).JPG (905.74 KiB) Viewed 582 times
IMG_1981 (1).JPG
IMG_1981 (1).JPG (1019.02 KiB) Viewed 582 times
IMG_1979 (1).JPG
IMG_1979 (1).JPG (936.81 KiB) Viewed 582 times

mclemens7
 
Posts: 13
Joined: Sat May 14, 2016 8:29 pm

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by mclemens7 on Sun May 15, 2016 9:21 am

here are more pictures
Attachments
IMG_1974.JPG
IMG_1974.JPG (137.38 KiB) Viewed 582 times
IMG_1984 (2).JPG
IMG_1984 (2).JPG (135.42 KiB) Viewed 582 times
IMG_1982 (2).JPG
IMG_1982 (2).JPG (105.84 KiB) Viewed 582 times

mclemens7
 
Posts: 13
Joined: Sat May 14, 2016 8:29 pm

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by mclemens7 on Sun May 15, 2016 9:22 am

These are all the pictures i took
Attachments
IMG_1983 (2).JPG
IMG_1983 (2).JPG (119.7 KiB) Viewed 582 times

mclemens7
 
Posts: 13
Joined: Sat May 14, 2016 8:29 pm

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by adafruit_support_bill on Sun May 15, 2016 9:36 am

SCL - analog in 5
SDA - analog in 4

Those are not the correct locations for SCL and SDA on a Mega. Use the SCL and SDA pins next to the AREF pin near the USB jack.

adafruit_support_bill
 
Posts: 74659
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by mclemens7 on Sun May 15, 2016 11:53 am

so i did what you told me to do and i redownloaded "servo" on the arduino and it does not work

mclemens7
 
Posts: 13
Joined: Sat May 14, 2016 8:29 pm

Re: Adafruit 16-Channel PWM / Servo HAT Coding

by mclemens7 on Sun May 15, 2016 11:53 am

the servo is not moving

mclemens7
 
Posts: 13
Joined: Sat May 14, 2016 8:29 pm

Please be positive and constructive with your questions and comments.