Another Simple Output-Amplifier, Using Discrete MOSFET Transistors

One of the facts which I’ve been writing about, is that I possess the open-source version of ‘SPICE’, that is named ‘NG-SPICE’, and that this acronym stands for ‘Simulation Program, with Integrated Circuit Emphasis’. The full, associated suite of programs allows me to edit schematic diagrams graphically, but to export ‘Netlists’, so that I can then simulate the circuit – and see if it works.

And one of the facts which I have also been contemplating, is that by default, SPICE will put transistors, which correspond to micron-sized transistors, which will therefore never be able to drive output-loads, from a hypothetical IC, unless an explicit attempt is made, to design output-buffers, which can. These output-amplifiers have as function, that they should merely follow their input voltage, but draw as little current from their respective inputs as possible – that are outputs of other, more interesting ICs – while allowing low load-resistances to be connected to their own outputs, which correspond to plausible external components, such as 100Ω load-resistors.

I had posted an earlier, conceivable design, of such an output-buffer, which had a major flaw, that I also pointed out in the preceding posting: That amplifier could only produce a range of voltages, which was a direct function of what the Gate-Source threshold voltages would be, of the component transistors used. Hence, because I had also specified low-quality, outdated MOSFET transistors with high threshold-voltages, the output-voltage-range, was also modest but reasonable. But, newer transistors will have lower threshold voltages by design, which would, oddly enough, reduce the voltage-range of that amplifier. This would be an important consideration if the transistors were not in fact discrete, but needed to be incorporated onto the IC, where low-threshold-voltage transistors are already standard. Which means, that I needed to design a better output-buffer.

So below is a better output-buffer, schematic:


And these are the SPICE definitions, of the discrete transistors which I decided to base my design on again, both enhancement-mode MOSFETs:

The main disadvantage of this latest design would be, that the transistors which I labeled ‘X2′ and ‘X3′, do in fact conduct current to their combined inputs, which makes the additional transistor ‘X1′ necessary, since this amount of current would already be excessive, to connect to an output, of any pre-existing IC circuits. But then, the advantage goes so far, that ‘X2′ now models a level-shift, which exactly mirrors the level-shift of ‘X4′, and the voltage-level-shift of ‘X3′ now mirrors ‘X5′. There is design beauty in this. But one disadvantage now is, that the Gate-Source threshold-voltage of (1) n-Channel MOSFET (2.2V) plus (1) p-Channel MOSFET (3.2V) gets subtracted from the input-voltage, so that the available voltage-range still suffers, with respect to both the supply, and the input-voltage. Input-voltage now ranges from 5.4V to approximately 12.5V, which is closer to the range of supply-voltages than what the previous circuit allowed, and the resulting output-voltages are graphed below:


(Update 06/20/2018, 0h20 : )

There is another observation which I should add:

In the days of vacuum tubes, ‘transconductance’ was measured in Amperes / Volt, and was therefore given in ‘Mhos’, which were the reciprocal of Ohms. Apparently, in modern days, the transconductance of a MOSFET, also given as its ‘KP’, is in Amperes / Volt2 . :-D This conscious design-decision must follow the real-world behavior of MOSFETs, but makes my earlier Math, of multiplying such a component-property by the series-resistance, to arrive at gain, incorrect. Gate-Source voltage-changes lead to current-changes, but greater Drain-Source voltages, lead to greater current-gain. This is good, because the actual gain of a MOSFET, reduces the apparent capacitance at its Gate.

The low-end output-voltage came into being as follows:

Continue reading Another Simple Output-Amplifier, Using Discrete MOSFET Transistors

A Simple Output-Amplifier, Using low-quality Discrete MOSFET Transistors

In This earlier posting, I described how I can use the program ‘NG-SPICE’, along with its associated GUI-applications, to create and edit circuit diagrams, and then to simulate approximately how those would function if actually implemented as circuits.

‘SPICE’ stands for ‘Simulation Program, with Integrated Circuit Emphasis’. And one of the facts which I had lamented in the posting linked to above, was that it tends to produce default transistors, that correspond to transistors one would find on an IC, those having sizes of 1 micron and smaller. Therefore I faced the challenge which I believe professional IC-designers also face, which is, to make circuits small that contain many transistors, yet, to drive output-pins of the ICs in such a way, that at least, discrete components can be connected to those output-leads, without doing so collapsing the output-waveforms.

But, my hypothetical solution to this problem will be different, from the professionally-chosen solution. What I think gets done commercially, is that special output-transistors are put on the IC, that take up greater surface-area there than unit transistors do, and which are difficult to diagram in a schematic faithfully, to how schematics depict discrete-transistor circuits. My solution was to accept the legacy n-Channel, ‘2N7000′, and the legacy p-Channel, ‘BS250P’, discrete, enhancement-mode MOSFET transistors, in the spirit that bipolar-transistor solutions are to be avoided, if the main chip-technology was MOSFET, but to mark these components as being ‘special’ – even though ages ago, the discrete components would have been regarded as ‘normal’, while the IC components would have been regarded as ‘special’, I defined those discrete components within NG-SPICE, as subcircuits, which are therefore labeled with descriptors that begin with the letter ‘X…’ , as opposed to native MOSFETs, that are to be labelled with the letter ‘M…’ .

Here are the subcircuit, Netlist-definitions of these two, now-defunct transistor-types:

I understand that this was to be an exercise, at amplifying the output of a hypothetical IC, as if with discrete components that would need to be connected to the IC externally, but remember, that equivalent, low-quality MOSFETs can be incorporated into any chips which are to be manufactured, so that in the event that they are, external components would not be necessary.

