As is my custom, I went to church this morning and then thought about Explaining Computers to watch this afternoon. I thought, "Wish he'd do another technical how-to type soon". In fact, that's how I found the channel a few years ago. I had a Raspberry Pi Model 1 B and wanted to learn about it and stumbled on to this channel and have been watching ever since. Much to my delight, this was the video waiting for me! Good deal. Thank you. I do like them all, but interested in this type of controller logic from time to time.
The straightforward precision with which you explain, diagram, apply and demonstrate is a refreshing and very QUICK way to learn! I've never been anywhere near a Rasberry Pi yet. But I can't wait to meet "familiar friends" when I finally get some! I find your dry humor a SCREAM! Thank you for making this topic interesting.
What kid wouldn't like to learn to code so he can control servos? The Raspberry Pi may be the greatest invention of the age -- it encourages young people to do something other than watch TV and play videogames. It encourages them to use their minds. And Chris is doing an excellent job of showing people what is possible with a Pi. Good job!
I can only confirm that controlling a servo with RPI was particularly exciting for me as an RPI enthusiast. This is the technology that inspires. Thanks again for an interesting Sunday.
Thank for your excellent video. Recently, I have started working with servos with the raspberry pi and this video is the clearest explanation of how to control them on RUclips. Your presentation is, as always, clear, logical and easy to follow and understand. Also, I like your supporting graphics, which help with the wiring up of the project. While I enjoy your many videos on SBCs, I am very grateful for your tutorials on the raspberry pi. Keep up the good work!
Thank you for this great explained Video. I built my first lamp-program with a raspberry pi just like 2 hours ago, worked on it, understood and now I'm working with servos. Never thought I could do stuff that fast.
I’m building a little robotics platform for myself and had typed out a little Python Library for myself to handle the wheels but didn’t know for sure if the PWM methods could control more than one servo at a time. With this hindsight I realize it’d be a bit silly if it weren’t capable of doing so. Now I just have to remember where I saved the two libraries, test them out, and add in turning to the Wheel library. Thank you again for the awesome videos!
Very interesting I very much appreciate your comments which add a real world perspective. For example, how the SG90 you used is the "most common type servo in the world" I just assumed it was a hobbyist piece of electronics. It really brings home how relevant what you are sharing is.. Thanks again
A most excellent Raspberry Pi servo example. I have a Picamera Pan/Tilt hat and when tracking an OpenCV object would like to position with tenths resolution to keep dead-band hunting to a minimum. 😎 Most servo examples just show simple motion control. 🥰 Thanks for some new ideas.
this channel has the best instructional videos. this video here s another great one. the tone and pace of the lesson is easy to follow while narrator exhibits complicated technology.
Not to argue with you, but, seemed more like 67,65 to me 😉. Thanks as always for charing your knowledge with us. Ordered a Rasp PI 4B for my 11 year old just today.
As the moment youtube notified me about this new video, I was watching Explaning Computers: the Latte Panda Delta Review. Bought two of those myself. :)
Thank you sir these videos are better than any college class and freely available to anyone a lot of students here in India benefit from these videos who can't quite afford to pay for a college so thank you and keep making such great videos !
With just 2 PWM chanels but 4 outputs I had wondered if you can coltrol 4 servos independantly, turnd out you can. All working fine thanks, for the code really speeded things up for me, only used stepper motors before.
Nice work! Must say your video quality, camera work and editing are top notch! You make it look easy breezy but I sure there's heaps of production gone into every video. Chris rules!
When I saw the two servo motors working in conjunction with one another it got me thinking to how automated car washes are possibly configured. Except I'd imagine that those companies may not be simply using micro PI systems today's video gives me a bigger illustration to the usage.
I used to run electric R/C cars & trucks, so I really love this stuff. Once again the RPi opens up a whole new world of possibilities. I still have a Zumo robot kit to build, so I'm ready and waiting for another video in this series. Great fun Chris, thanks.
@13:30 Explained for my sanity. Duty cycles range from 2 to 12, which represent 0 to 180 degrees. So for our input variable "angle" you are using "angle/18" (to get 10 degree position steps out of 180 degrees). So for an input "angle" of 90 degrees, it would be 90/18=5 for the duty cycle. However if we gave 5 as a duty cycle in the range of 2 to 12, then this would effectively be a 3 and not 90 degrees, because 5 is not the midway point between 5 and 12, 7 is. So this is why we add 2 for the duty cycle position (5+2).
Thanks Chris, I think you just cured my MeArm's Parkinsons symptoms. It's driven by Arduino but got it with the intention to link up to the Pie instead. Never got around to it, thought the servo's were sketchy. Other commitments killed off any progression, that's all history 01/01/2020 😀
I am running a software defined internet connected short wave radio receiver with an RPI4 and have been looking for a simple way to "tune" a loop antenna with a variable capacitor. I think I have now found my solution! thanks very much !
6:14 Chris says “...we do not have IDLE anymore...”. Chris we still do, actually. I’ve experienced the same until found out it is disabled. To enable it as well as other possibly disabled apps in the Pi do the following: Menu / Preferences / Main Menu Editor. In the editor dialog select 'Programming' and enable (tick mark) 'Python 2 (IDLE). That’s all. Changes are immediate, no reboot required. Ps Keep up a magnificent channel of yours Chris.
Indeed! :) Or sudo apt install idle -- and you have IDLE for Python 3. :) But I like to use standard settings where possible so that projects will work for the widest audience. And if I used Python 2 today, I would (sadly) get compaints in the comments.
Interesting, though a bit difficult for amateurs like me... I extrapolate: we will be able to use this new knowledge soon, in particularly exciting fields! Can't wait! Thank you very much!
Finally got mine all figured out. Thank you for the video. My breakout board was backwards but for some reason the 3.3 v pin was measuring as 5.2 v on a meter so I assumed the configuration was correct.. it was actually backwards. Anyway I had it all hooked up correctly except for the ribbon being backwards. All working now.
@@ExplainingComputers im struggling with the odd movements. Nothing is consistent. I may move my project to a stepper motor but i hope to give the servo more testing tonight. A single servo connected to the pi is clean for my project. Do you have advice for this Inconsistent odd movement? I test ran your improved python script and found the same resaults
Been following your videos for some time. I like them all, but this one is by far my favorite. I now have a raspberry pi 4 B, partially due to some of the videos on raspberry pi that you have made. I would have purchased it from an Amazon affiliate link from your video if one existed. I'm not sure what that kind of thing entails but it might help to pay for future projects. I can't wait to see what you do with the servos in future videos. Would love to see you control the servos remotely through wifi. Thanks for the great videos. :D
Hi Chris, thanks for the great tutorial. I have just completed this as my first raspberry pi 4 project. Very clear and precise instructions and having the code to download is an added bonus. Thanks again . From Sunny Manchester.
This is great to hear. And I suspect you may therefore be very interested in my video tomorrow, in which I do something practical with the same servos and a Raspberry Pi. Again the code will be available. :)
Hello Chris, thank you for the fantastic tutorial. I used the code for my program and it all worked well until I modified the main python program to run continuously. Based on the value on a table, it would trigger the python program to run the servo motor (change the angle), that program would use the same code principles (set up the servo, make the angle changes, then stop and then cleaned it up at the end). For some reason it work fine the first time the servo program is triggered by the main program, but once it triggers it again the program would run fine but the servo would not move. Tried all the different options and it failed to worked (e.g.: not stopping it but cleaning it, etc.). Only way I could finally make it work was to: Always have the servo running (no stop or clean up); Have all the code in one program (The table check and the servo change). Main problem with that solution is the fact that based on my requirements servo is always in used - which could reduce its life significantly. Any ideas on how I can solve this (main issue seems that once the servo is set-up in python and then closed/cleaned it will not move again unless the program python code is completely stop)? Thank you in advance and keep up the great videos
I was planning to use something similar for my tv to pivot to the otherside of the room and vice versa and this solves the trickiest part of it actually. Now i have find some stronger servos...
Probably cheaper to use some limit switches and a normal geared motor... Heavy duty servos are expensive, plus servos tend to be designed to move rapidly to arbitrary precise positions, while it sounds like you just want 2 positions.
You are correct -- it is 0.02. There are time when I detest having a weekly schedule, which means I have to produce things so quickly that errors creep in and are not found. I will now have myself and this video for ages. :(
@@ExplainingComputers On the bright side, this is only your first mistake in 2020. But sadly, now you've used up your entire quota for the year, and it's only January.
That left me quite confused and I thought I had become stupid, thanks for the comment :) PS: does the Raspberry have enough resolution to impose a 20ms delay?
@@ExplainingComputers no worries better to make an erroe here and there and do exciting projects as these than neither!! Really loved this one! I am so excited to see more singleboard builds, possibly with item detection and some wheels under with various functionality, dare I say an arm that could fetch drinks? We are allowed to dream right? :)))
Great stuff. Can't wait to see more Pi servo projects. Just watched the hamster one as well. I found that using hardware PWM helped a great deal with the jitter. Software PWM was terrible for camera quality when using it with a pan tilt stand. All that's needed is to install and use the PiGPIO library.
For my app, it's natural to think of angles between 0 and 180. I watched this video and experimented until I came up with the following correspondence between angles and duty cycles. '0':2, '45':4.2, '90':7, '135':8.5, '180':12 . I mentioned this on the Raspberry Pi forum and was warned: "I would not use 2%, that equates to a pulsewidth of 400µs which is probably damaging your servo. The pulsewidths you are using are 0-400µs 45-840µs 90-1400µs 135-1700µs 180-2400µs. The servo seems a bit hit and miss. I'd expect a stronger correlation between pulsewidth and angle." You all know understand this better than I. Can you comment on the warning?
Thank you a lot, you have got a new follower and student you made me fall in love with Python and Raspberry Pi. as a result, I've decided to build a drone with my proper PID or LQR controller code. I hope will achieve it
Bonjour Chris, Thank you for yet another great video. I've used servos controlled by an Arduino since I feel it is better suited for this purpose in my opinion. In addition, Arduino has better analogue I/O capabilities. Servos or mechanical interfaces do not require too much processing speed. It would be great to have a video that demonstrates a Raspberry pi as the main processor and using the Arduino to offload all the Electro mechanical functions. The big advantage is that all the coding can be in python.
I agree, if you only want to control a servo, an Arduino is the way to go. But if you have a larger project that needs servos added, then a Pi may be a better platform. And this is my intention here -- so show how a Pi can control servos, as something I can then integrate into future videos, with the servo stuff referenced back to this one. :)
I enjoyed this one a great deal Chris! I gave my 7 year old son an Edison robot for Christmas, which he has been programming via a EdScratch, an online Scratch variant specific to Edison which does a remote compile and delivers an executable to be loaded to the robot. I've asked Edison if they have explored an EdScratch for Raspberry Pi so that the Internet is not there as a distraction for kids. I'd love to see your thoughts to good approaches with robotics and children.
@@ExplainingComputers It will be when I get that far. RIght now I'm having difficulty since eBay sellers are willing to sell but not to supply. If I was back in Swansea I could go to Tom Whitehouse in the market but I'm in South Carolina.
Fascinating to see this. There is a whole world of unused possibilities for the humble Pi. All explained impeccably. I reckon you could explain Einstein's special theory of relativity to a bunch of 8 year olds and they would all understand
03:10 Was that a "sponsored" comment? Just kidding. I'm sure we all rectified on our own. Nice video, really got me wanting to try my hands on basic robotics. 👍🏼
Your servo video is inspiring. I've been trying to figure out how to make my own scanner for 16mm movie film. What you showed in the video is going to be a key part of it. I still need to figure out optics but I did figure out how I can use a time lapse function in an animation app in my iPhone to photograph the frames. I had thought about using a single board computer to perform this function as well but moving the film seems like a big enough challenge.
Reminds me of the days when I flew RC aircraft -- that was back in the late '80s and early '90s. We definitely didn't have anything like a Raspberry Pi to control them, however. :-) This looks like it would be a lot of fun to experiment with.
I find the Pi is much more interesting once you start interfacing it with the physical world. I already own four or five computers that are better than a Pi at everything else... but once you tinker with sensors, motors, hats, designing your own enclosures and so on, you find that there’s a real sense of achievement. Also, I am able to tell myself it doesn't matter if you nuke one... although I haven't lobotomised a single Raspberry Pi yet.
How to set the initial position of servo motor, and all angles with relation to it? It always starts of at 45 degrees. Whenever I input 0 degrees for example it's at a 45 degrees angle. And when I input 45 degrees it's at a 90 degrees angle.
Please setup one using NRF24L01 modules to wirelessly control servos on the pi. I've done it on arduino for a pan-tilt ESP32 camera mounting. I have uploaded my sketch on github and a youtube video on it using arduino. I would like to know how to do bi-directional communication as well.
Great video - I'm hoping to use this knowledge so I can get a servo to move the NoIR Pi Camera IR Filter in front of the camera during the day and remove it during the night. Looking to improve my MotionEyeOS home made PI security camera controlling this through a photoresistor light senstiive sensor and also API via IFTTT. I've seen a few of your videos already from other Pi related searches and they have always been helpful - thanks for making this!
Thanks for posting that very nice video. I am trying to make a solar powered security camera with pan and tilt control. I hooked up the pan servo of a tilt/pan 9g servo assembly to my Pi 3b running MotionEyeOS, SSH-ed into it from my Ubuntu 22.04 laptop, and wrote action button files to make the camera pan/tilt action buttons appear on the camera live feed. The next thing to do is to write code to put in those files. I modified your code to set the pan to straight ahead center, pause, then go fully to the left, pause, back to center, pause, fully to the right, pause, then back to center and end. It does that. Hooray! But what I need is code to bump the camera from right wherever it is at, to the right (or left as the case may be) say 22.5 degrees every time I click the button and make the code run again. For that, I think I need my code to find the current position to add or subtract to it. Is there a way of doing this? Otherwise I can only pan to one of three positions, home, left x degrees, or right x degrees. I want to be able to click the button repeatedly to move the camera more and more, another step each time I click. In fact, a video showing how to make best use of those pan and tilt buttons in MotionEyeOS would probably be helpful to a lot of people. Just sayin. You have a knack for explaining things like this. Liking and subscribing.
lol. i am not that interested in computers but love learning and I love this video. well done and thank you. I do like rc cars and other rc stuff so this would something nice to incorporate into that. like have the pi control the lights so when you turn it puts on the directional. when you brake it but on the brake lights
🎯 Key Takeaways for quick navigation: 00:21 🤖 *The video introduces how to control servo motors using a Raspberry Pi, a critical skill for various projects.* 01:19 🛠️ *A servo motor, like the SG 90 mentioned, allows precise control of its angular position and consists of a motor, gearing, a potentiometer, and control electronics.* 03:08 ⚡ *Servos have three wires: positive, negative, and a control signal wire, which requires a pulse width modulation (PWM) signal to control the angle.* 05:06 🔌 *Servo wiring example for a Raspberry Pi, including connecting the signal, negative, and positive wires to GPIO pins.* 06:27 🖥️ *Setting up servo control code in Python on a Raspberry Pi, including GPIO pin configuration and PWM frequency.* 09:12 🤔 *Demonstrates a servo motor moving in steps, but there's some jitter due to the motor trying to hold its position.* 10:19 ⏩ *A code modification is shown to reduce jitter by briefly turning off the servo after each move.* 13:05 🔄 *Code example allowing user input to set the servo angle, providing interactive control.* 16:22 🤖 *Controlling two servos simultaneously using a Raspberry Pi, demonstrating the capability to control multiple servos for various applications.*
I suspect that without a work load you could connect all 5 of the SG90 servos to the GPIO connector at once and even move 2 (or 3) at the same time. It's really when the servo is connected to something like the flight control surfaces of a fast model airplane (or the rudder of a model boat) that the servo has to work hard enough that it needs an independent battery to power it.
I don't know the construction of the motor in the case but it is always a good idea to add a flyback diode to provide a safe path for the inductive kickback of the motor. Motors can also consume some juice. Better is to use a dedicated power source instead (or use a cable splitter and connect it to that) of directly connect it to your PI. Remember, when you do this, you have to connect both grounds otherwise the PI cannot 'talk' to the motor (not required when using a splitter). Better safe than sorry.
As is my custom, I went to church this morning and then thought about Explaining Computers to watch this afternoon. I thought, "Wish he'd do another technical how-to type soon". In fact, that's how I found the channel a few years ago. I had a Raspberry Pi Model 1 B and wanted to learn about it and stumbled on to this channel and have been watching ever since. Much to my delight, this was the video waiting for me! Good deal. Thank you. I do like them all, but interested in this type of controller logic from time to time.
The straightforward precision with which you explain, diagram, apply and demonstrate is a refreshing and very QUICK way to learn! I've never been anywhere near a Rasberry Pi yet. But I can't wait to meet "familiar friends" when I finally get some! I find your dry humor a SCREAM! Thank you for making this topic interesting.
What kid wouldn't like to learn to code so he can control servos? The Raspberry Pi may be the greatest invention of the age -- it encourages young people to do something other than watch TV and play videogames. It encourages them to use their minds. And Chris is doing an excellent job of showing people what is possible with a Pi. Good job!
Thanks.
I can only confirm that controlling a servo with RPI was particularly exciting for me as an RPI enthusiast. This is the technology that inspires. Thanks again for an interesting Sunday.
Thank for your excellent video. Recently, I have started working with servos with the raspberry pi and this video is the clearest explanation of how to control them on RUclips. Your presentation is, as always, clear, logical and easy to follow and understand. Also, I like your supporting graphics, which help with the wiring up of the project. While I enjoy your many videos on SBCs, I am very grateful for your tutorials on the raspberry pi. Keep up the good work!
Thanks.
Again, explaining computers makes a video I find interesting even though I never knew I had any interest in servos. 👏👍
Thank you for this great explained Video. I built my first lamp-program with a raspberry pi just like 2 hours ago, worked on it, understood and now I'm working with servos. Never thought I could do stuff that fast.
This is great to hear! :) Good luck with your projects and experiments.
I’m building a little robotics platform for myself and had typed out a little Python Library for myself to handle the wheels but didn’t know for sure if the PWM methods could control more than one servo at a time. With this hindsight I realize it’d be a bit silly if it weren’t capable of doing so. Now I just have to remember where I saved the two libraries, test them out, and add in turning to the Wheel library. Thank you again for the awesome videos!
Good luck with your platform. :)
@@ExplainingComputers Thank you!
Very interesting
I very much appreciate your comments which add a real world perspective.
For example, how the SG90 you used is the "most common type servo in the world" I just assumed it was a hobbyist piece of electronics. It really brings home how relevant what you are sharing is..
Thanks again
A most excellent Raspberry Pi servo example. I have a Picamera Pan/Tilt hat and when tracking an OpenCV object would like to position with tenths resolution to keep dead-band hunting to a minimum. 😎 Most servo examples just show simple motion control. 🥰 Thanks for some new ideas.
this channel has the best instructional videos. this video here s another great one. the tone and pace of the lesson is easy to follow while narrator exhibits complicated technology.
Not to argue with you, but, seemed more like 67,65 to me 😉.
Thanks as always for charing your knowledge with us.
Ordered a Rasp PI 4B for my 11 year old just today.
One of the clearest explanations/demonstrations of using servos on the RPi. Also a good demonstration of using thonny.
I love any video you make. Always professional and always FULL of valuable information. It's like tech eye candy.
Thank you for taking the extra effort to explain the python code. Also thank you for explaining the power supply requirements.
As the moment youtube notified me about this new video, I was watching Explaning Computers: the Latte Panda Delta Review. Bought two of those myself. :)
Thanks for watching! :)
Thank you sir these videos are better than any college class and freely available to anyone a lot of students here in India benefit from these videos who can't quite afford to pay for a college so thank you and keep making such great videos !
Thanks for your kind feedback. :)
A master class in how to explain a relative complex topic with verbal and visual brilliance. Thanks
Sir, this is like the first Raspberry Pi tutorial that works 100% of the time
:)
With just 2 PWM chanels but 4 outputs I had wondered if you can coltrol 4 servos independantly, turnd out you can. All working fine thanks, for the code really speeded things up for me, only used stepper motors before.
Nice work! Must say your video quality, camera work and editing are top notch! You make it look easy breezy but I sure there's heaps of production gone into every video. Chris rules!
This is the most well documented piece of well put practical code I have ever seen, since witnessing Linus's kernel 1.0.
Thanks.
Great timing. I did Arduino servo control circuit and next step was Raspberry Pi. I am very happy, because now I can use your code :)
When I saw the two servo motors working in conjunction with one another it got me thinking to how automated car washes are possibly configured. Except I'd imagine that those companies may not be simply using micro PI systems today's video gives me a bigger illustration to the usage.
I used to run electric R/C cars & trucks, so I really love this stuff. Once again the RPi opens up a whole new world of possibilities. I still have a Zumo robot kit to build, so I'm ready and waiting for another video in this series. Great fun Chris, thanks.
@13:30 Explained for my sanity.
Duty cycles range from 2 to 12, which represent 0 to 180 degrees. So for our input variable "angle" you are using "angle/18" (to get 10 degree position steps out of 180 degrees). So for an input "angle" of 90 degrees, it would be 90/18=5 for the duty cycle. However if we gave 5 as a duty cycle in the range of 2 to 12, then this would effectively be a 3 and not 90 degrees, because 5 is not the midway point between 5 and 12, 7 is. So this is why we add 2 for the duty cycle position (5+2).
Thanks Chris, I think you just cured my MeArm's Parkinsons symptoms. It's driven by Arduino but got it with the intention to link up to the Pie instead. Never got around to it, thought the servo's were sketchy. Other commitments killed off any progression, that's all history 01/01/2020 😀
I am running a software defined internet connected short wave radio receiver with an RPI4 and have been looking for a simple way to "tune" a loop antenna with a variable capacitor. I think I have now found my solution! thanks very much !
Great to see servos in this context. Last time I saw them used was in aircraft modelling in the 70s.
Very interresting video!
Please make more of this practical video's, where you can learn what fun stuff you can do with SBC'S.
6:14 Chris says “...we do not have IDLE anymore...”. Chris we still do, actually. I’ve experienced the same until found out it is disabled. To enable it as well as other possibly disabled apps in the Pi do the following:
Menu / Preferences / Main Menu Editor.
In the editor dialog select 'Programming' and enable (tick mark) 'Python 2 (IDLE). That’s all. Changes are immediate, no reboot required.
Ps Keep up a magnificent channel of yours Chris.
Indeed! :) Or sudo apt install idle -- and you have IDLE for Python 3. :) But I like to use standard settings where possible so that projects will work for the widest audience. And if I used Python 2 today, I would (sadly) get compaints in the comments.
@@ExplainingComputers Agreed, this is important. Thank you for thinking of beginners!
Interesting, though a bit difficult for amateurs like me... I extrapolate: we will be able to use this new knowledge soon, in particularly exciting fields! Can't wait! Thank you very much!
Thanks for this -- keep watching! :)
Finally got mine all figured out. Thank you for the video. My breakout board was backwards but for some reason the 3.3 v pin was measuring as 5.2 v on a meter so I assumed the configuration was correct.. it was actually backwards. Anyway I had it all hooked up correctly except for the ribbon being backwards. All working now.
Great to hear! :)
Recently started with Raspberry.
Thanks for good and understandable explanation.
Excellent stuff. Perhaps I am strange, but your comments do make me smile
with some rusty fingers. I was working on a way to execute input to the servo with argv. You have just help me out so much here.
Great to hear. Hope all goes well.
@@ExplainingComputers im struggling with the odd movements. Nothing is consistent. I may move my project to a stepper motor but i hope to give the servo more testing tonight.
A single servo connected to the pi is clean for my project.
Do you have advice for this Inconsistent odd movement? I test ran your improved python script and found the same resaults
Nice little tutorial better than most out there, hope u continue them and show us how to combine them into other codes and with other sensors.
Excellent! A precisely detailed explanation. I feel confident I can use servos to control my model railway point motors now.
I really like the building block approach. This looks like the start of a very good thing!
Been following your videos for some time. I like them all, but this one is by far my favorite.
I now have a raspberry pi 4 B, partially due to some of the videos on raspberry pi that you have made.
I would have purchased it from an Amazon affiliate link from your video if one existed. I'm not sure what that kind of thing entails but it might help to pay for future projects.
I can't wait to see what you do with the servos in future videos. Would love to see you control the servos remotely through wifi. Thanks for the great videos. :D
wonderful demonstration of servo. this is the best toturial I have seen about servos. Thanks.
Hi Chris, thanks for the great tutorial. I have just completed this as my first raspberry pi 4 project. Very clear and precise instructions and having the code to download is an added bonus.
Thanks again .
From Sunny Manchester.
This is great to hear. And I suspect you may therefore be very interested in my video tomorrow, in which I do something practical with the same servos and a Raspberry Pi. Again the code will be available. :)
@@ExplainingComputers I will be looking forward to it!
Glad you have moved on to SBC implementation.... Thanks for another interesting video....
Very good, takes me back to closed loop servos using a 6502 and deceleration curves. Way back in the dark ages🧐
Why have I not subscribed to your channel already? You sir are one of awesomest dude around here! This is what I was looking for!
Welcome aboard!
Thankyou Sir ...it was a crystal clear content for a beginner working on servo with Raspberry Pi ....No words to say 😁
Thank you so much, with just this simple code I made a robotic arm for my robotics class
Excellent! :)
Thank you Professor! Fascinating, as always.
Hello Chris, thank you for the fantastic tutorial. I used the code for my program and it all worked well until I modified the main python program to run continuously. Based on the value on a table, it would trigger the python program to run the servo motor (change the angle), that program would use the same code principles (set up the servo, make the angle changes, then stop and then cleaned it up at the end). For some reason it work fine the first time the servo program is triggered by the main program, but once it triggers it again the program would run fine but the servo would not move. Tried all the different options and it failed to worked (e.g.: not stopping it but cleaning it, etc.).
Only way I could finally make it work was to: Always have the servo running (no stop or clean up); Have all the code in one program (The table check and the servo change). Main problem with that solution is the fact that based on my requirements servo is always in used - which could reduce its life significantly.
Any ideas on how I can solve this (main issue seems that once the servo is set-up in python and then closed/cleaned it will not move again unless the program python code is completely stop)?
Thank you in advance and keep up the great videos
Awesome video! Nicely paced and concise explanations. Thank you.
Thanks for your kind feedback, it is much appreciated.
I was planning to use something similar for my tv to pivot to the otherside of the room and vice versa and this solves the trickiest part of it actually. Now i have find some stronger servos...
There are some very big, heavy duty servos available! I had not thought of mounting a TV on one. You have now got me contemplating something!
Probably cheaper to use some limit switches and a normal geared motor... Heavy duty servos are expensive, plus servos tend to be designed to move rapidly to arbitrary precise positions, while it sounds like you just want 2 positions.
Just a heads up: at 3:19 you said that a pulse is expected every 0.2 seconds, whereas it should be 0.02 seconds.
You are correct -- it is 0.02. There are time when I detest having a weekly schedule, which means I have to produce things so quickly that errors creep in and are not found. I will now have myself and this video for ages. :(
@@ExplainingComputers On the bright side, this is only your first mistake in 2020. But sadly, now you've used up your entire quota for the year, and it's only January.
@@AnttiNannimus1 First and second mistake, he said PMW instead of PWM at 3:09 :)
That left me quite confused and I thought I had become stupid, thanks for the comment :)
PS: does the Raspberry have enough resolution to impose a 20ms delay?
@@ExplainingComputers no worries better to make an erroe here and there and do exciting projects as these than neither!! Really loved this one! I am so excited to see more singleboard builds, possibly with item detection and some wheels under with various functionality, dare I say an arm that could fetch drinks? We are allowed to dream right? :)))
Great stuff. Can't wait to see more Pi servo projects. Just watched the hamster one as well.
I found that using hardware PWM helped a great deal with the jitter. Software PWM was terrible for camera quality when using it with a pan tilt stand. All that's needed is to install and use the PiGPIO library.
Pan and tilt camera, didn't even think of that, thanks. I need more RPI zeros.
It works ! I think the link was a bit rusty, so it needed a little polish. Thanks for the video and the help. Great channel, I subscribed.
Glad it worked, and welcome aboard! :)
For my app, it's natural to think of angles between 0 and 180. I watched this video and experimented until I came up with the following correspondence between angles and duty cycles. '0':2, '45':4.2, '90':7, '135':8.5, '180':12 . I mentioned this on the Raspberry Pi forum and was warned: "I would not use 2%, that equates to a pulsewidth of 400µs which is probably damaging your servo. The pulsewidths you are using are 0-400µs 45-840µs 90-1400µs 135-1700µs 180-2400µs. The servo seems a bit hit and miss. I'd expect a stronger correlation between pulsewidth and angle." You all know understand this better than I. Can you comment on the warning?
Thank you a lot, you have got a new follower and student you made me fall in love with Python and Raspberry Pi. as a result, I've decided to build a drone with my proper PID or LQR controller code. I hope will achieve it
I hope you achieve it too! And the journey will be an interesting one.
@@ExplainingComputers Indeed, and thank you again for all your videos
Bonjour Chris, Thank you for yet another great video. I've used servos controlled by an Arduino since I feel it is better suited for this purpose in my opinion. In addition, Arduino has better analogue I/O capabilities. Servos or mechanical interfaces do not require too much processing speed. It would be great to have a video that demonstrates a Raspberry pi as the main processor and using the Arduino to offload all the Electro mechanical functions. The big advantage is that all the coding can be in python.
I agree, if you only want to control a servo, an Arduino is the way to go. But if you have a larger project that needs servos added, then a Pi may be a better platform. And this is my intention here -- so show how a Pi can control servos, as something I can then integrate into future videos, with the servo stuff referenced back to this one. :)
Excellent video and explanations. Thumbs up. Just on the side note - you could use a piece of something like Scotch tape to anchor the servos.
This is really interesting and I look forward to seeing what projects you have in store! Thank you.
Was having a hard time with the servo motor I had, thanks for the help!!
I enjoyed this one a great deal Chris! I gave my 7 year old son an Edison robot for Christmas, which he has been programming via a EdScratch, an online Scratch variant specific to Edison which does a remote compile and delivers an executable to be loaded to the robot. I've asked Edison if they have explored an EdScratch for Raspberry Pi so that the Internet is not there as a distraction for kids. I'd love to see your thoughts to good approaches with robotics and children.
Love the Raspberry Pi content. Please keep it coming!
Great video demo'ing the rasp pi pwm. I always wondered what that feature did. Thanks!
This is an awesome video, I am a sure the future content with servos is going to be very exciting and useful
Another wonderful video! Love from Johannesburg, South Africa ❤️
Excellent presentation. I'm going to have a fun time working out how to control two servoes on a Delta V-wing drone.
Sounds like a cool project.
@@ExplainingComputers It will be when I get that far. RIght now I'm having difficulty since eBay sellers are willing to sell but not to supply. If I was back in Swansea I could go to Tom Whitehouse in the market but I'm in South Carolina.
Fascinating to see this. There is a whole world of unused possibilities for the humble Pi. All explained impeccably. I reckon you could explain Einstein's special theory of relativity to a bunch of 8 year olds and they would all understand
fantastic, I always thought that the control wire had to be analogue, this opens up entirely new worlds of projects :)
Oh yes, loads of project possibilities . . . :)
03:10 Was that a "sponsored" comment? Just kidding. I'm sure we all rectified on our own. Nice video, really got me wanting to try my hands on basic robotics. 👍🏼
Thanks for the Explaining, beautiful Presentation.
👍👍👍👍👍
I love these video's, they are quality and not brian dead rubbish that goes round alot
Your servo video is inspiring. I've been trying to figure out how to make my own scanner for 16mm movie film. What you showed in the video is going to be a key part of it. I still need to figure out optics but I did figure out how I can use a time lapse function in an animation app in my iPhone to photograph the frames. I had thought about using a single board computer to perform this function as well but moving the film seems like a big enough challenge.
I'm going out and get me some servos for my Pi right now...
Thanks for the easy explanation, I feel I can actually do this now :)
Fantastic as always. Looking forward to more upcoming projects like these.
Absolutely incisive! Very grateful for this tutorial. Excited for more!
Thanks. This video kind of continues in this one: ruclips.net/video/lT4AZAJdtAs/видео.html
One of the most exciting things ever indeed. Amazing channel 🎩. Keep making awesome videos for us please.
Thank you! Will do!
Reminds me of the days when I flew RC aircraft -- that was back in the late '80s and early '90s. We definitely didn't have anything like a Raspberry Pi to control them, however. :-) This looks like it would be a lot of fun to experiment with.
This is why I now love Sundays! 😁
finally after long time real projects
Glad you appreciated. More soon!
I find the Pi is much more interesting once you start interfacing it with the physical world. I already own four or five computers that are better than a Pi at everything else... but once you tinker with sensors, motors, hats, designing your own enclosures and so on, you find that there’s a real sense of achievement. Also, I am able to tell myself it doesn't matter if you nuke one... although I haven't lobotomised a single Raspberry Pi yet.
SMART JOB CHRIS IMPRESSED WITH YOUR WORK ,WILL SOON DO IT MYSELF .THANKS A LOT FOR STIMULUS
Nice demo thanks. I have a RPi but haven't used it with servos yet.
Very helpfull. I like your Raspberry Pi projects. I always learn something new. Thank you.
How to set the initial position of servo motor, and all angles with relation to it? It always starts of at 45 degrees. Whenever I input 0 degrees for example it's at a 45 degrees angle. And when I input 45 degrees it's at a 90 degrees angle.
Thanks for the great explanation! Now I'm thinking of all the different thing I might make!
Ah yes, so many possibilities. :)
Your videos are very helpful and informative sir
Please setup one using NRF24L01 modules to wirelessly control servos on the pi. I've done it on arduino for a pan-tilt ESP32 camera mounting. I have uploaded my sketch on github and a youtube video on it using arduino. I would like to know how to do bi-directional communication as well.
Excellent servo motor tutorial, I really enjoy these resources. Thanks!
Thank you profesör. I from Turkey. 🙋♀️
One thing, when using the battery, you have co connect - ( black) to the raspberry pi -/gnd to get the servo working.
Thanks for sharing 👍😀
Agreed -- and I both mentioned and illustrated the ground rail connection to the Pi in all relevant places in the video. :)
Awesome channel. Simply love it 👍
Thanks.
Great video - I'm hoping to use this knowledge so I can get a servo to move the NoIR Pi Camera IR Filter in front of the camera during the day and remove it during the night. Looking to improve my MotionEyeOS home made PI security camera controlling this through a photoresistor light senstiive sensor and also API via IFTTT. I've seen a few of your videos already from other Pi related searches and they have always been helpful - thanks for making this!
Thanks! I wad planning to do a little project with servos and a Raspberry pi.
This was very useful.
Thanks for posting that very nice video. I am trying to make a solar powered security camera with pan and tilt control. I hooked up the pan servo of a tilt/pan 9g servo assembly to my Pi 3b running MotionEyeOS, SSH-ed into it from my Ubuntu 22.04 laptop, and wrote action button files to make the camera pan/tilt action buttons appear on the camera live feed. The next thing to do is to write code to put in those files. I modified your code to set the pan to straight ahead center, pause, then go fully to the left, pause, back to center, pause, fully to the right, pause, then back to center and end. It does that. Hooray! But what I need is code to bump the camera from right wherever it is at, to the right (or left as the case may be) say 22.5 degrees every time I click the button and make the code run again. For that, I think I need my code to find the current position to add or subtract to it. Is there a way of doing this? Otherwise I can only pan to one of three positions, home, left x degrees, or right x degrees. I want to be able to click the button repeatedly to move the camera more and more, another step each time I click.
In fact, a video showing how to make best use of those pan and tilt buttons in MotionEyeOS would probably be helpful to a lot of people. Just sayin. You have a knack for explaining things like this. Liking and subscribing.
lol. i am not that interested in computers but love learning and I love this video. well done and thank you. I do like rc cars and other rc stuff so this would something nice to incorporate into that. like have the pi control the lights so when you turn it puts on the directional. when you brake it but on the brake lights
Thank you very much! I learned a lot from the no jitter
🎯 Key Takeaways for quick navigation:
00:21 🤖 *The video introduces how to control servo motors using a Raspberry Pi, a critical skill for various projects.*
01:19 🛠️ *A servo motor, like the SG 90 mentioned, allows precise control of its angular position and consists of a motor, gearing, a potentiometer, and control electronics.*
03:08 ⚡ *Servos have three wires: positive, negative, and a control signal wire, which requires a pulse width modulation (PWM) signal to control the angle.*
05:06 🔌 *Servo wiring example for a Raspberry Pi, including connecting the signal, negative, and positive wires to GPIO pins.*
06:27 🖥️ *Setting up servo control code in Python on a Raspberry Pi, including GPIO pin configuration and PWM frequency.*
09:12 🤔 *Demonstrates a servo motor moving in steps, but there's some jitter due to the motor trying to hold its position.*
10:19 ⏩ *A code modification is shown to reduce jitter by briefly turning off the servo after each move.*
13:05 🔄 *Code example allowing user input to set the servo angle, providing interactive control.*
16:22 🤖 *Controlling two servos simultaneously using a Raspberry Pi, demonstrating the capability to control multiple servos for various applications.*
Thanks for this. Although the video is already divided into named chapters, which can be navigated via the bars at the bottom of the video.
I suspect that without a work load you could connect all 5 of the SG90 servos to the GPIO connector at once and even move 2 (or 3) at the same time. It's really when the servo is connected to something like the flight control surfaces of a fast model airplane (or the rudder of a model boat) that the servo has to work hard enough that it needs an independent battery to power it.
Great Job I didn't know you could move to servos Thanks for your tutorial
Agreed: the most exciting thing ever!!! Thank you for the video.
I don't know the construction of the motor in the case but it is always a good idea to add a flyback diode to provide a safe path for the inductive kickback of the motor. Motors can also consume some juice. Better is to use a dedicated power source instead (or use a cable splitter and connect it to that) of directly connect it to your PI. Remember, when you do this, you have to connect both grounds otherwise the PI cannot 'talk' to the motor (not required when using a splitter). Better safe than sorry.
All of my wiring diagrams for separate power show the ground wires connected to the Pi, and I mention this in the video too. :)
@@ExplainingComputers Okay, spot that (5:39) however no flyback diode at 5:25, could be a smart idea.
@@codebeat4192 Accepted on the diode. :)