0
\$\begingroup\$

Using algebraic expressions (right clicking in trace window header to enter arbitrary formulas), I am trying to plot the gain over time of a simple BJT-based common-emitter amplifier.

As is well known, the output signal of such an amplifier is phased-shifted by about 180⁰ from the input signal, and therefore, plotting the quantity abs(V(vout) / V(vin)) shows something that has nothing to do with the actual gain of the amp.

What would be ideal would be to read the voltage of a node at a specific point in time.

Something like:

abs(V(vout) / Voltage_at_time(vin, current_time - delay))

Does the V() function have an at_time kind of argument (I couldn't find the docs for it)?

If not, is there another way?

[EDIT]: To clarify, here's a snapshot of the two signals (Input is Vs, Output is Vo):

enter image description here

\$\endgroup\$
7
  • \$\begingroup\$ Why not plot Vout/Vin? \$\endgroup\$
    – Andy aka
    Commented Jan 14, 2023 at 15:00
  • \$\begingroup\$ @Andyaka : because Vout and Vin are not in phase (they're not even at 180⁰) and therefore their ratio tells you nothing about the instantaneous gain. I've edited my post with a snapshot of the waveforms to make it clear. \$\endgroup\$ Commented Jan 14, 2023 at 17:09
  • \$\begingroup\$ OK, so ideally, what points in those waveforms would you use to calculate what you need? How about the RMS function? \$\endgroup\$
    – Andy aka
    Commented Jan 14, 2023 at 17:12
  • \$\begingroup\$ Looks like an XY problem. You don't usually plot gain against time, you usually plot it against frequency which you can do with an AC analysis. Is there some reason you want to plot it against time? Is there any parameter of the amplifier that will change with time? \$\endgroup\$
    – GodJihyo
    Commented Jan 14, 2023 at 17:18
  • \$\begingroup\$ @both above : the traditional way EEs look at these things is what I am trying not to do. I want to see the gain evolve over time as the input and output signals evolve over time. This is (to me) way more intuitive than looking at a Bode plot : to me, signals are first and foremost functions of time and AC analysis moves everything to the frequency domain which I do not find very intuitive. But: this is not the essence of my question. I just want to know if one can fetch a time-shifted value in a expression, a tool that - if it does exists - is way more general than this specific problem. \$\endgroup\$ Commented Jan 14, 2023 at 17:30

3 Answers 3

4
\$\begingroup\$

Sounds like what you plot is the large-signal gain. In theory, the small-signal gain (AC simulation) must approximate it really well (assuming you're simulating a negative-feedback amplifier. If it's some sort of open-loop thing you can forget about it) before you saturate your amplifier with a large-amplitude input signal.

Your issue is very difficult because the phase shift is not exactly 180 deg across all frequencies.

The only way around this I can think of is to use the peak-to-peak function measurement for both input and output and then take the ratio:

.meas Vppout PP V(out)
.meas Vppin PP V(in)
.meas Gain param Vppout/Vppin
\$\endgroup\$
6
  • \$\begingroup\$ thanks for your answer. First: you are correct that the phase shift between output and input varies across frequencies. This is specifically why I'm working in the time domain because I want to see what amplification I get on non-sine signals. Second: I'm now sorry I used this example to support my question. What I really want to know is if LTSpice is capable of evaluating the V(node) function at an earlier time as this would be a very useful tool, independent of this specific amplifier question. But I guess I'm out if luck and will have to process the signals outside of LTSpice. \$\endgroup\$ Commented Jan 14, 2023 at 21:45
  • 1
    \$\begingroup\$ @blondiepassesby to the best of my knowledge, LTSpice cannot do that. An idea could be that you create some sort of ideal all-pass filter that produces the delay you want. Perhaps there are models you could do. I know in expensive simulators like Virtuoso you can do some with VerilogA. Not sure if you can do the same with LTSpice. \$\endgroup\$
    – Designalog
    Commented Jan 14, 2023 at 21:51
  • \$\begingroup\$ yeah, I am starting to realize that there's only so much you can do from within LTSpice. I'll get down to writing some C++ code that will load the traces and compute what I need, it's likely the easiest path. Thanks for your suggestions (I actually tought about creating another circuit that would do what you suggest, i.e. dephasing the output further so it gets aligned back to the input signal ... but that's too much work compared to just writing code). \$\endgroup\$ Commented Jan 14, 2023 at 21:55
  • 1
    \$\begingroup\$ @blondiepassesby Instead of over-delaying the output signal so it loops back around, what about delaying a copy of the input signal? You can using an ideal transmission line element to create an exact delay. Or even better in my opinion, use a B-source (bv element) with absdelay function to generate a delayed copy of the input. Then use the + node from your B-source in your plot functions. Something like this???: V=absdelay(V(in),100n) \$\endgroup\$
    – Ste Kulov
    Commented Jan 15, 2023 at 5:30
  • \$\begingroup\$ You can do it with free microcap v12. Take points at any time within simulation... and calculate what is needed. \$\endgroup\$
    – Antonio51
    Commented Jan 15, 2023 at 11:18
2
\$\begingroup\$

Use derivatives. For example, looking at the rate of change of the output versus the rate of change at the input provides the instantaneous gain.

enter image description here

Without accounting for \$r_e^{\,'}\$, the voltage gain should be \$A_v=-3.3\$. But taking it into account then \$A_v=\frac{3.3\:\text{k}\Omega}{1\:\text{k}\Omega+18\:\Omega}\approx -3.24\$. Which is pretty close to what's showing with LTspice, above.

Note also that the gain does vary with the input voltage. Higher input voltage means greater emitter current, which means smaller \$r_e^{\,'}\$ and therefore slightly higher voltage gain magnitude. Which shows up in the plot.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Very nice idea, I wouldn't have though of this in a million year, thanks! Also: yes, very aware that the gain is not constant. That's the whole point of this exercise, which is another way - and more intuitive to me - to visualize distortion. \$\endgroup\$ Commented Jan 15, 2023 at 20:34
  • 1
    \$\begingroup\$ I agree. If I could vote twice I would. \$\endgroup\$
    – Ste Kulov
    Commented Jan 15, 2023 at 21:37
0
\$\begingroup\$

As pointed out by @ErnestG ...

Here is a simulation for gain measured with different amplitudes (until quasi saturation).

One can see that gain does not really change a lot ...
It is "only" the effect of "saturation".

enter image description here

Here is another view with HARM() function (more representative).
Last view is for 10 mV input.

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ The peak-to-peak solution sort of assumes that the peaks in the output signal and the output signal "match" and that finding the peaks can therefore "repair" the phase shift between the two signals. It's a reasonable assumption to make if you're dealing with pure sine waves, but if does not work for arbitrary signals. And in all cases, it tells you nothing about how the gain behaves for non-peaks part of the signal. \$\endgroup\$ Commented Jan 15, 2023 at 20:30
  • \$\begingroup\$ The only way with a "complex" signal is the harm() function, which is "equivalent" to PP() function ... The DFT calculus would be also fine in an embedded system. Will add in answer. \$\endgroup\$
    – Antonio51
    Commented Jan 16, 2023 at 7:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.