How to control a DC motor with an encoder

Поделиться
HTML-код
  • Опубликовано: 23 дек 2024

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

  • @Ben_Lucy
    @Ben_Lucy Год назад +46

    I looked into it a bit more, the disadvantage of this method is that it is only looking for encoder A pin rising. This means that wiggling the motor back and forth a little looks like the motor is moving continuously forwards. It also counts more than one step if the input bounces. Instead: checking for all four quadrature transitions fixes these problems and means 4x as many pulses per rotation which means you can be more precise.
    I added these lines at the beginning:
    #define readA bitRead(PIND,2)//faster than digitalRead()
    #define readB bitRead(PIND,3)//faster than digitalRead()
    I changed the attachInterrupt line so that it triggered on CHANGE rather than rising, and added another line for the B encoder pin:
    attachInterrupt(digitalPinToInterrupt(ENCA),readEncoderA,CHANGE);
    attachInterrupt(digitalPinToInterrupt(ENCB),readEncoderB,CHANGE);
    And I changed the functions triggered by the interrupt to this:
    void readEncoderA(){
    if(readB != readA) {
    posi ++;
    } else {
    posi --;
    }
    }

    void readEncoderB(){
    if (readA == readB) {
    posi ++;
    } else {
    posi --;
    }
    }
    This eliminates bouncing (posi will just count forwards and then backwards with each bounce), increases precision as you get 4x as many interrupts triggered per rotation, and prevents you from 'tricking' the encoder by moving the motor back and forth by a small amount. Credit to Cattledog on the Arduino forums in 2017.

    • @MattCreativeStudio
      @MattCreativeStudio Год назад +7

      Very helpful - This ended up making my code work and support bi-directional control.

    • @muhammadtaimoor876
      @muhammadtaimoor876 11 месяцев назад +4

      YOU ARE A LIFESAVER. THANK YOU SO MUCH.

    • @msr15334
      @msr15334 10 месяцев назад +4

      You can set a interrupt on both pins and use it to access a lookup table. As a bonus, this can achieve full resolution of encoder.

    • @fear7356
      @fear7356 28 дней назад +1

      thanks a lot for this!

    • @abdulazizbokhari6695
      @abdulazizbokhari6695 15 дней назад

      thank you. my motor driver doesn't have PWM pin it's HW-95 what should i do ?

  • @rokonuddin72
    @rokonuddin72 3 года назад +162

    One of the best videos I have come across. The combination of the hardware setup and linking this to the block diagram and finally linking block diagram to code is an inspiring idea.

    • @curiores111
      @curiores111  3 года назад +26

      Thank you Rokonuddin. I'm very pleased that the format resonated with you. When I finished the video I was sure that I had covered too much. But I think that it can be worth the effort when you actually want to understand the details of how a system works.

    • @conraddiaz2274
      @conraddiaz2274 2 года назад +8

      Hi @@curiores111 , the scope of this video is perfect. If you had a feeling that it was too much, perhaps for a beginner it may be too much. For someone that already has a basic understanding and some experience coding it's absolutely perfect!! So well done!! Thank you so much.

  • @cristianotulio7716
    @cristianotulio7716 3 года назад +58

    A couple of months of my graduate course in just 10 minutes! :-D ... Thanks for sharing!

  • @my3dcncpnp408
    @my3dcncpnp408 Год назад +2

    So well done! Saved me a lot of time...

    • @curiores111
      @curiores111  Год назад +2

      Glad to be of help! And thank you so much, you are far too generous!

  • @Ben_Lucy
    @Ben_Lucy Год назад +8

    Feel like I struck gold finding this video - huge thank you for making it!

    • @curiores111
      @curiores111  Год назад +3

      Sure, and thanks for stopping by. 😉

  • @lightman500
    @lightman500 9 месяцев назад +1

    I have to commend you on the best tutorial I have seen on motor control using PID! As others have mentioned you are clear concise and to the point. Your animations and diagrams support your lecture perfectly. Your progressive coding makes it easy to understand your logic flow....given the real world, converted to math, and then to software. Kudos!

  • @fear7356
    @fear7356 28 дней назад

    can't be more grateful to have found channels like this

  • @luccarodrigues781
    @luccarodrigues781 3 года назад +25

    The near-perfect tutorial. Clear, concise, the animations are fluid and easy to understand, and straight to the point. Nice!

  • @andalibrahman1263
    @andalibrahman1263 3 года назад +34

    This is a great tutorial: short and very precise explanation, yet covering a vast area on the subject. Pleaee make more videos like this.

  • @co4erol
    @co4erol 2 года назад +3

    at 2:26 trajectories are wrong. When she said clockwise, it meant counter-clockwise. When she told counter-clockwise, it meant clockwise.
    We can see the results at 2:47. When she turns the arrow clockwise, the number goes to negative and vice versa.
    I'm fan of your channel by the way :)

    • @curiores111
      @curiores111  2 года назад +2

      Good observation. The gearbox actually reverses the direction of travel, so it's true that it triggers in the opposite order compared to the encoder by itself.

  • @TricksterJ97
    @TricksterJ97 3 года назад +22

    This, in comparison with many other videos on the subject, is very well done!

  • @lucasinacio8251
    @lucasinacio8251 3 года назад +6

    The video is very well produced, the code explanation is amazing and made me (as a mechanical engineer with rudimentary understanding of motor control) feel capable of implementing this, well done!

    • @curiores111
      @curiores111  3 года назад +4

      Thanks Lucas! I'm glad you feel that the level is right. It is hard to justify putting all that code in from a youtube video perspective, but when it actually comes down to implementing it yourself, it's probably the most important part.

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

      @@curiores111 You managed to keep the (usually boring) code exposure very well connected with the practical application so it wans't boring anymore hehe

  • @Greebstreebling
    @Greebstreebling 2 года назад +6

    Nice combination of electronics, maths and programming. I'd come across those PID values in my Sitech motor controller and now I know what they are ! Thanks for clear presentation and explanation.

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

    When my professor told me he can´t tell me how to implement pid into a microcontroller I thought it must be a very hard thing. Finally I came across your video and this was poor luck because my search on youtube gave nothing like yours. So thank you very much for taking your time to explain all of this. I like control theory because it´s hard to understand but If you understand it makes you proud.

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

      Sounds like my profs. :D
      Thank you so much for your comment. Your comment is literally the reason I make videos.
      I agree. Control theory is challenging, rewarding, and exciting.

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

      Theory is dry but what you show makes more fun at least :D Hey I have an idea do you think an encoder attached to a bldc motor would allow me to set the motor speed perfectly with your pid method ? I have such a motor left from an old hdd and I would play around with your code. I only knew how to do it with op amps but changing code is faster than changing capacitors and resistors.

  • @MrStrangerr2002
    @MrStrangerr2002 11 месяцев назад

    As a hobbyist I was struggling to get position control working on diy toy robot build, and this video has cleared a lot of questions for me. Thank you for the share!

  • @jeffdawson7936
    @jeffdawson7936 2 года назад +4

    I just discovered your channel -- it's fantastic! I appreciate your clarity, pace, and your choice of what to focus on in each video. I hope there will be more videos in the future!

    • @curiores111
      @curiores111  2 года назад

      Appreciate this Jeff. I am still working on some videos, but it's definitely a challenge to find the time and the right topics.

  • @multilaton4835
    @multilaton4835 2 года назад

    Whole PID, encoder, Basic control theory with real applications under 10 minutes. Thank you and you are very well on educating.

  • @johndiamond2548
    @johndiamond2548 2 месяца назад

    Does a great job of setting the ground work for "How to control multiple DC motors with encoders".

  • @sammflynn6751
    @sammflynn6751 3 года назад +1

    almost nobody on the internet used the term "Finite difference approximation", saved me a lot of hassle

    • @curiores111
      @curiores111  3 года назад +3

      Yeah, that's "math talk". More specifically numerical methods. It's kind of funny how educational discipline vernacular tends to have a divergent evolution. Makes vertical disciplines like control theory even more difficult for a beginner (as if they weren't hard enough already).

  • @Merfnad
    @Merfnad 3 года назад +29

    Super clear and straight to the point, I hope you're going to do more of these!

    • @DarrinSK
      @DarrinSK 2 года назад

      guess I am just a fucking idiot then

    • @Merfnad
      @Merfnad 2 года назад +2

      ​@@DarrinSK I know the feeling, but it probably just means you need to start with some other tutorials on whatever part of this seems complicated.

  • @brandenchristiansen8529
    @brandenchristiansen8529 Год назад

    Extremely well done. Have been utilizing an adaption of this PID control loop for leveling. Instead of using an encoder I pull data from a MPU6050 using the MPU6050_light library usually included in the Arduino IDE. Then Set the target to 0. It works really well!

  • @bleach96215
    @bleach96215 3 года назад +6

    Keep the hard work , I love how you connect the theoretical part with hand on application 😍

  • @Face_the_Reality
    @Face_the_Reality 11 месяцев назад +1

    My encoder is not giving values or giving unexpected and illogical values but when I build circuit which also includes the output Z wire and use a library Buttonfever then it gives appropriate values. Whats the reason?

    • @curiores111
      @curiores111  11 месяцев назад

      Sounds like your encoder probably has a different interface than the one I used. Certainly, there's no compatibility guarantee with electrical devices -- always consult your datasheets (-- or, a dedicated tutorial, if available, is always useful).

    • @Face_the_Reality
      @Face_the_Reality 11 месяцев назад

      @@curiores111 may be. Thanks for your reply

  • @curiores111
    @curiores111  3 года назад +8

    There's an update to the tutorial to include the volatile directive and the ATOMIC_BLOCK macro. These prevent potential issues with the interrupt. See this page for an example:
    www.arduino.cc/reference/en/language/variables/variable-scope-qualifiers/volatile/

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

      This page is down, FYI

    • @curiores111
      @curiores111  3 года назад +1

      @@PatchBOTS Ah yes missed that one, still updating the website...

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

    One of the best technical content I've ever seen on youtube. Please keep posting content!

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

      Thank you, friend. I have a couple even more technical videos planned for hardware implementation of controls, so stay tuned.

  • @darrennewell3845
    @darrennewell3845 3 года назад +1

    I so appreciate that you wrote the code out rather than called library functions - I've been working to control a motor with encoder via an MCU that doesn't work with Arduino IDE so seeing the code written out really helps.

    • @curiores111
      @curiores111  3 года назад +3

      Thanks for mentioning this Darren. Originally I thought I would be criticized for not using the library. Surprisingly, I haven't seen that yet. I'm pleased that the presentation I chose was suitable for your work. Good luck with your project.

  • @AminMansor-q4j
    @AminMansor-q4j 11 месяцев назад +1

    Thanks for clear presentation and explanation

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

    it is very clear and percise video and let me say ur voice is very comfort to listen to

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

      glad to hear that, and thank you :)

  • @eduardomeller6926
    @eduardomeller6926 3 года назад +1

    Your RUclips channel has a bright future. Excellent content. Keep up the good work!!

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

      You are too kind. Thank you.

  • @thejaydenx.3231
    @thejaydenx.3231 Год назад

    Thanks to Heavens I found you! THIS IS WHAT I TRULY NEED! Thank You SOOOOOO MUCH.

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

    oh wow! a future Multi-million subscriber channel in it's infancy! what an honor! Amazing content!

  • @mahirdrafi9579
    @mahirdrafi9579 2 года назад +1

    Hi Curio, theses videos are amazing! Please keep up the great work!

  • @rajivdey3103
    @rajivdey3103 Год назад

    you are great Curio, made a great simple to understand tutorial

  • @erikr6382
    @erikr6382 8 месяцев назад +1

    Are those Fritzing diagrams?

  • @mohamedbendary410
    @mohamedbendary410 Год назад +1

    using this method-- how to set a zero position to start with?

  • @NanoElektron
    @NanoElektron 2 месяца назад

    much appreciations for the content and the editing!

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

    You got the same voice tone of a lady on "Element 14" . Although it's a VERY PRECISE tutorial thank you and keep going , I'll test this with a infrared encoder

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

    one of the best tutorials I have ever watched. Have you thought of doing an MPC video?

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

      You're too kind, thank you. Yes, I have, among a couple others. Thank you for the suggestion.

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

    Nice narration - watched it a long time ago but made more sense this time as I have learned more !

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

      glad to hear that! there's a lot to unpack here and experience is everything...

  • @vedarovski4110
    @vedarovski4110 2 года назад +1

    How can we change position value to radian or degrees?

  • @squeakycheex7771
    @squeakycheex7771 Год назад

    Thanks!

    • @curiores111
      @curiores111  Год назад

      How generous! Thank you so much Squeaky Cheex 😉😄

  • @squeakycheex7771
    @squeakycheex7771 Год назад

    For single motor operation, HBRIDGE should be pulled high, then the single motor + should be connected to both A+ and A-, and - should be connected to both B+ and B-

  • @luisgpr1
    @luisgpr1 3 года назад +3

    Impressively well done tutorial. I hope you find the motivation and time to do more of these

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

      Thanks so much Luis. I am planning to do more videos. Feel free to make a request if you come a cross a topic that you feel needs a better explanation than what is currently available.

  • @ImminentDingo
    @ImminentDingo 2 года назад

    at 3:01 why is the motor red/black connected to the controller on A+ and B- instead of A+ and A-?

    • @curiores111
      @curiores111  2 года назад

      Good catch Ducksaws! I can barely even see that The reason is that I've jumped the A and B outs. Putting the driver in this parallel configuration allows the driver to handle twice the current. You can see the connections on the Pololu page: www.pololu.com/product/2999
      www.pololu.com/product/2999#lightbox-picture0J8698

    • @ImminentDingo
      @ImminentDingo 2 года назад

      @@curiores111 oh ok. In this case do you still only need to apply signal to pwm a, ina1 and ina2 and can ignore the b pins?

    • @curiores111
      @curiores111  2 года назад

      @@ImminentDingo Well, when they're jumped you're actually applying the same signal to both pins. So in a sense you can ignore them, but in another sense you're not ignoring them, simply simultaneously activating them. Note that you don't have to set things up this way, I just happened to do this because it's an option for the motor driver I was using that worked well for my application.

    • @ImminentDingo
      @ImminentDingo 2 года назад

      @@curiores111 oh I understand. Did not realize what you meant by jumped. Thanks

  • @PrasannaRoutray97
    @PrasannaRoutray97 8 месяцев назад +1

    Tried the same with a stepper?

  • @PatchBOTS
    @PatchBOTS 3 года назад +2

    This is a really great video. Thank you! It's very helpful for my latest project.

  • @EEAMD-co6nw
    @EEAMD-co6nw Год назад

    very well made video. consise, straight to point, focused, visual and audio on point. very good. edit: subscribed.

  • @Rino6357
    @Rino6357 Месяц назад

    When I try to measure position, turning the magnet gives me negative values of position no matter which way I turn the magnet. I spin it CW and itll be like -20 and then spin it CCW and itd go down to -40

  • @Rolla963
    @Rolla963 Год назад

    7:05
    Could you explain what 1.0e6 stand for in deltaT?

    • @curiores111
      @curiores111  Год назад

      1e6 is calculator/programming language speak for scientific notation. In other words, 1e6 = 1*10^6 = 1,000,000

  • @vagarthgaurav
    @vagarthgaurav 2 года назад +3

    Thank you for the very concise and clear explanation :) really looking forward to use this in my next project.

    • @curiores111
      @curiores111  2 года назад

      glad you thought so! and good luck with your next project. :)

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

    What does the output on the serial monitor at 2:48 shows, what unit is the output in? I know it measures distance but what is it actually?

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

      The positions refer to how many steps the encoder has taken. How that actually translates into the angular position of the motor shaft is determined by (1) how many encoder steps per unit of angle measurement there are and (2) what the gear ratio of the motor is. You can find that information on the spec sheet for the motor.

  • @tunmiseotegbayo6991
    @tunmiseotegbayo6991 2 года назад +1

    Hi, thanks for this tutorial. I have a question. Is there a reason why you didn't use the number of pulses in your calculation

  • @ProfeARios
    @ProfeARios 6 месяцев назад

    Thank you so much for sharing!!!! Greetings from Panama!!!! 🇵🇦

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

    I do belive you just saved my master thesis...

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

      Glad it helped! Thanks for stopping by.

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

      Speaking of it, there is a little 'mistake' in your integrator. There is a 'wind up' effect because it keeps integrating, even if the actuator is already at max power. If you 'clamp' the integrator, when u is 255, there will be significantly less overshooting :)

  • @blackwater7183
    @blackwater7183 2 года назад

    I am trying to figure out how DJI control its gimbals because it doen't look like it uses servos to move the motors. Are they using a micro controller like an aurdiuno to control the gimbal motor?

  • @amrmusa7217
    @amrmusa7217 2 года назад +1

    that was amazingly informative thank you very much for this magnificent work, and the way the overshoot was eliminated was surprisingly accurate, I'll make sure to subscribe.

  • @jonareyhdez153
    @jonareyhdez153 8 месяцев назад

    What happend do if my outputs of encoder print triangles graphics instead of square graphics?

  • @AlexAlex-fo9gt
    @AlexAlex-fo9gt Год назад

    7:50-7:55
    e(t) has dimension V, integral e(t)dt has dimension V*sec, derivative de/dt has dimension V/sec.
    Is it correct to add values with different dimensions ?

    • @curiores111
      @curiores111  Год назад

      There's nothing "wrong" with adding two signals with different dimensions.
      On the other hand, when you add two signals with different dimensions, a question arises: what does the result "mean"? Also, it creates a possible issue: if you rescale either, the sum is no longer the same. So it generates a potential inconsistency, and certainly a likely source of confusion. It's certainly a nice discussion topic.
      As far as this video is concerned, those questions are a non-issue, because e(t) and de/dt, and integral of e(t) dt are *not* added to each other.
      Instead, they are linearly combined with coefficients kp, ki, and kd. Since those coefficients are arbitrary, they would naturally encode the units required to make the dimensions consistent.
      Assuming a dimensionless u(t), that implies kp has units of 1/[e(t)], the integral has units of 1/([t][e(t)]), and kd has units of [t]/[e(t)], where [t] represents the units of t and [e(t)] represents the units of e.
      So, they do exist, although admittedly typically ignored and potentially generation a source of confusion at some point for someone trying to re-use coefficients.

  • @KishorParida
    @KishorParida 2 года назад

    I used a PID controller to make a self-balancing robot but the motors I used were stepper motors, though I achieved the most precise positioning yet the implementation was very complex. The stepper motors puls timing is exponential where the PID was failing

    • @curiores111
      @curiores111  2 года назад

      oh yeah sounds difficult. I think usually people do the balance bot with DC motors. If you use steppers probably have to tweak the control algorithm a bit.

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

    Excellent Video. It really was what i was searching for!!

  • @kijijikhalid601
    @kijijikhalid601 2 года назад +1

    wow, what a magnificent combination of hardware and software to explain the PID control. It's was a dream to understand it, and I got it now. How CAN THANK YOU💞

  • @naboulsikhalid7763
    @naboulsikhalid7763 2 года назад

    this video is an other level of programming, that make an other challenge and make me better programmer. Thank you very much

    • @curiores111
      @curiores111  2 года назад

      how kind. Thank you. I wish you luck in writing many beautiful programs. :)

  • @BedoAshraf
    @BedoAshraf Год назад +1

    hi I see that the encoder is connected to 5V of the Arduino why the motor driver is not connected to 5V of Arduino?! i used to do that with normal DC motor

    • @iota_i_1
      @iota_i_1 16 дней назад

      Friend , arduino can not provide I current for components like motors , servo motors (high Torque) , and some components. The here is connected to a motor drive and motor driver is connected to external power supply . U can only power only low power consuming sensors .
      What will happen if u connect motor drive to 5v pin of arduino???
      Answer: here the pulse coming out of the motor will be disturbed . U can not accurately measure the position of the Shaft. Why the pulse coming out from motor is disturbed ?? Because the motor drive is connected to arduino the motor will take the current from arduino due to high consumation of current the voltage get disturbed there will be fluctuations in voltage , so the pulse is also noised out .
      That's why using external power supply

  • @martinjadlovsky7510
    @martinjadlovsky7510 3 месяца назад

    Great video, but im kinda stugling at position measuring maybe because im using diferent wiring ? Ii dont knom, but there is only 0 at the serial monitor.
    could someone help me ?

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

    Amazing this is very helpful!

  • @PlanB-3751
    @PlanB-3751 Месяц назад

    Thank you for this informative video👍
    Is there a way to make a s-curve motion for the motor?
    Cheers🎉

  • @greendsnow
    @greendsnow Год назад

    what happens to the code when you add a gearbox to the motor?

  • @judyteresazacharia3348
    @judyteresazacharia3348 9 месяцев назад

    Where I can find the library that is given in the code

  • @filippeternel1194
    @filippeternel1194 9 месяцев назад

    Does such a code only work for incremental encoders or can it also work for absolute encoders?

  • @squeakycheex7771
    @squeakycheex7771 Год назад

    Wouldn't motor power ground lead be connected to second pin A- rather than B-? Also, don't you need VCC +5VDC out from Arduino to VCC pin on motor controller to power controller?

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

    Which part of the function you defined (3:50) sets the speed and how is that adjusted? Also, how accurately can you control RPM using this method?

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

      pwmVal sets the "speed" (really, it sets the duty cycle of the PWM signal). You can control the RPM well with position control by writing some wrapper code around the PID control. I did this in another video: ruclips.net/video/3ozgxPi_tl0/видео.html

  • @aaronallenantolin1765
    @aaronallenantolin1765 Год назад

    Is it possible to have 3 target position for using this code?

  • @everest8km
    @everest8km Год назад

    Great ! One of the best tutorial on DC motor control. When I run part4.ino, how to close the autoscale in serial plotter?

  • @inhdungho9509
    @inhdungho9509 2 года назад

    Excuse me, so in clockwise direction, Is output A before output B or output B before output A ? I got confused in Part 1 and Part 2, they seems not the same

  • @It4heath
    @It4heath Год назад

    Very nice video, and close to what I'm looking at doing. My plans so far will be with any Arduino board, I'm wanting to have a AS5600 read a direction/step every second and write/save that info, so an average can be calculated for later use. Then once a minute or so read another AS5600 with a Stepper motor and have the stepper match the average direction/steps of the other one.

  • @charleythom8031
    @charleythom8031 2 года назад

    why do you devide by 1.0e6 ? Where does that come from?

  • @getlost1997
    @getlost1997 3 года назад +1

    Hi thank you for posting! Would you be able to give me some pointers of how to do PID to reach a target velocity rather than target position?

    • @curiores111
      @curiores111  3 года назад +3

      The first thing I'd try is simply implementing the same feedback loop in terms of velocity and see if that's good enough for your application (this might not work - could be a lot of jitter. There are other more advanced methods that you could try - but it's a good/easy place to start). You can estimate the velocity, the derivative of the velocity, and the integral of the velocity using methods similar to the ones shown here. For example, you could compute the velocity as:
      velocity = (position - previousPosition)/deltaT
      where "previousPosition" is the position stored in the previous iteration of the loop.

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

      @@curiores111 thanks I'll give that a shot today :)

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

    Excellent, I just finished following your tutorial and everything worked out great. Still playing with the PID values to get the sinus as close as possible to the target but I think the motor just isn't precise enough.

    • @curiores111
      @curiores111  3 года назад +2

      Good work! Using a motor with a higher gear ratio will help with precision. (of course, if you need much better precision a stepper is often a better choice) Adjusting the PID parameters can help, but won't be able to overcome some of the limitations of the motor, as you're finding.

  • @littlestguy9589
    @littlestguy9589 2 года назад

    Hello, I have one little problem. Once my motor reaches the target in the serial plotter, the shaft stops rotating. Any idea of why this could be happening? Thank you

    • @curiores111
      @curiores111  2 года назад

      If you reach the target, the motor should no longer rotate. Do you expect something else to happen?

  • @Jim_One-wl4ke
    @Jim_One-wl4ke 8 месяцев назад

    This is awesome, and you are a good instructor and a good presenter. Very good content flow esp with lots of diagram & graphics to add with the presentation flow 👍..love it. Thanks for making this tutorial ❤

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

    My dear
    Curio Res!
    I don't know how to send the commands to Arduino?
    Use a potentiometer or other encoder to command the direction and speed of the DC Motor?
    How do you do it in the movie???

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

      I just assigned a target inside the code. If you want to use a pot or a rotary encoder to set the target, you could (a) connect your rotary encoder/pot to the arduino (b) write code to read from the rotary encoder/pot and (c) set the target based on the value of the rotary encoder/pot

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

      @@curiores111 Thanks again lovely Jewelry

  • @arelectroprojects
    @arelectroprojects Год назад

    Nice Detail Explanation . can we change Target RPM when Motor Is the Running condition ?

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

    Helped me a lot. The best video on this topic. Have subbed without thinking. You deserve a lot more audience. Keep going 👏👏👏

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

      Thank you, friend. You are too kind.

  • @Dasol0246
    @Dasol0246 2 года назад

    If i want the shaft to start at 000 degrees on startup would I need a limit switch to detect 000 degrees?

    • @curiores111
      @curiores111  2 года назад

      You need some way to calibrate the starting position... limit switch or otherwise.

    • @Dasol0246
      @Dasol0246 2 года назад

      @@curiores111 Thanks have it almost hooked up to a nano and l298n motor driver, double checking my wiring.

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

    can we use that on hi torque motor for antenna rotator?

  • @shubhamnayak9369
    @shubhamnayak9369 3 года назад +1

    Nice video... Make such videos which gives practical implementation based on Theory.. looking for more videos..keep it up

  • @GlobalDeviceSolution
    @GlobalDeviceSolution 2 года назад

    Excellent video. So much useful information in a very concise delivery.

    • @curiores111
      @curiores111  2 года назад

      Thank you for the kind words, Bill.

  • @abdulazizbokhari6695
    @abdulazizbokhari6695 15 дней назад

    There is no PWMA input in my motor driver. I am using HW-95 motor driver.
    Is there q solution?

  • @chrismaalouf-d2k
    @chrismaalouf-d2k 9 месяцев назад

    Very interesting! If i want to set a speed target, what should i do? Thanks for responding.

  • @johnpuckett4032
    @johnpuckett4032 2 года назад

    Another great video CR, thanks a bunch!

  • @sumankar4873
    @sumankar4873 11 месяцев назад

    can’t we use BTS7960 motor driver with arduino ?

  • @笑谈-f4v
    @笑谈-f4v Год назад

    It is a very useful video. Now I want to control a coil motor with a ACS driver. The quarter encoder signal is not symmetrical. Phase A and Phase B is not exactly 90 degree. The ACS driver always meet encoder not connected error.
    So for a unsymmetrical and not exactly 90 degree dealy encoder, may you suggest a suitable motor driver? Thanks in advance.

  • @lawrencestern8176
    @lawrencestern8176 2 года назад

    I want to control the position of some mini geared motors with quadrature encoders. Can I use this code? I have 4 motors inside a prosthetic hand I am making for my daughter

    • @curiores111
      @curiores111  2 года назад

      The code is applicable to any dc motor with an encoder (although there is always potential for some tweaking being required depending on the hardware).

    • @lawrencestern8176
      @lawrencestern8176 2 года назад

      @@curiores111 thank you so much

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

    What if the direction changes after encA goes high but before encB goes high? Wouldn't the position get out of sync? How would you reset this then?

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

    how to connect 4 dc motors with encoders with motor driver and Arduino? Or which motor controller do I need?

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

      You need a lot of pins to connect 4 motors. You could try a Arduino Mega, but that probably doesn't have a fast enough clock speed to handle the interrupts from all four. You could consider something faster, like an esp32, arduino due, or another arm based microcontroller (there are several made by adafruit).

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

      @@curiores111 Thank you for your reply. Arduino Mega has only 6 digital pins so I can not able to use that. So can I use two Arduino's with two motor controllers or One Arduino due with two motor controllers? I want to use those dc motors for controlling Mecanum wheels. Please suggest an option for that. can I go with raspberry zero? Thank You

  • @mathmaker6946
    @mathmaker6946 Год назад

    Please do a video using LQR control in arduino! The quality of your explanation would be super!

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

    Excellent ! An objective, clean explanation and good narration as well!

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

    according to what we setting target position and what is the position unit for example angle or meter ? i don't un

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

      neither, this is setting encoder pulses. If you want to set position you use the encoder and motor characteristics, like gear ratio and pulses per rotation. I explain it briefly near the end of another video: ruclips.net/video/3ozgxPi_tl0/видео.html

  • @mehmetbilen1667
    @mehmetbilen1667 2 года назад

    Hello I don’t have pwm pin so what I should to write to analogWrite ? May you help please

    • @curiores111
      @curiores111  2 года назад +1

      no pwm pin?? What microcontroller are you using Mehmet?

    • @mehmetbilen1667
      @mehmetbilen1667 2 года назад

      @@curiores111 sorry that my wrong question I’m working on bionic hand and I use some n20 gear motor with 8838 motor so my question is May you help me about how should be full rotation and full return about motor forward and backward ? Do you have any mail or website for contact with you ? My thank you

  • @ansonpaul2538
    @ansonpaul2538 2 года назад

    Hi can i use another external potentiometer to give the target ?

    • @curiores111
      @curiores111  2 года назад +1

      Certainly. You can set the target using something like this:
      docs.arduino.cc/built-in-examples/basics/AnalogReadSerial
      and then set the target equal to a multiple of the potentiometer reading.