Stepper Motor control w/ physical limits

hi all,

using a stepper w/ A4889 driver to control rotation of a 'hatch' with 45 degrees of movement. i'm curious to get some opinions on how to set up the physical limitations of the hatch so as not to 1) break the stepper and 2) not get the right results.

so the hatch can be 'fully open' (0 deg) and 'fully closed' (45 deg). curious what you all think is the best way to achieve this kind of effect:

if ( hatch is fully open already)
{
< don't rotate open any further >
}

if ( hatch is fully closed already )
{
< don't rotate closed any further >
}

i'd prefer to do it without any external sensors (even simple ones) if possible but i'm out of ideas how to do it without them.

my approach right now is have a global counter that starts at 0 and updates every time the code steps forward or backward during operation. no real problem there (other than it's ugly) unless the motor misses a step, which i think they're prone to, but it also means that after every operational restart, i would have to manually reset the hatch position to fully open (0 degrees).

any help is appreciated!

With a stepper motor there is no way to know where it starts from unless you have at least one limit switch. In your case you might arrange for the switch to be pressed when the hatch closes. When the switch is pressed you know the stepper is at the ZERO position. You can then command it to move as many steps as are required to get the hatch to the desired open position.

The limit switch will allow correction for any missed steps. However you should choose a motor with sufficient torque that there will be no missed steps unless something very exceptional happens.

Using a variable to keep track of the motor position is normal, not ugly.

...R
Stepper Motor Basics

thanks for the input robin, unfortunately the hatch is underwater so i might have to get creative with the limit switch placement. i could couple something to the shaft that comes out of the water tho. i'll give that a try.

thanks again!

emerkel:
thanks for the input robin, unfortunately the hatch is underwater so i might have to get creative with the limit switch placement. i could couple something to the shaft that comes out of the water tho. i'll give that a try.

Is the motor also underwater?
If not perhaps you could put the detectors on the shaft before it enters the water.

If the motor is underwater presumably it is in a dry compartment and maybe the detectors can be in there?

I wonder if you can get waterproof Hall Effect sensors - they don't have any moving parts.

...R

if you have a physical stop, you can drive the stepper to the stop. take 10 steps and intentionally over step to miss steps.
at that point, you can re-set your position to 0

underwater ? better to put a stop on the motor shaft inside the case, not outside.