Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

State-space model of magnetically suspended ball

  1. Jun 3, 2013 #1
    Hi,
    I have a 'simplified' equation of the magnetically suspended ball.

    a = g - (i/h * M)

    where

    a - actual acceleration of the ball.
    h - distance from the magnet.
    g - gravitational acceleration, to keep it simple let g = 10
    M - mass of the ball 0.05 kg
    i - current through the coil = how strong the magnet is.

    I need to make a simulation where controller's input 'u' is distance of the ball from magnet and 'y' from the controller is current 'i' of the magnet. The output y directly puts current into the coil (its just processing simulation with a falling ball). To keep it simple, no observer is required.

    My suggested solution:
    state x consists of [x1, x2, x3] = [h, v, i]
    h - dist. from magnet
    v - velocity of the ball
    i - current

    so steady state x0 = [10,0,5]

    But I do not know how to make matrixes A and B to build model:
    x_dot = Ax + Bu

    I started to compute matrix A as a Jacobian matrix but can not compute 3rd raw of the matrix. Maybe jacobian is not necessary.

    could anybody help me please? Thx.
     
  2. jcsd
  3. Jun 3, 2013 #2
    There's something off about your model. In the form you've given, the larger the mass M, the less current i it takes to keep it from accelerating. The model:

    [tex]
    \ddot{x} = g - \frac{c}{M} \frac{i}{x} \qquad (1)
    [/tex]
    makes more sense, I think. c = 1 [N*m/A] is a proportionality constant included to make sense of the units.

    First off, I think you should try to make a process model with the position and velocity of the ball as state variables and the current through the electromagnet as the input. That reflects what you'd be able to observe and control if you were to physically implement your control system. The thing is, the RHS of (1) is then not a linear combination of the state and input variables, so you can't put (1) into the form:
    [tex]
    \mathbf{\dot{x}} = \mathbf{A x + B u}
    [/tex]
    where [itex]\mathbf{x}[/itex] and [itex]\mathbf{u}[/itex] are the state and input vector, respectively.

    You can produce such a form from (1), though, by Taylor expansion. You could give that a try.
     
  4. Jun 3, 2013 #3
    Hi,
    thank you very much for your help. I would have two questions:

    1. what should the model look like to fulfill requirements:
    - input - position of the ball
    - output - current needed to keep the ball at the position defined by input. your (1) model can not be used for that? why?

    2. could I use a jacobian matrix to get state-space model from your (1) equation?
    x=[x1, x2]
    x_dot=[x2, x2_dot]

    then functions used to create jacobian matrix:

    f1: x2
    f2: your (1)

    Sorry if my questions are off, I am just trying to understand it.
     
  5. Jun 3, 2013 #4
    I know you want to implement a feedback control system so you can make the ball track some position reference you give as an input, but let's differentiate between the model of the controller and the model of the process.

    The process model should represent the physical system you want to control, which is the model I was referring to in my previous post. This model will enable you to simulate the response of your physical system to some input. You could, for instance, simulate how the position of the ball changes when you have a current through the electromagnet that's sinusoidal in magnitude.

    When you have a process model, then you need to decide on how to control its output. Since you want a linear state-space model, I assume you want to use linear state-space control design. Full state feedback with a reference input is relatively simple to implement. Maybe you've had a course in it?

    The Jacobian is certainly involved. Have a look at this:
    http://www.cc.ntut.edu.tw/~jcjeng/Linearization.pdf

    for some examples. It was the first hit on Google for 'linearize state space'.
     
  6. Jun 3, 2013 #5
    Ok. I see.
    Now to the point 1:
    I indeed want to implement a feedback control system. I did a course on coursera (control of mobile robots) and now want to put all things together. If I understand you correctly. First thing to do is to create a linear model of the physical system. For that I simply can use state variable x[position,velocity] and 3rd variable - current - is not needed. input would be current and output would be position.
    And here comes my question. At the course we were taught to use full state feedback with a reference input:

    u = -K*x

    and here comes my assumption: I though that since 'u' (input vector) is a current variable, it has to be presented in the state vector 'x'. or?

    Thx!
     
  7. Jun 3, 2013 #6
    Think of it this way: Your process model represents your physical system and, assuming you can't alter the design of your system in any way, you have no control over it. All you can do is run current through its electromagnet (its input variable) and observe how the position and velocity of the ball (its state variables) changes. The thing you can control is the current through the electromagnet.

    One way to make the state of the process behave in a certain way is to measure it and feed a function of it back into the system input. The control law:
    [tex]
    \mathbf{u} = \mathbf{-K x} \qquad (2)
    [/tex]
    does exactly that. You're just measuring [itex]\mathbf{x}[/itex], multiplying it by some matrix [itex]-\mathbf{K}[/itex] and using the result as the magnitude of current you need to produce in the electromagnet. Maybe you're using some analog sensors to measure [itex]\mathbf{x}[/itex], a digital computer with an analog-to-digital converter to multiply your measurement with [itex]-\mathbf{K}[/itex] and a current source with a digital interface to produce [itex]\mathbf{u}[/itex]. Your linear process model would be in the form:
    [tex]
    \mathbf{\dot{x}} = \mathbf{A x} + \mathbf{B u} \Leftrightarrow
    \begin{bmatrix}\dot{x} \\ \ddot{x}\end{bmatrix}
    = \mathbf{A}
    \begin{bmatrix}x \\ \dot{x}\end{bmatrix}
    + \mathbf{B} ,\, \mathbf{x} =
    \begin{bmatrix}x \\ \dot{x}\end{bmatrix}
    ,\, \mathbf{u} =
    [/tex]
    If [itex]\mathbf{K}[/itex] is chosen appropriately, [itex]\mathbf{x}[/itex] will tend asymptotically to the zero vector as t→∞, but please note that there's no reference input. Using (2), your control system can only drive your states to zero. You have to use another control law if you want to control what the state is driven towards.
     
    Last edited: Jun 3, 2013
  8. Jun 4, 2013 #7
    OK, so there is no way I can control the system you described so that u=h (distance from magnet) instead of u=i ? Or I have to use some more complex feedback controller that will allow me to do that?

    note: yes, I understand, that when using (u=-Kx) without reference, or with 0 reference, I will drive x asymptotically to zero. I just want to move step by step from the simplest solution to more complex.
     
  9. Jun 4, 2013 #8
    You can modify the control law so that it takes both the process state and a reference to track as inputs. The control law will use both these inputs to force your process state or output to follow the reference. The input to the process model will still be the current through the electromagnet.

    You should probably just start by producing a linear state-space model from (1) and then have a look at implementing full state feedback.
     
  10. Jun 4, 2013 #9
    Hi,
    I calculated this:

    LTI system:
    A={{0,1},{1,0}}
    B={{0},{-2}})
    C={{1,0}}
    D={}

    I use Octave, so eig(A) = [-1;1] which means unstable.
    Let's use pole placement P=[-1,-1] to compute K
    K=place(A,B,P);
    K={{-1,-1}}

    Now we can compute our new transformation matrix A_dash:
    A_dash=A-B*K
    A_dash=[0,1;-1,-2]

    eig(A_dash) proves position of the poles to be [-1,-1] so now we have asymp. stable system.
    I even wrote simulation in processing (based on (1)) where a ball is driven to zero distance from the magnet when full state feedback [u=-Kx; u=i (current)] is used.

    u = K.times(-1).times(x);
    i = u.get(0,0);

    I experimented then and used this code with a reference input of 50:

    float ref = 50;
    float N_scale = -0.5; //scale factor - we compare reference to result of K*x and not output of the system y
    u = K.times(-1).times(x);
    i = u.get(0,0)+(r*N_scale);

    It seems to work, although I do not fully understand why. Does the scale factor do that, that although u is current, I can fill in the distance (output [y] is distance) as reference?
     
  11. Jun 6, 2013 #10
    I completely forgot about this thread. Your linearized model looks good. I assume it's for the steady-state point (xss,iss) = (10,5)?

    It works because the algorithm you used to calculate N guarantees that your system will have zero steady-state error to any constant input. Does your reading material not show its derivation?
     
  12. Jun 7, 2013 #11
    Yes, the steady-state point is (xss,iss) = (10,5).
    I used formula
    h'' = g - (c * i)/(M * h)
    where
    h'' is actual acceleration,
    i is current,
    c is constant equal to 1
    g is gravit.constant equal to 10
    M is weight (0.05kg) and
    h is distance from the magnet

    I stated h'' to be zero and h to be 10 so i = 5.

    To calculate the scale factor "N" I used Octave and the function created for matlab described here: http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_rscale

    However I have not fully understood yet how is the N factor (a) computed (b) affects the feedback = how N guarantees that your system will have zero steady-state error to any constant input. Going to google it. MANY THX!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: State-space model of magnetically suspended ball
Loading...