Playing with NG-SPICE again, and designing two resonant-circuit bandpass filters.

NG-SPICE is a program designed to simulate circuits. The acronym stands for (Next Generation) Simulation Program, with Integrated Circuit Emphasis. While NG-SPICE is open-source, its cousins such as LT-SPICE and PSpice are proprietary. However, NG-SPICE also uses advanced Mathematical modelling of components and circuits. Sometimes I find it to be an educational toy.

A type of circuit which some people might find interesting, is the IF strip – the Intermediate Frequency stage – of a radio receiver, which receives its signal after the Radio-Frequency signal has been ‘mixed’ with a Local Oscillator, and heterodyned down to the Intermediate Frequencies. And due to modern technology, a final, intermediate frequency of 450kHz can be used both for AM and FM demodulation.

There is a type of resonant circuit that employs capacitors and inductors – i.e., coils, in order to accomplish two things:

  • To act as a bandpass filter, restricting the frequency range,
  • To establish a phase-shift between the incoming carrier wave, and an oscillating, derived wave, that is dependent on the momentary frequency of the carrier wave, so that later in the analog processing of the signal, a phase-discriminator can complete the task of FM demodulation. This task is also referred to as Quadrature Demodulation of an FM carrier.

This type of resonant circuit is also sometimes referred to as a “Tank Circuit”.

In short, I’ve been reinventing the wheel. But I did read an article from elsewhere on the Internet, which inspired me. The subject of that article was, how to design Varactors, which are variable-capacitance diodes, when restricted to only using CMOS transistor-pairs. These diodes would represent a good way to tune circuits and vary the frequency of oscillators, in many types of applications. But I had an application in mind, which this type of varactor would help me solve. The mentioned, “IMOS Varactors” are remarkable because they don’t actually involve any diodes. They involve a way to connect an enhancement-mode P-channel MOSFET, so that the effect of gate-voltage changes on the MOSFET’s gate capacitance, acts as a varactor.


If somebody is designing a tuned circuit using the smallest, most-modern coils, manufactured by high-tech factories, then those coils allow for a high Q-factor to exist, which is a measure of how selective the filter can become, as well as to have good thermal stability, but if they are on a budget, these components will have some amount of tolerance, meaning that in a constant way, each component’s actual inductance value will vary to some degree. This is especially unfortunate since high-quality inductors on a budget, are also unlikely to be tunable. If the inductor in question is of a better sort, that ‘only’ has 5% tolerance, this would mean that with an improperly designed radio tuned to an intended AM frequency of 800kHz, instead, the listener could end up receiving a station at 780kHz, or at 820kHz, just because this one filter’s frequency is off by 5%. Of course, real radios that are designed to any level of satisfaction don’t behave that way.

What can be done, is that in the assembly-process for the radio, some machine calibrates its tuned circuits. But again, a maximal use of the main integrated circuit is assumed, and a minimal expense of external, discrete components is assumed. Here, a trimming potentiometer is a more-affordable way to do, what back in the 1970s and 1980s, tunable inductors would have done. If the assumption was made that for reasons I won’t go in to here, The IC can hold an exact voltage steady, then this voltage can also be applied to varactors internal to the IC, in a way that corrects for whatever amount of error was present in the coil.

Even though today, tunable inductors can be bought in quantity that also offer a Q-factor of 48, those aren’t just more expensive than the fixed variety. In addition, those would be much larger components, measuring maybe ‘half a centimetre’ cubed, and requiring to be soldered in to the circuit-board, while the fixed sort can be much smaller units, soldered onto a circuit-board as a surface-mounted device.

And so, reinventing the wheel in order to educate myself, what I have done was to design two circuits, one of which tunes in to 450kHz with the aid of such monolithic varactors, and the second of which does the same at 10Mhz instead. I’m using transistors that are not the tiniest in existence, but which are still too tiny, for an implementation of these ideas to be attempted with discrete components. Capacitances in picofarads should act as a warning to any reader, not to try this with discrete components. It’s much less-risky financially, just to run some simulations using NG-SPICE…

(Updated 7/27/2019, 12h05 … )

(As of 7/15/2019 : )

This is a schematic of the first circuit:



In the circuit above, I inserted R1 and R2 in order to simulate a Q-factor of 40, which would be improbably high. The reason I need to do this, is the fact that by itself, NG-SPICE simulates ideal components, unless explicitly instructed to do otherwise. Actual models of MOSFETs however, are examples of components that are simulated realistically, with many imperfections. This means that apparently ideal inductors and capacitors could lead to simulated Q-factors that approach infinity. Many people are taught that series resistance in a real coil limits the Q-factor. Well, parallel resistance and load resistance do so as well.

