1

I have a Nucleo-IHM01A1 motor driver to drive a motor mounted with a spindle. The spindle has a limited length with an object in between. As the motor spins, the object moves along the spindle.

How can I set the Home position of the motor such that every time I run the program on the MCU, the Home position is set when the object is at the center of the spindle.

  • 1
    Words don't really describe the mechanics well, but it is probably irrelevant. Stepper-motors have no means of determining absolute position. You could need an absolute-position shaft encoder (in which case you might not need a stepper motor if you use a PID loop), or some means of indicating the home position such as a limit-switch or an optically detected index hole. Either way in is an electro-mechanical issue sot a software development issue so off-topic here. Perhaps https://robotics.stackexchange.com/ – Clifford Jan 26 '21 at 09:38
  • Or use a servo https://youtu.be/z3HNBt9s5ic – Clifford Jan 26 '21 at 09:43
  • This question is not exactly software related, although there is a (dirty) software workaround that I proposed in my answer – eeucalyptus Jan 27 '21 at 10:36

1 Answers1

1

Unfortunately, the mechanical and electrical setup you describe does not actually allow automatic home calibration in a proper way.

Stepper Motors are used, as name suggests, to perform steps. They are not capable of absolute positioning on their own. If you need absolute positioning, you will have to either set your home point whenever the current position is unknown (eg. start-up or after losing steps), or add an absolute encoder to the system (then you always know the system state).

One solution for automatic home detection are limit switches, commonly used in many mechanical systems, especially 3D printers and other CNC machines. You might want to add one of these to your setup and drive towards the switch until it is pressed. Then you move it the exact number of steps needed to move it to the center and you're done.

However, if you can't change anything in the setup, you could just move the sled in one direction by the length of the spindle. When the sled hits the end, the motor should stall and loose the remaining steps. Then you move it back to the center (constant number of steps as previously) and you're centered. Consider that stalling motors can overheat the motor as well as the motor driver. This will probably decrease their life-expectancy.

There are other solutions like servos or absolute encoders but as far as I understand your goal, a limit switch should be fine.

eeucalyptus
  • 194
  • 5
  • Thank you. I asked the question because I hoped there is a solution without external hardware. But it seems there is not, the easiest and the most common solution seems to be a limit switch like you said. – Phạm Hồng Nhung Jan 27 '21 at 13:35
  • Oh, I didn't say it doesn't work at all but it requires stalling the motor which isn't exactly the healthiest thing for them and the driver. – eeucalyptus Jan 27 '21 at 21:45
  • As I understand it, when the motor get stall, the current going through the motor gets extremly high until it gets to its current limit. Is there a way that the driver board can sense the hit when the motor stall, or it should stop when the power get to a current limit which is lower than its own current limit? If it is possible, then I probably do not have ot use a limit switch, also do not damage the motor as much as I just allow it to loose the remaining steps. – Phạm Hồng Nhung Feb 01 '21 at 16:07
  • There are drivers like A3981 that are able to detect motor stall and lost steps. But that is really an overkill for almost any application. – eeucalyptus Feb 02 '21 at 07:11