Stepper motor control for University Honors Project

Hi all.

First time arduino and general programming noob, but i like a challenge so here goes.
I'm building a prototype RC vehicle and plan on actuating control systems using a little mechanism i designed, but this mechanism requires precise rotation input (for which i chose a Nema 17 unipolar stepper motor)

Long story short i need to figure out how to record or update the motor position preferably without use of a rotary encoder. I understand i need to set a home position for this but as the motor will only ever need to perform a maximum of a single rotation, i imagined having a script that starts with the motor performing 1.2 rotations in the opposite direction would set the motor into a constant position before use. as it's only allowed to rotate once, it would get stuck and after a second of trying to rotate beyond allowance, sets its current position as home.

Then it will need to update to new positions based on transmitter input (or in testing case, potentiometer input)

What i'd like to know from your much more capable minds is how practical this set home method would be, and how accurate the later readings would be because of it? the housing apparatus would be more than strong enough to cope with the motor trying to rotate for a second or two as it sets home position, but would the motor cope or would it cause unforseen (by me) problems?

Looking forward to your responses.

To find "home" you would normally use a limit switch of sorts, instead of trying to not break something.

I did consider trying to implement limit switches, but unfortunately due to the compact nature of the mechanism i'd rather not utilize them. I also considered using linear potentiometers to record the mechanisms movement and program / monitor the limits from there, but this would be no more compact.

Magnets and hall effect sensors are really small and make great limit switches.

Hi,

Keep it simple. There are TINY switches.. See the RESET on your Arduino.

Some things have been tried out thousands of times and a consensus builds up. That's not a roadblock to innovation, it's a guide.

I've used the Limit Switch thing (Move-Check-Move-Check-repeat) for almost 40 years. If the "switch" is an optointerrupter like this:

...there is no force needed to activate it. You can epoxy it and a little blade to activate it where you want.

Info:

https://arduinoinfo.mywikis.net/wiki/Opto-Switch

Jango955:
I did consider trying to implement limit switches, but unfortunately due to the compact nature of the mechanism i'd rather not utilize them. I also considered using linear potentiometers to record the mechanisms movement and program / monitor the limits from there, but this would be no more compact.

Is everything the mechanism turns also so compact and hard to get to?

If there is an end-stop that prevents the motor from turning then driving the motor against the stop is a perfectly reasonable way of setting the HOME position. It won't do the motor any harm if it misses some steps. You just need to ensure that the motor cannot damage the end-stop.

...R
Stepper Motor Basics
Simple Stepper Code

You wrote: "What i'd like to know from your much more capable minds is how practical this set home method would be, and how accurate the later readings would be because of it?".

Your accuracy will ALWAYS be in "STEPS" because you are using a stepper motor. If you design your device properly and program it properly you can stop at any step and hold that position.

Paul

"GoForSmoke" It's compact but the mechanism is designed to be taken apart for maintenance. It's an aluminium construct so it's fairly durable.

"Robin2" that is the response i was hoping for, would you be able to share some insight on the code required to initialize this kind of set home method?

"Paul_KD7HB" By accuracy. i mean't how likely is this method of home position setting to skip steps and become desynchronized with the home position.

Jango955:
"Robin2" that is the response i was hoping for, would you be able to share some insight on the code required to initialize this kind of set home method?

Just move it for the minimum number of steps and it'll be at "home". Make sure the stepper really can't move further.

"Paul_KD7HB" By accuracy. i mean't how likely is this method of home position setting to skip steps and become desynchronized with the home position.

After you move away from the home position, the way you reached home becomes irrelevant.

If you miss steps, you need a stronger stepper so it can make the movement it should.

Jango955:
"Robin2" that is the response i was hoping for, would you be able to share some insight on the code required to initialize this kind of set home method?

Have you carefully studied the code in the link in Reply #6 - it probably has most of what you need.

wvmarle:
Just move it for the minimum number of steps and it'll be at "home". Make sure the stepper really can't move further.

I believe that should be maximum + 10% - otherwise you can't know whether it could go further

...R

Jango955:
"GoForSmoke" It's compact but the mechanism is designed to be taken apart for maintenance. It's an aluminium construct so it's fairly durable.

"Robin2" that is the response i was hoping for, would you be able to share some insight on the code required to initialize this kind of set home method?

"Paul_KD7HB" By accuracy. i mean't how likely is this method of home position setting to skip steps and become desynchronized with the home position.

For accuracy, you need to follow the tried and true method used by commercial equipment, like my CNC soldering machine. It uses stepper motors for all three axis. At start up it moves one axes at a time to where the micro switch is depressed. Then it moves away from the switch, one step at a time until the micro switch becomes open. That is the home position used for all subsequent positions, which are accurate to 0.001 inch.

You can do the same.

Paul

Paul_KD7HB:
For accuracy,

I can't see how there would be any inaccuracy if a stepper motor is slowly driven hard against an end-stop - assuming the end-stop is designed to take the load.

...R

Aluminum is transparent to non-changing magnetic fields. If you can embed a button magnet so that the NS faces cross the axis they rotate on, a linear Hall sensor not too far along that same axis can read 180 angle change as 10 bits, almost 6 steps per degree. Full circle is 2048 read steps.

An end stop sensor could be a spring that gets pushed back against a crosspin. One has a sense pin w/pullup and the other is ground. The motor can stop during debounce. :slight_smile: If you put a button magnet on a movement that passes by a cheap Hall switch pointed along the direction of movement the switch will flip, or should otherwise a linear Hall sensor will.

If you have an inaccurate count out from the stop and back, a catchall end calibration will hide it.

If this was my project, I’d put the home sensor (opto/hall etc) in the centre of typical travel, that way, you can recalibrate every time the moving vane passes the sensor point, with no need ever to move to either limit.

Initial calibration at power on, is simply to sweep left right in ever increasing spans until you hit the sensor - the rest is positioning wrt the learned ‘home’ position.

If this was my project, I'd put the home sensor (opto/hall etc) in the centre of typical travel

That's a good idea; I may use that. Particularly if there may be some accumulated error in the transport system.

BUT the end travels have to be positively OK with running against the physical stop, or there needs to be power-off end switches.

Agreed.
You could measure current draw, and not only learn the reference position, but also subtract a couple of steps for the hard end points.

(i did all these a while ago, with a geared DC servo motor operating in a tight mechanical application.
With three sensors, since you have control and knowledge of the direction, you can identify seven distinct zones of positioning without any other input...
Outside A, A, between A-B, B, between B-C, C, and beyond C.

it worked very well, and if power or reference was lost for any reason, I could gingerly move in either direction until it touches a
sensor or hard limit - then the rest was just keeping track!

lastchancename:
You could measure current draw,

It does not vary with load for a stepper motor.

...R