Electronic – How to deal with controling force by positioning oscillating magnet

closed loopcontrolformula-derivationmagneticspid controller

I am trying to code up a closed loop control system on force generated by the paring of strong rare earth magnets. I do not have much experience with PID logic but i have a weak grasp of the basics (ie controlling temp or something).

I am confused by the situation I find myself in below because I need to control through the positioning of the magnet. My positioning system is worm gear motor which will have a oscillating force wave-shape, which is by design since I want cyclical loading. The problem is I think this makes control way more difficult. I already have an issue in that the relationship between force and position is not linear. I think that can be managed, What I am concerned about is programing the controller to deal with the fact that if the motor goes far enough the force will not go up but down.

Ideally I would like to moderate the speed so that I could produce any sort of force(time) profile I want, without the motor going forward and reverse at all. Just accelerate/de-accelerate in one direction as necessary to fit the input curve during each revolution.

I have this set up on the beaglebone black with a PRU running the loop control. I chose this because the PRU has 5ns instruction processing times so it should be very quick the react to changes. I have a load cell digitizer capable 460800 baud rate which will be my limiting factor in processing the signals.

My first order of business is dealing with the the motor turning in one direction will both raise and lower the force depending on position. How do I cope with that? and then how do I deal with the non-linear relationship between force and magnet position.

Any advice would be much appreciated.

grgrg

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)\$.