Brilliant video and explanation. As others have noted, the outcome needs to be changed to match the table... Then it works flawlessly: outcome=[0,1,-1,0,-1,0,0,1,1,0,0,-1,0,-1,1,0]
If my motor has 64 cpr (400 per revolution of the gearbox output shaft) how do i determine my logic table, or is it the same (ie. quadrature) just more times the signal is generated.
Hi, Is it possible to make this work on a Motor which is ripped off from a PSP UMD Drive using any Microcontroller? There are 4 Pins. Can someone help me with the Pin Connections?
There seems to be an error in your list outcome. shouldn't it be outcome=[0,1,-1,0,-1,0,0,1,1,0,0,-1,0,-1,1,0] instead of outcome=[0,-1,1,0,-1,0,0,1,1,0,0,-1,0,-1,1,0] ??? The Values at outcome[1] and outcome[2] needs to be interchanged I guess
What if I stop the motor? Or what if I reduce the speed? Or waht if I reduce the speed and then increase the speed? Or what if I change the direction from forwards to backwards?
Out of the BOTS I tried it with one of my motors with a raspberry pi 3 b+ and the program would read values but keep incrementing even when I don’t turn my motor. And when I stop the program and start it over again, it just reads 0 and stays that way even when I turn the motor.
If you watch the video then it will not be difficult to write this simple code yourself in C. My videos are intended to educational so that people can write their own code :)
I rushed this code, so you'll have to modify it slightly according to your needs. Also, it's in python man. If you know Arduino, you should be able to easily translate it into C code. It's gonna be something like this, mate. #include "RPI.GPIO.h" // or whatever the library file is. optional: import as another name using namespace std; A_PIN = 21; B_PIN = 20; // may vary depending on your setup void setup() { RPI.GPIO.setmode(GPIO.BCM); GPIO.setup(A_PIN, GPIO.IN); GPIO.setup(B_PIN, GPIO.IN); int outcome = new int[16]; outcome = [0, 1, -1, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, -1, 1, 0]; lastAB = 0b00; counter = 0; } void loop() { int A = GPIO.input(A_PIN); int B = GPIO.input(B_PIN); int curr_AB = (A
@@idkEngineering there's no dedicated quadrature so motor pulses are missed. You need dedicated HW to capture all pulses as the raspberry died this in SW its accuracy will be determined by how utilised the cpu with other tasks
Brilliant video and explanation. As others have noted, the outcome needs to be changed to match the table... Then it works flawlessly:
outcome=[0,1,-1,0,-1,0,0,1,1,0,0,-1,0,-1,1,0]
Thanks, exactly what I wanted to know, short, sweet and easy to understand
Thank you. Very clear video on how rotary encoders works.
Very simple explanation. Much appreciated.
Thank you so much for the amazing presentation and the code! It helped me a lot with my encoder!
Thank you sooo much this really helped me understand how encoders work!
If my motor has 64 cpr (400 per revolution of the gearbox output shaft) how do i determine my logic table, or is it the same (ie. quadrature) just more times the signal is generated.
The measurement is in ticks then you can convert ticks to degree to radians
Hi,
Is it possible to make this work on a Motor which is ripped off from a PSP UMD Drive using any Microcontroller? There are 4 Pins. Can someone help me with the Pin Connections?
Wonderful and super simple explanation
There seems to be an error in your list outcome.
shouldn't it be
outcome=[0,1,-1,0,-1,0,0,1,1,0,0,-1,0,-1,1,0]
instead of
outcome=[0,-1,1,0,-1,0,0,1,1,0,0,-1,0,-1,1,0] ???
The Values at outcome[1] and outcome[2] needs to be interchanged I guess
I'm getting [0,1,-1,0,-1,0,0,1,1,0,0,-1,0,-1,1,0] too. He made a mistake in the video.
Awesome explanation! Thank you sir.
What if I stop the motor? Or what if I reduce the speed? Or waht if I reduce the speed and then increase the speed? Or what if I change the direction from forwards to backwards?
well the count will change to reflect the speed and direction it is turning
Brilliantly explained, thank you
best explaination
Interesting stuff. Thanks!
Huh, that's some simple code, thanks. ☺
It will be slow i will like to use logic gates and D Flip flop to get quadrature pluses and direction signal.
does this work for all quadrature encoders?
yes
Out of the BOTS I tried it with one of my motors with a raspberry pi 3 b+ and the program would read values but keep incrementing even when I don’t turn my motor. And when I stop the program and start it over again, it just reads 0 and stays that way even when I turn the motor.
this video is awesome! thank you!
THANK YOU!
Awesome...thanks!
i like it. Thanks
Very nice , please write it in c code for ardunio thanks
If you watch the video then it will not be difficult to write this simple code yourself in C. My videos are intended to educational so that people can write their own code :)
I rushed this code, so you'll have to modify it slightly according to your needs. Also, it's in python man. If you know Arduino, you should be able to easily translate it into C code.
It's gonna be something like this, mate.
#include "RPI.GPIO.h" // or whatever the library file is. optional: import as another name
using namespace std;
A_PIN = 21;
B_PIN = 20; // may vary depending on your setup
void setup() {
RPI.GPIO.setmode(GPIO.BCM);
GPIO.setup(A_PIN, GPIO.IN);
GPIO.setup(B_PIN, GPIO.IN);
int outcome = new int[16];
outcome = [0, 1, -1, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, -1, 1, 0];
lastAB = 0b00;
counter = 0;
}
void loop() {
int A = GPIO.input(A_PIN);
int B = GPIO.input(B_PIN);
int curr_AB = (A
Raspberry products inaccurate results as it misses encoder pulses
@@idkEngineering there's no dedicated quadrature so motor pulses are missed. You need dedicated HW to capture all pulses as the raspberry died this in SW its accuracy will be determined by how utilised the cpu with other tasks
Thank you!