Balancing Ball: PID controller test

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024
  • Trying some stuff out with my closed loop steppermotor and a PID controller. Still a work in progress.
    closed-loop stepper: • Converting a Stepper M...
    source code: github.com/neu...
    music: musopen.org/mu...
  • НаукаНаука

Комментарии • 138

  • @OregonDARRYL
    @OregonDARRYL 6 лет назад +34

    Why is it so nervous? Did you threaten to harm it if it dropped the ball?

  • @mareksumguy1887
    @mareksumguy1887 8 лет назад +58

    amazing.... your contraption has Parkinsons disease.

  • @melvin292
    @melvin292 6 лет назад

    Very nice video. Young hands at work and a future engineer. Keep up the great work and don't let anyone discouraged you.

  • @microdesigns2000
    @microdesigns2000 8 лет назад +23

    Hi, nice system. I think you would find more stable operation by using gears to increase the number of motor turns required to make a small motion and also to increase the number of encoder counts to make a small motion. More encoder counts makes more accurate PID calculation, and more motor turns makes smoother operation. :)

  • @KrisTemmermanNP
    @KrisTemmermanNP  9 лет назад +6

  • @NikhilTannk
    @NikhilTannk 8 лет назад +15

    Generally I never comment on any vidz on U-tube,
    But after watching this I must say
    U r awesome..!!

  • @osamaagag6021
    @osamaagag6021 7 лет назад

    Very Impressive, Good Thinking , Good Knowledge

  • @sideralikaband
    @sideralikaband 4 года назад +1

    I suspect that the jittering of the controller might have to do with “poor” discretisation of the system. That is, your pid I assume is tuned in continuous time (Laplace transformed ode) but the code you wrote runs in discrete time (Z-transformed ode). If the equations in your code ( the z transform ones) aren’t the exact equivalent to the Laplace ones, you might get the jittering you observe. (I have encountered this in modeling and controlling inverse pendulum dynamics with micro controllers). Cheers!

  • @archsakas
    @archsakas 7 лет назад +2

    Hello Kris, can I use these motors for CNC machine as closed loop stepper motor? My CNC stepper motors controled by Ethernet SmoothStepper (ESS) and Mach3 program. Or is it can be used only with Arduino applications (or CNC)?
    Commercial closed loop motors are very expensive...
    And your videos are amazing!

  • @oscarruiz4383
    @oscarruiz4383 7 лет назад +2

    excellent work Kris !!, my pleasure. building the parts, using computer vision, PID itself. even the music. very good example for all of us. thanks!!

  • @wendiwei8681
    @wendiwei8681 8 лет назад

    I love the piano!

  • @Westmach
    @Westmach 4 года назад

    I think that’s a really impressive project dude. I’ve mainly used PID on keeping temperature within range on industrial ovens. Controlling analog 4-20ma rotary valves. Rockwell/Allen Bradley controllers were considerably easier to tune. Im assuming the camera is acting like an optical sensor?

  • @bilalslama2098
    @bilalslama2098 17 часов назад

    Best regards. Great work! It would be better if you removed the stick's rebound to make it more fluid.

  • @marifhossain
    @marifhossain 9 лет назад +14

    Hi, I have seen your videos of stepper motor conversion. But I noticed a fundamental design flaw from the very beginning. You used gears to connect the motor and the encoder which introduces (or definitely has) backlash to the system. And it is clearly visible if you look closely at the place where the gears are mating. This ultimately contributes to all the jerkings/vibration/juddering of the bar holding the ball. These plastic gears are of low profile and not perfect. The backlash and uneven mechanical power transfer between the gears makes the system unbalanced for a while. It could have easily been avoided if you had directly connected the encoder on the motor shaft using some rigid coupling. Although it looks neat to have gears and some fancy CNC cuttings to connect the motor and the encoder, it is a fundamentally flawed concept. But I should really praise your initiative in creativity and your video making skills my friend. You seem to be more of an artist than a technologist ;-) Take care

    • @ztyy8185
      @ztyy8185 9 лет назад +1

      Mohammad Arif Hossain Yes much better to use belt and pulleys.

  • @danieldewindt3919
    @danieldewindt3919 4 года назад +1

    Finally a youtube channel with good background music

  • @Androidzombie1
    @Androidzombie1 7 лет назад +3

    You are amazing! Holy shit! :D How did you get so good at the three pillars of engineering? (mechanical, electrical, and software)? This is a genuine question.

  • @AnasSuhaimi
    @AnasSuhaimi 9 лет назад +3

    Dude, I am so jealous of you... The range of tools you have in your workshop, aaaaaaaaarrrrrgggggghhhhhhhhh...

  • @AaronLow1
    @AaronLow1 7 лет назад +3

    Hey! I have a burning question! What did you use that allowed you to program using a webcam???? I want to do that so badly!

    • @nickshavermatson
      @nickshavermatson 7 лет назад +5

      Not sure what he used, but OpenCV and Python (or C++) are very commonly used for things like this. It's only a few lines of Python to loop frame-by-frame through video received from a USB webcam, use HAAR cascades to identify an object (like the ball), get the location of the object (i.e. distance from the center), compare it to the last location (i.e. which direction is it moving?). Twenty lines of code maybe.

  • @rcztr
    @rcztr 5 лет назад +1

    Hey Kris.
    Did you model your system or all was arbitray? How you declare how much your system need to tilt?

  • @sergeantseven4240
    @sergeantseven4240 6 лет назад

    I would definitely try this with a timing belt set up instead of plastic gears, too much noise in your feedback loop causes the jitters.

  • @goldilauks
    @goldilauks 7 лет назад +1

    Now that I've seen derivative kicks in real life I feel that I am ready for this exam. Thanks.

  • @adimitrija
    @adimitrija 9 лет назад

    var error = 0;
    var error_next = 0;
    var integrator = 0;
    var diferenciator = 0;
    var power = 0;
    var setpoint = 160;
    function generatepower(plength){
    error = setpoint - plength;
    var kp = 11;
    var ki = 0.5;
    var kd = 9;
    var error = setpoint - plength;
    diferenciator = error - error_next;
    integrator = integrator + error;
    power = kp*error + ki*integrator + kd*diferenciator;
    error_next = error;
    return power
    }
    function populateform(enterlength){
    document.pgenerate.output.value=generatepower(enterlength)
    }
    Sensor:
    Power:

  • @jellyman1735
    @jellyman1735 6 лет назад +2

    With those skills you should get paid to tune quadcopter PIDs

    • @deishaw9567
      @deishaw9567 4 года назад

      Not with those skills. Understanding PID mathematically is one thing but applying that theory to quadcopter flying characteristics is another thing. You need to be able to fly pretty well to be able to feel what good and bad PIDs are on quadcopter manouveres.

  • @FutureAIDev2015
    @FutureAIDev2015 8 лет назад +3

    What kind of career path do projects like this represent? Control theory? Controls engineering?

    • @scotlandsimon
      @scotlandsimon 8 лет назад +7

      I think Mechatronics Engineering.

    • @Three2NineProject
      @Three2NineProject 8 лет назад

      control

    • @marcosmoura911
      @marcosmoura911 8 лет назад +3

      I had eletrical and computer engineering - automation and I could do that. It's not really about the specifics, you just have to know some math, some eletric and maybe some Matlab to help ;D

  • @cad3175
    @cad3175 9 лет назад +7

    WOW... very nice youtube video... love the music... the step by step video demo... the technology and of course your skill with mechanical + electronics + software... its all there... even the music ha ha... nice balance.... meditation.... really well done.... You are an artist Sir.... We've come a long way in 2 million years!.. Thank you very much for sharing :)

  • @Techn0man1ac
    @Techn0man1ac 9 лет назад

    2:51 я примерно так же держал паяльник с бодуна...

  • @kmlk1923
    @kmlk1923 8 лет назад

    thats great , inspiring

  • @AcerbicGangrene
    @AcerbicGangrene 8 лет назад

    You should consider system inertia and implement adaptive control to lower balls deviation amplitude (keep in closer the center). I assume it is proportional regulation?

  • @TheMetalButcher
    @TheMetalButcher 8 лет назад

    I'd say the smallest motor gear you can find and the largest platform gear should make for the smoothest platform.

  • @meannate
    @meannate 9 лет назад +1

    Wait! Are you using that second stepper motor for feedback? What a brilliant idea!

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад

      It's actually a rotary encoder, But you already saw that ;)
      Tnx for the comments!

  • @MuhammadArshad
    @MuhammadArshad 7 лет назад

    if you had put the camera in front instead of above you will have x and y both, right now u x only. but good project. I am trying to do the same with a Kinect v1 (I know it can be done using a simple camera, what can I say, my supervisor is an ass****). ;0
    Good video though! (y)

  • @featherbrain7147
    @featherbrain7147 5 лет назад

    I was expecting the ball to finish in the centre, or was not that the objective?

  • @Debraj1978
    @Debraj1978 6 лет назад

    Is it a critically stable system = oscillate at fixed frequency and amplitude?

  • @suharsh96
    @suharsh96 6 лет назад

    I am coming back to this video 2 years later, to use the same kind of idea in one of my own project. I was thinking, what if you put some weight at one of the ends of the stick ? Will the ball move to other side to keep the stick balanced ? Also, would be of great help if you help me out with this a bit, cuz looking at most stuff, I only keep finding the wheel balancing robot and nothing of such type, where the weight is balanced by moving another weight in the opposite direction. Thank you

  • @rodstartube
    @rodstartube 9 лет назад

    That gear backlash really sucks. This application should use timing belt/pulleys (to get trusty values) and results will be way more stable.

    • @rodstartube
      @rodstartube 9 лет назад +1

      +rodstartube in fact, encoder is useless while using a stepper motor, as you control step position, unless you use a brush dc motor as a servo (servo = motor + encoder)

    • @rodstartube
      @rodstartube 9 лет назад

      +rodstartube what is that music, Schubert?

    • @helmut666kohl
      @helmut666kohl 8 лет назад

      +rodstartube Yeah I was wondering too why he uses the encoder and then controls it all via openCV...
      CV should be well able to calculate the dynamics of the ball and correct via the stepper. Knowing the stepper's position is somehow useless in this case. On other mechanisms they make sense - to be sure you do not loose any steps for example.

  • @choupi4719
    @choupi4719 5 лет назад

    I think you should adjust (lower) your PID gain. :) That's why its si nervous, gain is amplifying PID's movements

  • @phinok.m.628
    @phinok.m.628 9 лет назад

    Closed loop feedback is quite unnecessary here, since the resistance will probably always be more or less the same, so the stepper motor (assuming it has enough torque) shouldn't miss steps anyway. Besides you're closed loop feedback apparently just makes it jitter like crazy. Although that may also be the ball tracking that isn't smooth enough.

  • @simonkrajnc
    @simonkrajnc 6 лет назад

    Very good project, idea and presentation with background music. Impresive project - visual control and ball balancing.

  • @danielmattsson8574
    @danielmattsson8574 9 лет назад

    Couldn't you make a software to keep trace of the position instead of that rotary encoder. I don't know how reliable steppers position are thought... Missing steps from time to time?

  • @soronemus8815
    @soronemus8815 9 лет назад

    Great videos! I am considering doing some closed loop stepper control as well. Do you think the vibration seen in your stepper motor shaft is due to the backlash that occurs due to the encoder not being attached directly to the motor shaft? I have read that having an encoder downstream of the motor instead of directly coupled to it can cause poor performance, or 'bouncing' around the target position.

  • @jellyman1735
    @jellyman1735 7 лет назад

    You don't happen to fly racing quads by chance, do you? I only say so because all custom built drones must be PID tuned as well.

  • @Dr.Stein99
    @Dr.Stein99 7 лет назад

    I can clearly see the gears are not engauged and the stepper motor is not in sync with the encoder gear. You may want to consider using pullies, or a double shaft stepper where an encoder can be mounted direct to the shaft on the reverse side.

  • @SergeiPetrov
    @SergeiPetrov 4 года назад

    The installation has no reduction gear in the motor. Therefore, the movement takes place with noticeable steps.

  • @decarbconsultant
    @decarbconsultant 9 лет назад +1

    Simply Amazing!

  • @daveyhi3154
    @daveyhi3154 7 лет назад

    With that large a motor you probably could have just attached the beam to the motor shaft

  • @mandysandy6025
    @mandysandy6025 6 лет назад

    very large overshoot as u know decrease the kp and increase the kd it may work better

  • @mizarstifmeister7298
    @mizarstifmeister7298 6 лет назад

    what program do u use to make all the vision things? i've never worked with vision

  • @fadhel97
    @fadhel97 5 лет назад

    You have your wolrd kris enjoy it

  • @merxellus1456
    @merxellus1456 5 лет назад

    Can anyone explain what can be done to smooth out the shaking motion?

  • @sprinterdomety1
    @sprinterdomety1 6 лет назад

    it just feels bad how the motor seems to be scared. it feels weird somehow :o

  • @MrHeatification
    @MrHeatification 3 года назад

    too much p and d

  • @teteatetetechswahili3208
    @teteatetetechswahili3208 5 лет назад

    Hello i was wondering what software is that you are using to program the mega

  • @alexxie3164
    @alexxie3164 9 лет назад

    hi,Kris,I want to know which GUI lib are you using, can make effect like 2“40!Its very beautiful .

  • @MystbornYT
    @MystbornYT 7 лет назад

    If you made a custom shaft coupling, why didn't you just couple it directly to the encoder?

  • @sidekick3rida
    @sidekick3rida 7 лет назад

    thanks for the video. what ide are you using to program your microcontroller?

  • @agrxdrowflow958
    @agrxdrowflow958 7 лет назад

    Maybe use micro stepping? Might get the jitter out.

  • @FrankLopezx
    @FrankLopezx 9 лет назад

    i wonder what would i have todo to do this with a arduino

  • @crazysavage7840
    @crazysavage7840 7 лет назад

    Specially thanks for the source code

  • @travers114
    @travers114 9 лет назад

    I love these projects, but you never give any hint as to what libraries you develop your interfaces with.

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад +1

      travers114 Thanks, mostly it's only Cinder: libcinder.org/
      It's a pretty complete package for the things I need. For the vision stuff I used openCV, but thats also integrated with cinder

    • @travers114
      @travers114 9 лет назад

      Thank you! Never heard of it before, looks awesome.

  • @mikestanzel1192
    @mikestanzel1192 9 лет назад

    Hi Kris, how is the encoder wired? I'm assuming it has to be connected to the driver.

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад

      Mike Stanzel Its not connected to the stepper driver. but to an Arduino that drives the stepper driver. Here You see how I did that:
      ruclips.net/video/Z6OMT1fIQnU/видео.html

    • @mikestanzel1192
      @mikestanzel1192 9 лет назад

      ***** There it is. It looks like you are sending signals to the stepper driver from some digital pins at the end of the Due and are receiving some PWM signals somewhere over there on pins 2 thru 13 from the encoder.
      So you send a signal out and then check to see if the encoder has moved with your program?
      I'm interested in this because I programmed a couple of identical CNC milling machines a long time ago (longer than I care to admit). One had an open loop system and one had a closed loop system. We always had to check the location of the machine table when the open loop system changed tools.

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад

      Mike Stanzel Yes, In a way it's like that. But Its a little bit more complicated.
      I made an abstraction of the stepper steps. I check the encoders current position and speed. And then I calculate how I want to move to get to the target position as fast as possible (limited by a max speed and max acceleration) . the result is the speed i give to the stepper motor (underlying it's still steps, but the "controller" doesn't know that).
      Its not how you would do a CNC because of the overshoots. Its to react as fast as possible to realtime changes. With a CNC you can anticipate the next moves and you definitely don't want to overshoot your cutter.

  • @herantd
    @herantd 7 лет назад +3

    very cool! i dont think u need direvative in ur project tho, too much noise and the process aint too fast for it to be worth using.

    • @herantd
      @herantd 7 лет назад +1

      your programming skills are very nice! would love to be able do these things

  • @xzmk
    @xzmk 9 лет назад

    can you tell me the names of the softweres that you are using? (The one with the black background, and the CAD one)

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад

      The Cad one is Rhinoceros. The other one is Xcode (a mac IDE, for C++ among other things) but you could use anything you want for writing C++ (for example Visual Studio if you use a PC)

    • @radist2s
      @radist2s 9 лет назад

      ***** I saw that you using Arduino. Did you use emebXcode for Xcode, or you write without Arduino functions?
      (Github link is missed)

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад

      Саша Б It's just Xcode (use the arduino IDE and a basic sketch and write a C++ library using Xcode ). The github link is also in the description.
      Never heard of emebXcode, looks cool, I'll check that out, tnx! :)

  • @CarlinComm
    @CarlinComm 9 лет назад

    That's awesome ;) Well Done!

  • @iamtirtechnol1685
    @iamtirtechnol1685 6 лет назад

    what program is that you used in the programming and control?

  • @sdrshnptl
    @sdrshnptl 7 лет назад

    Very amazing project.
    can you tell me which IDE you're using to compile arduino code?
    Original arduino ide sucks.

  • @KhurafatiEngineer
    @KhurafatiEngineer 6 лет назад

    can we make it with plc?

  • @thomashara7760
    @thomashara7760 6 лет назад

    Would increasing the gain reduce the shaking?

  • @carlosriccio7859
    @carlosriccio7859 7 лет назад

    Congratulations. nice setup

  • @legion2k988
    @legion2k988 7 лет назад

    Handsaw? weirdo..

  • @abubakarbakar8814
    @abubakarbakar8814 6 лет назад

    which softwere u r using for simulation and processing..

  • @----.__
    @----.__ 7 лет назад

    nice balls :)

  • @megadiddydave
    @megadiddydave 9 лет назад

    Hi Kris.
    I really like the idea of an encoder as a closed loop controller for the stepper motor, i see this as a 'poor mans' servo motor. My question is :- is the 'juddering' i.e. the 'large' amount of movement at the ends of the wooden channel a inherent feature of the stepper motor or is this a feed back loop timing issue ?
    Sorry to get a bit technical but my project is a CNC router and using an encoder would solve any 'missed' steps - so in your code is the encoder saying 'i am half a step away from my target position' but you stepper motor/driver cannot resolve the half step and does it's best...so would a 2:1 gearing on the stepper motor created a more stable channel?

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад

      megadiddydave Hi, the juddering has more to do with the camera capture delay and precision. I also wanted fast movements so I didn't care about some PID overshoot. for a CNC you really don't wat that.
      But what you describe can happen if your steppermotor steps are bigger then the resolution of the encoder. As long as the step resolution is bigger then the encoder resolution everything should be fine. (you can use a gear or smaller microsteps for that if needed). Good luck with your project!

    • @marifhossain
      @marifhossain 9 лет назад

      megadiddydave The juddering is coming from the gear backlash. The encoder should be connected directly to the motor shaft to avoid it. Kris missed the the point from the very beginning.

  • @nejcar92
    @nejcar92 9 лет назад

    What kind of 3D printer are you using? Good channel!

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад

      nejcar92 Tnx!, Its a Prusa i3 (RepRap) variant. I bought it as a kit form a local guy. Its not the best or the easiest printer. But it is cheap, and does the trick for me.

  • @IsaacC20
    @IsaacC20 7 лет назад

    That's pretty awesome.

  • @ramij4898
    @ramij4898 7 лет назад

    Nice

  • @cryptocrack
    @cryptocrack 9 лет назад

    which library are you using to capture the ball position

  • @fvgm
    @fvgm 8 лет назад

    Wow. Awesome project. Thank you.

  • @zabermunna721
    @zabermunna721 8 лет назад

    teach me master !

  • @pixware
    @pixware 7 лет назад

    Nice jobe !!!

  • @باسمجاسم-ع2ق
    @باسمجاسم-ع2ق 7 лет назад

    nice work

  • @mykhailomamchur4056
    @mykhailomamchur4056 7 лет назад

    Good music!!!

  • @mangeshdeokar3039
    @mangeshdeokar3039 6 лет назад

    Bravo!!

  • @khanidyaks8463
    @khanidyaks8463 7 лет назад

    cool, man!

  • @RyanPereira101
    @RyanPereira101 9 лет назад

    Love it brilliant.

  • @paulettenavarro6097
    @paulettenavarro6097 8 лет назад

    hermoso

  • @noneofyou78
    @noneofyou78 9 лет назад

    i want to know, what software you use?

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад +1

      Wayan Dharma Xcode for programming, rhino for 3D modeling. The balancing software is something I wrote myself. check the description for the github link :)

  • @millenia2222
    @millenia2222 8 лет назад

    TEACH!!!

  • @RobbieM07x
    @RobbieM07x 6 лет назад

    Too much "P" TERM, raise the "I" gain, and add some "D" term to smooth it out. Great video though.

  • @Techn0man1ac
    @Techn0man1ac 9 лет назад

    Автор вообще крут!

  • @Jai_Lopez
    @Jai_Lopez 9 лет назад

    what type of MCU are you using? i dont see the .ino file

    • @KrisTemmermanNP
      @KrisTemmermanNP  9 лет назад

      +jai Lopez Its an Arduino Due (but it can run on any arduino). The github link is just the PC (or Mac) side I think. This is the arduino part -> github.com/neuroprod/ClosedLoopDriver and matching video: ruclips.net/video/Z6OMT1fIQnU/видео.html.

    • @Jai_Lopez
      @Jai_Lopez 9 лет назад

      +Kris Temmerman thanks, can you explain to me where is the PID found ? i want to learn from your pid setting how and what i should be focusing for pid? i made my own Servo
      "DIY" and want to know how to use pid to control its direction of step in increments like any servo, i build my own Hbridge and i have a POT and a dc mototr with a 3D printed Gearbox i made but no control so i guess this is the one thing i need to learn before i can start moving the horn/shaft/arm, so i was hoping i can learn from yours so that i can apply to Arduino

    • @Jai_Lopez
      @Jai_Lopez 9 лет назад

      +Kris Temmerman as far as Visual Studios im fairly new tho i do write in C++ but im a;lways stuck with some friendly folks who pass me their code like you have when i upload it to VS and it ask me to Attach rather then play or build and run thats the easy part for me just click run or one of those but sometimes like now for your code i dont see the RUN i see Attach and im not sure attach to what

  • @4NDR3SV
    @4NDR3SV 8 лет назад

    Kris, what kind of sensor did you use?

    • @KrisTemmermanNP
      @KrisTemmermanNP  8 лет назад +2

      a rotary encoder for the rotation, and a webcam for the position

    • @padmapriyavenkatesan4746
      @padmapriyavenkatesan4746 7 лет назад

      Hey! is there any way in which we can reduce the trembling of the balancer? the system is very sensitive

  • @surfcello
    @surfcello 8 лет назад

    looks as if your differential coefficient is still too low, judging by the oscillations.

    • @illusivec
      @illusivec 8 лет назад +1

      +surfcello I looks too high to me