How Rotary Encoder Works and How To Use It with Arduino

Sdílet
Vložit
  • čas přidán 3. 07. 2024
  • howtomechatronics.com/tutoria... ► Find more details, circuit schematics and source codes on my official website .
    In this tutorial we will learn how rotary encoder works and how to use it with Arduino. A rotary encoder is a type of position sensor which is used for determining the angular position of a rotating shaft.
    Visit HowToMechatronics.com for more Tutorials, Tips, Projects and How It Works videos:
    ► howtomechatronics.com/
    Like my page on Facebook:
    ► / howtomechatronics
    Add me on Google+:
    ►plus.google.com/+Howtomechatr...
    Music: Aduro by Jens Kiilstofte (machinimasound.com/music)

Komentáře • 267

  • @fanBladeOne
    @fanBladeOne Před 5 lety +7

    Thanks once again for a greatly instructional video. After watching not only do you understand the principle behind it, you also have a piece of working code at the ready. Thanks alot :)

  • @badbush5
    @badbush5 Před 6 lety +2

    Fantastic! Looking at pictures of waves just didn't do it for me. This video completely cleared it up. Thank you! Subscribed.

  • @cdweng840
    @cdweng840 Před 6 lety +3

    Brilliantly explained from theory to application. Well done!

  • @jp040759
    @jp040759 Před 3 lety +13

    WOW. Finally I understand the rotary encoder logic. Best explanation I have run into in 10 years. Your description turned on the big light bulb on in my brain and I understand it now. The code is so simple too. THANX!!!!!

  • @waterman7733
    @waterman7733 Před 6 lety

    your explanations are so clear, makes it easier to understand how this works. thank very much!

  • @sub-arts128
    @sub-arts128 Před 3 lety +2

    well done. thats the best explanation for rotary encoder i ve seen so far

  • @slimydroid
    @slimydroid Před rokem

    Many thanks for the clear guide on how encoders work, I found the animated graphics particularly useful.

  • @sgtrumbi2265
    @sgtrumbi2265 Před 5 lety +9

    Just plain and simple explanation. Great video, exactly what I was looking for. Thank you so much! 😊

  • @camilo7087
    @camilo7087 Před 7 lety +38

    please no stop .. you explain so good

  • @mrcalico7091
    @mrcalico7091 Před 7 lety +13

    Great Job, articulate and directly to the point. Thank You!

  • @mirkomueller3412
    @mirkomueller3412 Před 7 lety

    Great tutorial !!! Helps me so much doing my current project. BIG THUMBS UP

  • @256k_
    @256k_ Před 2 lety

    Great stuff! I was initially looking at some library to handle this but it’s so easy thanks to your explanation I’ll just handle it myself

  • @vnesterov1817
    @vnesterov1817 Před 7 lety +6

    You are the Man! Thank you: very clear and very consecutive instructions and video. Great job.

  • @globalbusinessmachines3122

    You are my savior in ELECTRONICS.

  • @fouzaialaa7962
    @fouzaialaa7962 Před 8 lety

    awesome seeing your videos again its been a long time since you uploaded a video !!

  • @jaimeriquelme6727
    @jaimeriquelme6727 Před rokem

    Thanks Mechatronics for your time and work. From Sydney all the best. 👍

  • @loucostello3111
    @loucostello3111 Před 6 lety

    This guy is the greatest.

  • @SajalRajGautam
    @SajalRajGautam Před 7 lety

    Very helpful! Thank you so much! :)

  • @ricardocalletejada6707

    This is better than searching for confusing datasheets on the website. THANK YOU A LOT

  • @Sasch600xt
    @Sasch600xt Před 7 lety

    Thank you very much !!! Now i understand it :)

  • @0sekful706
    @0sekful706 Před 4 lety +1

    Amazing, thank's a lot!

  • @Three2NineProject
    @Three2NineProject Před 7 lety

    Simple and good explanation

  • @NanoIndustries
    @NanoIndustries Před 4 lety

    That's What I Want To Know Thanks

  • @HellaFunnyShorts
    @HellaFunnyShorts Před 7 lety

    great video. simply and to the point explanation

  • @cakdham4607
    @cakdham4607 Před 7 lety

    Awesome explaination.. Regards from Indonesia

  • @FOJOM13
    @FOJOM13 Před 3 lety

    Very informative! Thanks!

  • @boharihamen
    @boharihamen Před 6 lety

    Thanks for the video. Great Job and effort to produce it.

  • @GabrielSousa-hw4mg
    @GabrielSousa-hw4mg Před 6 lety

    omg you explain so good thanks

  • @thomashvnmusic
    @thomashvnmusic Před 7 lety

    Really helpful, thanks.

  • @efrailustun
    @efrailustun Před 3 lety

    Great job bro, thanks for everything.

  • @yoramstein
    @yoramstein Před 6 lety

    Good explanation, thank you.

  • @Keith12001
    @Keith12001 Před 6 lety

    Excellent videos, thank you

  • @duneeshasuloshini8567
    @duneeshasuloshini8567 Před 5 lety

    great explanation! Thanks a lot.

  • @ROBJECTS
    @ROBJECTS Před 2 lety

    Thank you friend!

  • @muratcanbarut64
    @muratcanbarut64 Před 5 lety +1

    Very good explanation

  • @MrAdd25
    @MrAdd25 Před 3 lety

    thanks, the best explication!!!

  • @bcinsteadof3
    @bcinsteadof3 Před 6 lety +4

    Wow, such elegant code...My overly complex code didn't work well when I spun the encoder quickly, this works flawlessly. Thanks!

    • @TheChrisey
      @TheChrisey Před 3 lety +1

      It's not that elegant tbh, it should be implemented with hardware comparators and interrupts

    • @jimwithheld7217
      @jimwithheld7217 Před měsícem

      @@TheChrisey Agree: the example in the vid is fine
      for slow speeds, and when there is feedback, such that if a count is missed, or extra, the user will self-correct, and everything is fine. For higher speeds, you need some hardware and maybe counters, which take care of the counts, and the main software just reads the counter any time it needs the values. Some of the Microchip PIC family have a hardware module built in. A quadrature Decoder. But you can also craft with some of the "soft" progamable gates, e.g. CLB and such.
      For very high speeds, e.g. motors at thousands of RPM, you can't really just poll the pins in a loop: you need hardware assist. Or very fast interupts might get you some of the way.
      But again: the example is fine for the right kinds of slower stuff.
      Also: switch-bounce shaping on the pins can be important, so you only get 1 count per count, not many. I did not look too deep at the code to see if maybe its state always handles that OK enough. A resistor and a cap might be enough, depending on the encoder used.

  • @heshteach8212
    @heshteach8212 Před 7 lety

    Grate job.. It was really effective for me.. thx alot and carry on..

  • @dgb5820
    @dgb5820 Před 6 lety

    Great instructional video

  • @javierferrer4634
    @javierferrer4634 Před 5 lety

    Nice video thank you!

  • @apbosh1
    @apbosh1 Před 7 lety

    great tutorial thank you.

  • @antipainK
    @antipainK Před 3 lety

    Great video, short and to the point :)

  • @Anton-wc7lb
    @Anton-wc7lb Před 9 měsíci

    Awesome video, thanks! :)

  • @jeffbeck6501
    @jeffbeck6501 Před 6 lety

    Thank you. Your code worked. I thought that Kevin Darrah's code using interrupts was working for me but it was not. It was skipping all around but your code works perfectly for me with no skipping at all. How u do dat? Thanks man.

  • @BrijeshKhumaar
    @BrijeshKhumaar Před 3 lety

    Thanks that was amazing...

  • @SimpleHumanInNY
    @SimpleHumanInNY Před 2 lety +1

    Thank you 🙏

  • @denadaisicari
    @denadaisicari Před 5 lety

    So great, thanks!

  • @TheJavaSync
    @TheJavaSync Před 3 lety

    Dear Friend, pls, upload another ligh & simply tutorial like this, I loved it, Thx You !

  • @kamranalidoosti9799
    @kamranalidoosti9799 Před 6 lety

    Thank you Dejan. You are a good teacher. Go on!

  • @bigd1266
    @bigd1266 Před 4 lety

    You are the man!

  • @_bluespider5470
    @_bluespider5470 Před 6 lety

    Great video!

  • @voxellab4339
    @voxellab4339 Před 7 lety +2

    Dejan, Great video! thank you. Got it to work. If I turn the dial to quick the nema jump, not smooth and has a pause when reveres. I've tried trimming the drive board and the delay times. Any idea?, thanks again for all you great work.

  • @karlklops3810
    @karlklops3810 Před 7 lety

    very nice and short video keep it up 😊👍👍

  • @minayakarimova
    @minayakarimova Před 3 lety

    Huge thanks

  • @shubhamdubey3585
    @shubhamdubey3585 Před 6 lety

    Nice video buddy keep it up :)

  • @pkteguh8199
    @pkteguh8199 Před 8 lety

    thanks for your tutorial, it helps,regards

    • @pkteguh8199
      @pkteguh8199 Před 7 lety

      referring your tutorial,so is it possible to synchronize two surface speed of conveying belt/goods ?, since the encoder rotated by a surface speed and give the signal as a control to a motor that can produce similar surface speed to another conveyor for example, thanks for your feedback,regards

  • @irfan2189
    @irfan2189 Před 4 lety

    GOOD WORK BRO..

  • @Bianchi77
    @Bianchi77 Před 8 měsíci

    Nice info, thanks for sharing with us, well done :)

  • @LifeGeneralist
    @LifeGeneralist Před 3 lety +1

    Can you do a video on measuring the angle of rotation of the stepper if connected the encoder to the shaft of the stepper and if the shaft is rotated manually?

  • @OMNI_INFINITY
    @OMNI_INFINITY Před 10 měsíci +1

    *Thanks! Recommend making a video on controlling position of a continuous servo using a continuous rotary encoder!*

    • @HowToMechatronics
      @HowToMechatronics  Před 10 měsíci +1

      Currently working on such a video. I will publish it next week.
      Cheers

    • @OMNI_INFINITY
      @OMNI_INFINITY Před 10 měsíci

      Oh, thanks in advance!@@HowToMechatronics

    • @OMNI_INFINITY
      @OMNI_INFINITY Před 10 měsíci

      Another recommendation that is likely easy is a record and playback motion robot arm using servos. Bonus points for making it a pick and place machine with OCR!@@HowToMechatronics

  • @arjunjanardhanan3301
    @arjunjanardhanan3301 Před 8 lety

    Again nice one ! Can you make a separate video on ADXL345?

  • @jugnu361
    @jugnu361 Před 7 lety

    Great Work

  • @endingalaporte
    @endingalaporte Před 5 lety +1

    suscribed, videos are very good, I'm studying mechanical engineering, have to choose If I want to specialise in Mechatronics, your videos help me a lot in my choice, very cool

  • @salmaelasmai5065
    @salmaelasmai5065 Před 7 lety

    thank you this was very helpful, but you didn't talk about the difference beetwen absolute and incremental encoders..

  • @bekhzodkh
    @bekhzodkh Před 8 lety +1

    Nice and clear explanation, thanks for the video. I wonder is it possible to control the LED light intensity using this encoder?

  • @glowpon3
    @glowpon3 Před měsícem

    Such a simple logic to test direction. I finally get it. Thanks so much ^,.'.,^

  • @ElectronGordo
    @ElectronGordo Před 7 lety

    Thanks!

  • @ruffnck4637
    @ruffnck4637 Před 4 lety

    The best one at yutub ¡

  • @afzalqureshi8091
    @afzalqureshi8091 Před 6 lety +2

    output is different from the code it gives only negative values on CW or CCW direction.

  • @er.jugalmandal7736
    @er.jugalmandal7736 Před 7 lety +9

    CAN U MAKE A VIDEO WITH IN MENU USING 16x2 LCD DISPLAY ???

  • @cdersch636
    @cdersch636 Před 6 lety +3

    Do you know the maximum speed of the decoder? Can it turn up to 200 rounds per minute? I tested once and it was not counting correctly - so the question is - was a problem with Arduino or with the mechanic of the decoder?
    Thanks you

  • @ahmedboudi1808
    @ahmedboudi1808 Před 6 lety

    thank you

  • @joost199207
    @joost199207 Před 6 lety

    Great explanation, everything i needed to know.

  • @yashgokhale5238
    @yashgokhale5238 Před 2 lety

    Thanks for uploading the video.
    For some modules above program functions only when INPUT_PULLUP is defined for CLK and DT pins

  • @gvinodkumar4224
    @gvinodkumar4224 Před 6 lety

    very super and good teching

  • @ngobachduong
    @ngobachduong Před 7 lety +1

    Nice explanation and animation.
    But in your code, it will be more accurate if you use interrupt function to detect the change of signal.

  • @sakshamsangwan6811
    @sakshamsangwan6811 Před 5 lety

    What is the least angle it can move ?
    For example
    If I connect it to a shaft of a robotic arm will it give 30 counts with 30 degree change ?

  • @AbhishekKumar1902
    @AbhishekKumar1902 Před 7 lety

    excellent

  • @huliyumain9536
    @huliyumain9536 Před 7 lety

    Great work!Thank U!
    But 20 pulses for one revolution,how can you show 1,2,3,4,5...n degree ,not 1,9,18 degree?

  • @m0gga
    @m0gga Před 7 lety +4

    Hi Dejan, thanks for sharing this helpful tutorial,I would like to use a rotary encoder to replace the menu navigation buttons in my project, your video is very useful.
    I notice that you did not appear to implement any software de-bouncing techniques to overcome the switch noise, yet your example did not appear to suffer from switch bounce. Did you use a hardware filter of some sort?
    Thanks.

    • @krallopian
      @krallopian Před 6 lety +1

      Yeah I was wondering about that. My encoder skips when I move it then when it clicks. So each "notch" counts as TWO. 0... 1,2... 3,4.... 5,6.... I suppose I can code accordingly but, slightly annoying.

    • @Xanty55
      @Xanty55 Před 6 lety

      Yes, my encoder produces the same behavior.

    • @itskevscott
      @itskevscott Před 2 lety

      Maybe the two Serial.print() statements in the loop slow it down sufficiently that the chatter has stopped by the time it looks around again. With a faster arduino like an ESP32 the bouncing may be seen again. Havent tested it but just a thought!

  • @airfilm_it
    @airfilm_it Před 6 lety

    i would like to build a wireless follow focus for cine lens, what's your suggest?

  • @navtejsinghsaini4945
    @navtejsinghsaini4945 Před 7 lety +1

    which animation tool did you use?
    Thanks

  • @microcontrollersprojects2762

    thanks.

  • @sakirdag2976
    @sakirdag2976 Před 4 lety

    Very good

  • @lukaszM46
    @lukaszM46 Před 6 lety

    in this example was the encoder connected to 5v at the common pin and then pins A and B were connected to digital pins with pulldown resistors?

  • @andrijaadamovic87
    @andrijaadamovic87 Před 8 lety +2

    Great

  • @asmaakter2929
    @asmaakter2929 Před 4 lety

    If I use a magnetic encoder circuit in micrometal gear motor ...does it be work like stepper motor
    Wait for a quick reply

  • @michaelcerkez3895
    @michaelcerkez3895 Před 6 lety

    Very good thank you, I love that Black Magic!

  • @aliaaaradi523
    @aliaaaradi523 Před 7 lety

    thanks

  • @dawidwilk7488
    @dawidwilk7488 Před 5 lety +4

    Your code working well but you must put it into interrupt event from rising and falling edge caused by A and B signals.

  • @djy.ainthemix1878
    @djy.ainthemix1878 Před 2 lety

    Very nice

  • @SimranjitSinghMehra
    @SimranjitSinghMehra Před 5 lety

    I made something similar using a potentiometer

  • @muratcanbarut64
    @muratcanbarut64 Před 5 lety

    would you please can you show the circle diagram for stepmotor section, is LCD connection I2C ? thank you

  • @manishsingh2961
    @manishsingh2961 Před 6 lety

    can we use this rotary encoder?
    In bidirectional Bluetooth app led brightness controlar project

  • @BinuMadhav.NetWork
    @BinuMadhav.NetWork Před 4 lety

    can you make a video of digital potentiometer x9c103 with and without Arduino? Thanks in advance

  • @mohammadomar1558
    @mohammadomar1558 Před 5 lety

    nice video

  • @balajijk52
    @balajijk52 Před 7 lety

    Is it possible to design detent switches along with continous rotary knob? and how if its possible?

  • @dunamiscrisostomo5441
    @dunamiscrisostomo5441 Před 5 lety +2

    2:47 that pitch tho

  • @taranagnew436
    @taranagnew436 Před 6 lety

    how many turns does a rotary encoder have and how would i code it so that when i tuen the knob, it goes to the selected menu and i want to press in to select the menu

  • @harishKumar-be7yn
    @harishKumar-be7yn Před 6 lety

    If power failure u can get reset to zero or it stay in its value and continue with next