Hi, Brainy Bits, I am so sad that you are under rated tutorials mentor, all your explanation are precise, simple and easy to grasp and implement. I hope one day see a 10000000 sub. please don't let us down. thank you
Hi guys, thanks a lot for that code and all. I´m looking for exactly that for hundred years and you made it happen. I´m very glad about it. I use it for my model train to move the track in front of an engine shed. Thank you so so much and continue with your great job. Stay safe. Many greetings from Germany.
Friend. Thanks a lot. I had been searching a lot to get rid of my analog potentiometer floating reads and this will save my life (hope so). I don’t need speed, but precision, keep simple and also portable. Thank you very much and will buy the encoder right now.
Hi! Great tutorials,everything well explained,without rushes. Ive seen all your videos, but i was (still am) looking for a multi movements of the steppers,previously saved in arduino code. This to avoid to use browsers, i.e., tell the arduino (by a string or similar) to move the stepper like this: move to 1stop,move to 2stop,move to 3stop etc. So,instead of using the encoder or a pot, to use sequencial predefined positions. Thanks!
this looks like a very useful setup, thanks for taking the time to upload, could you please add homing and limit switch's to the code, or a video on how to include homing and limit switch's, I'm new to motors and struggling with homing and limit switch's, i need exactly your setup in this video, same motor setup/encoder, i identical but with homing and limit switch's , ive been working on it for a very long time and about to give up, any help please. thanks
Could you do that same setup, but use the encoder to "start the motor in 1 direction, having it just run continually, until you push the button to stop it, or reverse the encoder? Also, the further you turn the encoder, the faster the motor spins. So 50% encoder clockwise means motor spins at 50% speed continually in the same direction? Thanks.. Great Video
Hi, thanks so much for the tutorial. I have a problem where my stepper will turn fine in one direction but in the other it is unreliable and will twitch around. This is the same with this tutorial and the one for the NEMA stepper. I have tested both motors with test code and they are both good. I think it must be the encoder but I have 5 and they all act the same. Any ideas?! Thanks again.
plz reply me.... Thanks for making this video .......I have some questions regarding my project are.... 1. for NEMA 23 motor 2.8 amp which driver should I use 2.plz can you send Arduino coading for ' if we rotate rotary encoder 30° then motor rotate 15° in opposite direction ' 3. when I rotate encoder the torque is same as on motor specifications or less?? Thank you very much.........
Nice, thanks. I think I followed all the steps but my stepper turns always in the same direction no matter which way I turn the encoder. Where am I wrong?
nice tutorial !!!!!!. Tell me something plz. In your video you can control the position of a stepper motor by rotating the rotary encoder. If you want continues rotation with speed control (like a potentiometer for example), can you do it with rotary encoder? . For example, you can control the position as you video. Fine. When click the rotary encoder, instead of returning back, can you use it for continues speed control ? (like a potentiometer?) thank you
parabens Brainy exelente projeto teria como gravar as duas posições e depois fazer a leitura, e que ficasse repetindo a gravação? direita esquerda? abraço Brainy
Hi,- Excellent tutorial. Can you tell me if the USB connection on the breadboard power supply is for 5v in or out because if its for 5v in I think you would need a special USB Cable. I will definitely get one if I can drive it from a USB input. Thanks - Keep up the good work
Hi, I believe these Breadboard power supply can be powered by USB, but keep in mind that a typical USB port on a computer has a 500mA limit. Or you could use a Cell Phone charger with the correct cable like you said. Thanks for your comment and for watching!
Sorry, cannot find this tutorial (nor subsequent ones relating to this first one) at that link. Is it under a different name or has it been removed. I would like to get involved more with my uno and stepper motors.
I use your code but when I turn one side it works well but in the other direction it starts to shock and does not turn around nicely. can you help me why he does so? I use a nano ivp the big arduino. the project is now taking to long hahah im working on it for 4years now and still not making progress. gr buas
Now just replace the cheap Rotary Encoder with a normal one that does not skip steps. Any way to make tutorial using buttons and a way to choose direction and number of steps to choose on LCD?
I set this up, but on mine it doesn't always turn the stepper, and the lights on the driver board kind of switch around without input, I must have messed something up in the code.
what if I wanna use more than 1 stepper motor?? lets say that for stepler motor one you have ints PinCLK, PinDT, PinSW... how would it be for then 2nd? could i name it PinCLk2, PonDT2, PinSW? and for each statement repeat twice but the second one adding 2 indicating stepper motor 2? Your answer would mean a lot.. Im new to stepper motors and Im using this stepper motors to control a robotic arm... thank you
+Rube G No, you would have to implement some sort of Home function when the Arduino starts up, to make sure the stepper motor goes to a starting point. You can check out this video here where I talk about using limit switches : ruclips.net/video/dQuTgngoFPQ/видео.html Hope that helps and thanks for watching!
Hallo, I wanted to build an automatic grill for shashlik ... The mechanics are not a problem (and most of it is ready) but we were thinking about something that would turn it automatikly for example 1/4 turn every minute by pushing a button! But we have no clue how to program something like this...Has sombodey an idea?
Hi, I am controlling my stepper motor automatically from the Arduino board, but once it moves and stops where I want, It does not go back to original (home) location [after short delay]. Any help with coding please
is there is a possibility to remove the shock from the stepper motor. when turning the rotary encoder it is only one direction .if I turn one way, it goes well but in the other direction it is shocking and it does not go well. how can I solve this?
hey brainy bits ..please help me brother..i want to control two stepper motors exactly like that..can i control two stepper motos with one rotary encoder?i want to move the motors at same time..
Hello. Very interesting video. Sorry to ask a boring question, but where do you get the gear from? I'm having trouble finding anything on Ebay/Amazon and can't seem to find it in your store?
+DarkShadow753 I cut this little gear at the last minute for this video with our laser cutter. We will start offering more custom parts in our store this coming year. Thanks for the comment and watching!
Hi! Have this encoder a little snap for accuracy? like the one in the car audio system of the volume control. Sorry for my english. Greetings from italy.
How can i use this encoders in a robotic arm with those stepper motors and save the positions to after make an infinite loop ??Can you help me please ??
greats think it very important for a beginner ARDUINO UNO programer my questions : *1st :can we use an arduino to control a real industrial machine (using a PC power supply to supply the Arduino ) ? *2ed : what happen when we use Arduino in an electromagnetic interferance place ......are there risques of loss informations controlling ? best regards frome Nouari LAZREG automation Engineer and Operation manager of AFITEX company
It depends on what kind of industrial machine ( control signals required etc ) . A pc power supply has both 12V and 5V so you have the answer. A Engineer who ask "what could happen in a electromagnetic interferences" ...you a Engineer, aren't you !? Man you're askind for the "shielding"...
AMIGO COMO EU FARIA PARA USAR 2 MOTORES NESSE MESMO PROJETO ? E PARABÉNS PELO VÍDEO. FRIEND LIKE I DO TO USE 2 ENGINES IN THE SAME PROJECT ? CONGRATULATIONS AND VIDEO.
Can I use this setup to run a 12v stepper motor? Also is there a safer way of ensuring the rotary encoder doesn't skip or twitch when it misses the que?
+jason daysh Check out our other video here: ruclips.net/video/O9Pr1ZLYUmE/видео.html i made some changes to the interrupt for the rotary encoder to make it more precise. Not perfect of course but better :) Hope it helps. Thanks for watching!
nice work, but i think if you connected the knob to a pulley by a cable and turn it you will get the same result, I m just joking thank you for your work.
Is there a particular Arduino kit I should get to run a stepper motor like in this video? Amazon has several different brands I'm not sure what the differences are to choose one : (
I got the elegoo kit which had 5 motors and 5 drivers. The driver board in this kit does nothing but increase the voltage from the arduino pins, and the leds on the side of driver show which pins (connected to motor) are getting power (which is great for learning). "Elegoo 5 sets 28BYJ-48 ULN2003 5V Stepper Motor + ULN2003 Driver Board for Arduino"
I got this motor in a starter kit from sunfounder. They say, that i can use the 5v pin of the arduino, but the kit is really poorly made and i think, the guys from sunfounder just don't know, what they are doing. Their example code is also shit. I don't have a power supply, so what should i do?
+Brainy-Bits I would like to control 3 stepper motors with different "rotary encoders" modules for each of them, and I would appreciate if you can explain me a doubt that I have, the encoder can be connect to different pins, for example I have a Arduino mega and I would like to know if I can connect to pins 24, 25 and 26, I have read the pinout of Arduino uno and I realize that the pins to which you connect the encoder in the video has something peculiar as to the type of outputs as of digital inputs (pwm pin) thank you very much
+Billy Zamora Díaz Check out this other video we did here: ruclips.net/video/O9Pr1ZLYUmE/видео.html were I explain how to make any pin an interrupt pin so you can attach 3 Rotary encoders to an UNO board if you want, each having their own interrupt! Hope it helps! Thanks for watching!
Can u help me? I know how to use an enconder and a stepper but, i want to learn how to save a sequence of movements with variations of speed during 5+ minutes and use a button to repeat the actions that ive done before...
The idea is a motion control... I want to use 5 motors with encoders to enter different sequences of movements, cw ccw, speed variations... Saving the movements to repeat forward and backward. Can u do a video about it? Tks!
Thanks for the suggestion, I have though of doing something like this, recording movements and play them back... Will try to do a video on that. Thanks for watching!
+sidgarth ansac You can check here: brainy-bits.com/tutorials/ to find more information, parts used and a schematic for most of the tutorials we post on RUclips. Thanks for watching!
#include "Stepper.h" #define STEPS 32 // Number of steps for one revolution of Internal shaft // 2048 steps for one revolution of External shaft volatile boolean TurnDetected; // need volatile for Interrupts volatile boolean rotationdirection; // CW or CCW rotation const int PinCLK=2; // Generating interrupts using CLK signal const int PinDT=3; // Reading DT signal const int PinSW=4; // Reading Push Button switch int RotaryPosition=0; // To store Stepper Motor Position int PrevPosition; // Previous Rotary position Value to check accuracy int StepsToTake; // How much to move Stepper // Setup of proper sequencing for Motor Driver Pins // In1, In2, In3, In4 in the sequence 1-3-2-4 Stepper small_stepper(STEPS, 8, 10, 9, 11); // Interrupt routine runs if CLK goes from HIGH to LOW void isr () { delay(4); // delay for Debouncing if (digitalRead(PinCLK)) rotationdirection= digitalRead(PinDT); else rotationdirection= !digitalRead(PinDT); TurnDetected = true; } void setup () {
pinMode(PinCLK,INPUT); pinMode(PinDT,INPUT); pinMode(PinSW,INPUT); digitalWrite(PinSW, HIGH); // Pull-Up resistor for switch attachInterrupt (0,isr,FALLING); // interrupt 0 always connected to pin 2 on Arduino UNO } void loop () { small_stepper.setSpeed(600); //Max seems to be 700 if (!(digitalRead(PinSW))) { // check if button is pressed if (RotaryPosition == 0) { // check if button was already pressed } else { small_stepper.step(-(RotaryPosition*50)); RotaryPosition=0; // Reset position to ZERO } } // Runs if rotation was detected if (TurnDetected) { PrevPosition = RotaryPosition; // Save previous position in variable if (rotationdirection) { RotaryPosition=RotaryPosition-1;} // decrase Position by 1 else { RotaryPosition=RotaryPosition+1;} // increase Position by 1 TurnDetected = false; // do NOT repeat IF loop until new rotation detected // Which direction to move Stepper motor if ((PrevPosition + 1) == RotaryPosition) { // Move motor CW StepsToTake=50; small_stepper.step(StepsToTake); } if ((RotaryPosition + 1) == PrevPosition) { // Move motor CCW StepsToTake=-50; small_stepper.step(StepsToTake); } } }
How did you manage to spin it that fast? It is 4096 step in one revolution according to spec (www.instructables.com/ORIG/FQY/RHST/HMVJ7U24/FQYRHSTHMVJ7U24.pdf) and frequency 100Hz.. which makes it about 40 seconds for one revolution, that is how fast I managed to spin it.. thanks.
From my understanding the library we are using runs those steppers in 4-step sequence. Your mention of 4096 steps per revolution is correct when the stepper is run in 8-step sequence. So in 8-step it will take 4096 steps for a full revolution of the shaft. But in 4-steps it will only take 2048 steps. That's why the stepper is running faster in this tutorial video. You can checkout our tutorial page here: brainy-bits.com/tutorials/stepper-motor-rotary-encoder-p1/ and get more information. Hope that helps and thank you for watching!
Hi Mike, you can find a tutorial page for most of our videos on our website here: brainy-bits.com/tutorials including a pic showing all the connections. Hope that helps and thanks for watching!
I was planing to the same project (without the push button turing tha same previous position) , but i notice than the driver lights stay always turned on. This mean than the motor is always on! and consume a lot of battery . how you can obviate this problem ?
+Julis Lybeshari The module that comes with this Stepper motor, doesn't have a pin to put to sleep or turn it off, but I guess you could use a 5V relay to turn it off with the Arduino when it's not needed, that way it wouldn't consume any power. Hope that helps and thank you for your comment and watching :)
Hi, Brainy Bits, I am so sad that you are under rated tutorials mentor, all your explanation are precise, simple and easy to grasp and implement. I hope one day see a 10000000 sub. please don't let us down. thank you
Hi guys, thanks a lot for that code and all. I´m looking for exactly that for hundred years and you made it happen. I´m very glad about it. I use it for my model train to move the track in front of an engine shed. Thank you so so much and continue with your great job. Stay safe. Many greetings from Germany.
Friend. Thanks a lot. I had been searching a lot to get rid of my analog potentiometer floating reads and this will save my life (hope so). I don’t need speed, but precision, keep simple and also portable. Thank you very much and will buy the encoder right now.
by far one of the best stepper motor videos I've seen. Very in-depth explanation of the code line by line which is hard to come by! well done!
Thanks Chris... Should have more videos coming soon... Thanks for watching!
I love your tutorials! They're all unique and useful.
Hi! Great tutorials,everything well explained,without rushes.
Ive seen all your videos, but i was (still am) looking for a multi movements of the steppers,previously saved in arduino code. This to avoid to use browsers, i.e., tell the arduino (by a string or similar) to move the stepper like this: move to 1stop,move to 2stop,move to 3stop etc. So,instead of using the encoder or a pot, to use sequencial predefined positions.
Thanks!
saw the Pebble and Subscribed instantly, great tutorial too
this looks like a very useful setup, thanks for taking the time to upload, could you please add homing and limit switch's to the code, or a video on how to include homing and limit switch's, I'm new to motors and struggling with homing and limit switch's, i need exactly your setup in this video, same motor setup/encoder, i identical but with homing and limit switch's , ive been working on it for a very long time and about to give up, any help please. thanks
GREAT video!
Thank you I am really trying to get into this you guys really helped
+XpiredMilkChunks Glad our videos are helping! Thanks for the comment and watching!
Great greetings from Argentina
Thanks for making such a great tutorial
Cool this helped a lot, thanks.
Excellent tutorial. Where can I get some help with modifing the code and wiring for my project? Thanks
You shouldn't use delay() inside your interrupts. You might mess up syncing with the internal clock in your code.
Can you break down "the why?" - I'm not familiar with why you would or wouldn't
Thanks for such a great video.
I have a question though; will it work with Esp 32's (Master and slave style) [Rotary Encoder: Stepper Motor]?
Very beautiful and wonderful but the nicest when you speak Arabic. Hossam / Egypt
thanks for this nice tutorial, it helps ,regards
its a web link and it doesn't have a lot of help unless you have the exact parts as they do
you can add two 1uF capacitor between A n GND and B n GND, and it will improve step skipping alot
Hi Herantd, can you please explain how to put these capacitors into the scheme?Thanks, Martijn
ccrma.stanford.edu/wiki/Images/c/c1/Encoder_filter.png
I'm not so good at reading schemas where the 1uf capacitors come in between thnx
Never delay inside an ISR. Period.
Really cool thanks
Thank you for the comment and for watching!
Could you do that same setup, but use the encoder to "start the motor in 1 direction, having it just run continually, until you push the button to stop it, or reverse the encoder? Also, the further you turn the encoder, the faster the motor spins. So 50% encoder clockwise means motor spins at 50% speed continually in the same direction? Thanks..
Great Video
Hi, thanks so much for the tutorial. I have a problem where my stepper will turn fine in one direction but in the other it is unreliable and will twitch around. This is the same with this tutorial and the one for the NEMA stepper. I have tested both motors with test code and they are both good. I think it must be the encoder but I have 5 and they all act the same. Any ideas?! Thanks again.
very nice site and the tutorial is gooooooood
شكرا
+Ali S.aldin Thanks for the comment and watching of course :)
plz reply me....
Thanks for making this video .......I have some questions regarding my project are....
1. for NEMA 23 motor 2.8 amp which driver should I use
2.plz can you send Arduino coading for ' if we rotate rotary encoder 30° then motor rotate 15° in opposite direction '
3. when I rotate encoder the torque is same as on motor specifications or less??
Thank you very much.........
Nice, thanks. I think I followed all the steps but my stepper turns always in the same direction no matter which way I turn the encoder. Where am I wrong?
nice tutorial !!!!!!. Tell me something plz. In your video you can control the position of a stepper motor by rotating the rotary encoder. If you want continues rotation with speed control (like a potentiometer for example), can you do it with rotary encoder? . For example, you can control the position as you video. Fine. When click the rotary encoder, instead of returning back, can you use it for continues speed control ? (like a potentiometer?) thank you
parabens Brainy exelente projeto teria como gravar as duas posições e depois fazer a leitura, e que ficasse repetindo a gravação? direita esquerda? abraço Brainy
Could you do a video with steppers and PID control for position?
Hi ... tnx for amazing tutoral . I have a question ... can u explain me for increscent a lcd for count with this rotary encoder!?
Can we change the degree?
if I turn the encoder 90' then the stepper turn 10' only.
I use this application for train turn table and working as a dream, just slow rotation to 70
Love to hear that others are using these tutorials to help them with their projects! Thanks for sharing and for watching!
Thanks. One question, I thought the little motor you were using was unipolar not bipolar? Maybe I'm mixed up....
Did this project take long to build?
Hi,- Excellent tutorial.
Can you tell me if the USB connection on the breadboard power supply is for 5v in or out because if its for 5v in I think you would need a special USB Cable.
I will definitely get one if I can drive it from a USB input.
Thanks - Keep up the good work
Hi, I believe these Breadboard power supply can be powered by USB, but keep in mind that a typical USB port on a computer has a 500mA limit. Or you could use a Cell Phone charger with the correct cable like you said. Thanks for your comment and for watching!
Sorry, cannot find this tutorial (nor subsequent ones relating to this first one) at that link. Is it under a different name or has it been removed. I would like to get involved more with my uno and stepper motors.
I use your code but when I turn one side it works well but in the other direction it starts to shock and does not turn around nicely. can you help me why he does so? I use a nano ivp the big arduino. the project is now taking to long hahah im working on it for 4years now and still not making progress.
gr buas
Friend, this blue knob you put on the encoder. What is this ? Where did you find it ?
Now just replace the cheap Rotary Encoder with a normal one that does not skip steps.
Any way to make tutorial using buttons and a way to choose direction and number of steps to choose on LCD?
awesome ! but will it work for the arduino nano ?
I set this up, but on mine it doesn't always turn the stepper, and the lights on the driver board kind of switch around without input, I must have messed something up in the code.
thank you so much for the tutorial, can you help me to use the serial monitor of the Arduino for example with this code? thank you =)
could you provide the code for the same project but with servo instead of stepper motor?
Sir how to run the continuous cycles like you done with rotary encoder
what if I wanna use more than 1 stepper motor??
lets say that for stepler motor one you have ints PinCLK, PinDT, PinSW... how would it be for then 2nd? could i name it PinCLk2, PonDT2, PinSW? and for each statement repeat twice but the second one adding 2 indicating stepper motor 2? Your answer would mean a lot.. Im new to stepper motors and Im using this stepper motors to control a robotic arm... thank you
Possible to use 2 step motor and 2 rotary encoder? And is it possible to find me the code please?
Hi!! What happend when you power off or reset the arduino when the motor is not in the 0 posicion? Does the motor save the correct 0 posicion?
+Rube G No, you would have to implement some sort of Home function when the Arduino starts up, to make sure the stepper motor goes to a starting point. You can check out this video here where I talk about using limit switches : ruclips.net/video/dQuTgngoFPQ/видео.html Hope that helps and thanks for watching!
+Brainy-Bits thank you greetings my friend!!
Hallo,
I wanted to build an automatic grill for shashlik ... The mechanics are not a problem (and most of it is ready) but we were thinking about something that would turn it automatikly for example 1/4 turn every minute by pushing a button! But we have no clue how to program something like this...Has sombodey an idea?
Hi, I am controlling my stepper motor automatically from the Arduino board, but once it moves and stops where I want, It does not go back to original (home) location [after short delay]. Any help with coding please
is stepper motor's speed gradually decrease and then become zero or not ?
is there is a possibility to remove the shock from the stepper motor. when turning the rotary encoder it is only one direction .if I turn one way, it goes well but in the other direction it is shocking and it does not go well. how can I solve this?
hey brainy bits ..please help me brother..i want to control two stepper motors exactly like that..can i control two stepper motos with one rotary encoder?i want to move the motors at same time..
is the rotary encoder an optical one?
Hello. Very interesting video. Sorry to ask a boring question, but where do you get the gear from? I'm having trouble finding anything on Ebay/Amazon and can't seem to find it in your store?
+DarkShadow753 I cut this little gear at the last minute for this video with our laser cutter. We will start offering more custom parts in our store this coming year. Thanks for the comment and watching!
Hi! Have this encoder a little snap for accuracy? like the one in the car audio system of the volume control. Sorry for my english. Greetings from italy.
How can i use this encoders in a robotic arm with those stepper motors and save the positions to after make an infinite loop ??Can you help me please ??
It's Possible to use uln2003 motor driver to control other stepper motors? Thanks!
greats think it very important for a beginner ARDUINO UNO programer
my questions :
*1st :can we use an arduino to control a real industrial machine (using a PC power supply to supply the Arduino ) ?
*2ed : what happen when we use Arduino in an electromagnetic interferance place ......are there risques of loss informations controlling ?
best regards frome Nouari LAZREG automation Engineer and Operation manager of AFITEX company
It depends on what kind of industrial machine ( control signals required etc ) . A pc power supply has both 12V and 5V so you have the answer. A Engineer who ask "what could happen in a electromagnetic interferences" ...you a Engineer, aren't you !? Man you're askind for the "shielding"...
hi I cant find 4 pin potentiometer.please somebody give a link for buy
Why isn't the code on brainnybits web site???
AMIGO COMO EU FARIA PARA USAR 2 MOTORES NESSE MESMO PROJETO ? E PARABÉNS PELO VÍDEO.
FRIEND LIKE I DO TO USE 2 ENGINES IN THE SAME PROJECT ? CONGRATULATIONS AND VIDEO.
Can I use this setup to run a 12v stepper motor? Also is there a safer way of ensuring the rotary encoder doesn't skip or twitch when it misses the que?
+jason daysh Check out our other video here: ruclips.net/video/O9Pr1ZLYUmE/видео.html i made some changes to the interrupt for the rotary encoder to make it more precise. Not perfect of course but better :) Hope it helps. Thanks for watching!
Brainy-Bits
Thanks for the extra info, I'm watching all your videos now and taking loads of notes. It's a great selection. Cheers :)
how can i do this with servo motors?
А можно ли использовать этот sketch с платой Arduino nano? И можно ли уплравлять одним энкодором двумя шаговыми двигателями, не сразу, а по очереди?
Plz help me with circuit daigram
nice work, but i think if you connected the knob to a pulley by a cable and turn it you will get the same result, I m just joking thank you for your work.
Hi, sorry I missed your comment a year ago... But started laughing when I read it just now :) Thanks for the laugh and for watching!
can you pass the code plis
I like it, But I don't want to use an arduino
Is there a particular Arduino kit I should get to run a stepper motor like in this video? Amazon has several different brands I'm not sure what the differences are to choose one : (
I got the elegoo kit which had 5 motors and 5 drivers. The driver board in this kit does nothing but increase the voltage from the arduino pins, and the leds on the side of driver show which pins (connected to motor) are getting power (which is great for learning).
"Elegoo 5 sets 28BYJ-48 ULN2003 5V Stepper Motor + ULN2003 Driver Board for Arduino"
I got this motor in a starter kit from sunfounder. They say, that i can use the 5v pin of the arduino, but the kit is really poorly made and i think, the guys from sunfounder just don't know, what they are doing. Their example code is also shit. I don't have a power supply, so what should i do?
+StarTrek123456 These motor only draw 92mA current so it's ok to connect them directly to an Arduino if you want. Thanks for watching!
+Brainy-Bits I would like to control 3 stepper motors with different "rotary encoders" modules for each of them, and I would appreciate if you can explain me a doubt that I have, the encoder can be connect to different pins, for example I have a Arduino mega and I would like to know if I can connect to pins 24, 25 and 26, I have read the pinout of Arduino uno and I realize that the pins to which you connect the encoder in the video has something peculiar as to the type of outputs as of digital inputs (pwm pin)
thank you very much
+Billy Zamora Díaz Check out this other video we did here: ruclips.net/video/O9Pr1ZLYUmE/видео.html were I explain how to make any pin an interrupt pin so you can attach 3 Rotary encoders to an UNO board if you want, each having their own interrupt! Hope it helps! Thanks for watching!
Can u help me? I know how to use an enconder and a stepper but, i want to learn how to save a sequence of movements with variations of speed during 5+ minutes and use a button to repeat the actions that ive done before...
The idea is a motion control... I want to use 5 motors with encoders to enter different sequences of movements, cw ccw, speed variations... Saving the movements to repeat forward and backward. Can u do a video about it?
Tks!
Thanks for the suggestion, I have though of doing something like this, recording movements and play them back... Will try to do a video on that. Thanks for watching!
is it possible to get the schematics for your circuit??
just found your website! thank you,
+sidgarth ansac You can check here: brainy-bits.com/tutorials/ to find more information, parts used and a schematic for most of the tutorials we post on RUclips. Thanks for watching!
Load cell + encoder project
thx ♪♫
Could I get a copy paste of the code used? I dont find it in my Arduino files
You can check out our tutorials page at : brainy-bits.com/tutorials/ to get the schematic and more information on this tutorial. Thanks for watching!
@@BrainybitsCanada Can't find the code
Est-ce que je détecterais pas une tite tite micro accent québécois? :)
arduino source code?
#include "Stepper.h"
#define STEPS 32 // Number of steps for one revolution of Internal shaft
// 2048 steps for one revolution of External shaft
volatile boolean TurnDetected; // need volatile for Interrupts
volatile boolean rotationdirection; // CW or CCW rotation
const int PinCLK=2; // Generating interrupts using CLK signal
const int PinDT=3; // Reading DT signal
const int PinSW=4; // Reading Push Button switch
int RotaryPosition=0; // To store Stepper Motor Position
int PrevPosition; // Previous Rotary position Value to check accuracy
int StepsToTake; // How much to move Stepper
// Setup of proper sequencing for Motor Driver Pins
// In1, In2, In3, In4 in the sequence 1-3-2-4
Stepper small_stepper(STEPS, 8, 10, 9, 11);
// Interrupt routine runs if CLK goes from HIGH to LOW
void isr () {
delay(4); // delay for Debouncing
if (digitalRead(PinCLK))
rotationdirection= digitalRead(PinDT);
else
rotationdirection= !digitalRead(PinDT);
TurnDetected = true;
}
void setup () {
pinMode(PinCLK,INPUT);
pinMode(PinDT,INPUT);
pinMode(PinSW,INPUT);
digitalWrite(PinSW, HIGH); // Pull-Up resistor for switch
attachInterrupt (0,isr,FALLING); // interrupt 0 always connected to pin 2 on Arduino UNO
}
void loop () {
small_stepper.setSpeed(600); //Max seems to be 700
if (!(digitalRead(PinSW))) { // check if button is pressed
if (RotaryPosition == 0) { // check if button was already pressed
} else {
small_stepper.step(-(RotaryPosition*50));
RotaryPosition=0; // Reset position to ZERO
}
}
// Runs if rotation was detected
if (TurnDetected) {
PrevPosition = RotaryPosition; // Save previous position in variable
if (rotationdirection) {
RotaryPosition=RotaryPosition-1;} // decrase Position by 1
else {
RotaryPosition=RotaryPosition+1;} // increase Position by 1
TurnDetected = false; // do NOT repeat IF loop until new rotation detected
// Which direction to move Stepper motor
if ((PrevPosition + 1) == RotaryPosition) { // Move motor CW
StepsToTake=50;
small_stepper.step(StepsToTake);
}
if ((RotaryPosition + 1) == PrevPosition) { // Move motor CCW
StepsToTake=-50;
small_stepper.step(StepsToTake);
}
}
}
How did you manage to spin it that fast? It is 4096 step in one revolution according to spec (www.instructables.com/ORIG/FQY/RHST/HMVJ7U24/FQYRHSTHMVJ7U24.pdf) and frequency 100Hz.. which makes it about 40 seconds for one revolution, that is how fast I managed to spin it.. thanks.
From my understanding the library we are using runs those steppers in 4-step sequence.
Your mention of 4096 steps per revolution is correct when the stepper is run in 8-step sequence.
So in 8-step it will take 4096 steps for a full revolution of the shaft. But in 4-steps it will only take 2048 steps.
That's why the stepper is running faster in this tutorial video. You can checkout our tutorial page here: brainy-bits.com/tutorials/stepper-motor-rotary-encoder-p1/ and get more information. Hope that helps and thank you for watching!
Brainy-Bits, yes, I wrote driver for 8 step sequence , I remembered it gave motor extra torque. Thanks.
on the 17th line delay(1000) remove the 1000 and add 0 the motor will move continuously .
Sir send Arduino code
Thank you; however, this tutorial does not help. There are no shots showing which pins are connected to the devices.
Hi Mike, you can find a tutorial page for most of our videos on our website here: brainy-bits.com/tutorials including a pic showing all the connections. Hope that helps and thanks for watching!
www.brainy-bits.com/stepper-motor-rotary-encoder-p1/
I was planing to the same project (without the push button turing tha same previous position) , but i notice than the driver lights stay always turned on. This mean than the motor is always on! and consume a lot of battery . how you can obviate this problem ?
+Julis Lybeshari The module that comes with this Stepper motor, doesn't have a pin to put to sleep or turn it off, but I guess you could use a 5V relay to turn it off with the Arduino when it's not needed, that way it wouldn't consume any power. Hope that helps and thank you for your comment and watching :)
+Brainy-Bits Many thanks. i will try.