Build a Custom Servo Motor with a DC Motor
HTML-код
- Опубликовано: 24 июл 2024
- Today I’ll convert a DC motor into a custom servo motor using a Seeeduino XIAO. Plus, we’ll learn about using PID controllers. This is a special project that I’m working on with Jeremy Fielding.
You can check out Jeremy’s video here - • Building A Self Drivin...
Article with all the code: dronebotworkshop.com/custom-s...
More articles and tutorials: dronebotworkshop.com
Join the conversation on the forum: forum.dronebotworkshop.com
Subscribe to the newsletter and stay in touch: dronebotworkshop.com/subscribe/
Servo motors are used in many hobby and experimenter applications. From radio-controlled aircraft to robot dogs, these motors are used whenever you need to be able to precisely position a motor shaft.
But most hobby servos are small devices, and even “large” hobby servos are not really all that large, and can only supply a limited amount of torque. Plus, larger servos generally mean a larger price tag.
Another limitation for some designs is that hobby servo motors are usually limited to either 180 or 270 degrees of rotation.
So why not build one ourselves? After all, internally, a servo motor is simply a DC motor with a control and feedback circuit. And you can buy, or salvage, a large DC motor for a lot less than the cost of a big servo motor.
Today, I’ll show you how to convert a DC gear motor into a custom servo motor. One that can rotate exactly to suit your requirements.
I’m doing this in tandem with Jeremy Fielding, a RUclipsr with incredible mechanical and design skills. Jeremy is building a “self-driving go-kart”, and for his steering system he will need a big servo motor that can spin a full two turns (720 degrees).
I’ve come up with a design that uses a Seeeduino XIAO and a 10-turn potentiometer. While I’m driving a fairly powerful motor driver, you can substitute a smaller, and less expensive one if you don’t require the big motor Jeremy requires in his design.
Incidentally, a potentiometer isn't the only method of sensing shaft position, it's just the cheapest (and probably most common) method. The article accompanying this video has a few other sensor types that can be used, and we'll be looking at those in future videos and articles.
Here is the table of contents for today's video:
00:00 - Introduction
03:17 - Custom Servo Design
06:39 - Servo Test Setup
09:20 - Controller Design with Seeeduino XIAO
14:17 - Input Test Code & Demo
19:47 - Endpoint Test Code & Demo
22:57 - PID Controllers
28:58 - PID-based Servo Controller Code & Demo
39:19 - Conclusion
Jeremy’s “self-driving go-kart” is a project that is being built in tandem with my 6-wheel rover, so you’ll be seeing more collaborations in the near future.
Make sure you check out Jeremy’s video at • Building A Self Drivin... - Хобби
Hi everyone - It's come to my attention that there has been someone masquerading as myself, responding to some comments here with a link to a Telegram chat to win a prize from me. THIS IS A SCAM, I am not holding a contest, nor do I have a Telegram account. PLEASE DO NOT RESPOND TO THESE MESSAGES!!
It's happening on a lot of my videos, I'm taking steps to remove them manually, but as I have 162 videos, it will take some time. If you do run across a suspicious comment, I would appreciate you letting me know at info@dronebotworkshop.com.
Thanks!
Bill (The real one!)
I am so glad we finally got to start making something together after talking all this time. I look forward to continuing the series! And great video as usual.
Big fan of both of your channels! Awesome.
I’m glad this happened. Great project both of you
Excellent cooperation of 2 of my heroes ! Awesome video !
Cool didn't know this will check it out
I've been watching your videos for a while. It's good to see you getting more exposure :)
Sir, I stumbled upon your channel looking for DIY projects, and I cannot be more than thankful for all the time and effort put in the content.
No annoying (techno/pop) music, No only-hands-pointing-to-objects-without-any-description, No wobbling camera, No rant/obscene/offensive content, etc.,
You take the time to explain all the things related to each project, and the information is easy to understand and the projects are easy to work even without the deep knowledge.
This is the 8th video so far I've watched in the last 2-3 days. This channel is what RUclips should be bringing up in their algorithm, not the other crap that shows twice or more on each search.
I'm glad I found and subscribed.
Totally agree that Jeremy Fielding is a genius. Not only that, but he’s a very humble guy who doesn’t assume you know how something works, and explains every step. He’s also a great father to his children, involving them at every stage so that they will have a thorough understanding of Electro-mechanical engineering. He’s the “go-to” guy when it comes to modelling.
Agreed on all points. He is a wonderful man. You'd be lucky indeed to have his acquaintance.
Title was awesome to begin with, didn’t know it was for Jeremy, another one of my favorite RUclipsrs. This will make him happy and filled with joy like a child.
You do just incredible videos, as does Jeremy! Can't wait to digest this, and see further collaborations! Love both of your work!
Love seeing two channels working together. Both great channels
This video came up in my feed with almost perfect timing as I am currently working on a couple of projects requiring custom servos that Ebay just cannot provide.
Thank you for this.
Fantastic! Thank you!!!
I drive a Tesla and have marveled at the steering and the lack of overshoot. I’m pretty sure the Teslas uses the PID logic (which I heard of here first) and your explanation of the three components of the PID system was very enlightening. It also gives me motivation to dig a little deeper in the PID thinking.
Thanks for helping Jeremy and his fantastic workshop. I’m eagerly awaiting his second video to see how he fixed the broken steering shaft. Giving him a couple of nights to think of solutions will yield interesting results. 🤔
Thank you for guiding us to Jeremy for increasing our skills morely
Am so glad that you and JF are buddies. I follow his channel. This project is thoroughly engrossing. Thank you!
I especially love the code you wrote. Simple and very effective. Great work!
Thanks for this Bill - such good quality and simply put - worth waiting for!
OMG! Perfect timing! Im undertaking a project just like this. Great video, excellent job!!!! And a very practical real-world purpose
This is one of the key components i''m using on my autonomous tractos project. Thanks for sharing!
These are two of my favorite electronic channels . Jeremy is smart guy and also does a great job explaining things to you. Looks like you got got a fly by wire system.
Mine, too!
I was controlling a dc motor to move a heater door on a vehicle that voltage varies from 12.8-14.3 volts dc. Using a standard actuator or pot for feed back. On the dash, it can be rotary or linear. This a custom built air distribution box in a 1967 pickup and just adjust heat from closed to wide open and anywhere in between. Enjoyed the channel & Jeremy.
ASE Master Tech since 1978, retired.
Man I love the way you explain everything like a great teacher would do!
I have watched a lot of Jeremy videos. Very smart guy.
This is awesome, Two of my favorite Makers on youtube.
Thanks for this great video! It gave me a good understanding of how to use the PID library.
Best channel in the business for this content.
Thats the video i am looking for so long. Thnks for detailed explanations ❤️👍
As always superb! Thank you!
Your videos are just fantastic!
Awesome video, learned a lot with it. God bless you!
Yes, Jeremy is awsome.😁😎
Another great video Bill. Thank you. I have been looking for closed loop DC motor control for years and just came across this video. This is what I need, except for the feedback. I have been a CNC tech for over 35 years, so "back in the day" all servo control was done with DC brushed motors, but now in these "modern" times it has moved into AC Servo motors. However, all industrial CNC machines use encoders to close the loop. Even China has been selling these cheap DC gear motors, with encoders, but there is not one person yet that has utilized this for any control. I want to control shades, windows, doors, DIY CNC, and anything to control linear motion with cheap DC closed loop. Would you please consider a video with H-bridge DC gear-motor, with encoder, to close the loop. It is needed more than most people think. lol
Bravo Bill !! Great and helpful video. I subscribed to Jeremy's site immediately! Thanks.
I'm so excited to go through your stuff, I'm a 4th year mechanical engineering student and I'm about to take mechatronics so this should be fairly useful. Jeremy sent me btw this collab is cool!
Timely, as I just snagged a 24vdc 3a 2560 rpm motor from the maker shop. It's part of an armchair lift actuator. I was considering using it in a CNC hack, and using a circuit like this is exactly what I had in mind.
If I will find a second so interesting channel it make me go out of my everday work!! - no time at all.
Excellent explanation. Thank you
Thanks for this video
Nice video and grate explanation, thanks!
Great episode! Also very good explanation of PID control! 🙂
I was hoping you were going to make a servo with an optical encoder attached to the motor shaft of a NEMA stepper motor.
That’s really cool
Thanks for the video. You can also use simple diode like 4148(cathode facing 5v side ) with a pull-up resistor on 3v3 side as a cheap and simple one-directional level convertor.
very useful gear set
This is an awsome video!!👍
very useful drive shaft
I mentioned this on his video as well, but figured it might be use to someone here too:
There is a really cheap alternative to traditional potentiometers called a magnetic absolute encoder. The typical one I have found that is cheap is called a AS5600 magnetic encoder. It can be had for about 2 bucks, and has a little breakout board where you either can get the same sort of signal you get from a potentiometer or receive data from I2C. It has sub degree accuracy, and won't fade and become less accurate over time like the wipes of a potentiometer.
Actually I think I might be talking about what's talked about in the article as Hall Effect Sensors
I was wondering the same. Thanks for bringing it up.
I been waiting for this
For those interested in more information on P.I.D. Controllers are also used with Type K Thermocouples and Relays to Control the Melt Temperature for Bullet Casters o greatly improve Temp. Consistency and improve uniformity by bullet caster to control the Melting Pot. There are several you Tube Videos about building them and Amazon has all the parts.
Helpful video. I liked it
i hope i will be able to adapt this knowledge to make robotic joint out of hydraulic valves and my cheapass muscles
anywho, thanks for the video and huge effort of making it!
Very good
Bill, your explanation of PID was one of the best ones I have seen. I would like to argue though that there is a critical fourth parameter that always gets minimal, if any, attention. That fourth parameter is Calculation Interval. In any controlled operation there is latency; it takes time for a motor to spin up and move to a new position. A program loop running on a microcontroller will almost always execute many times faster than the actuator's operational latency. It will remeasuring a new actual position and calculating a new error and output before the motor has reached the position commanded by the previous calculation. This new calculation will be based on the incorrect assumption that the new measured position was the result of the previous calculation. This mistake will lead to runaway actuator behavior. It would seem from your demonstration that you are addressing this in your code somewhere, but I cannot find it. It would seem to me that it is critical when explaining how to employ a PID controller to address how the latency of the system being controlled.
I love this series and this collaboration. I am trying to build a rover a little larger than Jeremy's so I will be following closely!!
If the digital sample rate is high enough (with enough averaging) this will not happen. Mathematically there are 3 possible solutions : critically damped, underdamped, and overdamped. It will be stable if the PID is tuned overdamped near critically damped. It can oscillate if underdamped. There are mechanical issues also, : gear lash and natural resonance.
This is vary helpful I been looking for a video like this to help with my robotics project I'm building a custom show time animatronic
U r the most wonderful person on earth. U shoud make videos on PID. It would be really nice for students.
You were right about Jeremy, he is a genius.
Nice video, keep it up, thank you :)
Thanks a lot i am also working on it and i face some troubleshooting , this video will help me lot.
Also i request you to please make video on FOC(Field operation control)
Great video on this sub.
I would think to use a stepper motor with a position encoder (can be a pot).
I'd also note that I took apart a small r/c servo and used it to power a bigger dc motor.
thanks
İşinin ehli bravo
Great video Bill, at the beginning of the video you outlined the requirements of 720 degrees of rotation yet while explaining the endpoints sketch the rotation was only 120 degrees, I assume that you doing so was that it would be the common servo movement range and not the specific project requirements...
have you played with the serial wombat io expansion chips? would love to see them used in a project. i have ordered a couple sets now and find them awesome to use especially with small microcontrollers where space is a factor.
Video içi teşekürler
great 😊
Another great episode! What I really find valuable in these, are the libraries and commands that are kind of hard to find out otherwise. As a question, I'm not sure why you called the D component of the PID a dampening element, as it is producing an output proportional to the rate of change of the input. The faster something is moving, the greater the output. I suppose you could use a negative Kd value to subtract a rapid motion, so slow things down.
D helps prevent oscillations via "prediction". It actually is related to damping.
Bill, I signed up for the newsletter about 2 years ago, received several through early 2020 and nothing since. I've resubscribed, but a question. Are the newsletters archived so one may read old letters? Thanks. As an aside, glad to see you working with Jeremy, he's quite a talented fellow!
Nice
Awesome video. On a different note, have you ever made a video on the Canaduino Full-Automatic Bootloader Programmer for Atmega328P?
Very Good Çok Íyi :)
Hello DroneBot team,
thanks for this wonderfull tuto.
I did it with my son for one of his project......works great.
I have a quick question that i'm trying to solve.
I use a small 12v actuator and drive it with the arduino.
when approching the target, the motor slows down in order no to overshoot but up to a point that the motor is forcing whithout moving creating a buzzing noise.
I try to fine tune my PID with no succes so far.
if you have any idea how to solve this probleme like creating a deadzone i would appreciate.
Thanks one again for sharing your work.
best
Pascal.
Like it ⭐️💫
Interesting!
I've never considered PID use in a servo. Great video as usual. With P set to one and I and D set to zero is not doing anything that remapping the input wouldn't though, right?
Can gear positioning accuracy be improved by using gears with smaller teeth? Hope you can explain the pros and cons when it comes the size/number of gear teeth.
this is very helpful thanks, aside from the confusion: it is called subscript, not "underscore" which would mean underlined
Güzel video
Hi, very good video. How can I modify the code to instead of an output for a pwm motor controller , use only one L293D with two wires one for each direction of the dc motor.
Thanks for the video. But why use PWM as a command ? It's complicated to "decode" and doesn't mean a rotation. Wouldn't it be simpler and clearer to use something like i2c, spi or even serial communication to send the rotation command ?
great stuff! what brand and model power supply you using? Looks like a KORAD possibly KA3005D? squinting a bit lol
Good
good ideas. car window motors are cheap and wanted to build a steering mechanism such as a joystick for an outboard engine on a boat. The common steering wheels and cables used are expensive and clunky.
Jeremy Fielding on the Dronebot Workshop? Looks like Christmas has come early this year!
What software do you use to make your diagrams? (e.g. PID loop diagrams)
Bill: Jeremy likes to build big machines. Jason: hold my beer…. Great video, best PID explanation. Looking forward to the series !
What about using the circuitry inside a hobby servo and soldering it to a bigger motor to drive it?
Hi there, is it possible that you can do a video on how to create my own nodes in ZOD?
Love Jeremy's channel.
Just wondering why you didn't use a stepping motor.
Harika 👏👏
Thank you for your videos.
But can explain PID with quadcopter
You trying to do PID tuning?
Do you have any suggestions for how to add acceleration or deceleration with pid as you mentioned in the video? I don't seem to be able to find any tutorials about that!
Search for Baldor Motion Products AN00115-001 Trapezoidal Move Calculations
There are many texts on this subject but the above document really simplifies the problem.
Muito bom !
Hi, can we build a servo with a latch such that no power is needed when holding at a position for long time?
Hi sir how to make steeper closeloop with magnetic sensor as5600
What setting do I change in the code if i want to replace the potentiometer as my input to an AS5600 encoder as my input?
Why are you setting the position with PWM? That makes sense if you are transmitting position via an RF link but if you are hard wired an error voltage makes for a simpler implementation.
hello sir, I want to ask when I make a program using the ultrasonic sensor in the Labview application on the arduino the Tr and Tx lights keep flashing after I run the program and the sensor can't detect it, why sir?
Can you make a video on Pi Pico PID motor controller for position using micropython, I don’t see any out there on RUclips.
Good stuff, and great to see you having a collab. with Jeremy. One tiny niggle: I'd've been happier to see "Kp = 1.0;" rather than "Kp = 1;" to emphasise that it's not an integer. Just being a grumpy old git!
I would say that the PWM controls the servo arm position and not the motor shaft position. (3min 58s)
**Music starts**
Me: "Hermitcraft recap?"
I haven't been getting notifications off these videos lately.
I have 4 of these motors and I wonder if they would work to move a heavy 2-axis CNC.
BALDOR 590CD2 TYPE PM3336P ½ HP FR 48Z 1140 RPM 230 V DC MOTOR