Motor control

Has anyone been able to successfully position a motor using a quadrature encoder with arduino or any microcontroller? By sucessfully position, I mean have the motor stop within 4 or less pulses of the desired encoder position and be able to repeat the process hundreds of time with dead-reckoning precision. Not interested in what a microcontroller can theoretically do. Practical experience doing this only, please. Thanks.

You don't mean "dead-reckoning precision" do you? You mean "absolute precision" perhaps?

People normally use steppers motors to meet your requirement.

[quote author=joe mcd link=topic=188759.msg1398034#msg1398034 date=1379624717] People normally use steppers motors to meet your requirement. [/quote]

I need 300RPM at 80+ in.lb. torque in a NEMA-17 (or less) footprint. Do you have a stepper motor in mind that will do this?

Anyone???

Has anyone tried to do this, regardless of success or failure? Please post your experience.

in a NEMA-17 (or less) footprint

You got a link to whatever this is talking about?

zoomkat:

in a NEMA-17 (or less) footprint

You got a link to whatever this is talking about?

Here's one

NEMA-17 is a motor classification by the National Electrical Manufacturers Association that specifies, among many other things, that the motor is 42mm (1.65") in diameter.

However, frame size is irrelevant to the question.

The question is: has anyone, either successfully or unsuccesfully, tried to control the position of a motor with an Arduino or any other microcontroller? If so, please post your experience.

js69307: The question is: has anyone, either successfully or unsuccesfully, tried to control the position of a motor with an Arduino or any other microcontroller? If so, please post your experience.

Well since you seem to be urgently seeking an answer that apparently nobody has, I will speculate.

But first, how many steps is your quadrature encoder? A quick Google suggests encoders can have hundreds to thousands of steps per revolution. At 300RPM, we have 200mS between revolutions, which is turtle slow to an Arduino. I think an Arduino could handle a 256-step encoder at that speed quite easily, no heroics necessary.

But if you want a 8192-step encoder, well, that might be pushing things (only 24uS between steps -- do-able in theory with careful coding, but I have no idea about reality).

As for "stopping within 4 pulses repeatably and reliably hundreds of times in a row", that's no problem at all. Be aware that the software you write will have to take into account the flywheel effect (motors don't stop on a dime when you shut them off) so you'll need to shut off the power some time (based on an algorithm) before you get to the desired stop point. If you're in a hurry, short the motor windings to each other for a braking effect when you get close to the stop point. If you're really in a hurry, reverse the polarity for an even stronger braking effect.

Even with polarity reversal, expect the motor to take a few mS to stop. But as long as your load on the motor is consistent, you can start braking early and arrive precisely at the stop point every time.

If your motor load varies, it's a little more difficult, but by allowing for worst-case-scenario deceleration period, it should still be quite reliable. It'll just take a little longer to arrive at the stop point in the best-case scenario.

Now, if you're talking about letting the motor spin full speed 300RPM and suddenly stop within 4 pulses of some arbitrary input trigger, I doubt that can happen. The Arduino can do it, but I bet the motor can't.

I used a Motion Mind 3 controller from Solution Cubed. It does what you request. IT is based on a PIC,and does trapezoidal speed curve with position control. THe Arduino is able to do the same.

http://www.solutions-cubed.com/motor-control/

Note, I don't make any publicity for them but it is working. I tested &used them in my projects

Thank you, allebaut, for your feedback. In looking at the link you posted, I don't see any closed loop options on the motor controllers specified (aside from the fact that none of them handle anything close to the current I need). Are you saying that you were able to precisely control the position of a motor through software by reading pulses from a quadrature encoder and driving the motor accordingly?

tylernt, what you have posted works great in theory. In practice, not so much. Actually, "stopping within 4 pulses repeatably and reliably hundreds of times in a row", is a nightmare in practice. I would urge you to try it.

To give you more detail, the motor is turning at 16,000rpm with a 52:1 planetary gearbox, which is the only method I've found of achieving 80 in-lb of torque at 300rpm in a NEMA-17 footprint. If anyone has discovered a better solution, I would love to hear about it.

I have experimented with a variety of quadrature encoder resolutions from 48ppr to 8192ppr. I have tested with microprocessors up to 96mHz clock speed. I am abundantly familiar with all current theories of motor control using a microcontroller. Unfortunately, they are just that: theories. I haven't seen one applied. Yet.

js69307: tylernt, what you have posted works great in theory. In practice, not so much. Actually, "stopping within 4 pulses repeatably and reliably hundreds of times in a row", is a nightmare in practice.

So, what's the problem exactly? Can we see the code you have written?

What design constraints do you have? I.e., do we have to suddenly stop at an arbitrary point, or do you know ahead of time when you need to stop so you can begin deceleration before you get there? Does the load on the motor vary or is it constant?

To give you more detail, the motor is turning at 16,000rpm with a 52:1 planetary gearbox, which is the only method I've found of achieving 80 in-lb of torque at 300rpm in a NEMA-17 footprint. If anyone has discovered a better solution, I would love to hear about it.

You may not hear much. Stopping an stepper motor rotating at 16,000 rpm with in four encoder clicks may involve some serious physics.

It’s not a stepper motor, zoomkat. This is a BDC motor. I wish there was a stepper motor that would do this. Unfotunately, it would also involve serious physics trying to get the necessary number of windings in that frame size.

16000rpm is full speed. I have not had any better success trying to control it at 1/10 speed. I have also tried controlling it from the gearshaft at 300rpm (and slower) with no success. Before I waste much more time on this, I need to know if anyone has actually (not theoretically) done this with any motor at any speed.

js69307: 16000rpm is full speed. I have not had any better success trying to control it at 1/10 speed. I have also tried controlling it from the gearshaft at 300rpm (and slower) with no success.

Define "no success", please. Tell us what the motor does that it shouldn't do (or doesn't do that it should), and show us the code you have written. We're willing to help find a solution.

