How to Turn Off Positioning Servo

I have a Adafruit 16-Channel PWM / Servo HAT for my Raspberry Pi.
It works well. Nice and smooth. I note when it drives to a position it is still working. I’ll be using this servo to move a camera position remotely so after it has moved I’d like to turn it off so it is not burning up my battery. Is this possible?

2 Likes

Many libraries have a myServo.disconnect() method. I don’t know what language or lib you’re using but if you check the docs looking for words like ‘disconnect’, ‘detach’, or maybe in python I’d search close().

1 Like

Ho Brian
You might find that it leaves the power on to hold position. I don’t think it is good policy as you risk damage to internal gears but it could be possible to move a servo without power to hold position.

Although having said that I don’t think your camera would be likely to move it. BUT be very careful when restarting as if the position control is moved it will assume the new position very rapidly.
Cheers Bob

1 Like

Thank you, I will check it and if i want to know more, I will ask, by starting my own thread.

Ok, here’s the solution (sorry as I don’t know how to input code in this forum so don’t forget to indent):

def servo_off(kit, ch):
“”“Turn off servo (stop PWM signal).”“”
kit._pca.channels[ch].duty_cycle = 0
print(f"Servo {ch} OFF")

def servo_on(kit, ch):
“""Re-enable servo control on that channel.”""
kit.servo[ch].set_pulse_width_range(500, 2500)
kit.servo[ch].actuation_range = 180
print(f"Servo {ch} ON and ready for movement")

…and call these functions from somewhere in your program. Works very well.

servo_on(kit, 0)
kit.servo[0].angle = 90
time.sleep(1)
servo_off(kit, 0)

1 Like

That’ll work. Nice! :slight_smile:

1 Like

So when the duty cycle is zero is the servo still using power ??
And if it is physically moved what will it do when the duty cycle it set on again ??

There is a good reason the servo needs power. To maintain its position.
You would need a way of knowing where the servo arm is so the movement is not too violent when power is applied again. I have experienced this violent movement with servos I have played with, it can be reduced by software. But will slow servo operation.

High torque gearing can act like a locking mechanism but introduces other problems like broken gears if the arm is physically moved. In my experience the amount of current used to hold a servo is not an issue with what I have built. Short duration use.

Cheers
Jim

2 Likes

Hi Jim,

My application is a network of remote cameras on a farm. The power supply will be via battery/solar so power consumption is very important. The camera will be a Raspberry Pi High Resolution with wide angle lens. I’m using two DSS-P05 positioning servos (came with the metal camera bracket kit) for tilt and pan. These I believe have brass gears and feel rock solid when gently trying to turn shaft by fingers. So my expectation in my application is that with no power the servo gearbox will hold position nicely. Yes, gears will be damaged if a cow tries to move the camera. At the moment whilst I’m waiting on my 5VDC 4Amp power supply to turn up I’ve only been testing one servo type SG90 and it runs smooth. I also have SG-5010 positioning servo’s but the Adafruit 16-Channel PWM / Servo HAT for my Raspberry Pi definitely needs a strong 5VDC supply. I can run one SG90 on any channel but cannot run two and can see the green LED dim when a second is connected. My test supply at the moment is 5VDC @ 0.5 Amp.

Regards,

Brian

2 Likes