Stack two 16-Channel PWM Hats

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/
Locked
User avatar
Marco01___
 
Posts: 2
Joined: Mon Nov 09, 2015 12:26 am

Stack two 16-Channel PWM Hats

Post by Marco01___ »

I just bought two 16-Channel PWM Hats for my Raspberry Pi 2 Model B+, separate the two hats work well but when i stack them and try to use both on the same Python code (The Servo_Example code) just one of them move the servos.
I change the adress of one hat but i don't know how to initialize them properly.
pwm = PWM (0X40)
pwm = PWM (0X41)

I need some help. Thanks.

User avatar
GerardWassink
 
Posts: 29
Joined: Tue Sep 08, 2015 5:52 am

Re: Stack two 16-Channel PWM Hats

Post by GerardWassink »

Perhaps you could use the gawServoHandler.py Library. I wrote it for my Servo Hat.
You can find it on my GitHub repository.

It sounds like an initialization problem.
The library initializes the board when it detects that another board is being addressed.

Let me know how it works for you.

Gerard

User avatar
Marco01___
 
Posts: 2
Joined: Mon Nov 09, 2015 12:26 am

Re: Stack two 16-Channel PWM Hats

Post by Marco01___ »

Check the code but same problem.
I just return to the Servo_Example code and change the lines

pwm = PWM(0x40)
pwm = PWM(0x41)

to

pwm1 = PWM(0x40)
pwm2 = PWM(0x41)

and create a objet for each one, change the instruction to move the servos from

pwm.setPWM(Channel,Address,Position)

to

pwm1.setPWM(Channel,0x40,Position)
or
pwm2.setPWM(Channel,0x41,Position)

Now the two hats work in a single Python Code.
Thanks.

Locked
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/

Return to “Adafruit Raspberry Pi® accessories”