my project so far is just an Arduino Uno a Nema 17 stepper motor and a Hobby Servo ,12 volt Brushless digital type the rotary encoder is the standard type that outputs 5 volt square waves all wiring and electronics are good the pins used for input and output are defined in the setup section my power supply is a 12 volt battery . I don't really plan to change the wiring if I don't have to . I'd rather seek a solution in the programing . Since the circuitry is so simple I don't have a diagram prepared.
Hi,
Please some links to your hardware.
NEMA 17 tells me the physical size of the stepper but not the all important electrical characteristics.
A schematic is essential to help you configure and debug your code.
What are you using to drive the stepper?
Do you have a DMM? (Digital MultiMeter)
Thanks... Tom..
Yes I have a DMM. Big tree tec tmc 2209 is the stepper driver I'm using . its plugged into a CNC shield and Im also driving a Servo Sincecam 50KG High Torque Servo 12V. Thats it nothing else is involved except the rotary encoder and that's something I took off of a CNC milling machine that someone scrapped it runs on 5 volts and puts out 5 volt square waves . I not sure of the brand .
Its a 2 amp Stepper motor Im running the driver at 12 volts DC. The issue I have is really about getting the program loop to run more quickly somehow so the type of Motor is not very important .
If you use the NewEncoder-library detecting all encoderpulses become independant of the speed of loop(). Because the NewEncoder-library uses interrupts. But this requires using the interrupt capable io-pins wjich on an uno are io-pins 2 and 3
You are using 1200 baud which is really slow. Is there a special reason for this?
If not change to 115200 baud
If you want loop() running fast The only loop that is allowed is loop() itself.
For fastest looping you have to use the non-blocking stepper functions, avoid all while-loops, avoid all for-loops. The looping must be done by loop() no internal while-loops or for-loops.
Another approach is to use the mobatools-library for driving the stepper-motor
which creates the step-pulses in the background based on a timer-interrupt.
General experience:
Arduino Uno driving a steppermotor + reading an encoder = special code optimised for high-speed is required.
Yes I’m only using serial print in the debug sections of the program. I included the entire sketch so people could see all the code but . As I upload I change diagnostic mode to a one or a zero to eliminate all loops but the one called main program.
I’ll try this encoder library and see how I can use it to speed things up thanks
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.