/* Third order filter with Sallen-Key architecture */ /* Start clean */ kill(all); /* Network current equations */ node1: '(i5 = i1 + i6); node2: '(i1 + i3 = i2); node3: '(i2 = i4); /* Active element constraint equation */ node4: '(vvo = vv3); /* Component constraint equations */ i5: (vvi - vv1)/z5; i6: (vv1 / z6); i1: (vv1 - vv2)/z1; i3: (vvo - vv2)/z3; i4: vv3/z4; i2: (vv2 - vv3)/z2; /* Eliminate vv3 terms using amplifier constraint. */ /* Node 4 is no longer needed after this. */ i4: subst(vvo, rhs(node4), i4); i2: subst(vvo, rhs(node4), i2); /* Force evaluation of node equations using component constraints */ node1: ''node1; node2: ''node2; node3: ''node3; /* Rearrange the node1 constraint to evaluate node voltage vv1 */ solve(node1,vv1); node1: %[1]; /* Substitute this result into the node2 voltage constraint */ /* The only remaining terms in node2 are vvi and vvo. */ node2: subst(rhs(node1),vv1,node2); /* Rearrange the node2 constraint to obtain an expression for vv2 */ solve(node2,vv2); node2: %[1]; /* Substitute this into the constraint for node3 */ node3: subst(rhs(node2),vv2,node3); /* The voltage transfer expression we want is the ratio vvo/vvi */ solve(node3,vvo); tr: %[1] / vvi; /* Insert the impedances according to component types */ tf: ev(%, z1:r1, z2:r2, z3:1/(c3*s), z4:1/(c4*s), z5:r5, z6:1/(c6*s)); tf: ratsimp(%);