Adafruit DC & Stepper Motor HAT with servo

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
smith9
 
Posts: 5
Joined: Thu Mar 23, 2017 12:33 pm

Adafruit DC & Stepper Motor HAT with servo

Post by smith9 »

I´m trying to control a high torque servo (http://alturn-usa.com/products/PDF/ABDS-996HTG+HV.pdf) with the Adafruit DC & Stepper Motor HAT for Raspberry.

The connection to the servo is shown in the picture:
Red: Positive
Black: Ground
Gray: Signal
Blue: 6V power supply
Servo_connection.jpg
Servo_connection.jpg (880.51 KiB) Viewed 475 times
And here is my test code:

Code: Select all

#!/usr/bin/python3

from Adafruit_MotorHAT.Adafruit_PWM_Servo_Driver import PWM

import time
import atexit



# create a default PWM
pwm = PWM(0x60, debug=False,i2c=None, i2c_bus=None)
pwm.setPWMFreq(50)


def turnOffAllPWM():

    pwm.setAllPWM(4095,0)
    print("Motors stopped")

atexit.register(turnOffAllPWM)


################################# PWM test!


try:
    #set Voltage

    pwm.setPWM(10, 4095,0)
    pwm.setPWM(9,0,4095)
    pwm.setPWM(8,0,4095)

    #setPWM
        
    position = 1.5

    if position < 1:
        position = 1.0
    elif position > 2:
        position = 2

    print(position)

    off = int(round((4096 * position / 20 )))
       
    pwm.setPWM(15,0, off )

    while (True):
        

        time.sleep(1.0)
        
except KeyboardInterrupt:
    turnOffAllPWM()
    print("KeyboardInterrupt")
However, the servo isn´t moving when I set different position values. Only short random movement when the signal cable is not connected. Do you have any suggestions what I have done wrong?
Thanks

User avatar
adafruit_support_carter
 
Posts: 29473
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit DC & Stepper Motor HAT with servo

Post by adafruit_support_carter »

Only short random movement when the signal cable is not connected.
I guess I'd expect that. Without the signal cable connected, it'll just send in noise.

In your code, I see only one position being commanded. How are you changing that?

User avatar
smith9
 
Posts: 5
Joined: Thu Mar 23, 2017 12:33 pm

Re: Adafruit DC & Stepper Motor HAT with servo

Post by smith9 »

I change the value and restart the program. I wrote this code to test the correct connection of the servo. The servo should move to the new position and stop there.

User avatar
adafruit_support_carter
 
Posts: 29473
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit DC & Stepper Motor HAT with servo

Post by adafruit_support_carter »

Is the gray wire going into the PWM 15 header soldered in place?

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT with servo

Post by adafruit_support_bill »

It is possible that the 3.3v control signal from the HAT is not high enough to drive that servo. I'm not familiar with that particular model, but we have seen several high-torque servos that don't respond to signal levels much less than 5v.

User avatar
smith9
 
Posts: 5
Joined: Thu Mar 23, 2017 12:33 pm

Re: Adafruit DC & Stepper Motor HAT with servo

Post by smith9 »

I also tried higher signal voltage by connecting the signal cable to the output 3 of the Motor Hat and adding these 3 lines to the code.

pwm.setPWM(11, 4095, 0)
pwm.setPWM(12 ,0, 4095)
pwm.setPWM(13, 0, off)

This should generate a 6V PWM signal. In the beginning, I added a voltage divider to get a 5V signal. But with or without voltage divider, the servo did not move.
If it´s not a problem with the HAT or the connection, I guess the servo is damaged.

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT with servo

Post by adafruit_support_bill »

This should generate a 6V PWM signal.
The PWM signal voltage level is determined by the VDD of the PCA9685 chip. Since this is being driven by the Pi - which operates at 3.3v - it is running at 3.3v also.

https://cdn-learn.adafruit.com/assets/a ... 1422045515

User avatar
smith9
 
Posts: 5
Joined: Thu Mar 23, 2017 12:33 pm

Re: Adafruit DC & Stepper Motor HAT with servo

Post by smith9 »

With output 3, I mean the BO2 output of the TB6612FNG chip. The dead time of the chip is only 230 ns ( https://www.pololu.com/file/0J86/TB6612FNG.pdf) which should be no problem with a frequency of 50 Hz.

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT with servo

Post by adafruit_support_bill »

I see now. Yea, that should give you a 6v pulse. Do you have access to a oscilloscope to see the actual output?

User avatar
smith9
 
Posts: 5
Joined: Thu Mar 23, 2017 12:33 pm

Re: Adafruit DC & Stepper Motor HAT with servo

Post by smith9 »

No, I don´t have an oscilloscope, that would be much easier. But I used a normal voltmeter and the measured voltage equals approximately 6V * duty cycle. Also, when I connect a LED instead of the servo to the signal cable, I can barely see a rapid flickering.

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT with servo

Post by adafruit_support_bill »

That is a pretty good indication that you have a good signal. Your servo diagnosis sounds pretty likely then.

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”