Simulate Feedback Systems with Laplace Blocks

The Laplace transform lets you express differential equations as rational polynomials in "s". CircuitLab lets you work with Laplace Blocks directly. Flip through the screenshots below to see how to use this to easily define filters and feedback loops.

Press / (forward slash) to begin a toolbox search, and type "laplace". Drag a Laplace Block to the schematic, and double-click it to edit its parameters:

Enter "1/(1 + s/(2*PI*10000))" in the TF (transfer function) box:

This is the transfer function of a one-pole low-pass filter with a bandwidth of 10 kHz.

Click the X to clear the toolbox search, and then click and drag to insert a voltage step source, a ground node, and two node names. Double-click the node names to label them "in" and "out", wiring the circuit as shown:

Click Simulate at the bottom of the window, then click Frequency Domain. Choose V1 as the Input source, increase Points/Decade to 50, and click the "out" node name to add DB(MAG(V(out))) and PHDEG(V(out)) to the Outputs list:

Click Run Frequency-Domain Simulation. A plot window appears:

The Laplace Block LB1 behaves like a low-pass filter, flat at 0 dB (neither amplifying nor attenuating) until a corner with a -3 dB frequency exactly at 10 kHz, as expected.

How about in the time domain?

Click Hide in the plot window. In the simulation settings window, expand the Time Domain tab. Enter a Stop Time of 1m, Time Step of 100n, and click "in" and "out" node name labels to add V(in) and V(out) to the Outputs list:

Click Run Time-Domain Simulation. A plot window appears:

This is the step response of the Laplace transfer function provided.

Let's make things more interesting by building a feedback loop.

Click Build at the bottom of the window to return to build mode. Double-click LB1 and change its transfer function to ā€œ10000/sā€, and drag it to the right to make some space on the left side near V1:

Scroll down in the toolbox to find Voltage Signal Elements. Click and drag a Voltage Difference onto the wire between V1 and LB1's input:

Click and drag a wire from LB1's output back to the negative input of SUM1:

Press F5 to repeat the simulation. A plot window appears:

LB1 is an integrator. If a physical analogy helps, we might think of this like a car, where the speed of the car is (in a simplified sense) the integral of the accelerator (minus brake) input. The input to LB1 is the accelerator (minus break) control, and the output of LB1 is the speed of the car.

We've made a closed-loop feedback system, where the output feeds back to produce an error signal. Continuing our analogy, this is like cruise control in your car. Our input V(in) is our desired speed, and our feedback loop subtracts the desired speed minus the measured speed to produce an accelerator (minus break) control signal to feed into LB1.

What happens if our speed feedback sensor is slow, as all real-world sensors are?

Click Build to return to build mode. Click and drag a new Laplace Block onto the schematic, onto the feedback wire, pressing R twice to rotate it so that the signal flows from V(out) back toward SUM1:

Double-click on LB2 and set its transfer function to "1/(1 + s/(2*PI*1000))":

This is roughly like saying the speedometer in our car can't update faster than 1 kHz.

Press F5 to repeat the simulation. A plot window appears:

Simply by making the speed sensor a bit slow to update, we now have considerable overshoot in our cruise control system: the actual output exceeds the desired output by 54% -- definitely a recipe for a speeding ticket!

As engineers, it's our job to design a controller to fix this problem.

Click Build to return to build mode. Click and drag another Laplace Block onto the wire between SUM1's output and LB1. Drag the wires and components so there's lots of room to work:

LB3 is our cruise control controller. LB1 is our plant, and LB2 is our sensor.

Double-click LB3 and set its transfer function to "0.6 *(1+s/(2*PI*1200))/(1+s/(2*PI*10000))":

This is a controller with a zero at 1.2 kHz and a pole at 10 kHz, as well as a fixed gain of 0.6.

Press F5 to repeat the simulation:

Now there's only 4% overshoot, and the output also reaches the target much much faster! This might be too aggressive for a car with human passengers (unsafe levels of acceleration), but looks pretty ideal for other kinds of control systems.

Determining a good feedback controller transfer function is beyond the scope of this email. Consider taking a course in classical Feedback Control Systems.

An example of a bad controller would be changing LB3's transfer function to simply ā€œ1/(1+s/(2*PI*10000))ā€:

With this simpler controller transfer function, the overshoot is even worse.

CircuitLab provides you the tools to easily validate the behavior of your control system by designing and simulating in terms of Laplace Blocks, easily placing poles and zeros where you desire. It's up to you to use that power wisely.

That's it! Click below to open the final circuit, or try it yourself from scratch (recommended).


« Return to Table of Contents

Search Documentation


About CircuitLab

CircuitLab is an in-browser schematic capture and circuit simulation software tool to help you rapidly design and analyze analog and digital electronics systems.