Is there any way to limit the travel of the stepper motors for 90º??
I have this code and want to add something that limits the travel of the stepper motors without using a end stop switch because this is a printable robotic arm project and i don't have enough space for the switch.
Something like a counter with an if but i cannot get anything to work, i have a Joystick that is running the stepper motors for now.
If you have to ask this question, then you must already know the beginning position of the arm when you start the Arduino program.
Most projects have to begin the program by finding a fixed beginning position for the arm and call that position zero or position one, and count steps from that position.
When you are not able to find a beginning position, there is not any way for a program to know the real position of the arm.
You can always add a projection on the arm to trigger a zero position sensor. Or add a second arm 180 degrees from the current arm, or use you imagination to design some way of sensing a beginning position.
Paul
So the idea is to force the steppers do a home at the start and then trying to make the reading and the stops??
My imagination is huge, the coding skills not so much
Yes, that is absolutely correct. The code should first test for the end sensor indicating the arm is at the end. If not, move ONE step towards the end and repeat those two pieces of code until the end is sensed. Now you know where to begin the real program for your project.
Paul
There is no 'zero point'. Without a physical stop, limit switch, or position sensor, there is no way to recognize a 'zero point'. You can count steps and set software limits but without a way to recognize a 'zero point' you can't make the software limits correspond to any particular physical limits.
To limit the angle of the arm without limit switches you need a manual way to set the starting position, a position counter that can be used to count the steps between the 0 degree angle and the 90 degree angle and logic that prevents moving past the limits
At power up you could use a momentary contact button that slowly moves the arm toward the 0 position while pressed. Once there, releasing the button sets the position sensor to 0.
You need to calculate how many steps there are between 0 and 90 degrees of the arm. This depends on how you connect the motor to the arm. Example: if the arm is directly connect to the motor, then ¼ turn of the shaft is 90 degrees. If the motor has 200 steps per revolution and microstepping is set to 16, then the math is:
Steps per rev = 200 x 16 = 3200
Steps for 90 degrees = 3200 / 4 = 800
Increment or decrement the position counter depending on the direction of each step
Your logic then uses the position variable to limit movement between 0 and 800. Never allow the counter to exceed the limits and never allow the motor to step past the limits.
What does the stepper shaft control?
What is your project?
If you overstep, what happens if it does not stop?
If it damages something or someone, then put a limit switch in, no brainer.
Make room or find somewhere on the device the stepper is moving to put the limit switch.