Thanks for another very helpful video! I do have a question concerning the interrupts... the ISRs you use are "rotate1" and "rotate2", but they are not declared elsewhere. Should these be "RotateCounter1" and "RotateCounter2", or am I missing something? One other thing... I am using two independent circuits for each motor (Nano, EasyDriver, rotary encoder for each motor) and am not using the LCD. For each circuit I am using D8 and D9 on the Nano for Dir and Step from driver. I am using D2 for CLK, D3 for SW, and D4 for DT from driver. I cannot get the motor to respond to the encoder clicks. Is there something in the LCD code that I should not have removed (I removed all LCD references from the sketch) when simplifying the code? I wish I knew what I was doing wrong!
Hi Allan, I am glad you found it helpful! The ISRs are declared in the setup and that's all. You just have to create the function that is being performed when the interrupt is called, but the interrupt itself is not part of the "main code" (loop()). This is the specialty of interrupts that they circumvent the main code and they have priority over the main code, so whenever an interrupt is triggered, anything which is being performed in the loop() is _interrupted_ and the code in the interrupt is performed. RotateCounter1-2 are the variables which store the number of clicks done with the rotary encoder. So when you turn it in CW direction, the value of the RotateCounter increases and when you turn it in CCW direction, the value of the RotateCounter decreases. What would be easy for troubleshooting is to connect the whole circuit to the PC and put some Serial.Println() functions to those places where you expect something to happen (a value changes, a code runs....etc). Of course in the println(), you would put some message or the value of the variable. Then you would see if the encoder works properly. You could also check if the motor is being polled...etc. Also, with you current setup, try to switch the DIR and STEP wires of the stepper motor driver. It might be also a "classical issue". Removing the LCD-related parts should not be an issue. In fact this is why I made the code modular so one can easily ditch certain features of the code. Let me know how you progressed!
@@CuriousScientist Thanks for the speedy response! I understand what you are saying about the interrupts, but when I put the code into the Arduino Editor, it returns "rotate1 was not declared in scope" and will not allow me to load the code onto the Nano. I will follow your recommendations. Thanks again!
@@CuriousScientist I did. But the rotate1() function does not appear until later in the sketch and the Arduino Editor does not get that far before giving the error message. I am doing something wrong, but I don't want to waste any more of your time! There must be something I am not doing correctly in the editor.
Try to check for the semicolons ";" and curly brackets "{" and "}" as they tend to be hard to notice when they are missing from somewhere where they should be used.
@@CuriousScientist I have played around with them from time to time which is why I ask. I typically run them open loop with salvaged power transistors and drive them with a CD4017. I don't have any real purpose in mind for them and so its not worth buying a specialized BLDC driver.
That was cool, or should I say a "hot issue" ;) Every video I saw about recycling this motors nobody alerted about this topic you addressed here. Thanks
Thanks! Yes, it is not that obvious, one would think that they are just fine with any drivers. But if one digs deeper, it will be seen that the different drivers deliver different minimum voltages (and thus current), so if you have a "weak" motor, it will turn into a heater very fast. I wanted to address this issue together with a solution, so I can hopefully help out some people.
@@CuriousScientist Stepper motors can run hot, but that may be OK. Having said that, if you think they are running too hot, most drivers have a current limiting adjustment.
Thanks for another very helpful video! I do have a question concerning the interrupts... the ISRs you use are "rotate1" and "rotate2", but they are not declared elsewhere. Should these be "RotateCounter1" and "RotateCounter2", or am I missing something? One other thing... I am using two independent circuits for each motor (Nano, EasyDriver, rotary encoder for each motor) and am not using the LCD. For each circuit I am using D8 and D9 on the Nano for Dir and Step from driver. I am using D2 for CLK, D3 for SW, and D4 for DT from driver. I cannot get the motor to respond to the encoder clicks. Is there something in the LCD code that I should not have removed (I removed all LCD references from the sketch) when simplifying the code? I wish I knew what I was doing wrong!
Hi Allan, I am glad you found it helpful! The ISRs are declared in the setup and that's all. You just have to create the function that is being performed when the interrupt is called, but the interrupt itself is not part of the "main code" (loop()). This is the specialty of interrupts that they circumvent the main code and they have priority over the main code, so whenever an interrupt is triggered, anything which is being performed in the loop() is _interrupted_ and the code in the interrupt is performed. RotateCounter1-2 are the variables which store the number of clicks done with the rotary encoder. So when you turn it in CW direction, the value of the RotateCounter increases and when you turn it
in CCW direction, the value of the RotateCounter decreases. What would be easy for troubleshooting is to connect the whole circuit to the PC and put some Serial.Println() functions to those places where you expect something to happen (a value changes, a code runs....etc). Of course in the println(), you would put some message or the value of the variable. Then you would see if the encoder works properly. You could also check if the motor is being polled...etc. Also, with you current setup, try to switch the DIR and STEP wires of the stepper motor driver. It might be also a "classical issue". Removing the LCD-related parts should not be an issue. In fact this is why I made the code modular so one can easily ditch certain features of the code. Let me know how you progressed!
@@CuriousScientist Thanks for the speedy response! I understand what you are saying about the interrupts, but when I put the code into the Arduino Editor, it returns "rotate1 was not declared in scope" and will not allow me to load the code onto the Nano. I will follow your recommendations. Thanks again!
@@AllanWallsPhotography Well, the compiler is looking for the rotate1() function but it does not find it. Have you copied everything to your code?
@@CuriousScientist I did. But the rotate1() function does not appear until later in the sketch and the Arduino Editor does not get that far before giving the error message. I am doing something wrong, but I don't want to waste any more of your time! There must be something I am not doing correctly in the editor.
Try to check for the semicolons ";" and curly brackets "{" and "}" as they tend to be hard to notice when they are missing from somewhere where they should be used.
Do you have any plans for the BLDC motors you set aside?
Hi! Not yet. I have many other projects that I want to finish and refurbishing these salvaged parts is not on the list at the moment.
@@CuriousScientist I have played around with them from time to time which is why I ask. I typically run them open loop with salvaged power transistors and drive them with a CD4017. I don't have any real purpose in mind for them and so its not worth buying a specialized BLDC driver.
That was cool, or should I say a "hot issue" ;)
Every video I saw about recycling this motors nobody alerted about this topic you addressed here. Thanks
Thanks! Yes, it is not that obvious, one would think that they are just fine with any drivers. But if one digs deeper, it will be seen that the different drivers deliver different minimum voltages (and thus current), so if you have a "weak" motor, it will turn into a heater very fast. I wanted to address this issue together with a solution, so I can hopefully help out some people.
@@CuriousScientist Stepper motors can run hot, but that may be OK. Having said that, if you think they are running too hot, most drivers have a current limiting adjustment.
Yes, I know! Thanks.