Analog Circuit Analysis with Simulink

Analog Circuit Analysis with Simulink

Here we will find out the charge and current inside a given circuit by solving a Differential equation using Simulink.

Simulink finds one of its greatest use in the analysis of an Analog Circuit. Where one can use it to analyze the Voltage Currents Characteristics of electronic circuits.

Here we will find out the charge and current inside a given circuit by solving a Differential equation using Simulink.

According to Kirchoff’s Law, We have L \frac{Di}{dt} +Ri+ \frac{1}{s} \int idt = Esin(t)

q=cv\ and\ i=\frac{Dq}{dt}

so,\ L \frac{D^2q}{dt^2} +R \frac{Dq}{dt}+ \frac{q}{c} = Esin(t)

The above equation can be solved and the equation of charge can be obtained as a function of time, but here in simulink we simulate the above equation by modifying the given sine wave input signal by using required blocks and measure the output at some point of the flow using a scope.

the Equation can be written as:

so,\ L \frac{D^2q}{dt^2} = Esin(t)-R \frac{Dq}{dt}- \frac{q}{c}

now Let L=1, C=1/3 and R=4, then

so,\  \frac{D^2q}{dt^2} = 5sin(t)-4 \frac{Dq}{dt}- 3q

A Simple Beginning

Once you open MatLab you can open Simulink by typing ‘Simulink’ in the command line. Once you open Simulink library browser you can create a fresh Simulink project and start adding blocks from the library.

Here the input signal is a sine function of time with a gain of 5, so we select a sine input signal from the Simulink toolbox, then we connect a gain with value 5 to this.

Plot of Sine wave

Now we place an adder block (with three input terminals) in the Simulink workspace and connect the the input sine signal along with the gain to one input terminal of the adder.

Note: You can edit the properties of any block by right-clicking the block and selecting properties.

The output of the adder is connected to the scope. When analyzed the output of the scope is a sine wave with amplitude equal to that of the gain (i.e 5) .

Note:Here the adder block provides no functionality it is just used to avoid confusion to the readers at a later stage, the output remains the same even if the adder block is removed.

The output can be viewed by running the simulation (ctrl+T) and then double clicking on the scope icon.

The equation of what we have done is as follows:

q = 5sin(t)

The Integrator Block

Now we will start simulating the differential equation by using the integrator blocks. Here we need 2 integrator blocks, as the highest order derivative in this equation is 2.

The output from the adder block is removed from the scope and is connected to the input of the integrator block and the output of the

Resultant Plot

integrator block is connected to the input of another integrator block. The output of this integrator block is connected to the scope.

This way we can integrate the output of the adder block twice before viewing it in the scope.

Now we can set the initial conditions for the integration by each block. Right click the integrator blocks and select properties set the initial value parameter as 0 for the first integrator block and 0.5 for second integrator block.

The equation of what we have done is as follows:

\frac{D^2q}{dt^2} = 5sin(t) , with y=0 and y’=0.5 initally.

On solving we get,

q=5.5t-5sin(t) , which is the same curve plotted on the right side.

The Complete Circuit

Now we need to get the other two terms (i.e 1st and 2nd order terms of q). For that we add another root to the output of the first integrator block that gives (that gives the dq/dt term) and connect it to one terminal of the adder block then we add a gain block in between to represent the multiplier.

We do the same thing for obtaining the q term, we connect the output of the second integrator block before the scope to the third input of the adder through a gain block (with gain 3).

The Output

Now the resultant equation is obtained by solving the given differential equation: q = -e^{-t} + 0.5e^{-3t} + 0.5sin(t) - cos(t)

Plot of Current Vs Time

Plot of Charge Vs Time

Thats it!!

Thank you for following this tutorial, I hope you have followed all the parts of this tutorial. If you did’nt you can feel free to post your doubts in the comments section. You can also download the source files and run the simulation in Simulink, then you can experiment with the different blocks until you get a hold of it. All the Best!

Download the Source code

Similar topics you might like…

Share this Post and become one of us...