Pages: [1] 2   Go Down
Author Topic: Stepper Position Sensing and Control  (Read 3538 times)
0 Members and 1 Guest are viewing this topic.
Central MA (US)
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am new to Arduino and to stepper motors, but I believe they are the solution to a part of my flight simulator project.  I need to simulate the magnetic compass that will be mounted on top of my instrument panel.  The motor needs very little torque since it will only be turning a small plastic disc, but precision as close to 1 degree as possible is important.  And, positional awareness, at least initializing it at start up, is critical.

My sim software will be able to feed the compass direction to the Arduino as a numeric value from 1 to 360 and I am finding a lot of code examples that seem  straight forward, IF, I can initialize the starting point when I boot up the sim.  That would be an ok solution.

I also started reading about steppers with position encoders built in and that got my attention since it might allow me to skip the initialization and simply drive the stepper to the correct position at any point in time.  However, I'm not finding any Arduino sketches or projects that leverage this position encoder functionality.

Any thoughts or direction on initial position set or use of a position encoder would be greatly appreciated!
Thanks!
Logged

Tom G.

Offline Offline
Full Member
***
Karma: 1
Posts: 175
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the lazy way is to just grab it and point it to north or some parked position at startup, and enjoy from there.  otherwise you need some reference location and a sensor/switch of some type
Logged

Central MA (US)
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

the lazy way is to just grab it and point it to north or some parked position at startup, and enjoy from there.  otherwise you need some reference location and a sensor/switch of some type

The compass will be in an enclosure so unfortunately that's not an option.  So I am looking for ideas on an initial position sensor or a maybe more ideal a way to take advantage of the position encoders that some steppers have.
Logged

Tom G.

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 323
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you just need a starting reference point, consider attaching a hall effect sensor to the housing, and a small magnet to the dial, such that the magnet is directly over the hall effect sensor at 360'.  Then, you can just move in either direction until the magnet is directly over the sensor at startup.
Logged

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1025
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some type of switch, either mechanical or hall effect. When the Arduino starts it rotates the dial until it senses the switch and then slowly backs up until the switch breaks and calls that 0 degrees. then you just send the arduino a position and let it move to that position. you will need to code for the 0-360 degree transition and how to handle going from 5 degrees to 355 and from 355 to 5.

Unless you buy an expensive encoder you will still have to go through an initialization routine as most encoders are incremental instead of absolute.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I also started reading about steppers with position encoders built in and that got my attention since it might allow me to skip the initialization and simply drive the stepper to the correct position at any point in time.  However, I'm not finding any Arduino sketches or projects that leverage this position encoder functionality.

But there is a lot posted on using quadrature encoders which is just the input side of your stepper/encoder assembly. The problem with simple 2 channel encoders is that on power up there is no way for the encoder to tell you the specific starting point of the shaft, it just allows one to count steps up or down once you do command the stepper to move in one direction or the other. Often a design will have a optical gate at one extreme end of travel and your start-up code will move the sensor towards that direction until it detects that end of travel stop and thereafter you can just keep track of step counts to determine where you are in the full travel range.

Lefty
Logged

Central MA (US)
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I understand how hall sensors work, but don't have any hands on experience with.  I have however worked with opitcal sensors.  I'll have to look at both and see which one I can get the most precision from.

Interesting about the stepper encoders not being absolute.  Kind of a bummer actually...  Does make a simple initialize function seem like the better way to go then.

Any suggestions on motors?  Most are either 1.8 or 0.9 degree steps so I wasn't sure about accuracy on a compass display.  Can they be held between steps to get at least close 1 degree accuracy or should I be looking at a some of the more expensive 0.36 steppers?
Logged

Tom G.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Interesting about the stepper encoders not being absolute.  Kind of a bummer actually...  Does make a simple initialize function seem like the better way to go then.

Well there are industrial absolute encoders available and many would be no problem to wire up to an arduino, but their price can be pretty much a sticker shock. The fact that with one external sensor and one quadrature encoder, you can emulate a absolute encoder function in software, pretty much tells you which way you should proceed. As far as optical Vs magnetic encoders that is pretty much internal details of the encoder that doesn't much concern one, it's just a matter of the electrical interface method and getting the steps per revolution resolutions you require for your application. You might note that most encoders are specified as having X number of 'steps' per shaft rotation, but with standard software encoder decoding methods you can turn that into detection of X or 2X or 4X steps per shaft rotation. So a 100 SPR rated encoder you can resolve 100 or 200 or 400 counts per revolution just by the software decoding method used to decode the A and B encoder signals.

Lefty
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 36
Posts: 1083
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you consider a 360 degree servo ?
Logged

Central MA (US)
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you consider a 360 degree servo ?

