I will be using stepper motor in 6 DOF robotic arm along with Servo motors. Unlike Servo motor ,I find difficult to control Stepper motor. I was earlier using only Servo Motors but due to lack of Torque I had to use stepper motors. I read that in Stepper Motors there is no initial position or reference (0 degrees) position unlike servos. I searched on various links also where I came to know about rotary encoders but these wont be any good for my robotic arm. I will be using raspberry pi to control stepper motor. I need to know a way so that I can control the stepper motor so that there is some reference angle to the stepper motor.
I came to know about rotary encoders but these wont be any good for my robotic arm.
But why won't they be any good for your robotic arm?
There are several approaches to position control. From best to worst, your options are generally:
- Use an absolute encoder. On power-on, the robot will know the exact joint angle. You can immediately control the arm.
- Use a relative encoder. Relative encoders typically have a "home index" that will indicate a known position, then you get to count encoder pulses. A typical startup routine is to seek for the home index, zero your internal encoder count when you find it, and then you can begin operating as if it were an absolute encoder. Depending on your arrangement, you might be able to get by with the assumption that the arm didn't move while the robot was powered off, and you can resume operation if you saved the previous encoder position in nonvolatile memory.
- Count stepper motor steps. As with the relative encoder, you'll need some way to find a "known" or "home" position. You'll still need a startup routine. You could have a hard stop and rotate the motor one revolution, counting on the hard stop to prevent the motor shaft from continuing to rotate. Then you can assume that motor steps will increment up from the hard stop position. You could also use a "soft stop," like a limit switch as @RobertSutton mentioned. Again, once you "find" that position, zero your count and then begin operating normally.
The difference between (2) and (3) above is that you must always assume the arm traveled the correct number of steps if you don't have any encoder. If the torque applied to the arm exceeds the running or cogging torque of the stepper motor, then the arm will not be in the position you think it's in. If you use a relative encoder, then you will at least be able to detect that something moved the arm. A stepper motor is completely open loop and you have no means of determining if you're in the correct position unless (if) you happen to pass the soft stop/limit switch.