One axis PID encoded DC motor control

Поділитися
Вставка
  • Опубліковано 12 січ 2025

КОМЕНТАРІ •

  • @ELECTRONOOBS
    @ELECTRONOOBS  5 років тому +4

    Sign up at ELECTRONOOBS.io: electronoobs.io/
    Follow me on FACEBOOK for more: facebook.com/Electronoobs
    help me on Patreon: www.patreon.com/ELECTRONOOBS

    • @aaronramly1705
      @aaronramly1705 5 років тому

      more of this type of project please

    • @jamesbrown99991
      @jamesbrown99991 5 років тому

      Hey man, your code looks like the I and D terms are 0, because you're converting/truncating a double to integer. From your site:
      int kp = 2, ki = 0.01, kd = 0.02;

    •  4 роки тому

      MUY BUEN VIDEO AMIGO...
      PUEDEN VER LA MIA ua-cam.com/video/VQamz6D0LwY/v-deo.html ///// ua-cam.com/video/0OEZiJNIVvw/v-deo.html

  • @laharl2k
    @laharl2k 5 років тому +45

    A better solution for controling brushed motors with PID is using PD + minimum value. DC motors tend to stall at low pwm values because of the friction and cogging of the motor. You set your pwm frecuency and measure the minimum pwm value you need for the motor to just start moving. Take note of the value you need so that its just before that. Then just set the P and D values accordingly and that will give you a much more responsive and linear system as you dont have I lag and will even easily do really low speeds without stalling (if it stalls, raise your minimum value)
    your final values shoud me [0, - 255] and the corresponding negative values. Be sure to add the case for 0 so that if wont keep it at when 0

    • @electronicscaos
      @electronicscaos 5 років тому +2

      Old industrial drives used tacho with encoders, so the tacho allowed precise control of speed and the encoder allowed the position precision.
      There is old school machines with incredible precision, with DC servo motors with permanent magnets as field.

    • @nrdesign1991
      @nrdesign1991 4 роки тому

      Oooh, will definitely try that. I just finished my implementation of a PID control software, and hacked an RC servo tro try it out with. PI works wonderfully with a PC fan, but PID gave me a heck of a lot of trouble with the servo. Especially a D over 1.0 ist making everything just shake and rattle, by generally amplifying the sensor noise

    • @laharl2k
      @laharl2k 4 роки тому

      @@nrdesign1991
      PID doesnt work for everything, first you need to understand the system you are working with, in other words its response curve. PID assumes a linear system but friction and other physics things cause things not to be linear at all.
      I dont think this would apply to an rc servo as it has its own pid inside, this is mainly for motors being controled with pwn with a mosfet. As motors are inductive loads, the higher the frequency the more exponential the response so that why the minimum value, to ofset the pid to the point where the friction, cogging and exponential response stop stalling the motor.
      PC fans are capasitive most of the times, they usually have a capasitor at the input to filter the noise generated by the switching.
      You should try either making a linear aproximation or an exponential curve (pass the output of the pid to a exponential function and use the function to set the pwm)
      Also as with with inductive loads, lowering the frequency reduces the reactance, so the lower the frequency the more lineal the response will be, for both inductive or capasitive loads.
      The only downside of lowering the frequency is coil whine or vibrations, but that depends on the motor or whatever you are powering so give it a try.

    • @nrdesign1991
      @nrdesign1991 4 роки тому

      @@laharl2k 1) I hacked the servo so I'm left with the H bridge, motor and potentiometer for my own control (also the gears, naturally). I've already implemented the minimum PWM, but havent had good results yet (either too shaky control, or creep). Some of it is to blame on mechanical play of the gears, too.
      2) the PC fan is a model with tach output and PWM input, so the only "capacity" is the kinetic energy of the spinning fan. It runs extremely well and comes up to the desired speed when tuned properly, even under load.

    • @laharl2k
      @laharl2k 4 роки тому

      @@nrdesign1991
      1) i would check the original controller's frequency and duty cycle as a reference and also check whether it had hysteresis or not. I guess they should to avoid oscilation.
      My guess if your fequency is too high, try something like 50-500hz
      2) yeah but i bet you cant go below 20% duty cycle. I thought you were doing pwm to the power line. PWM pc fans usually follow the intel standard which says that fans should turn off below 20%.
      Not that it would matter a lot for a fan but if you want anything below you will have to switch the power directly, i dont think the circuitry has any problem with that, mostly for compatibility with older motherboards.

  • @vidyadharjogi
    @vidyadharjogi 5 років тому +14

    I think there may be competition between electronoobs and great Scott 😂😂😂😂

    • @nrdesign1991
      @nrdesign1991 4 роки тому

      Give Homofaciens a try. He made an extensive series about servos, positional encoding and closed-loop control

    • @saqibsanadi5648
      @saqibsanadi5648 4 роки тому

      Or may b collaboration

    • @superabbasalmani6079
      @superabbasalmani6079 4 роки тому

      @@nrdesign1991 Also
      DroneBot Workshop
      He is realy the largest Teacher in such Branches since the birth of the Arduino board !

    • @Adi-Xplains
      @Adi-Xplains 3 роки тому

      There is no competition. Electronoobs is far far better than Great Scott!

  • @ofsanjay
    @ofsanjay 5 років тому +4

    you always make quality content. Thanks for all deep detail of the project. You do proper study before making a single video.
    Thanks keep it up

  • @almosh3271
    @almosh3271 4 роки тому +1

    absolutely a great educational video. I've built some thing similar to this board but I use it to raise and lower my radio control plane's flaps. I did that just because I enjoy using micro controllers such as audrino. Please keep up the good work.

  • @MCsCreations
    @MCsCreations 5 років тому +7

    Pretty interesting project, dude! Really well done! 😃

  • @FernandoBS.
    @FernandoBS. 4 роки тому

    Este foi o único código para arduino que funcionou perfeitamente no meu motor com encoder, parabéns!

  • @FCADurgeshKumar
    @FCADurgeshKumar 5 років тому +2

    Awesome, amazing...
    Well explained
    Your tutorials are easily understandable.

  • @rklauco
    @rklauco 5 років тому +1

    Btw - homing. You can measure the encoder output correlation to amount of PID output. I've made a routine which is activated if PID output is full (e.g. +127 or -127) and measures time since last encoder change. If it does not change for the specified time, the motor hit a "wall" (virtual endstop). Then I would move the axes into the opposing side and measure the number of steps taken - again employing the routine to verify if I've hit the wall. Like that you can get:
    a) sensorless homing
    b) information about the full axes range (real data, not calculated)
    c) verify, if the expected length is really available or your carriage has some problems
    Needs just a few lines of code and works like a charm ;)

    • @ELECTRONOOBS
      @ELECTRONOOBS  5 років тому

      Thanks for the tips. Do you share your code somewhere? Have a good day!

    • @rklauco
      @rklauco 5 років тому

      @@ELECTRONOOBS I think it's still available on misan's github, let me check...

    • @rklauco
      @rklauco 5 років тому

      @@ELECTRONOOBS It's part of the attiny85 part in github.com/sanchosk/dcservo, derived from github.com/misan/dcservo

  • @PankajSharma-ch3bp
    @PankajSharma-ch3bp 4 роки тому

    I Can't ignore your video...so interesting nd knowledgeable 👍

  • @theshavypirate5230
    @theshavypirate5230 5 років тому +1

    Your videos are so fascinating to watch 😊 everytime i learn something interesting! Thank you for that and keep up the good work man! Love your videos

  • @PowerScissor
    @PowerScissor 5 років тому +1

    such a great project. If only there were more hours in the day it would be so much fun to do something similar. I have so many ½ finished projects laying around just waiting for the time to get to them...I need to stop watching your videos as they are always so creative I want to add another one to list of things to try.

  • @PauloSergioDiasCarmo
    @PauloSergioDiasCarmo 5 років тому

    Esse é um dos vídeos mais esperados por mim pena não ter em espanhol, espero muito ver logo a CNC pronta com todos os eixos e uma versão em espanhol, patreon e like, like sempre, ótimo vídeo, like.

  • @weirdsciencetv4999
    @weirdsciencetv4999 Рік тому

    If your interpolator has rotational velocity output, you could use some feed forward to eliminate some of the lag.

  • @vidhyasagar1990
    @vidhyasagar1990 4 роки тому

    You are my GOD! Thanks for the effort and teaching!

  • @sammflynn6751
    @sammflynn6751 5 років тому +1

    awesome ,thanks for the awesome video,maybe in the future we can see some more of that code and acceleration and precise control of pid?

  • @NeedToDIY
    @NeedToDIY 4 роки тому

    very complex but well explained video, nice job

  • @electronic7979
    @electronic7979 5 років тому +1

    Excellent project 👍

  • @BrianBoniMakes
    @BrianBoniMakes 5 років тому +2

    Nice control. It's sort of a power steering circuit. Could this be made to use "STEP" and "DIRECTION" like a commercial controller instead of the pot?

  • @franhdez4711
    @franhdez4711 Рік тому

    Nice video. Animations are just awsome. Just one question. How could you design an H-brigde using high-power MOSFETs for a huge current-consuming motor?

  • @themanyone
    @themanyone 4 роки тому

    In theory, it should be possible to (very roughly) count the rotations of a brushed DC motor by monitoring the current going through it. Granularity would depend on the number of magnetic poles, but a computer could interpolate values in between to get a fairly-accurate position. Three points define a curve...

  • @zeffofx
    @zeffofx 5 років тому +5

    oh man, I hope to see that CNC from you a long time ago. Any chances that you might finish it?

  • @x87alpha1
    @x87alpha1 4 роки тому

    what about using a proximity sensor on the CNC head for example, any idea if that has drawbacks/advantages?

  • @nomecognome9710
    @nomecognome9710 5 років тому

    Actually, with trinamic stepper controllers you can detect lost steps and home the cnc and keep working, it’s not the best but it does the job. The prusa i3 has this feature

  • @ZuNunchaku
    @ZuNunchaku 3 місяці тому

    if the reason not using stepper because of "prices". ive been through this dc motor need gear for hold torque, need separate mcu to monitor the encoder in high speed, surely wearout in long use.
    short answer is, if the reason is price there is lot of used/second hand stepper that way cheaper than brushed with encoder and gearbox

  • @peterciurea7771
    @peterciurea7771 4 роки тому

    Is there an off the shelf equivalent to the stepper controller for using a large DC or AC motor with an encoder, and if necessary a electromagnetic brake?
    I mean a complete boxed controller, like the ones available for Steppers in CNC kits. Connect motor, power supply and and connect dir pulse enable to the breakout.
    I have several large 1 to 3hp motors that come with pre attached encoders and gear box, in either DC or 3 phase.AC . I'm thinking about making a large format cnc table, and to use one of these guys for a 12 foot long Y axis. I have all the rail and timing belt stuff needed to go with this, from a automation project a friend built years ago with ISA card automation hardware. It seems someone ought to make a modern controller that could drop in next to the typical stepper controllers that all talk to a breakout board and standard software and save the trouble of doing special circuits and coding

  • @prasadkirkire6311
    @prasadkirkire6311 5 років тому

    Great video as always 😘😍😘

  • @TheRainHarvester
    @TheRainHarvester 4 роки тому

    How do fast machines step 1 step at a time when their encoders define the step size? Do they just go full on, then wait for an encoder pulse, then turn off? What about inertia?
    (I'm currently making a 3d printer and looking for ideas.)

  • @rahilsheikh3653
    @rahilsheikh3653 5 років тому

    Sir can you please make a complete tutorial on controlling 3axis using g
    -code and pid system please
    You are doing great work

  • @noureddinebenakrim5458
    @noureddinebenakrim5458 5 років тому

    Very nice as always

  • @minchoivanov1961
    @minchoivanov1961 4 роки тому

    Hello!
    That's great video. May I give you idea for next video? It will be nice to see PWM DC motor speed control with PID regulator. WIth soft start, stuck rotor protection, current protection function and etc.

  • @manusholm3536
    @manusholm3536 3 роки тому

    hi. i love your projects. and the way you do your code. make good explanations so that in experienced like me can follow. my question. how do i change from dc motor to stepper to make it closed loop drive. and how do i use encoder for position rather than a pot. i want to use this to drive the lead screw on my metal lathe. will be very great full if you can help and explain how the code change.

  • @siddharthmali5841
    @siddharthmali5841 5 років тому

    Another great video✌️

  • @tricksandtechs8830
    @tricksandtechs8830 5 років тому

    Super amazing video bro 😀👍👍

  • @romualdaskuzborskis
    @romualdaskuzborskis 5 років тому

    My question, would it not be possible to caunt steps and direction simply by reading what direction H bridge is switched to, and how many steps are taken?

  • @ScienceLab760
    @ScienceLab760 5 років тому +1

    hi nice video, maybe later you can milling with your CNC prototype and this motor system the problem is the G code interface for vectors of images, thanks for share

  • @MichaelRHead-zv2zf
    @MichaelRHead-zv2zf 3 роки тому

    can you please help me figure out how to change the steps in the code so it doesn't go as far when turning the pot? thank you for any help you can give

  • @relaxinglofichillmusic7382
    @relaxinglofichillmusic7382 2 роки тому

    Do you by chance have a tutorial for 3 motors?

  • @pr2207A
    @pr2207A 5 років тому +3

    Thanks for your awesome content.
    If you don't mind can u please tell which software do you use to make the animated video?😊

    • @ELECTRONOOBS
      @ELECTRONOOBS  5 років тому +3

      After effects

    • @pr2207A
      @pr2207A 5 років тому +2

      @@ELECTRONOOBS thank you so much once again MR. electronoobs

  • @FixDaily
    @FixDaily 5 років тому

    Great video once again :)

  • @boudchichemohammed9066
    @boudchichemohammed9066 5 років тому

    nice job your friend from morocco

  • @BharatMohanty
    @BharatMohanty 5 років тому

    I was waiting for your video... :)

  • @Amir-kz6yq
    @Amir-kz6yq 5 років тому

    thanks for sharing your knowledge

  • @wahidshirdel1119
    @wahidshirdel1119 3 роки тому

    Hi whats up?
    i was woundering about how microcontroler(arduino ) undrestand g-code which sent to it from pc .
    For example when i press the top arrow of my keybord in computer it goes one step toward and vice versa.

  • @orange_tweleve
    @orange_tweleve 10 місяців тому

    Printers use brushed dc motors with some sort of a long strip inside to know the precise location

  • @badouriaymane5548
    @badouriaymane5548 5 років тому

    Geart job as usual 👍👍

  • @luizbueno5661
    @luizbueno5661 3 роки тому

    Hi Electronoob,
    we are just starting now a Clay 3D printer project, I run the FabLab TU and I want the students to have access to diy printers and we’ll build them ourselves.
    Ideally I would like to use these encoded dc motors but i’m struggling to understand how to integrate them with Marlin and with the signals sent by ,
    Let’s say, Ramps 1.4 (or a Treetech 32bits board)
    This project is going to be open source. Could you help us?

  • @klave8511
    @klave8511 5 років тому

    A source of optical encoders is (was) the old roller ball mouse. Not that common anymore but you may have one left over.

    • @tiagotiagot
      @tiagotiagot 5 років тому

      What about the wheels on modern mice?

  • @rahilsheikh3653
    @rahilsheikh3653 5 років тому +1

    Sir but how we are going to send the g-code to the machine

  • @jaishankarm5920
    @jaishankarm5920 5 років тому

    What is meter in the right side at the time of 9:16 ? Waiting for Ur replay

    • @ELECTRONOOBS
      @ELECTRONOOBS  5 років тому +1

      Is a power supply

    • @jaishankarm5920
      @jaishankarm5920 5 років тому

      @@ELECTRONOOBS send me the buying link of power supply

  • @DimitarManovski
    @DimitarManovski 5 років тому

    Great video, thanks :)

  • @shreyaskumar5366
    @shreyaskumar5366 5 років тому

    Sir is this precise enough for a 3d printer?
    I dont have enough money to buy those stepper motors

  • @certified-forklifter
    @certified-forklifter 5 років тому

    cool editing

  • @christopherj3367
    @christopherj3367 5 років тому

    very informative. thank you.

  • @kurtnelle
    @kurtnelle 5 років тому

    Wouldn't replacing the pot in a hobby servo with a linear potentiometer achieve more or less the same thing, but with greater accuracy? Or perhaps an LVDT?

    • @artbyrobot1
      @artbyrobot1 5 років тому

      you'd have to not only change the potentiometer to a rotary encoder but also make the drive circuit changed to be continuous rotation modded and you'd have to remove the cog that prevents continuous rotation. You also are forced to use PWM so lose control of the switching speed of the individual mosfets so you lost speed control fine tuning and power control fine tuning.

  • @ayoubghallab
    @ayoubghallab 5 років тому

    great job thanks for sharing

  • @docstrench948
    @docstrench948 5 років тому

    Hola Electronoobs, porfa, haz este tutorial en español, ya que me interesa mucho saber del tema.
    Gracias

  • @mohamedayman3288
    @mohamedayman3288 4 роки тому

    can you modify this to keep constant rpm ?

  • @cs_99x14
    @cs_99x14 5 років тому

    How did you program the arduino, so that it can read the optical sensor and watching at the same time the endstop? Would be interest cause multitasking is, i think, not possible with the arduino.

  • @hunkbol6154
    @hunkbol6154 5 років тому

    Can we use servo motor 😇😇😇😇😇😇😇

  • @XTronical
    @XTronical 5 років тому

    As usual, excellent. A question : when reversing direction is backlash (the slack in the gears) an issue for accuracy on this? It could be allowed for in coding though.

    • @giovannibianchessi1578
      @giovannibianchessi1578 5 років тому

      Since he uses encoders, If he placed encodes on the screw instead of the motor, the backlash would be automatically avoided backlash.

    • @XTronical
      @XTronical 5 років тому

      @@giovannibianchessi1578 wouldn't that reduce the resolution a lot?

    • @giovannibianchessi1578
      @giovannibianchessi1578 5 років тому

      @@XTronical Yes, if there is a gearbox, you are right. And those encoders, seems to me, they have few pulses per revolution.
      However, mine was and is only a theorical speech.
      But let's suppose the screw pitch is 4 mm and the encoder has 32 sectors. If we consider both fronts, rising and falling, pulses become 64.
      4/64=0,0625 mm if I am not wrong.
      (And if the encoder has a qudrature output, giving two signals, it is possible to multiply pulses by four.)
      For that kind of machine and if we consider torsions, low rigidity etc. in my opinion, is not bad.

  • @antnhebayu2746
    @antnhebayu2746 4 роки тому

    can i use mouse mechanical scroll as encoder ??

  • @vibhutigoyal769
    @vibhutigoyal769 4 роки тому

    Is PID controller used in this project??

  • @mouizimran1032
    @mouizimran1032 5 років тому

    Hi Andrei,
    I have learnt a lot from your videos. I need your suggestion.
    As I am an Instrumentation Engineer I was able to make one IoT product which I want to put in Market as a product and star selling it. So, I want to know can
    can I rely on Wemos Esp8266 boards or there any high quality and high performance esp8266 boards that I need to use for making that IoT products and selling to customers.
    Kindly reply in this regard.
    My best wishes for you always.

  • @maheshjawahar
    @maheshjawahar 4 роки тому

    You are amazing!!

  • @hardikmonga
    @hardikmonga 5 років тому

    When is your podcast?

  • @thenovicesretroreview7841
    @thenovicesretroreview7841 5 років тому

    Great channel

  • @tiagotiagot
    @tiagotiagot 5 років тому

    Don't brushed motors tend to deteriorate fast if you spin them in the wrong direction too much?

    • @PowerScissor
      @PowerScissor 5 років тому

      Depends on how they are manufactured. Cheap ones sometimes have directional brushes that will permanently damage the motor if reversed. Some brushes just wear in one direction, so don't like reversals after that. Some have well designed brushes that work well in either direction and don't wear abnormally from a dominant direction.

  • @chanelndeso114
    @chanelndeso114 2 роки тому

    Req injection molding micro sir tanks

  • @rahilsheikh3653
    @rahilsheikh3653 5 років тому

    Sir could you make a complete tutorial on how can we make a close loop cnc like this one because. I've tried using 3 different Arduino for 3 axis but if one axis is stopped the other 2 continue to make which completely distroy the design

    • @artbyrobot1
      @artbyrobot1 5 років тому

      that's just a code issue. If one axis stops, the arduino main loop should stop all operations and send you an email or something

  • @prkreddy5912
    @prkreddy5912 5 років тому

    How to use potentiometer as distance controller....

  • @luukvandenbent9453
    @luukvandenbent9453 5 років тому

    Couldnt you use a servo motor for this? Has build in rotational encoder?

    • @artbyrobot1
      @artbyrobot1 5 років тому

      they have a built in potentiometer that can only turn a few times which is different from a rotational encoder which can turn infinite times. So you would have to change things

    • @luukvandenbent9453
      @luukvandenbent9453 5 років тому

      @@artbyrobot1 ah fair enough thanks

  • @elektrikelektronik5404
    @elektrikelektronik5404 4 роки тому

    hi do you have a drawing of proteus?

  • @arvindh13
    @arvindh13 4 роки тому

    it's not working, i tried this...when i rotate the pot it starts rotating and when i rotate it a bit more it stops and if it starts again after rotating further, when i press the limit switch the motor still runs

  • @bilalhussain4021
    @bilalhussain4021 5 років тому

    Bro please start making tutorials on stm8 and stm32

  • @MicheleHjorleifsson
    @MicheleHjorleifsson 5 років тому

    link for 3d files is broken

  • @jaishankarm5920
    @jaishankarm5920 5 років тому +1

    Super 👍

  • @dodman0907153500
    @dodman0907153500 5 років тому

    homemade toys use stepper motors. cnc machines very rarely use stepper motors and and if, exclusively as closed loops...

    • @artbyrobot1
      @artbyrobot1 5 років тому

      not true. all desktop cnc 3d printers us stepper motors

    • @dodman0907153500
      @dodman0907153500 5 років тому

      @@artbyrobot1 yes. which are all toys...
      professional cnc equipment NEVER use open loop...

  • @ThinkAny
    @ThinkAny 3 роки тому

    hi bro i want help for my project please help me

  • @basilstadnik1342
    @basilstadnik1342 5 років тому

    а как насчет удержания

    • @gb614erg
      @gb614erg 5 років тому

      Удержания позиции? Я как раз сейчас строю ЧПУ станок с DC моторами: когда мотор в уже заданной позиции, то он в режиме "торможения", если он вдруг сдвинется, то мы это увидим и вернём в ранее заданную позицию. Но это маловероятно из-за использования редукторов в таких моторах.

    • @basilstadnik1342
      @basilstadnik1342 5 років тому

      @@gb614erg спасибо

  • @eziosoft
    @eziosoft 4 роки тому

    int kp = 2, ki = 0.01, kd = 0.02;

  • @haddad8956
    @haddad8956 5 років тому

    ❤❤

  • @motilalsuthar4048
    @motilalsuthar4048 5 років тому

    How to make useless box.

    • @motilalsuthar4048
      @motilalsuthar4048 5 років тому

      I am very happy that, sir you reacted on my comment. Please make a video on that topic.

  • @nowheremanjk8624
    @nowheremanjk8624 5 років тому

    used in printers

  • @gerleimarci
    @gerleimarci 5 років тому

    Next video: Odrive
    odriverobotics.com/

  • @nfcradio4622
    @nfcradio4622 2 роки тому

    QEI is best

  • @tvishmaychoudhary69
    @tvishmaychoudhary69 5 років тому

    First

  • @sri20141
    @sri20141 3 роки тому

    Why I see banana in some of your videos

  • @davey2k12
    @davey2k12 5 років тому

    Do it with brushless lol

  • @erick28alfaro
    @erick28alfaro 5 років тому

    good idea, but it is a toy

  • @jayytee8062
    @jayytee8062 5 років тому +1

    Your up and down tones in your voice and speech pattern is enough to give me an epileptic seizure.
    I learned nothing.