Control stepper motor starting position?

Hi,

What would be the best way to initialize a stepper motors starting position? Im would like my motor to operate 0-180 degrees but never go beyond that since it will be fitted against a wall. The starting position would be 90 degrees straight out from the wall.

Is there a way to control this? If i have to use a sensor it should be able to last a couple of thousend initializations.

Cheers,
Mike (beginner :slight_smile:

The standard method of initializing a stepper motor position is with a "home" position switch.

If you want your stepper motor to have a 0-180º range of motion, set up a mechanic switch at the 0 or 180º point. During startup, move the stepper motor in the direction of your home switch until the switch is activated. Now you know the position of the motor, and can move it to the 90º starting position.

Another option (since you do not require continuous rotation) is using a potentiometer as a voltage divider tied to the stepper motor shaft. This will allow you to determine it's current position without having to move the motor.

One such switch is called an opto slot, as it is optical it will not ware out like a mechanical one. It consists of a photo transistor and detector.

you might be better using a RC servo
easy to drive from *duino
easy to set it's position
travels 0-180
sounds just the job to me (from here)

I'm about to have a similar "problem" to this with an antenna Azumith/Elevation (Az/El) rotator. My Az needs almost 360 degrees rotation (it has a South "stop" so the cables don't wrap around) and the El needs 180 degrees. My thoughts were heading towards using a compass sensor such as the HMC6352 Compass Module - HMC6352 - SEN-07915 - SparkFun Electronics for the Az so I knew where the stepper was but I was having trouble finding an inclinometer to handle the El stepper motor. I was trying to stay away from the mechanics of using a pot with such a large rotation.

I like the look of those opto slot switches, should have thought of those sooner - thanks for the tip :slight_smile:

I have found these being used in 3 axis mills to "home" the steppers, they are small, cheap and if they are good enough for a cnc mill will solve my problem nicely :slight_smile:

Optical Detector / Phototransistor - QRD1114 - SEN-00246 - SparkFun Electronics QRD1114

I think a simpler method for a home position indicator/sensor is a simple hall effect switch mounted on a fixed part and have a small permanent magnet attached to the rotating part. Won't be effected by light level or dirt/dust build up, etc.

Lefty

If the stepper setup has the mechanical strength, one can just drive the stepper motor in in a desired direction until it hits the hardstop. Drive the motor with a larger number of steps than the full travel step number, and then start at that position as step 0.

What have these motors got to do with this thread? They are brushless motors and this thread is about stepping motors and initial position.

The code I wrote measures the current going to one of the windings to detect the end point if there's a hard stop.

41south:
My thoughts were heading towards using a compass sensor such as the HMC6352 http://www.sparkfun.com/products/7915 for the Az so I knew where the stepper was but I was having trouble finding an inclinometer to handle the El stepper motor.

3-axis accelerometer?

But what accuracy / repeatability are you looking for?

sbright33
Can you share the code please ?

If you want to go with the hard stop method, you have to wire a "resistance sensor" - normally a very small resistor (0.05 .. 0.1 Ohms) in series with the power supply of the motor "to the GND side".

Then you measure the voltage across the resistor and GND with an analogue input of the Arduino. Adjust your code such that the voltage level triggers the Arduino to do something, when a certain level is reached or overrun. This happens because the motor draws more current when it is stopped by an external force (in your case: the wall).

But this is a brutal method and not all motors like that for a longer time and you have to make sure that this state will be left soon after it happened. By the way: in automatic coffee machines this method is used to find the Zero position of the internal brewing mechanism.

@tautau123, you have resurrected a 3-years-dead Thread.

I would expect it to be difficult to sense that a stepper motor had run into an end-stop by measuring a change in current. Stepper motors draw much the same current whether they are moving or not - that is how they hold position. And they are designed to hold position under power indefinitely.

If you are using a specialized stepper driver (as you should be) it will further complicate any attempt to measure the current due to its own motor current management arrangements. IIRC some of the expensive stepper drivers are equipped with the ability to sense a stalled motor.

Another factor to keep in mind is that your stepper motor system should be designed so it does not stall.

...R
Stepper Motor Basics

Measuring the current of a current driven stepper motor is pointless, you are setting the current.
(Well it will detect a broken winding!)

Stall detection for steppers can be done, but the simple techniques (periodic back EMF sensing) are
crude and don't work at low speed. Advanced techniques work better I believe, but require DSP
levels of processing.

Hi All, I am also trying to control the position of the stepper motor. Are there any codes that I am able to do that using a code like the servor motors ?

Regards,

YH

@vader92, you have resurrected a very old Thread. I suggest you start your own Thread and provide more information about the project you want to create.

I presume you have read the link I posted in Reply #13 in this Thread?

...R