previous | back | home | next | ||||||||||||||||||||||||||||||||||||||||||||||||
CACD Group updated 2000.03.30 Author Janez Puhan | ||||||||||||||||||||||||||||||||||||||||||||||||
Fifth-order active low-pass filterThe circuitIn this example the fifth-order active low-pass filter will be optimised by optimize command. The circuit is shown in figure below. We can see, that we have two ideal operational amplifiers with 120dB gain and five resistors and capacitors, which determine pole locations in s plane. In fact all circuit poles can be set without changing resistor values. So all resistors are the same (resistance is 50kW). Here is the netlist of the circuit (part of fifth-order_active_low-pass_filter.cir file): *** the fifth-order low-pass filter *** vin 1 0 dc 0 ac 1V r1 1 2 50k r2 2 3 50k r3 3 4 50k r4 5 6 50k r5 6 7 50k c1 2 0 250nF c2 4 0 25nF c3 3 5 500nF c4 6 8 500nF c5 7 0 5nF e1 5 0 4 5 1meg e2 8 0 7 8 1meg .end We want to design the low-pass filter with -3dB at 100Hz (cutoff frequency) and at least -70dB at 350Hz. Minimal ripple is desired at the same time. So we are looking for capacitances c1, c2, c3, c4 and c5, which will give the most satisfying frequency response. Frequency response is in our case given by: H(jw) = H(jw, c1, c2, c3, c4, c5) Because of the given circuit topology the dc gain will always be 0dB for arbitrary capacitances c1, c2, c3, c4 and c5. H(j0, c1, c2, c3, c4, c5) = 1 = 0dB We can estimate the explicit constraints of the capacitances c1, c2, c3, c4 and c5. 50nF < c1 < 500nF In this example, we are searching for the capacitances c1, c2, c3, c4 and c5 inside these intervals, which will give the required frequency response. Now we have to define the cost function. It has to increase with ripple, difference between cutoff frequency and 100Hz and dBs above -70dB at 350Hz. The cost function will be defined by simply adding those three requests without weights (all are equally important). The second request will not be strictly realised. The cost function will be increased if frequency response is below -3dB at 98Hz (cutoff frequency is to low) and if frequency response is above -3dB at 102Hz (cutoff frequency is to high). E(c1, c2, c3, c4, c5) = (ripple) + Because we are interested only in vector v(8), we will not save all other vectors calculated in a particular analysis. save command defines which vectors will be saved. Then the circuit's netlist is loaded by source command. We will also define two vectors min and max in a const plot, which is never destroyed. Those two vectors will point to the highest and the lowest component of the frequency response and will be needed for calculating the ripple in the cost function. Spice Opus 1 -> source (filename with netlist of the circuit) Circuit: *** the fifth-order low-pass filter *** Spice Opus 2 -> save v(8) Spice Opus 3 -> let max = vector(100) Spice Opus 4 -> let min = vector(100)First we have to define the parameters, which can vary in the optimisation process. Those are capacitances of elements c1, c2, c3, c4 and c5. This can be done by optimize parameter command. At the same time we will give the explicit constraints for all parameters and the initial point (c1 = 250nF, c2 = 25nF, c3 = 500nF, c4 = 500nF and c5 = 5nF), where the optimisation algorithm will start. Spice Opus 5 -> optimize parameter 0 element c1 parameter capacitance low 50n high 500n initial 250n Spice Opus 6 -> optimize parameter 1 element c2 parameter capacitance low 5n high 50n initial 25n Spice Opus 7 -> optimize parameter 2 element c3 parameter capacitance low 100n high 1u initial 500n Spice Opus 8 -> optimize parameter 3 element c4 parameter capacitance low 100n high 1u initial 500n Spice Opus 9 -> optimize parameter 4 element c5 parameter capacitance low 1n high 10n initial 5nWe also have to define the commands, which will be executed in every iteration. Those commands have to provide data for computing the value of the cost function and for verifying the implicit constraints (in this example there are no implicit constraints). To compute the cost function the frequency response is needed. It will be computed by three ac analyses. Also min and max vectors will be determined for later use in the cost function. So we will define three ac commands and two let commands by optimize analysis command. Spice Opus 10 -> optimize analysis 0 ac lin 100 10Hz 95Hz Spice Opus 11 -> optimize analysis 1 ac lin 3 98Hz 102Hz Spice Opus 12 -> optimize analysis 2 ac lin 3 350Hz 360Hz Spice Opus 13 -> optimize analysis 3 let max = norm(db(ac1.v(8)) + 100) eq 1 Spice Opus 14 -> optimize analysis 4 let min = norm(db(ac1.v(8)) - 100) eq -1The expression for the cost function have to be defined next. We will use the optimize cost command. The expression have to be written in standard Nutmeg language. Spice Opus 15 -> optimize cost mean(max * db(ac1.v(8))) / mean(max) - mean(min * db(ac1.v(8))) / mean(min) + (db(ac2.v(8)[0]) lt -3) * abs(db(ac2.v(8)[0]) + 3) + (db(ac2.v(8)[2]) gt -3) * (db(ac2.v(8)[2]) + 3) + (db(ac3.v(8)[0]) gt -70) * (db(ac3.v(8)[0]) + 70)The optimisation method and its parameters can be defined by optimize method command. We will choose the constrained simplex method (complex). Parameter size determines the relative distance of the constrained simplex points from the simplex centre. The total number_of_iterations limit will be also set. Spice Opus 16 -> optimize options number_of_iterations 2500 Spice Opus 17 -> optimize method complex size 1e-7Now we are ready to start the optimisation algorithm by optimize command without parameters. When the algorithm converges the results and some statistics are written. Spice Opus 18 -> optimize Time needed for optimisation: 89.850 seconds Number of iterations: 2073 Lowest cost function value: 3.909609e-001 Optimal values: c1 capacitance = 1.020333e-007 c2 capacitance = 9.907678e-009 c3 capacitance = 2.011568e-007 c4 capacitance = 2.822121e-007 c5 capacitance = 3.772917e-009It is interesting to see how did the parameter values (capacitances) travel around the parameter space during the optimisation. The normalised values of the capacitances can be plotted by plot command. Spice Opus 19 -> plot (c1_capacitance-5e-8)/45e-8 (c2_capacitance-5e-9)/45e-9 (c3_capacitance-1e-7)/9e-7 (c4_capacitance-1e-7)/9e-7 (c5_capacitance-1e-9)/9e-9 ylimit -0.1 1.1 xlabel iteration ylabel capacitances We can see that rough optimal values are determined after 350 iterations. We optimised our low-pass filter. Now we will determine capacitances analytically and compare them with obtained results. The fifth-order 0.5dB Chebyshev low-pass filter meet our requirements. We can calculate the capacitances and compare them:
Finally it is interesting to compare frequency responses of optimised and analytic filter. Capacitances will be changed to analytically calculated by alter command. Spice Opus 20 -> ac dec 100 1Hz 1kHz Spice Opus 21 -> alter c1 capacitance = 106n Spice Opus 22 -> alter c2 capacitance = 9.66n Spice Opus 23 -> alter c3 capacitance = 218n Spice Opus 24 -> alter c4 capacitance = 301n Spice Opus 25 -> alter c5 capacitance = 3.64n Spice Opus 26 -> ac dec 100 1Hz 1kHz Spice Opus 27 -> plot db(ac1.v(8)) db(ac2.v(8)) ylimit -100 10 xlabel f[Hz] ylabel magnitude[dB] title 'AC analyses'
Spice Opus 28 -> _We can see that the filters are almost identical and that they equally satisfy our requirements. The input file (fifth-order_active_low-pass_filter.cir) comes with the installation. It does not do exactly the same steps which are described above. | ||||||||||||||||||||||||||||||||||||||||||||||||
previous | back | home | next |