## Control System Question

I am trying to implement a digital state space control and am confused about something. The system has the standard state space form:
$x(k+1) = Ax(k) + Bu(k)$
$y(k) = Cx(k)$

The vector y(k) comes from the sensors measurements and u(k) is what is sent to the actuator, right?
 PhysOrg.com engineering news on PhysOrg.com >> PNNL-developed injection molding process recognized with emerging technologies award>> How soon could car seats enter the 3-D comfort zone?>> NASA: Austin, calling Austin. 3-D pizzas to go
 I am confused because I am reading the following in a book that uses standard state space notation: The flow diagram assumes that the real-time processor provides the following capabilities. "A real-time clock enabling execution of the update loop at integer multiples of the sampling interval h. Input devices for reading the plant sensors. Output devices that enable the controller to drive the plant actuators."
 If you are talking about a diagram like this: then Y is your output and U is the input into the system. Your sensor measurement would happen somewhere after Y and feedback through a controller that would generate U. Remember, the state space diagram is a model of the system you are trying to control and does not include the controller.

## Control System Question

That block diagram is what we are trying to implement.

So we are measuring two out of four of the states. The system is fully controllable and observable. We want to implement state feedback, and have generated a gain matrix K. So we would like to implement the following algorithm:

1. Get values from sensors, store in $y$.
2. Estimate the state, store in $x$.
3. Calculate $u=-Kx$.
4. Send $u$ to the actuator.
5. Repeat.

Is my logic correct?
 Sure, if your closed-loop estimator and process poles are placed right. Does your process model include the dynamics of your actuator though? Otherwise you might not be feeding your process the input you're expecting.
 No I am not. The system is an inverted pendulum on a cart. The actuator is a DC motor. The value produced for $u$ is the force that is supposed to be applied to the cart to move it. I would like to just combine the models. How do I do that because the matrices describing the dynamics of the inverted pendulum and the motor are different dimension and also have different state variables. How do I combine state space models? Here are the models I am using: Inverted Pendulum: http://ctms.engin.umich.edu/CTMS/ind...trolStateSpace Motor: http://ctms.engin.umich.edu/CTMS/ind...trolStateSpace
 You generally combine state space models by including their interconnections as internal state information instead. Here's your 'DC Motor Position' state space model split into electrical and mechanical subsystems: $$\frac{\mathrm{d}}{\mathrm{dt}}i = -\frac{R}{L}i + \begin{bmatrix} \frac{1}{L} & -\frac{K}{L} \end{bmatrix} \begin{bmatrix} V\\ \dot{\theta} \end{bmatrix}$$ $$\frac{\mathrm{d}}{\mathrm{dt}} \begin{bmatrix} \theta\\ \dot{\theta} \end{bmatrix} = \begin{bmatrix} 0 & 1\\ 0 & -\frac{b}{J} \end{bmatrix} \begin{bmatrix} \theta\\ \dot{\theta} \end{bmatrix} + \begin{bmatrix} 0\\ \frac{K}{J} \end{bmatrix}i$$ You can see how they're easily combined by adding more states to account for their interconnections.
 The variable $\theta$ is what relates the motor to the inverted pendulum system. This is because the torque the motor exerts is converted to the linear force applied to the cart through a pulley gear system. But I still don't see how I combine their state space models. Do I augment the matrices together - resulting in a higher order system, or do I combine them in some other sense?
 I used the state space model on the page you have linked to, 'DC Motor Position', as a simple example. I have split it into two state space models (I do not include the output equation for each) so you can see how they're combined to form the model on the 'DC Motor Position' page. First model has current, i, as state and motor terminal voltage and angular velocity as inputs, V and theta_dot, respectively. Second model has angular position and angular velocity as states, theta and theta_dot, respectively and current, i, as input. Can you try to make a combined model of these two? Start with states: $$\begin{bmatrix} \theta\\ \dot{\theta}\\ i \end{bmatrix}$$
 Okay, so would the states be augmented like this: $$\begin{bmatrix} \theta\\ \dot{\theta}\\ i\\ x\\ \dot{x}\\ \phi\\ \dot{\phi} \end{bmatrix}$$

 The variable θ is what relates the motor to the inverted pendulum system. This is because the torque the motor exerts is converted to the linear force applied to the cart through a pulley gear system.
The input for your cart-pendulum model is a force. The DC motor produces torque K*i, so the force applied to the cart will only be a function of current, i. You don't need theta, theta_dot. States could be:

