What sort of throw do you need. There are, in fact, linear servos for model aircraft (e.g., http://www.spektrumrc.com/Products/Default.aspx?ProdId=SPMSA2030L) that might serve off the shelf. You just send these guys a PWM signal-- 50% duty would be center, and changing the duty cycle would move in either direction.
My experience is that the servos are pretty well tuned off the shelf, as they tend to be geared down enough that the servo barely sees the load, so they work just fine for a whole range of loads simply by tweaking duty cycle. You don't need to build a whole PID around them.
The short answer
forget it, because of 5. Edit: open loop.
Regarding your edit
The main question here is how to choose the resolution of the encoder [...]
Asking for a better encoder is simply not the right question to ask.
A higher resolution encoder will bring the two states of the flip-flop-control (that you are essentially creating here) closer together, but it will remain a flip-flop.
[...] and the motor
As stated above, if you need accurate positions that are not arbitrary, just use open loop. It will be able to reach the positions as calculated in 3. and do so accurately. Choosing a higher resolution for the motor means smaller steps between positions. If this is necessary depends on what positions you want to reach.
Does the encoder increase the accuracy in a microstep setup?
No. A microstep is a microstep and reaching a position in between is still not accurately possible. The microsteps represent the smallest interpolation possible. If you need smaller steps, try to find electronics that do more microsteps per step.
but a global motor and mechanical tools manufactor offered the closed loop system as it would be standard
I worked for a company producing positioning systems like the one you describe.
It doesn't matter if it is a standard or not.
What matters is if it is the right tool for the job or not.
Maybe it is a standard product.
But it's not the right product for your application.
almost every motor driver has an encoder input
Modern motor drivers are often able to control different kinds of actuators. For other actuators it is very common to be controlled in close loop, but that doesn't mean you have to use that input. Depending on the driver, the encoder input can be combined with the limit switches. Using limit switches is common for a lot of actuators (including stepper motors) to find the limits, because encoders usually do not give absolute position values.
And now for something completely different: Why do male humans have nipples?
So I thought I'd be a simple question
It is, just like the answer I provided above.
I have the feeling that you bought this positioning system, realised that it doesn't work in your application as intended and you think buying a newer/better/whatever encoder will solve your problems somehow.
It's very strange to me that you list all the problems that are intrinsic to a closed loop controlled stepper motor yourself, yet refuse to let go of your idea of a better encoder solving all your problems.
I don't know what kind of answer you expect. Maybe something like "Yes go ahead, throwing more money at it will make it work". But that's not the one I can give you, sorry.
The original answer
In the end it will always be an on-off control between two microsteps. There's no way around it. They are called stepmotors for a reason.
If you are fine with being able to only reach those positions dictated by the microsteps of the stepper motor, just run it in open loop.
If you want smooth, accurate movement to arbitrary positions, use a regular motor.
From my experience with such systems, you need special requirements to justify a closed loop stepper motor and live with the drawback mentioned above.
Trying to address some of your questions:
- The loop is closed. If the encoder has less resolution, it cannot distinguish between two positions of the motor. If the motor has less resolution, it cannot make that move to correct what the encoder measured as position error.
- The stepper motor can only reach (and hold) the positions according
to its (micro)steps. Those are the positions it can reach accurately. throwing a higher resolution encoder at it will not change that.
- What positions a stepper motor can reach, depends on two numbers
\$\frac{steps}{revolution}\$, which is a property of the motor
itself and \$\frac{microsteps}{step}\$ which depends on the
electronics that drive the motor.
$$\frac{360°}{\frac{steps}{revolution} \times
\frac{microsteps}{step}}=angle~of~one~microstep$$
- Depends on your definition what a problem is for you (your system)
if never reaching a position is a problem, then yes, there's your
problem.
- As pointed out above, use a different actuator or open loop
- If you want to treat this like a synchronous motor, why don't you
simply use a synchronous motor? I have seen it a lot that people
come up with stepper motors for applications where they are simply
not applicable. You stumbled upon some of the problems one can
encounter. This is not an optional question. this is the mandatory
first question of using the right tools for the right job. If you
feel that a stepper motor is not the right tool for this job, don't
try to force it into that role but pick a different actuator or
control scheme.
Best Answer
This answer is going to be rather abstract.
Let the direction your magnet travels be the x direction.
You have one known or knowable function from the position of the magnet to the force exerted. So let \$F = f_{pf}(x)\$. This function is monotonically increasing with \$x\$, which makes things easy.
You can calculate the position of the moving magnet with respect to the crank angle. Let \$x = f_{a p}(\theta)\$. Note that -- as discussed -- this is periodic on \$\theta\ \mathrm{mod}\ 2\pi\$ (and roughly, but not exactly, sinusoidal). It's also going to be continuous. This means that \$x\$ is constrained such that \$x \in [x_{min}, x_{max}]\$. Working backwards, it means that \$F\$ is also constrained: \$F \in [F_{min}, F_{max}]\$.
This means that \$F = f_{pf}\left (f_{ap}(\theta) \right)\$
You want the force to be some periodic -- and presumably continuous -- function of time, and you're willing to live with the constraints on \$F\$.
So -- easy peasy. Define your desired \$F(t)\$. For any value of \$F\$ in the interval \$[F_{min}, F_{max}]\$ there exists not one, but two values of \$\theta\$ that give you that force. So if you're at \$F_1, \theta_1\$ and you want to go to \$F_2\$, solve \$F_2 = f_{pf}\left (f_{ap}(\theta_2) \right)\$ for the two possible values of \$\theta_2\$ and choose the one that you'll get to first.
For a predetermined force vs. time relationship, solve \$F = f_{pf}\left (f_{ap}(\theta) \right)\$ for as many points as you need to get the precision you want for \$F(t)\$, making sure that \$\theta(t)\$ goes in a circle. Then control your motor with a PID controller to make it follow your predetermined \$\theta(t)\$.