# LTspice: Plot energy efficiency in the same window with volt and amp graphs

I am trying to draw energy-efficiency in the wave-plotter. Like what you get using .meas and .param commands (as seen in the schematic), but plotted.
I want to have the efficiency of the circuit together with the other waves in the same windows because I want to quickly change components and see how that changes the efficiency. (Theoretically)

The .meas commands use the average of the whole waveform as the basis of the calculation of efficiency:
pin: AVG(-v(vbat)*i(staticbattery))=0.0487199 FROM 0 TO 2 pout: AVG(v(vled,vled2)*i(led))=0.0305857 FROM 0 TO 2 efficiency: 100/pin*pout=62.7785
I could plot or look at this in a separate window - with an irritating amount of clicks everytime I change a component - sure. But I want a line or wave together with the other measurements in one window.

So I was trying to put battery-milli-Watts in relation to LED-milli-Watts, to get a factor in %, in the plot window.
Why isn't it as easy as (100 / BATmW) * LEDmW? It seems like wave peaks and troughs interfere and put the calculation off.
For example, this calculation doesn't work: (100 / (V(VBAT)*-I(StaticBattery)/1mW)) * (V(VLED,VLED2)*I(Led)/1mW) (I use /1mW to get rid of the unit)
That gives me a graph that could be useful if clicking it with CTRL WOULD show the correct average - But it shows a value of 241.52. The waveform has peaks in the ten-thousands, pointing at interference. So it's useless.

How do I create the same behavior as 100 / averageIN * averageOUT = efficiency in the plot-view window? Since the "AVG" command does not work in there, unfortunately, I need a different solution.

Thank you very much!

• Can you post your Ltspice schematic and waveforms? Clicking with CTRL should give the correct average – EE_socal Apr 6 '18 at 19:28
• done. I don't know if you need ALL the symbol files, but I included the one I made myself. – Distelzombie Apr 6 '18 at 20:33
• "But it shows a value above 100". Suppose you have a circuit whose only effect is to delay the delivery of power to a load: you put in a constant power pin from ti to tf, and your load gets the whole power from ti+tdelay to tf+tdelay. Would you agree in saying that this circuit has 100% efficiency? Now, try to plot pout/pin*100. What is the average of that curve? – Sredni Vashtar Apr 6 '18 at 20:45
• It would help to just post the schematic so I don't have to try to open it in Ltspice. – EE_socal Apr 6 '18 at 21:01
• Oh, that's what you meant. Unclear. I'll do it – Distelzombie Apr 6 '18 at 21:27

## 1 Answer

LTSpice's waveform viewer won't integrate for you, but LTSpice itself will.

Use a capacitor to integrate a behavioral current source Then you can plot V(Eout)/V(Ein) • @Distelzombie I mean absolutely no offense when I say try reading the manual, from the beginning. It's very terse in some places, but it provides the basic info about the functionality of LTspice. Not knowing about behavioural sources means you don't know about the basic elements, not knowing how to write an expression (I(LED), for ex.), means you don't know the correct syntax, same about idt. I am just pointing out that these things can be learned by simply pressing F1 and reading about them, and trying to make schematics with a program you don't know doesn't make much sense. – a concerned citizen Apr 7 '18 at 9:36
• B is a behavioral current source. You can read about it in the manual, section LTSpice->Circuit Elements->B. Arbitrary Behavioral Voltage or Current Sources – τεκ Apr 7 '18 at 14:15
• .IC is an initial condition SPICE directive. You can read about it in section LTSpice->Dot Commands->.IC -- Set Initial Conditions – τεκ Apr 7 '18 at 14:16
• While this is part of the "circuit" simulated by LTSpice, it's only related by the expression for the behavioral source. It will have no effect on the rest of your circuit. – τεκ Apr 7 '18 at 14:19
• @Distelzombie, what tek did is to exploit the fact that the voltage across a capacitor is the integral of the current 'through' it. By creating a circuit with C=1, zero initial conditions, and a current equal to the expression you want to integrate, you will end up with a voltage across the capacitor that is the integral of that expression. So, those circuits are just a 'calculator', actually an analog computer, that you place nearby your actual circuit to produce the signal (in this case the numerator and denominator of the efficiency curve) that you want to plot. – Sredni Vashtar Apr 7 '18 at 14:35