There are three sides to this -- the mechanical engineering, the electronics engineering, and the software engineering. The Arduino is up to the task on the electronics side (with a suitable controller), and as long as you are up to the task on the software side (with our help), that just leaves the mechanical side. We may be able to compensate for some mechanical issues with software, but to do that we need to know your design constraints -- i.e., do we have to suddenly stop at an arbitrary point, or do you know ahead of time when you need to stop so you can begin deceleration before you get there? Does the load on the motor vary or is it constant?

Standard servos have built in speed control ramping when approaching a desired position to minimize over shoot and a dead band to limit hunting. The below has some info on the internals of a standard servo. What is the required final rpm of the gearbox output shaft? You might be able to use the internal electronics of a servo for the motor control, and the arduino to monitor encoder position and send commands to the servo controls.

http://www.seattlerobotics.org/encoder/200009/S3003C.html

Thanks, zoomkat. I would be ecstatic if I could use a servo motor for this application. Unfotunately none are robust enough. I have only discovered 2 BDC gearmotor combinations on the planet that will do what I need to do. They both have stall current ratings in excess 60a. That would destroy any servo mechanism in that form frame, unfortunately.

The other problem is, this is an industrial application. Over the next 5 years, we are projected to produce over 760,000 of these. Even if I could hack a servo motor, it would be cost-prohibitive to attempt to do this on a large-scale basis.

Servo internals in combination with large h-bridges can be used to drive large DC motors (below videos). As you are seeking to make a commercial product, it might be best for you contact Chinese manufactures (alibaba below has some listings) and have them design and make your motor setup.

http://www.alibaba.com/

http://www.youtube.com/watch?v=VCbM8qvdXxU

http://www.youtube.com/watch?v=Rpqsvw2iTIo

js69307: I have only discovered 2 BDC gearmotor combinations on the planet that will do what I need to do

So you've tried all sorts of things and nothing worked for you, but you won't show us the code you tried nor will you tell us in what manner it failed, and you won't tell us the design requirements either.

I guess what you want is impossible. Give up now before you waste any more time on it. :roll_eyes: