LTSpice LM394 Log Converter - Page 1
Forum section: electronics / projects

author: mc172
author_rank: Frequent Contributor
timestamp: July 19, 2019, 08:54:38 am
content: I'm messing around with a log converter (aka log amplifier) in LTSpice and am a bit stuck. I figured that a good place to start would be an application note or something so found this on the LM394 NPN "supermatched pair" datasheet:The LM394 datasheet can be found here:http://www.sycelectronica.com.ar/semiconductores/LM394.pdfWhen I put this circuit into LTSpice I get the following performance:The red trace is Vout and the green trace is Vin. I have attached a ZIP file containing the LTSpice simulation.The plot has Vin (V(n009)) as the horizontal scale, which is the input to the log converter and is a 1 Hz triangle wave going from 1 uV to 10 V. I expect to see a straight line (which would be the log of a triangle on a log scale) but I only see that for 3 decades. Has anyone got any idea why I only get log conversion after 10 mV?I have built other variants such as the circuit in the SSM2212 datasheet and have the same problem - I can only get about 3 decades out of it. I am tempted to just build one and see if it works but I'd like to get the simulation working really.

author: Ian.M
author_rank: Super Contributor
timestamp: July 19, 2019, 10:23:50 am
content: The LM394 datasheet only claims four decades range for that circuit, and elsewhere it notes that most datasheet parameters are guaranteed from 1uA to 1mA Ic, which implies only a three decade range with guaranteed accuracy.I don't have your transistor or OPAMP models, but doing a .dc sweep over a carefully chosen six decade range:Code:.dc dec V4 30u 30 50using the generic UniversalOpamp2 model with its default parameters and any small signal NPN, gives very close to a straight line for six decades - far better than I suspect you'll achieve in real life. Remember all LTspice components default to being 0% tolerance, and most to being ideal.

author: mc172
author_rank: Frequent Contributor
timestamp: July 19, 2019, 04:58:09 pm
content: Thanks for that. I just tried what you wrote in the code tags and indeed I get around 6 decades.I was previously manually commanding a voltage source to generate a triangle, something like this:Code:PULSE(0.000001 10 0.1 0.4 0.05)Do you know why doing a DC sweep gives different results to giving it a triangle? Not that it matters - I won't do that any more!

author: Ian.M
author_rank: Super Contributor
timestamp: July 19, 2019, 06:20:51 pm
content: At the very beginning of the triangle wave, the transient response of the circuit is critically important. I think it is compromising the result for very low Vin due to the brief period from when the up-ramp starts till it crosses 1mV.

author: Ian.M
author_rank: Super Contributor
timestamp: July 20, 2019, 03:37:27 am
content: Yep, confirmed. Avoid the too rapid transition through the uV decades by using a behavioural voltage source to implement an exponential function for the input:Code:V=pow(10,7*time-6)and you'll get six decades with acceptable linearity same as the .dc sweep gave.

author: mc172
author_rank: Frequent Contributor
timestamp: July 21, 2019, 07:20:08 pm
content: Thanks Ian, thanks for your time and effort. Much appreciated!