# Circuit Theory/State Variables

New techniques are needed to solve 2nd order and higher circuits:

- Symbolic solutions are so complicated, merely comparing answers is an exercise
- Analytical solution techniques are more fragmented
- The relationship between constants, initial conditions and circuit layout are becoming complicated

A change in strategy is needed if circuit analysis is going to:

- Move beyond the ideal
- Consider more complicated circuits
- Understand limitations/approximations of circuit modeling software

The solution is "State Variables." After a state variable analysis, the exercise of creating symbolic solution can be simplified by eliminating terms that don't have a significant impact on the output.

### State Space

editThe State Space approach to circuit theory abandons the symbolic/analytical approach to circuit analysis. The state variable model involves describing a circuit in matrix form and then solving it numerically using tools like series expansions, Simpson's rule, and Cramer's Rule. This was the original starting point of matlab.

### State

edit"State" means "condition" or "status" of the energy storage elements of a circuit. Since resistors don't change (ideally) and don't store energy, they don't change the circuit's state. A state is a snap shot in time of the currents and voltages. The goal of "State Space" analysis is to create a notation that describes all possible states.

### State Variables

editThe notation used to describe all states should be as simple as possible. Instead of trying to find a complex, high order differential equation, go back to something like Kirchhoff analysis and just write terminal equations.

State variables are voltages across capacitors and currents through inductors. This means that purely resistive circuit cut sets are collapsed into single resistors that end up in series with an inductor or parallel to capacitor. Rather than using the symbols v and i to represent these unknowns, they are both called x. Kirchhoff's equations are used instead of node or loop equations. Terminal equations are substituted into the Kirchhoff's equations so that remaining resistor's currents and voltages are shared with inductors and capacitors.

### State Space Model

editThis State Space Model describes the inputs (step function μ(t), initial conditions X(0)), the output Y(t) and A,B,C and D. A-B-C-D are transfer functions that combine as follows:

A control systems class teaches how to build these block diagrams from a desired transfer function. Integrals "remember" or accumulate a history of past states. Derivatives predict future state and both, in addition to the current state can be separately scaled. "A" represents feedback. "D" represents feed forward. There is lots to learn.

Don't try to figure out how a negative sign appeared in the denominator and where the addition term came from. How does the above help us predict voltages and currents in a circuit? Let's start by defining terms and do some examples:

- A is a square matrix representing the circuit components (from Kirchhoff's equations.
- B is a column matrix or vector representing how the source impacts the circuit (from Kirchhoff's equations).
- C is a row matrix or vector representing how the output is computed (could be voltage or current)
- D is a single number that indicates a multiplier of the source .. is usually zero unless the source is directly connected to the output through a resistor.

A and B describe the circuit in general. If X is a column matrix (vector) representing all unknown voltages and currents, then:

At this point, X is known and represents a column of functions of time. The output can be derived from the known X's and the original step function μ using C and D:

### MatLab Implementation

editThis would not be a step forward without tools such as MatLab. These are the relevant MatLab control system toolbox commands:

- step(A,B,C,D) assumes the initial conditions are zero
- initial(A,B,C,D,X(0)) just like step but takes into account the initial conditions X(0)

In addition, there is a simulink block called "State Space" that can be used the same way.

### Video Introduction

edit## Further reading

edit- Control Systems/State-Space Equations
- matlab help links