myka
Posts: 9
Joined: Sun Jun 02, 2019 12:05 am

4 AA Battery pack for Servo

Tue Jun 18, 2019 10:51 pm

Hi all

I am trying to power a super simple setup of 1 servo connected to the GPIO of my Raspberry Pi 3b+

It works fine when I hook it up directly to the 5V pin on my Pi, but I've seen countless times in other posts that you shouldn't just connect it directly.

It also works when connected through a breadboard.

When I try to hook it up to a battery pack with 4x AA batteries it doesn't work. I tried alkaline and lithium batteries. I've tried many different connections for the grounds and power and using breadboard etc. It just won't budge.

Can anyone tell me what I'm doing wrong? I'm at my wit's end with this.

thanks!

(I also have 2 USB power banks but can't figure out how to get them to supply power to a servo lol. I bought a USB to 5v device but it wouldn't activate the power banks)

W. H. Heydt
Posts: 10296
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: 4 AA Battery pack for Servo

Tue Jun 18, 2019 10:54 pm

We need wiring diagrams of exactly how you did the various hookups in order to tell what's wrong.

myka
Posts: 9
Joined: Sun Jun 02, 2019 12:05 am

Re: 4 AA Battery pack for Servo

Tue Jun 18, 2019 11:12 pm

Not sure how to do a wiring diagram but tried many combinations including...

Battery Pack + => Servo +
Battery Pack Ground => Servo Ground

Battery Pack + => Servo +
Battery Pack Ground => RPi GPIO Ground
Servo Ground => Breadboard

Battery Pack + => Breadboard => Servo +
Battery Pack Ground => Breadboard => Servo Ground

No resistors used (all the articles/forums I've read said one isn't needed, but correct me if I'm wrong)

W. H. Heydt
Posts: 10296
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: 4 AA Battery pack for Servo

Wed Jun 19, 2019 4:38 am

Do you have a controller for your servo? The Pi very likely can't provide the power the servo motor needs. (But one can't be sure without a part or model number.) What GPIO pins are you using? How is your breadboard wired? You speak of "a" resistor. Most circuits (other than extremely simple ones) have several.

If all else fails, draw your circuit diagram on a piece of paper, then photograph it and post the photo. You can look up standard electrical/electronic circuit element symbols. Label all values.

User avatar
joan
Posts: 14006
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 4 AA Battery pack for Servo

Wed Jun 19, 2019 5:28 am

It needs Pi ground to battery or servo ground. Battery ground to servo ground. Battery +ve to servo power. Pi GPIO to servo control.

It then needs pulses. At 50Hz

pcmanbob
Posts: 6205
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: 4 AA Battery pack for Servo

Wed Jun 19, 2019 10:07 am

If you connect your battery/servo and pi like this

Image

if you are unsure of your servo connection colour coding have a look here
https://www.hooked-on-rc-airplanes.com/rc-servos.html#9
it covers most of the common servo wiring colour codes ( scroll to bottom of page for colour codes ).

and then run this code

Code: Select all

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.OUT)
p = GPIO.PWM(23, 50)
p.start(5)
try:
    while True:
        p.ChangeDutyCycle(2.5)
        time.sleep(5)
        p.ChangeDutyCycle(12.5)
        time.sleep(5)
        p.ChangeDutyCycle(0)
        time.sleep(10)

except KeyboardInterrupt:
        GPIO.cleanup()
your servo should move from one end of it travel to the other repeatedly, until you Crtl , C
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

myka
Posts: 9
Joined: Sun Jun 02, 2019 12:05 am

Re: 4 AA Battery pack for Servo

Sun Jun 23, 2019 6:00 pm

Thank you so much for the info and diagram!

The way you have it drawn up is exactly how I have it now (have tried a few other combinations too)

I have all the code working and when I hook up the + to the 5v GPIO pin (#1) on the rPi the servo works great.

As soon as I plug the battery pack into the servo + it doesn't work. Not sure why. My multimeter says the pack is providing 5.2v which is more than the 5v of the rPi... is that too much maybe?

User avatar
joan
Posts: 14006
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 4 AA Battery pack for Servo

Sun Jun 23, 2019 7:22 pm

The obvious interpretation is the battery pack is flat and can not supply enough current. A clear photo of the connections may help.

User avatar
Imperf3kt
Posts: 2389
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: 4 AA Battery pack for Servo

Sun Jun 23, 2019 8:29 pm

Pin #1 is 3v3 and has a square pad.
Are you sure you don't mean pin #2?
Google is ubiquitous - Try it today, it's free!
https://opensource.com/life/16/10/how-ask-technical-questions

pcmanbob
Posts: 6205
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: 4 AA Battery pack for Servo

Sun Jun 23, 2019 9:15 pm

Have you tried measuring the battery voltage while trying to make the servo move ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

myka
Posts: 9
Joined: Sun Jun 02, 2019 12:05 am

Re: 4 AA Battery pack for Servo

Mon Jun 24, 2019 12:37 am

Imperf3kt wrote:
Sun Jun 23, 2019 8:29 pm
Pin #1 is 3v3 and has a square pad.
Are you sure you don't mean pin #2?
I'm sorry yes, pin #2

myka
Posts: 9
Joined: Sun Jun 02, 2019 12:05 am

Re: 4 AA Battery pack for Servo

Mon Jun 24, 2019 12:38 am

pcmanbob wrote:
Sun Jun 23, 2019 9:15 pm
Have you tried measuring the battery voltage while trying to make the servo move ?
No, I will do that, thank you.

Also will take a photo and post later.

Return to “Beginners”