Hi! I tried to move 2 stepper motors simultaneously, but i failed. Code that i wrote looks like this. I uderstand why it doesn't work, but i have no idea how can i improve it. Now, second stepper make 5 rotations, then first stepper make another 5 rotations and it is understandable. I wrote three functions:
takeStep- which generates one step
precisionRotation- where we declare how many step we want to make
setDirection- when we declare direction of rotation
paweljmo:
I was hoping that i will be able deal with it without this library.
The general approach in your takeStep() function is correct.
The problem is your use of FOR loops to move the motors because a FOR loop blocks until it completes. Just use a variable to keep count of the steps and allow loop() to do the repetition. That way each motor can take a step when it is next due. You will probably want to take the stepCount out of the takeStep() function so you can count the steps separately for each motor.
If i delete FOR loop still one motor works. It is because i use the same takestep function for two steppers?
Should I write there digitalWrite commands for every steppers instead of using parameters stepPin or maybe even every stepper should have own takeStep function? Because if i understand it well i cannot call takestep() functions again with another arguments if previous doesn't end?
I've read a documentation of AccelStepper Library and made some tests and i really enjoyed how it works. At the beginning i was not convinced to use it but now i think it is great. Thanks!