I have and am ordering one to test for other applications, but have been told that absent the position feedback (which none of the 360 servos I've found have) it won't work for this application.  Am I mistaken?
Logged

Tom G.

Central MA (US)
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Interesting about the stepper encoders not being absolute.  Kind of a bummer actually...  Does make a simple initialize function seem like the better way to go then.

Well there are industrial absolute encoders available and many would be no problem to wire up to an arduino, but their price can be pretty much a sticker shock. The fact that with one external sensor and one quadrature encoder, you can emulate a absolute encoder function in software, pretty much tells you which way you should proceed. As far as optical Vs magnetic encoders that is pretty much internal details of the encoder that doesn't much concern one, it's just a matter of the electrical interface method and getting the steps per revolution resolutions you require for your application. You might note that most encoders are specified as having X number of 'steps' per shaft rotation, but with standard software encoder decoding methods you can turn that into detection of X or 2X or 4X steps per shaft rotation. So a 100 SPR rated encoder you can resolve 100 or 200 or 400 counts per revolution just by the software decoding method used to decode the A and B encoder signals.

Lefty

Funny you should mention sticker shock.  What got me started down this road was just that, sticker shock when I looked at purchasing a prefabricated simulated aircraft compass and found they cost between $500 and $700 US.  That said, the lower the cost the better, but I suspect there are many options that would put me well below that mark.

I wonder if you might know of any such steppers absolute encoders that you could point me to as an example?  That would allow me to access the cost/benefit as compared to likely less costly options.

Thanks!
Logged

Tom G.

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if you want to always know where the arrow always point at, you have only one choice that is to use an absolute encoder. however it is expensive, and even if you do it yourself, i cant say how cheap can you get. however i think since it is just to show direction you could get away with maybe  a switch/reed switch/hall effect sensor or opto switch. that should be your 0 position and use a quadrature encoder to detect the angle of you if you use a dc motor , if you use a stepper motor then you could count the number of step. i i just remember what if you use a sail winch servo use for rc sail boat. that have a 700 ++ rotation.
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 36
Posts: 1083
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have and am ordering one to test for other applications, but have been told that absent the position feedback (which none of the 360 servos I've found have) it won't work for this application.  Am I mistaken?

Try to look for winch servo (they are used in model sailboats to control the sail).
They can rotate 360 degrees ore more and and they have the same position control as "normal" servos .

example:

http://www.pololu.com/catalog/product/522
« Last Edit: December 05, 2012, 10:45:59 am by Erni » Logged

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1025
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A servo won't do what you want. Isn't a sail winch just a continuous rotation with a winch attached?

You could go half steps which would give you 400 positions, you could use a gear train and come up with more positions.

The hardest part is how do you handle the moves across 0 degrees. Not a major issue, just depends on how big the steps are that you would be sending to the stepper motor.

Another thought - Power up the compass and assume that is 0 degrees. then have a mechanical cam, push a button and the compass is then zeroed. You could also sense when the compas has beeen zeroed, delay a bit and then move it to the proper heading.

If the Arduino that is controlling the compass is recieving just degree numbers and moving the dial to position you should be able to keep the position correct for quite a while, no load, low speeds mean the stepper should have no problem keeping position without feedback.

How much total rotation do you think you would have in one "flight"? If your number for compass position were a long you could do a lot of 360's before you ever hit overflow.

Will your flight sim be sending position info in degrees? or degree step?
Logged

Central MA (US)
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try to look for winch servo (they are used in model sailboats to control the sail).
They can rotate 360 degrees ore more and and they have the same position control as "normal" servos .

I just looked at the winch servos and because they are still limited in the number of rotations they will not work for this application.  On a long multi leg flight in bad weather with heavy traffic it is possible to be stuck in holding patterns (oval track loops) at length so any limit on the number of turns would not be realistic.

A servo won't do what you want. Isn't a sail winch just a continuous rotation with a winch attached?

You could go half steps which would give you 400 positions, you could use a gear train and come up with more positions.

The hardest part is how do you handle the moves across 0 degrees. Not a major issue, just depends on how big the steps are that you would be sending to the stepper motor.

Another thought - Power up the compass and assume that is 0 degrees. then have a mechanical cam, push a button and the compass is then zeroed. You could also sense when the compas has beeen zeroed, delay a bit and then move it to the proper heading.

If the Arduino that is controlling the compass is recieving just degree numbers and moving the dial to position you should be able to keep the position correct for quite a while, no load, low speeds mean the stepper should have no problem keeping position without feedback.

How much total rotation do you think you would have in one "flight"? If your number for compass position were a long you could do a lot of 360's before you ever hit overflow.

Will your flight sim be sending position info in degrees? or degree step?

I did find one servo for about $80 us that had 0.337 degree steps so about 3 steps to a degree.  A bit pricey but not out of reach.

I need to double check the interface app but I believe I am getting heading info as integers from 1 to 360.  Having given this more thought, absent absolute position feedback, I am leaning towards an initialization routine using an optical sensor to bring the compass disc to zero and then read the initial aircraft heading and step the motor x steps to align with the actual heading value.  From there I can keep track of the last heading value read and compare it to each subsequent value to step the motor as needed. I may also add a sync button so I can trigger the initialization at any time should errors start to accumulate and throw off the heading.  I don't think crossing zero will be an issue as I can work out the math/logic programmatically.
Logged

Tom G.

Pages: [1] 2   Go Up
Jump to: