Thanks for getting back to me. Would this be a good power supply to power up the servo?
Also, Im using Python. I’ve noticed that when the Pi initially boots, the servo will rotate a bit, is this because its being powered from the GPIO and will this stop if I power is using the external power supply?
If your are using this common servo then yes, that power supply is a good choice.
Different servos may require different power supplies. If you’re feeling unsure, shoot us a link to your servo and we can help.
Bob has noted the dangers of using GPIO headers for powering a motor. Note also the importance of a common ground between the servo’s power supply and the pi power supply.
That is, you can EITHER power both the pi and the servo from the same power supply, OR you can power each separately, but you must tie there ground pins together.
Check it out, CE have done a guide on this you can read.
It has circuits, pictures, and some python code to get you started.
Thanks so much Pixmusix I will go through the tutorial. With the GPIO, I just wanted to double check as I have seen alot of videos where the Pi is being used to power a servo and the user doesnt report any problems or potential issues.
I guess on this forums most are relatively conservative in their advice. I think that’s a good thing.
It is technically possible to damage your raspberry pi that way and we just wanted to warn you. This is because the traces on the pi are small and not rated for fast and hard inrush current like you find on a motor. This is especially true because you are powering on boot.
That said, electricity in real life is not always predictable. If you want experiment with powering it off the pi, and you accept the risks, that’s cool
I’d lastly like to remind you that some online might not know the risk. I know I didn’t when I started with motors.
For the record, I think I’ve got a good handle on these simple servos at the moment, and I have decided that an external power supply is sensible and well worth it.
I personally think you are a bit crazy. Why risk damage (true it might never happen, But…) when it is so easy not to. But it is your baby so do as you wish.
And there are a whole lot of videos that are just a load of absolute garbage. A situation that Pix just summed up.
Indeed I think that sometimes this AI stuff has a bit of revision to do. Quite recently a contributor to this Forum complained about the trouble ChatGp (whatever that is, some form of AI I think) caused him when it advised to fit a capacitor (which was required) to the wrong position in an Op Amp input circuitry. He finally got it fitted in the correct place. He came out of that a bit disillusioned with AI I think.
Some of these tools are not really the holy grail they seem to be. The problem is for the inexperienced hobbyist to filter this information and to know when and what to cross check and mark for further research.
This is a very real problem and can be difficult to spot and address.
Your case regarding powering a motor via GPIO is easy. The risk of destroying your RPi is real and is there. Why do it when the alternative is so easy??? Just because some people have done it successfully (there are many others that have not been successful) and made some videos???.
Like I say the choice is yours. Make up your own mind.
Cheers Bob
Add on:
You say you are powering from a GPIO pin. I don’y think this is strictly true. GPIO is General Purpose In Out pin and will only sink/source very few mA. Unfortunately RPi have chosen to put power delivery pins on the same 40 pin header so everybody refers to ALL these pins as “GPIO”. A monumental mistake I really think as intends to confuse thinking somewhat.
I had some discussion with Jane recently regarding this.
I think the pins you are referring to are one of these power pins. They will supply a few more mA to power light loads but nothing serious.
Your servo might be seen as a light load which it probably ie when rotating. BUT a motor (particularly brushed type) is an entirely different beast when starting and stopping. All sorts of voltages (some reversed) are involved hence the suggestion for using a separate supply.
Robert, all I was trying to say was that I have seen other users power their servos directly off the pi, never said that was the best or only way…I was merely looking for some information and seeing other users’ experiences. I didnt say thats what I was going to…it was merely a question but thank you both for the information.
I was initially testing using GPIO 12 as that is one of the pins for PWM.
Not a problem though and lesson learned. I will defintily not be powering the servo off the pi and will be using the power supply I have linked above.
Thank you both for the vaulable information..and saving my Pi! Much appreciated:)
Sorry if I seemed a bit harsh BUT:
I think we are running into a pin function description problem here. As I described above i think referring to ALL of the 40 pins as “GPIO” is a disastrous mistake.
Firstly I just had a look and I can’t find anywhere you say what flavour RPi you have, so GPIO12 probably means nothing (to me anyway, might as well be swahili) but I will take your word for it that it is a PWM capable pin.
This pin would not be used to POWER the servo. It provides a controllable logic level (5V or 3.3V is common) pulse width stream to CONTROL something else. Ir will not provide any supply POWER. Commonly used for lamp dimming, brushed motor speed control etc. Usually controls some form of high or low side switch (Mosfet ???) which would control the ON time of the controlled device. The pulse period could be whatever the RPi or Arduino etc defaults to. Probably about 500Hz or 2mSec.
A servo on the other hand requires a logic level control pulse of between 1000µSec to 2000µSec at a period of 20mSec (50Hz) which will determine the servo position. 1500µSec being centre (90º) position. This could vary between brands of servo but not by much and will be documented. A different servo is a continuous rotation type where this control apparently will change speed and direction. I personally have never had any joy with the speed part of this but that is probably me or the servo problem. BUT this PWM signal IS NOT a power supply.
There should be 3 wires to the servo. Ground, Control, and Power. It is the Control and Power difference of concern here. There may be some sort of feedback signal line as well but this is a different matter.
The Power we have been concerned about would be a suitable DC supply for the servo. Could be anything as long as within servo specs. it is unrelated and can be isolated from the control signal and MCU supply. But Control and Power grounds should be connected.
The control signal I think cannot be derived from the native PWM system as this will be too fast. Should be a period of 20mSec (50Hz as said above) Don’t know about RPi but Arduino have dedicated servo libraries. I would be surprised if RPi don’t have similar. Or you could roll your own control signal in software and you WOULD use a GPIO for this function.
A Bit more info from you might help like What RPi are you using, A sketch of EXACTLY how you have it connected etc.
I hope his has made things a bit clearer.
Cheers Bob
Hi BellAmi
Add on to post 10:
I just expanded Pix code sample at post 2 to have a look at the whole thing.
I do not know what programming language that is or claim to know anything about it.
However there are some patterns to suggest that on this RPI at least (unknown at the moment, to e anyway) GPIO12 is hardware PWM 0. And this PWM output is fairly easily externally controllable in regard to Period and Pulse Width and can indeed be set to Period = 20mSec and Pulse Width between 2 extremes to control position. and thus the required control signal to position a servo.
Note: Some time ago I had occasion to do this with an Arduino UNO R3 and with a lot of assistance from Alan73922 and a lot of research was successful by writing directly to the associated registers.
Now I repeat here that this signal will be a logic level CONTROL signal and will have nothing to do with supply power.
And also I have no idea what flavour of RPi was used in that demo sketch. Nor do I know what RPi you are using. The point I am making is you are going to have to do some cross checking. I don’t know how much compatibility exists across different RPi models or if there is any at all.
If you expand Pix’s example you will get back to the original GitHub project where digging might reveal the Pi type and programming language
Or if you look up your specs to see if GPIO12 appears on the same pin and does the same function (PWM 0) that might work.
Although I don’t profess to know much about RPi I have started to believe that as soon as anyone at the Pi Foundation changes their socks everything else changes with it and you almost have to start again. BUT there are a lot of users so it can’t all be bad. Just seems to have to be a lot of juggling with operating systems etc to get some things working at a lot of times. When something finally works I don’t think anyone is really sure why or what was wrong in the first place. Very confusing.
But that is only me.
Cheers Bob
Edited:
Par 2. “Period = 20mSec” was “Period = 20µSec”