Arbitrary Behavioral Sources (Experimental)

Apr 13 2012, 1:45 PM PDT · 1 comment »

We're happy to announce a major upgrade to our simulation backend: voltage and current sources can now become arbitrary behavioral sources. For those not familiar with the tech lingo, it means that voltage and current sources are now "programmable". This feature is currently experimental within CircuitLab, but we wanted to provide you with the power you need to go beyond our included device models.

Let's take a look at a simple modeling example: a TL431 programmable shunt voltage regulator. It's sort of like a Zener diode in that it's a shunt-type device where the incremental resistance becomes tiny past the "on" voltage. However, the TL431 has a third terminal which allows it to be adjustable, and it basically draws as much current from the "cathode" terminal as needed to keep the "reference" terminal at 2.5 volts above the "anode" terminal. The user can then build a simple feedback network, like a resistor divider, to have a programmable shunt voltage reference. Beyond the programmability, the TL431 has another advantage over Zener diodes, which is that its incremental "on" resistance is quite low, so its voltage stays quite steady over varying load currents.

Here's a very simple model built in CircuitLab (from a bigger test circuit we'll link below):

You can see that I2 is a normal current source, drawing 2uA into the reference terminal. But I1 is a current source that's defined by an expression, "MAX(0, (V(REF)-V(ANODE)-2.5)/1m)". That expression means that the current flowing through I2 is the maximum of 0 and the quantity on the right side -- meaning that if the right side is less than 0, the current is just zero, so the current is never negative. The other piece of the expression is "(V(REF)-V(ANODE)-2.5)/1m", which means to take the voltage difference between REF and ANODE nodes, subtract 2.5 volts (which is the built-in reference voltage of the TL431), and then divide by 0.001. That 0.001 is almost like a resistance, where the current varies by 1000 amps for every volt of difference. But here, it's really a transconductance, because the terminals that the current flow through aren't the same terminals whose voltages are being measured.

This is part of a test circuit:

We can run a DC sweep, and demo the parameter sweep options as well to adjust the resistors connected in the external circuit:

Here, we can see that the output voltage is adjustable by the feedback resistors R2 and R3.

Behavioral sources are experimental, but feel free to go ahead and give them a try! Read more about allowed expressions and behavioral sources. Beware that behavioral sources make it very easy to cause convergence problems. We work hard to make sure that CircuitLab-defined built-in models converge in most cases, but arbitrary behavioral sources means that you're on your own. If you're having trouble, feel free to ask for help on the forums and see if another user can help re-structure your equations to achieve the desired effect.


Deep joy.

A really great improvement in the usefulness of CircuitLab.

An example shows how much circuitry can be collapsed into a very few behavioural sources for instance when the detailed discrete circuitry to implement a particular set of functions isn't actually what you want or need to simulate in detail.

by signality
April 14, 2012

Leave a Comment

Please sign in or create an account to comment.