$$\begin{bmatrix} x\\ \dot{x}\\ \phi\\ \dot{\phi}\\ i \end{bmatrix}$$
 Well, from your equations that separate the electrical and mechanical description of the motor: $$\frac{\mathrm{d}}{\mathrm{dt}}i = -\frac{R}{L}i + \begin{bmatrix} \frac{1}{L} & -\frac{K}{L} \end{bmatrix} \begin{bmatrix} V\\ \dot{\theta} \end{bmatrix}$$ $$\frac{\mathrm{d}}{\mathrm{dt}} \begin{bmatrix} \theta\\ \dot{\theta} \end{bmatrix} = \begin{bmatrix} 0 & 1\\ 0 & -\frac{b}{J} \end{bmatrix} \begin{bmatrix} \theta\\ \dot{\theta} \end{bmatrix} + \begin{bmatrix} 0\\ \frac{K}{J} \end{bmatrix}i$$ The equations written out of matrix notation are: $\frac{d}{dt}i=-\frac{R}{L}i + \frac{1}{L}V -\frac{K}{L}\dot{\theta}\\ \frac{d}{dt} \dot{\theta} = -\frac{b}{J} \dot{\theta}+\frac{K}{J}i$ But I need to separate $i$ from the variables $V$ and $\theta$ in order to put in in the matrix equation with the state vector you wrote: $$\begin{bmatrix} x\\ \dot{x}\\ \phi\\ \dot{\phi}\\ i \end{bmatrix}$$ But I can't figure out how to do that. Where is my logic going wrong?
 You need to know the angular velocity of the motor shaft in order to calculate the back-emf, but if you assume the motor shaft to be connected to the cart through rigid interconnects, then the cart velocity, x_dot, is also a measure of the angular velocity of the motor shaft. Edit: The motor terminal voltage, V, is still an input to the combined model.
 Okay, I will walk through what I have done to try to figure out $i$ in terms of $V$: $\frac{d}{dt}i=-\frac{R}{L}i + \frac{1}{L}V -\frac{K}{L}\dot{\theta}\\ \frac{d}{dt} \dot{\theta} = -\frac{b}{J} \dot{\theta}+\frac{K}{J}i$ Solve the first equation for $\dot{\theta}$: $$\dot{\theta}=-\frac{L}{K} \dot{i} - \frac{R}{K}i +\frac{1}{K}V$$ Differentiate: $$\frac{d}{dt}\dot{\theta}=-\frac{L}{K}\frac{d}{dt} \dot{i} - \frac{R}{K}\frac{d}{dt}i +\frac{1}{K}\frac{d}{dt}V$$ Plug these two equations into the second of the first two equations: $$(-\frac{L}{K}\frac{d}{dt} \dot{i} - \frac{R}{K}\frac{d}{dt}i +\frac{1}{K}\frac{d}{dt}V) = -\frac{b}{J} (-\frac{L}{K} \dot{i} - \frac{R}{K}i +\frac{1}{K}V)+\frac{K}{J}i$$ But the terms with the derivatives of $i$ don't fit into the equation with the state vector: $$\begin{bmatrix} x\\ \dot{x}\\ \phi\\ \dot{\phi}\\ i \end{bmatrix}$$ What am I doing wrong here?
 You need to fill this out: $$\frac{\mathrm{d}}{\mathrm{dt}} \begin{bmatrix} x\\ \dot{x}\\ \phi\\ \dot{\phi}\\ i \end{bmatrix} = \begin{bmatrix} ? & ? & ? & ? & ?\\ ? & ? & ? & ? & ?\\ ? & ? & ? & ? & ?\\ ? & ? & ? & ? & ?\\ ? & ? & ? & ? & ? \end{bmatrix} \begin{bmatrix} x\\ \dot{x}\\ \phi\\ \dot{\phi}\\ i \end{bmatrix} + \begin{bmatrix} ?\\ ?\\ ?\\ ?\\ ? \end{bmatrix}V$$ I can not do it for you because I do not know the details of what connects the motor shaft to the cart (I have assumed rigid interconnects). Here are some things you need to get straight before you proceed if you decide to use the state vector I have suggested: - How is the force applied to the cart related to the motor armature current, i? - How is the angular velocity of the motor shaft related to the linear velocity of the cart, x_dot?
 Okay, so referring to my previous post, I am getting to this point: $$(-\frac{L}{K}\frac{d}{dt} \dot{i} - \frac{R}{K}\frac{d}{dt}i +\frac{1}{K}\frac{d}{dt}V) = -\frac{b}{J} (-\frac{L}{K} \dot{i} - \frac{R}{K}i +\frac{1}{K}V)+\frac{K}{J}i$$ I can simplify this further to get the last row of the state space equation, but you can already see that the derivatives of $i$ don't fit into the equation: $$\frac{\mathrm{d}}{\mathrm{dt}} \begin{bmatrix} x\\ \dot{x}\\ \phi\\ \dot{\phi}\\ i \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0 & 0 & 0 \\ 0 & \frac{-(I+ml^2)b}{(M+m)I+Mml^2} & \frac{m^2gl^2}{(M+m)I+Mml^2} & 0 & 0\\ 0 & 0 & 0 & 1 & 0\\ 0 & \frac{-mlb}{(M+m)I+Mml^2} & \frac{(M+m)mgl}{(M+m)I+Mml^2} & 0 & 0\\ ? & ? & ? & ? & ? \end{bmatrix} \begin{bmatrix} x\\ \dot{x}\\ \phi\\ \dot{\phi}\\ i \end{bmatrix} + \begin{bmatrix} 0\\ 0\\ 0\\ 0\\ ? \end{bmatrix}V$$
 I'm not sure what it is you want from that equation. As I see it, this: $$\frac{\mathrm{d}}{\mathrm{dt}}i = -\frac{R}{L}i + \begin{bmatrix} \frac{1}{L} & -\frac{K}{L} \end{bmatrix} \begin{bmatrix} V\\ \dot{\theta} \end{bmatrix}$$ fits perfectly well into the last row if you can express the angular velocity, theta_dot, as a function of the linear velocity, x_dot. Also, shouldn't the force applied to the cart affect its acceleration?