Bandpass filter - ltspice vs real life - Page 1
Forum section: electronics / projects

author: injb
author_rank: Regular Contributor
timestamp: April 20, 2020, 01:51:40 am
content: I'm learning LTSpice, and I am confused about why this simulation gives different results from real life.The circuit is an opamp bandpass filter for an engine knock sensor. I believe that knocking on this engine would be in the 5.7Khz range. I hooked up a function generator to the input and swept the frequency from a few Khz up to around 12Khz, and what I found was that at around 5.5 the response suddenly goes up quickly, and keeps increasing until around 7Khz, and then drops off very quickly above that.So, it seems to be centered around 5.5 - 7 Khz, which is a tad higher than I expected, but close enough.But the spice simulation of the circuit shows that the filter should be most sensitive around 4Khz. So I'm trying to understand what other factors affect this that I haven't taken into account. The capacitors are marked only as "0.01", but I think it has to be uF because otherwise I'd be off by a factor of 1000 which could not work. The resistor values, I measured.I'm attaching screenshots of both decibel and linear scales (I find the linear one clearer)Any ideas where I've gone wrong?EDIT: changed the screenshots to correct a mistake (which didn't make any difference to where the filter is centered)

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 20, 2020, 03:06:09 am
content: Huh, what type of "0.01" capacitors?What supply? Also, what supply and GBW is the amp in the simulation? Don't tell me you used the three-terminal ideal amp!Tim

author: Mechatrommer
author_rank: Super Contributor
timestamp: April 20, 2020, 03:08:46 am
content: every wire is an inductance, no perfect capacitor without ESR, and no exact value of 0.01uF and 9K ohm in real life.

author: injb
author_rank: Regular Contributor
timestamp: April 20, 2020, 03:32:47 am
content: Quote from: T3sl4co1l on April 20, 2020, 03:06:09 amQuote from: Mechatrommer on April 20, 2020, 03:08:46 amYes I did use the 3-pin amp - is that a no-no? The actual one wasn't in the list (LM2902).The caps are marked as "0.01 100-WIMA VN" and "5%". The resistor - I checked using a color code calculator (https://www.allaboutcircuits.com/tools/resistor-color-code-calculator/). It's white-black-white-brown-brown which comes out at 9.09k. I also measured it and got approximately that value.

author: JimRemington
author_rank: Regular Contributor
timestamp: April 21, 2020, 12:43:26 am
content: The LM2902 is not even audio quality; performance starts to degrade abruptly at 5 kHz.

author: SilverSolder
author_rank: Super Contributor
timestamp: April 21, 2020, 01:10:49 am
content: Code:* LM2902 Spice Model** WARNING : please consider following remarks before usage** 1) All models are a tradeoff between accuracy and complexity (ie. simulation time).** 2) Macromodels are not a substitute to breadboarding, they rather confirm the* validity of a design approach and help to select surrounding component values.** 3) A macromodel emulates the NOMINAL performance of a TYPICAL device within* SPECIFIED OPERATING CONDITIONS (ie. temperature, supply voltage, etc.).* Thus the macromodel is often not as exhaustive as the datasheet, its goal* is to illustrate the main parameters of the product.** 4) Data issued from macromodels used outside of its specified conditions* (Vcc, Temperature, etc) or even worse: outside of the device operating* conditions (Vcc, Vicm, etc) are not reliable in any way.**** Standard Linear Ics Macromodels, 1993.** CONNECTIONS :* 1 INVERTING INPUT* 2 NON-INVERTING INPUT* 3 OUTPUT* 4 POSITIVE POWER SUPPLY* 5 NEGATIVE POWER SUPPLY.SUBCKT LM2902 1 2 3 4 5***************************.MODEL MDTH D IS=1E-8 KF=3.104131E-15 CJO=10F* INPUT STAGECIP 2 5 1.000000E-12CIN 1 5 1.000000E-12EIP 10 5 2 5 1EIN 16 5 1 5 1RIP 10 11 2.600000E+01RIN 15 16 2.600000E+01RIS 11 15 2.003862E+02DIP 11 12 MDTH 400E-12DIN 15 14 MDTH 400E-12VOFP 12 13 DC 0VOFN 13 14 DC 0IPOL 13 5 1.000000E-05CPS 11 15 3.783376E-09DINN 17 13 MDTH 400E-12VIN 17 5 0.000000e+00DINR 15 18 MDTH 400E-12VIP 4 18 2.000000E+00FCP 4 5 VOFP 3.400000E+01FCN 5 4 VOFN 3.400000E+01FIBP 2 5 VOFN 2.000000E-03FIBN 5 1 VOFP 2.000000E-03* AMPLIFYING STAGEFIP 5 19 VOFP 3.600000E+02FIN 5 19 VOFN 3.600000E+02RG1 19 5 3.652997E+06RG2 19 4 3.652997E+06CC 19 5 6.000000E-09DOPM 19 22 MDTH 400E-12DONM 21 19 MDTH 400E-12HOPM 22 28 VOUT 7.500000E+03VIPM 28 4 1.500000E+02HONM 21 27 VOUT 7.500000E+03VINM 5 27 1.500000E+02EOUT 26 23 19 5 1VOUT 23 5 0ROUT 26 3 20COUT 3 5 1.000000E-12DOP 19 25 MDTH 400E-12VOP 4 25 2.242230E+00DON 24 19 MDTH 400E-12VON 24 5 7.922301E-01.ENDS

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: April 21, 2020, 01:32:06 am
content: Hi,Using the generic 3 terminal opamp you adjust the parameters including GBW.Here I have setup the model to step the GBW of the opamp from 100kHz to 10MHz in a logarithmic fashion:ResultsThe results show that the circuit is relatively insensitive to the opamp GBW.This is the expected result. The filter should be defined by the passive components not some parameter of the opamp.Regards,Jay_Diddy_B

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: April 21, 2020, 01:38:10 am
content: Hi,The LM2902 is very similar to an LM324. It has a 1.3MHz GBW product.The LT1013 is has similar GBW,but much better offset voltage.Use the LT1013 in place of the LM2902.Regards,Jay_Diddy_B

author: injb
author_rank: Regular Contributor
timestamp: April 21, 2020, 01:41:45 am
content: Thanks for the replies. I discovered I made a few mistakes in my schematic - there is actually a resistor between R1 and C1 that goes to the noninverting input, and the noninverting input is biased to 5v. Adding that missing resistor made a big difference, but it was still noticeably off where the actual circuit is, this time much higher. I downloaded an LM2902 spice model from TI and that seems to have fixed it - now it's giving me a very good match to what I see in the real circuit.To everyone giving advice about the quality of the 2902: thanks, I'll keep that in mind, but I'm not building anything in this case, I'm just trying to understand an existing circuit that uses the 2902. It was designed in the mid 80s.

author: Wimberleytech
author_rank: Super Contributor
timestamp: April 21, 2020, 01:51:28 am
content: Quote from: Jay_Diddy_B on April 21, 2020, 01:32:06 amThanks for sharing...until now, I did not know about the "step" feature. Cool!