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!!!!!
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 :)
@@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.
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
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?
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
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.
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.
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
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.
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.
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!
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
I had this problem too. it was counting on, both, the falling and rising edge since the initial "if" was "if(current != previous){other statements}". to fix it it, just add a second condition, like this "if ( current != previous && previous ==1){other statemetns}". i simplified it further and just ended up with "if( previous==1 && current =0){other statements}". this will only run the condition on the falling edge.
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!!!!!
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 :)
please no stop .. you explain so good
well done. thats the best explanation for rotary encoder i ve seen so far
Great Job, articulate and directly to the point. Thank You!
@Samir Ben This is spam
Just plain and simple explanation. Great video, exactly what I was looking for. Thank you so much! 😊
Fantastic! Looking at pictures of waves just didn't do it for me. This video completely cleared it up. Thank you! Subscribed.
Many thanks for the clear guide on how encoders work, I found the animated graphics particularly useful.
This is better than searching for confusing datasheets on the website. THANK YOU A LOT
Glad it was helpful!
Wow, such elegant code...My overly complex code didn't work well when I spun the encoder quickly, this works flawlessly. Thanks!
It's not that elegant tbh, it should be implemented with hardware comparators and interrupts
@@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.
*Thanks! Recommend making a video on controlling position of a continuous servo using a continuous rotary encoder!*
Currently working on such a video. I will publish it next week.
Cheers
Oh, thanks in advance!@@HowToMechatronics
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
You are my savior in ELECTRONICS.
Brilliantly explained from theory to application. Well done!
Thanks Mechatronics for your time and work. From Sydney all the best. 👍
Thank you too!
You are the Man! Thank you: very clear and very consecutive instructions and video. Great job.
your explanations are so clear, makes it easier to understand how this works. thank very much!
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
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?
Great tutorial !!! Helps me so much doing my current project. BIG THUMBS UP
This guy is the greatest.
awesome seeing your videos again its been a long time since you uploaded a video !!
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
Thanks!
Thank you 🙏
great video. simply and to the point explanation
Thank you friend!
Would be better if you used interrupts to accurately get only the falling edge of the output A's clock
Very good explanation
Thanks for the video. Great Job and effort to produce it.
Simple and good explanation
Awesome explaination.. Regards from Indonesia
2:47 that pitch tho
4:45
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.
Dear Friend, pls, upload another ligh & simply tutorial like this, I loved it, Thx You !
Very informative! Thanks!
Such a simple logic to test direction. I finally get it. Thanks so much ^,.'.,^
Great video, short and to the point :)
Glad you enjoyed!
thanks, the best explication!!!
Thank you very much for the information " Hugs
Great job bro, thanks for everything.
Amazing, thank's a lot!
Thanks that was amazing...
Grate job.. It was really effective for me.. thx alot and carry on..
Thank you very much !!! Now i understand it :)
omg you explain so good thanks
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.
great explanation! Thanks a lot.
Very helpful! Thank you so much! :)
output is different from the code it gives only negative values on CW or CCW direction.
That's What I Want To Know Thanks
great tutorial thank you.
Thank you Dejan. You are a good teacher. Go on!
Great instructional video
Nice video thank you!
Huge thanks
Excellent videos, thank you
Really helpful, thanks.
You are the man!
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
So great, thanks!
Good explanation, thank you.
Awesome video, thanks! :)
very nice and short video keep it up 😊👍👍
thank you this was very helpful, but you didn't talk about the difference beetwen absolute and incremental encoders..
Again nice one ! Can you make a separate video on ADXL345?
Nice info, thanks for sharing with us, well done :)
Great video!
CAN U MAKE A VIDEO WITH IN MENU USING 16x2 LCD DISPLAY ???
Thanks you
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.
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.
Yes, my encoder produces the same behavior.
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!
Nice explanation and animation.
But in your code, it will be more accurate if you use interrupt function to detect the change of signal.
thanks for your tutorial, it helps,regards
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
Thanks for uploading the video.
For some modules above program functions only when INPUT_PULLUP is defined for CLK and DT pins
Your code working well but you must put it into interrupt event from rising and falling edge caused by A and B signals.
Can you explain this?
@@MrKadvaga i don't think he can
Nice and clear explanation, thanks for the video. I wonder is it possible to control the LED light intensity using this encoder?
Just use a potentiometer DUH
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?
some tutorials put input pins as INPUT_PULLUP. What's the difference?
Why it need vcc and gnd if it is passive type?!
GOOD WORK BRO..
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 ?
i would like to build a wireless follow focus for cine lens, what's your suggest?
Hello How To Mechatronics, Keyes Rotary Encoder Module can connect to stm32f103 to control?
Can we bind a rotation to a key? For example if i turn it clockwise with every step it will press 'A'.
The best one at yutub ¡
Great Work
would you please can you show the circle diagram for stepmotor section, is LCD connection I2C ? thank you
Now I understand.
Very good
Thanks!
Great explanation, everything i needed to know.
Nice video buddy keep it up :)
Very nice
how to set position to 0 dge , I Should have insert sensor ?
Is it possible to design detent switches along with continous rotary knob? and how if its possible?
thank you
Does the rotary encoder have a limited amount of full turns you can make before it needs to be turned in the opposite direction?
They doesn't, you can turn them infinity.
Can it continue to increment after more than one revolution please ? Thanks for answering.
which animation tool did you use?
Thanks
very super and good teching
Thanks!
Hi, I'm getting double count, for ex: did one turn - result: 1,2. one more turn: 3,4. and so on. How to fix that? :/
I had this problem too. it was counting on, both, the falling and rising edge since the initial "if" was "if(current != previous){other statements}". to fix it it, just add a second condition, like this "if ( current != previous && previous ==1){other statemetns}". i simplified it further and just ended up with "if( previous==1 && current =0){other statements}". this will only run the condition on the falling edge.
I just don't know what you mean by current and previous is it like aState and aLastState in the code
Thank you Its finally working!!! :)
I made something similar using a potentiometer