I have been designing a circuit to control multiple stepper motors and i succeeded in that,now my main objective is to be able to control them independently in a way that i am able to command the motors to go to any position randomly without having to wait for all that time of uploading the code to the arduino uno.I have been using this code,any suggestions are highly appreciated. #include <AccelStepper.h>
How can i control the positions,velocity and acceleration of five stepper motors, apparently i was able to use the accelstepper library to control 2 bipolar stepper motors but i dint have control of the position.i really really need some help figuring it out..
fortunately or unfortunately the entire project deals with driving five stepper motors of the articulating so not being able to control position of any means a dead end
Do I understand correctly that you seek to control the motors by means of some influence outside the Arduino platform, such as a sensor, switch, pot, etc.? - Scotty
How to use the Stepper motor library with 5 stepper motors
How to have the code "go to" a position and then stay there
To solve 1, you have to look at your stepper drivers, and see what connections they have. External controllers just need two inputs: direction and step. If those are the ones you're using, then you can use 10 digital pins, such as pins 2 .. 11, to drive 5 motors. If you use EasyDriver shields or similar, then you have more of a wiring problem.
To solve 2, you have to look at the API for the library and how it lets you configure which pins are used. It may support that use case, or it may not -- I haven't used it much myself, so I don't remember. An alternative, if you use two wires per stepper, is simply to set the outputs yourself, and generating the pulses yourself. It's not that hard.
To solve 3, you have to initialize a variable saying "motor is at position 0" on start-up. For each step it takes in the "forward" direction, add one to the variable. For each step it takes in the "backward" direction, subtract one. Then, to control the motor, send not a direction ("forward") but a target ("37"). Then, in the loop, if the motor value is less than the target, step forward once; if the motor value is greater than the target, step backward once; else hold. Because you run the loop many hundreds of times a second, the actual motor movement will be sufficiently smooth. I don't know whether the stepper library actually supports you telling it "only take one step," or whether you need to control the pulses yourself to do this -- check the documentation.
akatende:
Thanks,my question is more of like the third point,i still havent yet figured it out,so I am asking,sorry if this is a stupid question.
Have you tried this? If so, what part do you run into problems with?
initialize a variable saying "motor is at position 0" on start-up.
For each step it takes in the "forward" direction, add one to the variable.
For each step it takes in the "backward" direction, subtract one.
to control the motor, send not a direction ("forward") but a target ("37").
in the loop, if the motor value is less than the target, step forward once; if the motor value is greater than the target, step backward once; else hold.