Thank you! Yes, this is a neat function of them. I will show some more applications in the future, but right now I am fighting with the post office to receive my missing parts for the upcoming projects.
I just bought the components to make your project. I'll need it for the fence of a DIY milling wood machine. It doesn't matter if it skips a few steps, I'll use a DRO to see the fence move. We hope the cnc encoder will come from china soon. Great explanation!
It was an excellent suggestion, thanks! Yes, the direct control is so neat. If my packages finally go through the customs, I will be able to build a nice controlling and encoding circuit.
Good explanation of the quadrature values coming from the wheel. Though I might say that I was a little confused by the scope pictures of the two channels, until I realised that they were overlapping. I will usually keep a little separation on the vertical axis between the channels. Especially since the rising and falling edges are not easily seen. Thank you for another excellent video!
Thanks! Yes, the vertical separation maybe was too large between the two signals. When I explained the signals before showing the source code, I also wrote and mentioned that there is a vertical separation, roughly 2.5V to avoid any confusion by the overlapping signals. Maybe I was not clear enough or I was too confusing. Also, I tried to increase the brightness on the scope signal, but this was the maximum. Next time, I will enhance the waves manually and make the edges thicker. Thanks for the feedback, next time I will try to explain and present the things a bit more clearly!
Great video. Now i can control my old junky lathe with steppers and arduino, I hope I can add one more MPG. with two mpgs it would allow me to use two axis on a lathe. Thanks a lot
If you use a microcontroller that allows more than two interrupt pins (e.g. NOT Arduino Uno or Nano), then you can add many MPGs. I hope your project will be a success! Cheers!
Well, just for better understanding of my second question: I meant magnetic rotary encoder which looks like mechanical rotary encoder and which I can turn and control this way the stepper motors... Many Thanks!!!
Awesome vidz as always .... the cnc encoder helps eliminate the need for arduino in harsh environments implementation ... I'm still looking for a wiring diagram that show the by-pass of the arduion module , connecting the encoder directly to the driver ... any directions i should be looking at ... thank in advance.
Hi, and thanks! What kind of diagram are you looking for? You literally directly connect one of the outputs of the CNC encoder wheel to the step pin...
Great Work! and useful! I would like to ask you, if we can bypass the microcontroller, is that possible with any microcontroller and any driver or just in that case as you described... The enable pin must be connected anyway - as GND. But it does not have to be programmed, just ON. Am I right? My second question is about magnetic encoders. Do they appear on the market just in that form like a future part of a stepper - for feedback and alignment? Can I buy it in the shape like mechanical rotary encoder - like CNC wheel or KY-040? If so, could you give me advice where to get it? Thanks and all best for your future projects!!! Martin.
Hi and thanks! Yeah as long as you use a stepper driver that accepts square waves to control the stepping you can directly connect the wheel to the driver. Also, you can use a switch for the ENA pin. Regarding the magnetic encoders, check my AS5600-related videos on my channel. I even made a board that can be directly attached to NEMA17 stepper motors for the exact purpose you described. Also, recently a viewer recommended a rotary encoder-looking magnetic encoder: P3022-V1-CW360. It is a bit expensive, but it looks quite good.
Good Video, I was interested in using the stepper motor driver, pulse generator, and stepper motor. (And power supply). What is the enable wire for that is still connected to the bread board? Do I need it? I don't need the display. Thanks.
Does your encoder skip or miss steps if the encoder is turned too fast? There are capacitors added to the pin pf B10 and B11 in your video but not shown on the circuit diagram. Can you tell me how much are the capacitors. I made the circuit as you described but I am experiencing step skipping - a full rotation returns steps of 94 or 101, not exactly 100 every time.
Hi! The capacitors are 100 nF (104). I think I mentioned this either in this video or in the video I uploaded after this one that sometimes I notice that the number of clicks registered by the microcontroller is not the same as the position of the encoder. It is usually not the speed but the interrupts what is not OK. I have noticed that if I use the oled display, this jumping is more common (afaik, the oled library also uses some interrupts, so those might "compete" with the encoder's interrupts). I think I know the problem and you can see it yourself too if you try the following: put a print command in the A pin's interrupt and print a letter "A", then do the same with the B interrupt. If you rotate clockwise, the serial terminal should show "ABABABAB..." as the output. After just one click, it should show "AB". This is the two square waves I showed in the video. Now, sometimes I noticed that I only get an "A" after a click and if I rotate the wheel one more step, I see "BA" on the terminal. If the microcontroller sees this, it will actually think that you rotated in the CCW direction. So, sometimes something is fishy with the pulses or with the way how they get registered. I will keep working on this, but I also encourage you to play with it!
Hi! It is mechanically more robust. But that's all in my opinion. If you use a microcontroller and you can afford those absolute encoders, then you should go for them. They are extremely reliable. Otherwise, you can also use rotary encoders from some better manufacturers. They are cheaper than the absolute encoders.
Your vids and website blogs are great...subscribed and going through them now. I built a pendant for my diy Cnc (arduino controlled)and used a cheap ky01 rotary encoader, but I would like to rebuild the pendant with one of these pulse hand wheels. What is the difference between the 4 and 6 terminal hand wheels?
Hi and thanks! If I am not wrong, the 6 terminal hand wheel also outputs the inverted versions of the A and B pulses. For general applications, I don't think we need it. I also used the 4 terminal version.
nice. any advantage of these CNC wheels compared to the absolute encoder you showed in the previous video? other than you can bypass the MCU, that is (which I don’t need to do). thanks!
Hi! Seems like the answer I wrote in the morning just disappeared. This encoder/pulse generator is a bit more sturdy, but this is the only advantage that I can think of. The absolute encoder is the absolutely best (pun intended) choice if you are aiming for precision and repeatability. But, it will be the most expensive choice. Also, if you use a proper code, and a bit better components, a simple rotary encoder can do the job too and you can buy multiple of them for the price of the absolute encoder.
Can please help me, How to use an optical rotary encoder to stop the motor when it rotates a certain amount, I’m building a cablecam, the cable cam should stop automatically when the cable cam reaches a certain distance
i need my linuxcnc all axis own encoder can controller closed loop, but how this can made i not understand code how make and what need, no have many input my paraller port. all has used, probe,limits,end-stop,home switch,
Thank you for these tutorials! I have tried this with a TB6600 and an UNO without any luck. I set the pinA = 2 and pinB = 3, also stepper (1, 9, 8); but no luck so far. When I look at the serial monitor ( I do not have the oled yet) I get "CNC" not "CNC encoder test". I changed the baud rate to 9600 in sketch but that did not help. Any suggestions would be helpful. My goal is to dust off my old Teensy2 and run the encoder and limit switches as interrupts while a joystick is used to quick adjustments for a router lift. If anyone could point me in the right direction I would appreciate it. I do understand that this session was uploaded 2 years ago. Take care.
Hi! What do you mean by no luck? It does not work at all? Where do you encounter issues? I would suggest only using pinA as an interrupt and defining pinB at 7 for example. If you don't get the full serial message, try inserting a 3-5 second delay right after Serial.begin(115200). Or put a blocking while there. while(!Serial){;}. But when you use the device without the computer, comment out all the serial-related things, otherwise, you will notice some lagging. Also, since I have no idea what's wrong because you haven't told me ("without any luck" is not a good description), it could also be that your wiring is wrong and the TB6600 stays disabled thus the motor won't move.
Sorry, I should have been more specific. The TB6600 is not receiving any signals so the stepper motor does not move. I used pinB to 7 and still no signal. I tried your "Arduino with TB6600 using AccelStepper library" and everything worked fine. I am going to pick up new Dupont connectors and try again.
Please drop me an email with your modified code. Also, checking the connections is a great idea. Breadboards sometimes can have poor connections. Recently, I messed up an SD card because of it. 😄
I have practiced from your video and it was successful even though the components are not the same as you used, especially the encoder part, everything runs normally but it seems that the rotation is limited. If it reaches the limit, the stepper motor will rotate in the opposite direction itself. can you tell me so that the stepper motor rotates without limit what should I do?
Hello. I am completely reviewing your youtube channel that I recently discovered. I am a total beginner in programming and your work is a great contribution.I am trying to modify this program to be able to modify the speed of a stepper motor in proportion to the pulses generated in a rotary encoder coupled to another motor. How can I modify the program so that the speed is a function of those encoder pulses? MUCHAS GRACIAS
How could I generate an arduino program to control a large number of microsteps so as to generate different divisions between the motor and the encoder. The idea is to control a gear cutter shaft with the encoder and move the part to create gears with different number of teeth. Thank you very much for sharing your knowledge!
Hi! I think you can count the pulses of the encoder, than set up some multiplying factor that connects the number of pulses per second with the number of steps per second. So in this case, you will get a linear response on the pulses.
Hi, just a little question: why did you specify in the description that you need to use pin 2 or 3 for the encoder output A (instead of 10)? Can output B remain on pin 11 (arduino)? Sorry but I have never used the STM32 (I will use arduino Nano). (my cnc encoder is coming soon from china!! :o)) )
Hi! If you use Arduino Nano, the interrupt pin has to be either 2 or 3. The other pin (pinB) can be any other leg. But you have to be very careful about the definition of the pins. The code on my website is adjusted for STM32, so you need to use different pin descriptions for Arduino. It is not a rocket science, you just need to pay attention.
@@CuriousScientist of course, I have already set the pins on ArduNano, I have added small pieces of code that will be useful to me but, I cannot understand why I have to use pins 2 or 3 only for the encoder A output. I will study the matter, I am not an expert and I want to understand ;o) Thanks again for sharing your studies, I follow you! ;o)
You are welcome. Arduino Nano and Uno can only use pin 2 and 3 as an interrupt pin, that's why. The STM32 can use nearly all of its pin as an interrupt pin, so if you use that microcontroller, you can pick any of the pins as an interrupt.
@@CuriousScientist ok, ok, thanks a lot! I am more versed in mechanics but I like to add electronic controls to the machines I build (I really like working wood on weekends). When I have finished the milling machine, if you want, I will send you the photos. Good evening Prof!
Probably you're trying to compile it for an Arduino while the pin definition is according to STM32 requirements. You have to modify the pins to make it compatible with Arduino.
the more I look at your channel the more I get value it is insane
Thanks! I hope you'll become a regular viewer of the channel. More good stuff is on the way!
I never realized that an encoder can use directly with a stepper, that's was simply clever. Another great video👍
Thank you! Yes, this is a neat function of them. I will show some more applications in the future, but right now I am fighting with the post office to receive my missing parts for the upcoming projects.
I just bought the components to make your project. I'll need it for the fence of a DIY milling wood machine. It doesn't matter if it skips a few steps, I'll use a DRO to see the fence move. We hope the cnc encoder will come from china soon. Great explanation!
Hi! I am glad that you liked my explanation! Let's hope it will arrive soon and safely.
great job and great explanation .. hope you have other stuff as well on your channel
Thanks! I have plenty of other stuff! I hope you'll find something interesting.
Thanks for trying out the encoder wheels. They seem nice. A very neat use of the encoder to directly drive the stepper controller!
It was an excellent suggestion, thanks! Yes, the direct control is so neat. If my packages finally go through the customs, I will be able to build a nice controlling and encoding circuit.
Good explanation of the quadrature values coming from the wheel.
Though I might say that I was a little confused by the scope pictures of the two channels, until I realised that they were overlapping. I will usually keep a little separation on the vertical axis between the channels. Especially since the rising and falling edges are not easily seen. Thank you for another excellent video!
Thanks! Yes, the vertical separation maybe was too large between the two signals. When I explained the signals before showing the source code, I also wrote and mentioned that there is a vertical separation, roughly 2.5V to avoid any confusion by the overlapping signals. Maybe I was not clear enough or I was too confusing. Also, I tried to increase the brightness on the scope signal, but this was the maximum. Next time, I will enhance the waves manually and make the edges thicker. Thanks for the feedback, next time I will try to explain and present the things a bit more clearly!
Great video. Now i can control my old junky lathe with steppers and arduino, I hope I can add one more MPG. with two mpgs it would allow me to use two axis on a lathe. Thanks a lot
If you use a microcontroller that allows more than two interrupt pins (e.g. NOT Arduino Uno or Nano), then you can add many MPGs. I hope your project will be a success! Cheers!
Well, just for better understanding of my second question: I meant magnetic rotary encoder which looks like mechanical rotary encoder and which I can turn and control this way the stepper motors... Many Thanks!!!
Yes, it is the P3022-V1-CW360. Check it on AliExpress.
Awesome vidz as always .... the cnc encoder helps eliminate the need for arduino in harsh environments implementation ... I'm still looking for a wiring diagram that show the by-pass of the arduion module , connecting the encoder directly to the driver ... any directions i should be looking at ... thank in advance.
Hi, and thanks! What kind of diagram are you looking for? You literally directly connect one of the outputs of the CNC encoder wheel to the step pin...
Great Work! and useful! I would like to ask you, if we can bypass the microcontroller, is that possible with any microcontroller and any driver or just in that case as you described... The enable pin must be connected anyway - as GND. But it does not have to be programmed, just ON. Am I right? My second question is about magnetic encoders. Do they appear on the market just in that form like a future part of a stepper - for feedback and alignment? Can I buy it in the shape like mechanical rotary encoder - like CNC wheel or KY-040? If so, could you give me advice where to get it?
Thanks and all best for your future projects!!!
Martin.
Hi and thanks! Yeah as long as you use a stepper driver that accepts square waves to control the stepping you can directly connect the wheel to the driver. Also, you can use a switch for the ENA pin.
Regarding the magnetic encoders, check my AS5600-related videos on my channel. I even made a board that can be directly attached to NEMA17 stepper motors for the exact purpose you described.
Also, recently a viewer recommended a rotary encoder-looking magnetic encoder: P3022-V1-CW360. It is a bit expensive, but it looks quite good.
Good Video, I was interested in using the stepper motor driver, pulse generator, and stepper motor. (And power supply). What is the enable wire for that is still connected to the bread board? Do I need it? I don't need the display. Thanks.
Thanks! The enable wire is pulled to the ground to let the stepper motor driver power the stepper motor.
Does your encoder skip or miss steps if the encoder is turned too fast? There are capacitors added to the pin pf B10 and B11 in your video but not shown on the circuit diagram. Can you tell me how much are the capacitors.
I made the circuit as you described but I am experiencing step skipping - a full rotation returns steps of 94 or 101, not exactly 100 every time.
Hi! The capacitors are 100 nF (104). I think I mentioned this either in this video or in the video I uploaded after this one that sometimes I notice that the number of clicks registered by the microcontroller is not the same as the position of the encoder. It is usually not the speed but the interrupts what is not OK. I have noticed that if I use the oled display, this jumping is more common (afaik, the oled library also uses some interrupts, so those might "compete" with the encoder's interrupts). I think I know the problem and you can see it yourself too if you try the following: put a print command in the A pin's interrupt and print a letter "A", then do the same with the B interrupt. If you rotate clockwise, the serial terminal should show "ABABABAB..." as the output. After just one click, it should show "AB". This is the two square waves I showed in the video. Now, sometimes I noticed that I only get an "A" after a click and if I rotate the wheel one more step, I see "BA" on the terminal. If the microcontroller sees this, it will actually think that you rotated in the CCW direction. So, sometimes something is fishy with the pulses or with the way how they get registered. I will keep working on this, but I also encourage you to play with it!
Hi! It is mechanically more robust. But that's all in my opinion. If you use a microcontroller and you can afford those absolute encoders, then you should go for them. They are extremely reliable. Otherwise, you can also use rotary encoders from some better manufacturers. They are cheaper than the absolute encoders.
Excellent!
Thank you!
Your vids and website blogs are great...subscribed and going through them now. I built a pendant for my diy Cnc (arduino controlled)and used a cheap ky01 rotary encoader, but I would like to rebuild the pendant with one of these pulse hand wheels. What is the difference between the 4 and 6 terminal hand wheels?
Hi and thanks! If I am not wrong, the 6 terminal hand wheel also outputs the inverted versions of the A and B pulses. For general applications, I don't think we need it. I also used the 4 terminal version.
Very nice
Thank you!
nice. any advantage of these CNC wheels compared to the absolute encoder you showed in the previous video? other than you can bypass the MCU, that is (which I don’t need to do). thanks!
Hi! Seems like the answer I wrote in the morning just disappeared. This encoder/pulse generator is a bit more sturdy, but this is the only advantage that I can think of. The absolute encoder is the absolutely best (pun intended) choice if you are aiming for precision and repeatability. But, it will be the most expensive choice. Also, if you use a proper code, and a bit better components, a simple rotary encoder can do the job too and you can buy multiple of them for the price of the absolute encoder.
Can please help me, How to use an optical rotary encoder to stop the motor when it rotates a certain amount, I’m building a cablecam, the cable cam should stop automatically when the cable cam reaches a certain distance
Hi! Count the number of clicks from the encoder, and if you reach the desired number, stop the motor.
@@CuriousScientist can you give me an idea for coding
I just wrote what to implement. I can not write the code for you for free. If you want, you can hire me.
@@CuriousScientist okay thank you
i need my linuxcnc all axis own encoder can controller closed loop, but how this can made i not understand code how make and what need, no have many input my paraller port. all has used, probe,limits,end-stop,home switch,
Sorry, it is hard to understand what you want. What's the question? I provided a tutorial and a source code for everything I showed.
Thank you for these tutorials! I have tried this with a TB6600 and an UNO without any luck. I set the pinA = 2 and pinB = 3, also stepper (1, 9, 8); but no luck so far. When I look at the serial monitor ( I do not have the oled yet) I get "CNC" not "CNC encoder test". I changed the baud rate to 9600 in sketch but that did not help. Any suggestions would be helpful. My goal is to dust off my old Teensy2 and run the encoder and limit switches as interrupts while a joystick is used to quick adjustments for a router lift. If anyone could point me in the right direction I would appreciate it. I do understand that this session was uploaded 2 years ago. Take care.
Hi! What do you mean by no luck? It does not work at all? Where do you encounter issues? I would suggest only using pinA as an interrupt and defining pinB at 7 for example. If you don't get the full serial message, try inserting a 3-5 second delay right after Serial.begin(115200). Or put a blocking while there. while(!Serial){;}. But when you use the device without the computer, comment out all the serial-related things, otherwise, you will notice some lagging. Also, since I have no idea what's wrong because you haven't told me ("without any luck" is not a good description), it could also be that your wiring is wrong and the TB6600 stays disabled thus the motor won't move.
Sorry, I should have been more specific. The TB6600 is not receiving any signals so the stepper motor does not move. I used pinB to 7 and still no signal. I tried your "Arduino with TB6600 using AccelStepper library" and everything worked fine. I am going to pick up new Dupont connectors and try again.
Please drop me an email with your modified code.
Also, checking the connections is a great idea. Breadboards sometimes can have poor connections. Recently, I messed up an SD card because of it. 😄
magnificent video tutorial !!! it is compatible with arduino uno
Thanks! Yes, the code, with slight modifications, can work on any Arduino microcontrollers.
@@CuriousScientist Please I need it for Arduino Uno. Send me the code Please. I really need it for University Project. Thank you
The code is available, use it. ;)
@@CuriousScientist Thanks
I have practiced from your video and it was successful even though the components are not the same as you used, especially the encoder part, everything runs normally but it seems that the rotation is limited. If it reaches the limit, the stepper motor will rotate in the opposite direction itself. can you tell me so that the stepper motor rotates without limit what should I do?
What do you mean by limited? I don't understand, really. What limit is reached?
Hi can this project use Arduino nano"?
Hi! Yes, of course.
Hello. I am completely reviewing your youtube channel that I recently discovered. I am a total beginner in programming and your work is a great contribution.I am trying to modify this program to be able to modify the speed of a stepper motor in proportion to the pulses generated in a rotary encoder coupled to another motor. How can I modify the program so that the speed is a function of those encoder pulses? MUCHAS GRACIAS
How could I generate an arduino program to control
a large number of microsteps so as to generate different divisions between the motor and the encoder. The idea is to control a gear cutter shaft with the encoder and move the part to create gears with different number of teeth. Thank you very much for sharing your knowledge!
Hi! I think you can count the pulses of the encoder, than set up some multiplying factor that connects the number of pulses per second with the number of steps per second. So in this case, you will get a linear response on the pulses.
Hello, Is Point A Step, Direction or Pulse? Likewise, is Point B Step, Direction or Pulse?
Hi! It does not matter. They are the same pulses with some delay between them.
And now I am also a Patron, Dr. of Curiosity... 🙂
Thank you very much for the generous support!
Hi, just a little question: why did you specify in the description that you need to use pin 2 or 3 for the encoder output A (instead of 10)? Can output B remain on pin 11 (arduino)? Sorry but I have never used the STM32 (I will use arduino Nano). (my cnc encoder is coming soon from china!! :o)) )
Hi! If you use Arduino Nano, the interrupt pin has to be either 2 or 3. The other pin (pinB) can be any other leg. But you have to be very careful about the definition of the pins. The code on my website is adjusted for STM32, so you need to use different pin descriptions for Arduino. It is not a rocket science, you just need to pay attention.
@@CuriousScientist of course, I have already set the pins on ArduNano, I have added small pieces of code that will be useful to me but, I cannot understand why I have to use pins 2 or 3 only for the encoder A output. I will study the matter, I am not an expert and I want to understand ;o)
Thanks again for sharing your studies, I follow you! ;o)
You are welcome. Arduino Nano and Uno can only use pin 2 and 3 as an interrupt pin, that's why. The STM32 can use nearly all of its pin as an interrupt pin, so if you use that microcontroller, you can pick any of the pins as an interrupt.
@@CuriousScientist ok, ok, thanks a lot! I am more versed in mechanics but I like to add electronic controls to the machines I build (I really like working wood on weekends). When I have finished the milling machine, if you want, I will send you the photos. Good evening Prof!
Sure! You can drop me an email via my web page.
I Try your Code but get this Error: sketch_sep21f:13:12: error: 'PB10' was not declared in this scope
int pinA = PB10; // Pin A of the encode
Probably you're trying to compile it for an Arduino while the pin definition is according to STM32 requirements. You have to modify the pins to make it compatible with Arduino.
@@CuriousScientist thx i found this Error 1 Hours ago. Thank you👍
You are welcome! I hope you could fix it.
Then I think is my nano problem! Thanks
Make sure that you define the pins according to the Nano.
hi! Ya I already define it to nano pin
I will change it to oun try again while waiting for my new nano
Are you a school teacher or engineer?
Hi! I am a scientist with a great interest in engineering.
@@CuriousScientist are you a scientist at a university in Sweden?
@@gibbs-13 No.