Direct Numerical Integration of a One Pole Linear Low
Pass Filter
© Andrew Simper, Cytomic, 2013, [email protected]
last updated: 24th November 2013
References
@1D http : en.wikipedia.org wiki Capacitor
@2D http : en.wikipedia.org wiki Resistor
@3D http : en.wikipedia.org wiki Operational_transconductance _amplifier
@4D http : en.wikipedia.org wiki Trapezoidal_rule
@5D http : en.wikipedia.org wiki Backward_Euler _method
@6D http : en.wikipedia.org wiki Nodal_analysis
@7D http : qucs.sourceforge.net tech node26.html
@8D http : www.ecircuitcenter.com SPICEtopics.htm
@9D http : www.native - instruments.com fileadmin ni_media downloads pdf VAFilterDesign_ 1.0 .3.pdf
Capacitors [1]
An idealised capacitor can be described by:
QHtL 1
vcHtL = = Ù icHtL
C C
Trapezoidal integration of capacitor [4, 7]
h
vcn+1 = vcn + I1 2 icn+1 + 1 2 icn M
C
2C 2C
vcn+1 = vcn + icn+1 + icn
h h
2C 2C
vcn+1 - vcn = icn+1 + icn
h h
2C 2C
icn+1 = vcn+1 - vcn - icn
h h
We can write the expression with these grouped terms of a scalar and and offset:
icn+1 = gc vcn+1 - iceqn (1)
where:
2C
gc =
h
iceqn = gc vcn + icn
To update iceqn+1 for the next time step after you have solved for vcn+1 and so icn+1 we have:
iceqn+1 = gc vcn+1 + icn+1
iceqn+1 = gc vcn+1 + gc vcn+1 - iceqn
which can be simplified to :
iceqn+1 = 2 gc vcn+1 - iceqn (2)
In general the linear form show in equation (1) can be used to solve any numerical integration
scheme, but the gc and iceq terms, and how iceq is updated will be different depending on which
numerical integration scheme is used. To illustrate this next is shown how to apply Backwards Euler
integration to a capacitor.
2 OnePoleLinearLowPass.nb
Backwards Euler integration of capacitor [5, 7]
QHtL 1
vcHtL = = Ù icHtL
C C
h
vcn+1 = vcn + Iicn+1 M
C
C C
vcn+1 = vcn + icn+1
h h
C C
icn+1 = vcn+1 - vcn
h h
We can write the expression with these grouped terms of a scalar and and offset:
icn+1 = gc vcn+1 - iceqn
where:
C
gc =
h
iceqn = gc vcn
To update iceqn+1 for the next time step after you have solved for vcn+1 we have:
iceqn+1 = gc vcn+1 (3)
Resistors [2]
An idealised resistor can be described by:
ir = vr R
which can be written as :
ir = gr vr (4)
where:
gr = 1 R
Transconductance Amplifier [3]
A linear transconductance amplifier can be described by:
ia = ga Hvin+ - vin- L (5)
and no current is drawn from either input, so only the output current ia will appear in any nodal
analysis equations.
Voltage follower
Denoted by a triangle with a 1 in the middle an idealised voltage follower, which is a voltage source
that draws no current from its input and reproduces the input voltage at its output. This means that it
won’ t appear in any nodal analysis equations on the input side, and the output side is a voltage
source.
OnePoleLinearLowPass.nb 3
Passive one pole low pass
Figure 1: passive one pole RC low pass filter
Solving for terms using nodal analysis (also called KCL, ie the sum of currents
at each node is zero) [6, 8]
Using equations (1) and (4) for currents of the capacitor and resistor respectively we can write the
nodal equations as follows:
0 = ir1 - ic1
0 = gr Hv0 - v1L - Hgc Hv1 - 0L - ic1eqL
0 = gr v0 - gr v1 - gc v1 + ic1eq
0 = gr v0 - v1 Hgr + gcL + ic1eq
v1 Hgr + gcL = gr v0 + ic1eq
v1 = Hgr v0 + ic1eqL Hgr + gcL
If we set gc = 1, and g = gr then this can be further simplified as
v1 = Hg v0 + ic1eqL H1 + gL (6)
Since this is a linear circuit it can be solved in one step, and then once we have solved for v1 we
can update your equivalent current of the capacitor ready for the next time step, for trapezoidal
integration this is:
ic1eq = 2 v1 - ic1eq z-1
Active one pole linear low pass
4 OnePoleLinearLowPass.nb
Figure 2: active one pole operational transconductance amplifier low pass filter
Solving for terms using nodal analysis (also called KCL, ie the sum of currents
at each node is zero) [6, 8]
This circuit looks a lot more complicated than the passive one, and all this extra effort is done to
allow voltage control of the cutoff frequency. More accurately a voltage is turned into a bias current
which sets the transconductance gain of the amplifier.
This circuit has a linear transconducance amplifier a1 To simplify this circuit lets have a look at on of
the voltage dividers at the input
Figure 3: voltage divider
Using equations (1) and (4) for currents of the capacitor and resistor respectively we can write the
nodal equations as follows:
0 = ir1 + ir2
0 = gr1 Hv0 - v2L + gr2 H0 - v2L
0 = gr1 v0 - gr1 v2 - gr2 v2
0 = gr1 v0 - v2 Hgr1 + gr2L
v2 = v0 gr1 Hgr1 + gr2L
We can now directly write down the same solution for v3:
v3 = v1 gr3 Hgr3 + gr4L
For a low pass filter we set r1 = r3 and r2 = r4, and so gr1 = gr3 and gr2 = gr4, so we can write
v2 = gr v0
v3 = gr v1
where :
gr = gr1 Hgr1 + gr2L = gr3 Hgr3 + gr4L
The inputs to an idealised operational transcductance amplifier pull no current, so the nodal equa-
tions that we have already solved for the voltage divider as sufficient at both inputs, so we just need
to solve at the node where a1 and c1 connect:
0 = ia1 - ic1
0 = ga1 Hv2 - v3L - Hgc Hv1 - 0L - ic1eqL
0 = ga1 Hgr v0 - gr v1L - Hgc Hv1 - 0L - ic1eqL
0 = ga1 gr v0 - ga1 gr v1 - gc v1 + ic1eq
0 = ga1 gr v0 - v1 Hga1 gr + gcL + ic1eq
v1 = Hga1 gr v0 + ic1eqL Hga1 gr + gcL
Which can be simplified to the same equation (6) we got for the passive low pass filter, if we set
g = ga1 gr and gc = 1:
OnePoleLinearLowPass.nb 5
v1 = Hg v0 + ic1eqL H1 + gL
And we also have an identical update of your equivalent current of the capacitor for the next time
step using trapezoidal integration:
ic1eq = 2 v1 - ic1eq z-1
If we remove the voltage dividers at the input and note that we can makeup any gain they attenu-
ated by adjusting the the g term of the amplifier we can write draw the schematic as follows:
Figure 4: simplified active low pass filter with input voltage divider resistors removed
From the nodal equation at the output of the amplifier we can write down the equtions to solve this
circuit as:
0 = g Hv0 - v1L - HHv1 - 0L - iceqL
0 = g Hv0 - v1L - v1 + ic1eq
v1 = g Hv0 - v1L + ic1eq
and further more we could have labelled all the variables differently, lets let y = v1, x = v0, and
s = ic1eq, then the nodal equations can be written as:
y = g Hx - yL + s
Identical formation with alternate notation [9]
Figure 5: alternative notation to describe a low pass filter
The previous two methods show how existing long standing circuit analysis methods are applied to
solve a one pole low pass filter. You can write these same equations with alternative notation if you
want, it doesn’
t change any of the underying and well established mathematics. For example if we
express a one pole filter as shown in figure 5 we can write down the equations as:
y = g Hx - yL + s
y = gx - gy + s
y H1 + gL = g x + s
y = Hg x + sL H1 + gL
6 OnePoleLinearLowPass.nb
y = g Hx - yL + s
y = gx - gy + s
y H1 + gL = g x + s
y = Hg x + sL H1 + gL
If we set v1 = y, v0 = x, and ic1eq = s we have our familiar equations written in a more standard
form:
v1 = Hg v0 + ic1eqL H1 + gL
So, if we are using trapezoidal integration, we can immediately write down how to update s for the
next timestep as:
s = 2 y - s z-1
Which is equivalent to our regular terms:
ic1eq = 2 v1 - ic1eq z-1
But without alterning the equations or methods we can use an extra intermediate term v instead of
calculating y directly, so lets define:
v = g Hx - yL
v = g Ix - Ig x + s z-1 M H1 + gLM
v = g Ix - s z-1 M H1 + gL
and so:
y = v + s z-1
we now update our s term by setting:
s=y + v
s = v + s z-1 + v
s = 2 v + s z-1
But how does this relate to trapezoidal integration? To find out we substitute the full expression for v
into the above:
s = 2 Ig Ix - s z-1 M H1 + gLM + s z-1
now re-arrange this to express the update of s in terms of y and s z-1 instead of x. To do this we
need to express x in terms of y, which we can do from our original equations:
y = g Hx - yL + s z-1
y = g x - g y + s z-1
g x = y + g y - s z-1
x = Iy + g y - s z-1 M g
Now we can substitute this value for x into our equation that defines how s is updated for the next
timestep:
s = 2 Ig Ix - s z-1 M H1 + gLM + s z-1
s = 2 Ig IIIy + g y - s z-1 M gM - s z-1 M H1 + gLM + s z-1
s = 2 Iy + g y - s z-1 - g s z-1 M H1 + gL + s z-1
s = 2 Iy H1 + gL - s z-1 H1 + gLM H1 + gL + s z-1
s = 2 Iy - s z-1 M + s z-1
s = 2 y - s z-1
OnePoleLinearLowPass.nb 7
s = 2 Ig Ix - s z-1 M H1 + gLM + s z-1
s = 2 Ig IIIy + g y - s z-1 M gM - s z-1 M H1 + gLM + s z-1
s = 2 Iy + g y - s z-1 - g s z-1 M H1 + gL + s z-1
s = 2 Iy H1 + gL - s z-1 H1 + gLM H1 + gL + s z-1
s = 2 Iy - s z-1 M + s z-1
s = 2 y - s z-1
So with a bit of algebra we have uncovered that introducing the extra term v leads to an identical
formulation of the equations, but also requires some intermediate algebra and an extra addition to
compute.