0

Wrestling with my new Servo 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/
Please be positive and constructive with your questions and comments.

Wrestling with my new Servo HAT

by GerardWassink on Wed Sep 09, 2015 12:43 pm

Hi guys,

Toay I received my Adafruit 16 channel Servo HAT. After some tinkering (hardware and software) I'm afraid that it does not work. The problem is described in this topic on the Raspberry Pi forum.

It would mean a lot to me if you guys would lend a hand, I'm at my wit's end.

Gerard

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

Re: Wrestling with my new Servo HAT

by adafruit_support_mike on Wed Sep 09, 2015 10:55 pm

Post a photo showing your hardware and connections and we'll take a look. 800x600 images usually work best.

adafruit_support_mike
 
Posts: 61796
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wrestling with my new Servo HAT

by GerardWassink on Fri Sep 11, 2015 3:08 am

Hi Mike,

Here two pictures:

20150911_Overview.jpg
Overview of setup
20150911_Overview.jpg (178.51 KiB) Viewed 291 times

20150911_Closeup.jpg
Closeup of servo connection
20150911_Closeup.jpg (180.02 KiB) Viewed 291 times


HTH, Gerard

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

Re: Wrestling with my new Servo HAT

by GerardWassink on Fri Sep 11, 2015 6:11 am

Added information:

With the pigpio test program the servo works, as described on the RPi forum. Here is an image of the working signal:

20150911_01_Scope_image.jpg
Scope image while testing with pigs and pigpio, settings 50mV/cm - 5 ms /cm
20150911_01_Scope_image.jpg (107.25 KiB) Viewed 279 times


So, the signal is ~ 130mV with a period of 10ms, which fits with the command: pigs s 21 1000

Pulse width varies according to the pigs setting (1000, 1500, 2000),

Next post will contain signal from the servo HAT.

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

Re: Wrestling with my new Servo HAT

by GerardWassink on Fri Sep 11, 2015 7:12 am

As promised, the results of the measurements with the scope on the same settings, but now measuring the output of the servo HAT. As you can see, the timing is about right again. It seems to me the amplitude is a bit lower.

20150911_02_Scope_image.jpg
Scope image while testing with my test program, settings 50mV/cm - 5 ms /cm
20150911_02_Scope_image.jpg (110.34 KiB) Viewed 274 times

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

Re: Wrestling with my new Servo HAT

by GerardWassink on Fri Sep 11, 2015 7:57 am

Guys!

I'm joyed as well as flabbergasted... The servo HAT all of a sudden decided to kick in. I have NO idea what I did... Perhaps it got frightened by all you guys help. Anyway, the code below gave me a nice result now.

See also this Youtube movie.

Code: Select all | TOGGLE FULL SIZE
#!/usr/bin/python

from Adafruit_PWM_Servo_Driver import PWM
import time

# ===========================================================================
# *** Test Code
# ===========================================================================

# Initialise the PWM device using the default address
pwm = PWM(0x40)

# I Want debug output
#pwm = PWM(0x40, debug=True)

servoMin = 210  # Min pulse length out of 4096 (~ 10ms)
servoMax = 400  # Max pulse length out of 4096 (~ 20ms)
speed = 0.01

pwm.setPWMFreq(50)                      # Set frequency to 50 Hz

while (True):                     # Change angle of servo
  for i in range(servoMin, servoMax):
    pwm.setPWM(0, 0, i)
    time.sleep(speed)
  for i in range(servoMax, servoMin, -1):
    pwm.setPWM(0, 0, i)
    time.sleep(speed)

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

Please be positive and constructive with your questions and comments.