I also understand that my schematic is imperfect, in that it creates voltage-level-errors, but that such errors would become irrelevant, if the output-amplifier was put inside a feedback-loop, that has high, open-loop gain, as such a feedback loop would also just correct the voltage fed in to the circuit of this posting, so that correct output-voltages nevertheless follow.

This is the schematic:


One reason for the voltage-level errors is the fact that in this schematic, ‘X1′ and ‘X3′ do not match, and that equally, ‘X2′ and ‘X4′ do not match. Even though ‘X1′ and ‘X2′ were meant to model the threshold-voltage, with which each transistor turns on, and then to apply the correct level-shifts to the gates of ‘X3′ and ‘X4′, the main problem in my design is, that ‘X1′ is of the p-Channel type, while ‘X3′ is of the n-Channel type, and vice-versa. There was never any guarantee, that the positive threshold-voltage of the n-Channel transistor, exactly mirrors the negative threshold-voltage, of the p-Channel transistor! But, unless such an amplifier is to place a load-current onto the input-terminal, I found no simple way to avoid this situation. As it stands, the input-terminal would offer minimum load on the circuit designed in the posting linked to above, because all it drives is floating gates. All this does is add some capacitance, while the driven output-resistance of 100Ω, is a direct function of the fact that the chosen, discrete MOSFETs, were only able to handle 200mA maximally.

Interestingly enough, the direction of the level-shift between ‘X1′ and ‘X3′ is the same, as the direction in which ‘X2′ and ‘X4′ shift the voltage-levels, which means that ‘VSD(X1)’ + ‘VDS(X2)’ == ‘VGS(X3)’ + ‘VSG(X4)’, for which reason the circuit can be expected to work anyway. And, neither the Source-Drain current through ‘X1′, nor that through ‘X2′, ever reverse, over the operating range.

(Updated 06/16/2018 : )

Continue reading A Simple Output-Amplifier, Using low-quality Discrete MOSFET Transistors

Getting The Edit-Image Function (Crop) within my (standard) WordPress Media Library to Work Again

My WordPress blog has many plug-ins, in addition to which it uses Debian-maintained core-files, instead of standard downloadable core-files.

Eventually, the error that was irking me enough, to insist on finding the solution, was that within the Media Library function, which is built-in to WordPress 4.1, when I clicked on an image, then on the Edit button, I was obtaining the ubiquitous ‘broken thumbnail’, which also prohibits cropping uploaded images within WordPress itself.

According to the Internet, there can be a wide variety of reasons this bug comes up, including but not limited to, not having ‘php5-gd’ installed. And needless to say, that library is installed on my server, one reason being, the fact that it’s an actual package-dependency, which means that Debian won’t allow us to install WordPress, unless we also install ‘php5-gd’.

(Edit 1/21/2018 :

Additionally, ‘’ core files generally benefit from having the package ‘php5-imagick’ installed, but one reason this may not be declared as a package-dependency under ‘Debian’, could be the fact that to state it as a dependency, would also require that our Debian installation have ‘ImageMagick’ installed, which is a larger suite of programs. Yet, even under Debian, ‘WordPress’ core files check whether the ‘imagick’ PHP-extension is loaded, and if its properties are as required, will try to make use of it.

As it happens, ‘php5-imagick’ was installed on my computer from the beginning (of my use of WordPress). But one question which I still do not know the answer to, is whether WordPress actually needs ‘imagick’, to offer its image cropping and editing capability. I only knew that either way, I had this PHP-extension installed, so that there was little else I could do, to try to offer WordPress what it needed. )

The culprit for me turned out to be, that I was already using an Output Buffer, in order to get rid of leading white-space, which was threatening to make my RSS / Atom Feeds unreadable on many clients, due to plug-ins I have installed, which I don’t even keep track of in a complete way.


This deserves some colloquial explaining. Ideally, if every WordPress plug-in was coded according to best-practices, they would all have leading ‘<?php’ tags at the very beginning of their scripts, and no corresponding ‘?>’ tags at the ends. This way, the creep of white-space – i.e., of blank lines between actual HTML-formatting, and before starting-tags of the HTML document, might be avoidable. But a reality which some instances of WordPress offer instead, is that users like me have many plug-ins, some of which are not coded well, so that blank lines can come in front of the leading tags of the HTML-document itself.

One side-effect of this can be – and early in my own blog was – that when a client-program was pointed either at my Entries RSS Feed, or my Comments RSS Feed, that client-program would just display an error-message, instead of displaying a feed.

So, instead of kicking all possibly-sloppy plug-in code off my blog, many months ago, I installed a script, which set up an Output Buffer, and which, in very specific cases, would clean up the blank lines – the whitespace – that was preceding the document-start. In itself, this was a dubious fix to my problem, and could also corrupt other types of output.

But since then, a situation arose in which such whitespace was causing problems again, without my knowing where. There is a script-file named ‘/wp-admin/admin-ajax.php’. One of the things it does, like so much other Ajax, is allow a hovering -panel in my editing view to be updated, with a preview of an image which I’ve uploaded, but which I might wish to edit from within WordPress, after having uploaded it.

The problem is, that if whitespace gets inserted there, it will just cause garbled JPEG Files to be generated, which the editing panel cannot display within the browser, and for which reason I was unable to Crop such images. But I had to know what was causing the problem.

Continue reading Getting The Edit-Image Function (Crop) within my (standard) WordPress Media Library to Work Again