Adventures in Science: How to Use Rotary Encoders

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ค. 2024
  • Rotary encoders are useful tools for measuring rotation on a shaft. They come in many different forms, including optical, mechanical, and magnetic. In this video, we show you how they work and how to use them on DC motors to ensure that a robot drives in a straight line for a set distance.
    Optical encoder demo: www.hackster.io/ShawnHymel/qu...
    Code for making Fred drive in a straight line: gist.github.com/ShawnHymel/1d...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 109

  • @billsmith5166
    @billsmith5166 3 ปีที่แล้ว +22

    Every time I see a quadrature encoder I imagine the inventor smiling when he thinks of it. It's just such a beautiful concept.

  • @naboulsikhalid7763
    @naboulsikhalid7763 4 ปีที่แล้ว +24

    OH, man, you nailed it. well explained with demo integration. Thank you for sharing knowledge and for giving the opportunity to a person like me to evolve and progress. great video with great value

  • @bikefarmtaiwan1800
    @bikefarmtaiwan1800 5 ปีที่แล้ว +1

    That was great!Flipped from the very basic to the relatively advanced - lots of info. Thanks

  • @bolibardo1514
    @bolibardo1514 2 ปีที่แล้ว

    I have read 20 odd tutorials on rotary encoder. But those miss the philosophy and application of encoders. This video is better than all those 20 videos.

  • @TeagueChrystie
    @TeagueChrystie 6 ปีที่แล้ว +28

    This is fantastic, Shawn and team. Well done, thanks.

  • @jesusesquibel4181
    @jesusesquibel4181 6 ปีที่แล้ว

    Brilliant! This work is much appreciated. Please keep them coming.

  • @gael6364
    @gael6364 5 หลายเดือนก่อน +1

    Getting me through my Masters degree in engineering, thanks Bud

  • @IoTLearner
    @IoTLearner 6 ปีที่แล้ว

    Great tutorial...One step more closer to my Project...Thanks

  • @axelperez5166
    @axelperez5166 ปีที่แล้ว

    Love it, excellent explanation on the workings of encoders.
    Thank you.

  • @TheTinkerDad
    @TheTinkerDad 6 ปีที่แล้ว +10

    So this is the first time I'm watching a SparkFun video - my first impression was like "whoa this guy with the stereotypical scientist costume... wtf is this a comedy?" but for some reason I kept watching and in the end I subscribed. Well done.

  • @mafhper
    @mafhper 2 ปีที่แล้ว

    something similar for devs regarding centering a div.
    the explanation was very good!

  • @mivison
    @mivison ปีที่แล้ว

    Thanks soooo much for this. You don't know how hard it was to find a good tutorial on this subject. Its funny but I have about 4 Arduino books on bots and not a one talk about this. They all talk about line following and other easy stuff. SparkFun, you have made a customer today!!!!

  • @gregorymurad
    @gregorymurad 4 ปีที่แล้ว +1

    Beautiful video. Thank you, sparkfun!

  • @dilipsuthar1836
    @dilipsuthar1836 2 ปีที่แล้ว +1

    Simply superb, good piece of information for new entrants like me in the world of Arduino. Do keep sharing your knowledge....

  • @varunnagpal2258
    @varunnagpal2258 3 ปีที่แล้ว +3

    At 9:47, there is an error in explanation: If B is high (should be low) on A's falling edge, then we know that disc is rotating clockwise
    At 10:02, there is an error in explanation: if there is a falling edge on A and we detect B is low (should be high) then we know that the disc is rotating counter-clockwise

    • @muhammadridhwan266
      @muhammadridhwan266 ปีที่แล้ว

      yeah i noticed this one too. thanks for mentioning it. a bit confused but overall the whole video explanation is very clear.

  • @lumaclite8341
    @lumaclite8341 5 ปีที่แล้ว

    remarkable, well explained. Good work Shawn.

  • @chiparooo
    @chiparooo 6 ปีที่แล้ว

    Very interesting! Good explanations.

  • @TruthInFacts
    @TruthInFacts 6 ปีที่แล้ว +1

    i am glad i found your channel. i have subbed looking forward to looking through your videos

  • @AT-ny4ct
    @AT-ny4ct 5 ปีที่แล้ว +1

    PACKED with info...luv it.

  • @JayasuryaaGR
    @JayasuryaaGR 2 ปีที่แล้ว +1

    Great lecture! Thank you so much🙏🙏

  • @waredetester86
    @waredetester86 3 ปีที่แล้ว

    Amazing explanation. Your the best.

  • @leochen4891
    @leochen4891 4 ปีที่แล้ว +2

    Exactly what I am looking for.

  • @devinmckee5463
    @devinmckee5463 5 ปีที่แล้ว +5

    @ 9:51, "If B is HIGH on A's falling edge, then we know that the disk is rotating Clockwise" Wouldn't we be able to tell if the disk is rotating Clockwise when B is LOW on A's falling edge? Using the videos diagram, I think this logic makes sense. If the disk is rotating Counterclockwise, B would read HIGH on A's falling edge. Please correct me if I'm wrong, I would like to make sure I understand the rotary encoder logic.

  • @chrisBruner
    @chrisBruner 6 ปีที่แล้ว

    Great tutorial

  • @omsingharjit
    @omsingharjit 4 ปีที่แล้ว

    Wow ! So Far your video is so informative about this topic and Even special for me because 1:26 now i know where to find it near by .👍

  • @luissantiagoyaurikacyacuri4160
    @luissantiagoyaurikacyacuri4160 6 ปีที่แล้ว +12

    This video is gold!

  • @bluehornet6752
    @bluehornet6752 5 ปีที่แล้ว

    Awesome video!

  • @moelashrey4923
    @moelashrey4923 ปีที่แล้ว +1

    thank you for that great work ❤

  • @mirellamelo
    @mirellamelo 6 ปีที่แล้ว

    Nice!!!! Tks so much!

  • @bhartitak4084
    @bhartitak4084 6 ปีที่แล้ว

    Can we use rotary encoder for sensing the projection's xy coordinates?
    As we can use Lidar for the same.

  • @anteconfig5391
    @anteconfig5391 6 ปีที่แล้ว

    Thanks for this. I was thinking about buying a servo but now I know I could just make a rotary encoder instead.

    • @zeus-mn9nf
      @zeus-mn9nf 5 ปีที่แล้ว

      Use a good quality encoder. Otherwise go for stepper motor. I personally tried all three. Servo (real rc servo only rotate 180° , 360° servo doesn't have feedback so there just plain dc motors with speed control) , dc motor with encoders and stepper.

  • @yunche9671
    @yunche9671 5 ปีที่แล้ว

    Thank you so much!!!

  • @j.davidslaugh5761
    @j.davidslaugh5761 3 ปีที่แล้ว

    Thank You. You got me off on a I want to learn this stuff start.

  • @wahidhamidy6886
    @wahidhamidy6886 6 ปีที่แล้ว

    thanks a lot sir,
    i 've a question, is rotary encoder and shaft encoder mean the same thing?

  • @mmorena2787
    @mmorena2787 6 ปีที่แล้ว

    Does Sparkfun carry any "thru-shaft" rotor encoders? I'm wondering how to prototype a inverted pendulum without wires creating issues.

  • @PaweSkalczynski
    @PaweSkalczynski 6 ปีที่แล้ว

    Awesome !

  • @Smooth219
    @Smooth219 6 ปีที่แล้ว

    pretty cool!

  • @mushupat
    @mushupat 3 ปีที่แล้ว +1

    If I may share my experience, instead of comparing the rising and falling moments to determine the direction, I'm simply using flags for moving forward, which I set at the end of every direction function and reset at the begining of it. Therefore I always know when my robot is moving forward or spinning/turning to a side, or moving back etc.

    • @user-yb5cn3np5q
      @user-yb5cn3np5q ปีที่แล้ว +1

      Usually encoders use two sensors that are offset at a multiple of 9/10 of a step, same way as in calipers. In this way precision is increased tenfold.

    • @mushupat
      @mushupat ปีที่แล้ว

      Not exactly my point.
      I'm talking about integers or booleans set or reset every time on every action. Then you will have a "source" for many conditions after.

  • @AvantGrade
    @AvantGrade 4 ปีที่แล้ว

    excellent all the way 😍

  • @SawbanHash
    @SawbanHash 5 ปีที่แล้ว

    How would you mount the disc onto the output shaft?

  • @mdandry
    @mdandry ปีที่แล้ว

    Hi, thanks for the video. I recently had an idea for the navigation for bot I’m designing using encoders to essentially map a grid for the bot to travel within. I think my idea is doable. What are your thoughts?

  • @EvanRustMakes
    @EvanRustMakes 6 ปีที่แล้ว +5

    I'll make a library for this if you want

  • @farrukhbashirxhah7997
    @farrukhbashirxhah7997 4 ปีที่แล้ว

    Hi sir
    Could u tell me please
    Can we use PushPull encoder instead of TTL or HTL

  • @Counselor77
    @Counselor77 5 ปีที่แล้ว

    Can I use a Rotary Encoder in a wind vane circuit for wind direction?

  • @SawbanHash
    @SawbanHash 5 ปีที่แล้ว

    would the same code work for optical encoders?

  • @LAKHANPALSINGH-jk5zc
    @LAKHANPALSINGH-jk5zc 3 ปีที่แล้ว

    Sir how use camera in a remote car using arsduino plz reply

  • @alfinuralbab114
    @alfinuralbab114 5 ปีที่แล้ว

    I just try the code showed. But why do I get different value of ticks everytime the coding I uplod to arduino board?
    Regard,

  • @ripu6464
    @ripu6464 6 ปีที่แล้ว

    perfect

  • @Desmessed
    @Desmessed 6 ปีที่แล้ว

    Thanx!

  • @teethy28
    @teethy28 5 ปีที่แล้ว

    where can i buy the magnetic disk and hall effect sensor for this demo?

    • @bspringer
      @bspringer 4 ปีที่แล้ว

      Hall effect sensor is available on e.g. banggood, eBay or AliExpress. Did you find any magnetic encoder disks?

  • @tpc-vids1589
    @tpc-vids1589 4 ปีที่แล้ว +1

    We're do you buy this encoder in the video

  • @magdy890
    @magdy890 3 ปีที่แล้ว

    is it the same for optical encoders ?

  • @bhagavatshinde1083
    @bhagavatshinde1083 2 ปีที่แล้ว

    amazing

  • @franciscojosecamposarizmen4484
    @franciscojosecamposarizmen4484 6 ปีที่แล้ว

    How do you extend the shaft of the yellow motor in order to mount the encoder?, thanks

    • @fransdebruijn6763
      @fransdebruijn6763 6 ปีที่แล้ว

      Francisco José Campos Arizmendi you buy a motor with shafts out both sides.

  • @marciochao4849
    @marciochao4849 4 ปีที่แล้ว

    Do you guys have something with draw wire encoder for Arduino?

  • @imadreamer9526
    @imadreamer9526 3 ปีที่แล้ว

    Best video

  • @AnwarAlfaqeehAlhusseini
    @AnwarAlfaqeehAlhusseini 5 ปีที่แล้ว

    hi
    how we can make dc motor as servo ? with encoder
    or how can i control dc motor shaft to turn 20 degrees 45 degrees 360 degrees etc ?

    • @zeus-mn9nf
      @zeus-mn9nf 5 ปีที่แล้ว

      You can however do not that these encoders are very inefficient.

  • @ncheetamorero8203
    @ncheetamorero8203 6 ปีที่แล้ว +1

    There is so many pins defined....i only have the two encoders. The others i don't understand what they are, please explain.

    • @gilmaimon7355
      @gilmaimon7355 5 ปีที่แล้ว

      Ncheeta Morero read about H bridges. 2 digital output pins for every wheel determine the direction of rotation + 1 pwm output (again, 1 for each wheel) to control the speed of that wheel. This should explain it!

    • @zeus-mn9nf
      @zeus-mn9nf 5 ปีที่แล้ว

      For each motor there are two pins and one pwm pin. For two motors that's 6 pins. There is one standby pin that has to be held high for motor driver to work. And then there are one pin each for encoder output.( If u r using quadrature encoders, then there are 2pins each for a motor). So in total there are 6+1+1+1=9 pins.

  • @bspringer
    @bspringer 4 ปีที่แล้ว

    Where can I get those magnetic encoder discs? I only find those ones from pololu and I'd just like some more options...

    • @user-os1xg1rh4c
      @user-os1xg1rh4c 4 ปีที่แล้ว

      Bastian Springer you can take cheap standard optical encoders, the result will be the same

    • @bspringer
      @bspringer 4 ปีที่แล้ว

      @@user-os1xg1rh4c I'm quite space limited. That's why I was looking for magnetic discs with a hall sensor. But I ordered the ones from Pololu by now and they work perfectly

  • @roinaldopho5785
    @roinaldopho5785 6 ปีที่แล้ว

    Can anyone help me? I don't understand this section:
    // Constrain power to between -255 and 255
    power_a = constrain(power_a, -255, 255);
    power_b = constrain(power_b, -255, 255);
    Why constrain power between -255 and 255? motor speed only 0-255.
    Thank you

    • @roguepathfinder2477
      @roguepathfinder2477 5 ปีที่แล้ว

      Roinaldo Pho it most probably is because it uses and 8 bit data system and can’t handle more than +/- 255.

    • @zeus-mn9nf
      @zeus-mn9nf 5 ปีที่แล้ว

      @@roguepathfinder2477 microcontroller has an 8bit ADC.

    • @roguepathfinder2477
      @roguepathfinder2477 5 ปีที่แล้ว

      zeus 0101 good to know! And i was almost right, that’s a win in my book.

  • @kifahzaidan4505
    @kifahzaidan4505 ปีที่แล้ว

    GREAT

  • @LSUtiger607
    @LSUtiger607 6 ปีที่แล้ว +1

    Where can we find these magnetic encoder discs? Do they have a rpm sensing limit?

    • @denninosyos
      @denninosyos 6 ปีที่แล้ว +1

      Depends on the hall effect sensor and the electronics detecting the pulses.

  • @jbexplosionTV
    @jbexplosionTV 4 ปีที่แล้ว

    Are there any rotary encoders that are 0.75 inches?

  • @perceyjakeson3634
    @perceyjakeson3634 5 ปีที่แล้ว

    Is it possible to measure distance using rotary encoders?

    • @ShawnHymel
      @ShawnHymel 5 ปีที่แล้ว

      Yes, if you watch the video at around 7:53 (th-cam.com/video/oLBYHbLO8W0/w-d-xo.htmlm53s), you'll see that I set the robot to measure millimeters and stop after it's traveled 1000 mm. For a human-scale example, measuring wheels (like this one www.amazon.com/TR-Industrial-Collapsible-Measuring-Yellow/dp/B01018D7MS/ref=lp_3753421_1_1) work on the same principle. As you walk with it on the ground, a device counts the number of rotations and by knowing the circumference of the wheel, you can figure out how far you've walked with it.

  • @abbaschandorwal724
    @abbaschandorwal724 2 ปีที่แล้ว

    Can a command from this encoder if connected to a priting head will print a 5meter long tape
    This I want to sell in market

  • @dhruvpatil5472
    @dhruvpatil5472 3 ปีที่แล้ว

    How can we use this for raspberry pi? please help

  • @SoCalFreelance
    @SoCalFreelance 6 ปีที่แล้ว +2

    Kids, take apart your home printer to see an example of an optical encoder!!

    • @vladtomoiaga4721
      @vladtomoiaga4721 6 ปีที่แล้ว

      A linear optical encoder (if it's an inkjet)

    • @UpcycleElectronics
      @UpcycleElectronics 6 ปีที่แล้ว

      Many of the last generation of mass production VCR's use them as well. I've taken several from old TV's that had integrated VCR's. They are usually mounted on stands that are easier to incorporate in other hacked designs too. You can also grab the LED's from a remote control and the IR receiver to make your own encoder, although you need the simple kind. A lot of newer IR receivers have integrated IC's in them and that can complicate the design.

  • @ahmedyehia5553
    @ahmedyehia5553 6 ปีที่แล้ว

    3:21

  • @kethanvignesh2143
    @kethanvignesh2143 3 ปีที่แล้ว

    Make it with n20 micro gear motor with encoder

  • @GreatNerve
    @GreatNerve 5 ปีที่แล้ว

    If I have single shaft bo motor and main motor shaft in no long so what I do.

  • @busraahmed1708
    @busraahmed1708 4 ปีที่แล้ว

    please add english subtitles. thanks in advance

  • @aaaooaao9949
    @aaaooaao9949 4 ปีที่แล้ว

    Why INT?
    At least my Arduino doesn't have enough pins that I need int.
    At least byte thick is enough for me!
    But as in every example - a few delay and you can use the example for nothing else - congratulations.

  • @seeingdragons4319
    @seeingdragons4319 4 ปีที่แล้ว

    You didn't show how to adjust the speed of one wheel to keep up with the other. You just said could be done and blew past it.

  • @willybee3056
    @willybee3056 6 ปีที่แล้ว

    Oops, •¿° d x pi =c
    But won't d vary with weight on the axel?
    Oh,, and is there a difference between absolute encoder and a gray code... oops. I just dated myself....

    • @ShawnHymel
      @ShawnHymel 6 ปีที่แล้ว +2

      The diameter might decrease slightly if your wheels are particularly squishy. A gray code is used to correct the potential issue of an absolute encoder counting false states between two real states (en.wikipedia.org/wiki/Rotary_encoder#Ways_of_encoding_shaft_position).

  • @MathieuGosbee
    @MathieuGosbee 6 ปีที่แล้ว

    Please normalize your volume

  • @bagatis1
    @bagatis1 6 ปีที่แล้ว

    Speaking about computer mouse, kids this days have no idea about the old school ball mouse

  • @antoningazda9154
    @antoningazda9154 6 ปีที่แล้ว

    * odometrie

  • @rokolokas6590
    @rokolokas6590 2 ปีที่แล้ว

    Your explanation for graph at 3:40 is faulty. If one is rising edge and one is falling, what is with the empty space in the schematic?
    If u are using bipolar hall senzor that explanation is ok but change the simplification animation then.

  • @user-yb5cn3np5q
    @user-yb5cn3np5q ปีที่แล้ว

    But of course while you tell "high for north, low for south" your graph shows "high for both north and south", and the rest of explanation just gets even more confusing after that.

  • @robotmad
    @robotmad 5 ปีที่แล้ว

    Nice vid with very annoying background music.

  • @jonathanvathauer9512
    @jonathanvathauer9512 6 ปีที่แล้ว

    Anyone else bothered by his rounding on multiple steps?

  • @AdaptivePhenix
    @AdaptivePhenix 5 ปีที่แล้ว

    I don'y get why, with all the popularity of "robots", people are not being taught about feedback. Would you build a temperature control system with no feedback? No!
    Real encoders feature 3 channels; A, B, Index. The method demonstrated here cannot detect a change of direction.
    Forget the interrupt counter and grab a LS7366 (SPI). Grab a DC motor with a HEDS encoder and learn about PID control.

  • @ottokueng4236
    @ottokueng4236 3 ปีที่แล้ว

    What a stupid music in the background. Have you heard this in your scool too?
    Is this a tutorial or a personal show?

  • @pirateman1966
    @pirateman1966 6 ปีที่แล้ว

    It's hard to believe that people who don't know how an encoder works, would buy anything from your store!

    • @ShawnHymel
      @ShawnHymel 6 ปีที่แล้ว +9

      Well, I'm hoping that the video can teach someone about encoders, and it might entice them to look at our store. We were all beginners at one point :)

  • @AhmedIbrahim-vv9lo
    @AhmedIbrahim-vv9lo 5 ปีที่แล้ว

    Great tutorial