Therefore, if the circuit was providing AM radio reception, then R1 and R2 would be left disabled – perhaps by the Source-Drain resistance of another p-Channel MOSFET in quiescent mode, in series with actual resistors – so that the real components could generate a Q-factor as high as they can (maybe, around ~30).

But, for FM demodulation, the Q-factor that could result would be too high. And so physical resistors would need to be switched on or inserted – perhaps by that same MOSFET – such that R1 and R2 actually become much lower. And I recommend that a total of 3.2kΩ be used both times in that scenario. This will result in an apparent Q-factor of 2, and in FM demodulation with a minimum of distortion.


(Update 7/16/2019, 9h10 : )

In a similar vein, real coils possess internal capacitance. For a 1mH coil, this could be somewhere between 7 and 10pF, and can be computed from the frequency of self-resonance, which manufacturers often specify for a given product – in this case, either 1.9MHz or 1.6Mhz. A thorough simulation should connect a corresponding capacitor across the coil, to verify the frequency-range. Since the frequency-range these can be tuned over is narrow, the widths of the MOSFET channels needed to be reduced.

I should also mention, that as it’s commonly assumed with Ground, ‘Vcontrol’ in my example needs to be a buffered voltage. If a potentiometer is to be applied where Vcontrol is supposed to be, then the fact should also be realized that IF signal will travel through Vcontrol partially, and that if this results in any voltage-changes there, this will considerably reduce the Q-factor of the circuit. Therefore, if a potentiometer or some such analogue is to be used, then there should also be a shunting capacitor, to return the behaviour of this terminal to that of a controlled voltage.

However, unfortunately, my simulations with NG-SPICE reveal, that when accounting for the internal capacitance, I was only able to shift the centre-frequency by +6.2%, -5.4%. Obviously, the use of real, discrete Varactor Diodes over MOSFETs would have as advantage, that a wider ratio of capacitance-values could be attained. Also, the use of higher supply voltages, than 3V, would have the same effect, as would the use of thinner oxide-layers, than 15nM.

(End of Update, 7/16/2019, 9h10.)


(Update 7/21/2019, 8h30 : )

I suppose that a type of question which the reader might have would be of the form:

‘Fine. So the externally connected coil could have some amount of internal capacitance, which is not known at the time this IC is designed. How can it be helpful, that the circuit suggested above, always inserts 10pF?’

The answer to such a question would be, that it could be known that the maximum amount of internal capacitance will be 10pF. In case the coil has less, such as only 7pF, a 3pF capacitor could actually be connected in parallel to the coil, when the coil is connected to the IC.

(End of Update 7/21/2019, 8h30.)


And this is a link to the Net-List, of the circuit and its simulation:

My assumption is that the thickness of the oxide layer is 15nM.

And this is a link to the Model-Card of the MOSFET, that is meant to act as the Varactor:


Here is the second circuit, that is meant to do the same thing at 10MHz:



Here, in a real circuit, R1 and R2 should simply be left out.

The following is the corresponding Net-List:

And this is the additional designation, for its MOSFET:


(Update 7/16/2019, 9h10 : )

In this example, I’m only able to shift the frequency by +5.88%, -3.42% (See Above).

(End of Update, 7/16/2019, 9h10.)


I hope that the reader of this blog finds this information either useful or just interesting.


(Update 7/27/2019, 12h05 : )

The fact should be observed that, even though my schematic suggests a range in control voltages from 0.6V to 2.6V with respect to ground, I’ve established elsewhere in this blog, that control voltages as high as 3.0V could be made stable. What I’ve observed is that, as the control voltages are made more-positive, and the relative gate voltages of ‘M1′ and ‘M2′ result as more-negative, a more-substantial decrease in gate capacitance results, and therefore also, a more-substantial increase in frequency. ‘M1′ and ‘M2′ then get closer to being ‘turned on’, as though they were to be operated as transistors, because they are P-channel MOSFETs.

This would ultimately be useful, because when capacitors ‘C2′ and ‘C3′ are removed, because they are not physically real, at some point the surface areas of ‘M1′ and ‘M2′ will need to be increased, so that these two MOSFETs produce greater gate capacitance, and then, a wider range of available capacitance will become desirable.

I’ve also blogged elsewhere, as to why I did put ‘C2′ and ‘C3′ into the schematic, even though on an actual chip, they would only exist as part of the properties of ‘M1′ and ‘M2′.



Print Friendly, PDF & Email

4 thoughts on “Playing with NG-SPICE again, and designing two resonant-circuit bandpass filters.”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>