Reverse Engineering Audio Equipment

Hello,

I’m pretty new to drawing schematics. I thought I’d start by reverse engineering something I thought might be pretty easy. What I have is Silence Sensor based around an LM324N and a microcontroller. I think the LM324N is a comparator and that signal is being sent to the microcontroller which is manipulating LEDs as well as a relay. So far, I’ve only drawn the audio section.

What I’d like to do is use the simulator to see what kind of signals the OpAmp is generating. Here’s what I have so far:

I’ve read that the LM324N doesn’t have the proper Spice model(?) for simulations.

First question is: Does this look correct so far? I can upload a picture of PCB if it’s necessary.

Second question: How do I send an audio signal (probably a sine wave) to the inputs and generate a proper simulation?

Schematic looks mostly plausible, but at least the values for C30 and c31 are missing. I also recommend using GND symbols instead of PE, and to put them the right side up. (Just for easier reading).

But for starting with simulations, I suggest you start with something simpler first. There are a bunch of things that can make it difficult to get started with simulations, and building it up in small steps is recommended.

Where did you read that?

If you’re not familiar with SPICE I’d start with LT-Spice, Tina-TI or QSpice.

If you would like to stay within KiCad, this is what I recommend:

Circuit diagram:
Replace the earth symbol by GND symbol (indeed not a recommendation, but a must).
Connect your in and out labels.
A suitable voltage source is the VSIN symbol, used for transient (voltages versus time) simulation.
Your power supply symbol part U1E is not used adequately. You may watch this video for an example https://www.youtube.com/watch?v=Wg7uSs4J_0U.

Model:
Now the difficult part
Download the model from the TI web site. Indeed KiCad/ngspice does not provide ngspice models for simulation (except for some generic devices).
If you then have a look at the model file lmx24_lm2902.lib, you will see the line
.subckt LMX24_LM2902 IN+ IN- VCC VEE OUT
it has only 5 connections, not pins number 1 to 14, as the 4-part LM324 has in its packages and your symbol U1A to U1D is showing). This is indeed stemming from the PCB-orientation of KiCad/ngspice. Other simulator don’t care about this, so the next step may be skipped with using them. There has to be some translation between the 14-pin package and the 5-pin model.

Some explanation (example two-part TL072) is given here: KiCad Eeschema as GUI for ngspice, tutorial for setting up the simulation.

@holger, In the example above you use XU1A and XU1B But that seems to make it dependent on the RefDes. I did it like below, where the TL072 and TL074 reuse the model from the TL071. If you agree this is a better method, it may be worth to update that example on sourceforge.

* TL071 OPERATIONAL AMPLIFIER "MACROMODEL" SUBCIRCUIT
* CREATED USING PARTS RELEASE 4.01 ON 06/16/89 AT 13:08
* (REV N/A)         SUPPLY VOLTAGE: +/-15V
* CONNECTIONS:      NON-INVERTING INPUT
*                   | INVERTING INPUT
*                   | | POSITIVE POWER SUPPLY
*                   | | | NEGATIVE POWER SUPPLY
*                   | | | | OUTPUT
*                   | | | | |
.SUBCKT TL071_TI    1 2 3 4 5
*
  C1   11 12 3.498E-12
  C2    6  7 15.00E-12
  DC    5 53 DX
  DE   54  5 DX
  DLP  90 91 DX
  DLN  92 90 DX
  DP    4  3 DX
  EGND 99  0 POLY(2) (3,0) (4,0) 0 .5 .5
  FB    7 99 POLY(5) VB VC VE VLP VLN 0 4.715E6 -5E6 5E6 5E6 -5E6
  GA    6  0 11 12 282.8E-6
  GCM   0  6 10 99 8.942E-9
  ISS   3 10 DC 195.0E-6
  HLIM 90  0 VLIM 1K
  J1   11  2 10 JX
  J2   12  1 10 JX
  R2    6  9 100.0E3
  RD1   4 11 3.536E3
  RD2   4 12 3.536E3
  RO1   8  5 150
  RO2   7 99 150
  RP    3  4 2.143E3
  RSS  10 99 1.026E6
  VB    9  0 DC 0
  VC    3 53 DC 2.200
  VE   54  4 DC 2.200
  VLIM  7  8 DC 0
  VLP  91  0 DC 25
  VLN   0 92 DC 25
.MODEL DX D(IS=800.0E-18)
.MODEL JX PJF(IS=15.00E-12 BETA=270.1E-6 VTO=-1)
.ENDS

* https://ngspice.sourceforge.io/ngspice-eeschema.html#multi
* 2024-10-17T23:12 Tested. Works.
.subckt TL072 1out 1in- 1in+ vcc- 2in+ 2in- 2out vcc+
XTL072A 1in+ 1in- vcc+ vcc- 1out TL071_TI
XTL072B 2in+ 2in- vcc+ vcc- 2out TL071_TI
.ends
* Not tested.
.subckt TL074 1out 1in- 1in+ vcc- 2in+ 2in- 2out 3out 3in- 3in+ vcc- 4in+ 4in- 4out vcc+
XTL074A 1in+ 1in- vcc+ vcc- 1out TL071_TI
XTL074B 2in+ 2in- vcc+ vcc- 2out TL071_TI
XTL074C 3in+ 3in- vcc+ vcc- 3out TL071_TI
XTL074D 4in+ 4in- vcc+ vcc- 4out TL071_TI
.ends

There appears to be an error in this model in that there are two vcc-

* Not tested.
.subckt TL074 1out 1in- 1in+ vcc- 2in+ 2in- 2out 3out 3in- 3in+ vcc- 4in+ 4in- 4out vcc+
XTL074A 1in+ 1in- vcc+ vcc- 1out TL071_TI
XTL074B 2in+ 2in- vcc+ vcc- 2out TL071_TI
XTL074C 3in+ 3in- vcc+ vcc- 3out TL071_TI
XTL074D 4in+ 4in- vcc+ vcc- 4out TL071_TI
.ends

Corrected version:

.subckt TL074 1out 1in- 1in+ vcc- 2in+ 2in- 2out 3out 3in- 3in+ vcc+ 4in+ 4in- 4out
XTL074A 1in+ 1in- vcc+ vcc- 1out TL071_TI
XTL074B 2in+ 2in- vcc+ vcc- 2out TL071_TI
XTL074C 3in+ 3in- vcc+ vcc- 3out TL071_TI
XTL074D 4in+ 4in- vcc+ vcc- 4out TL071_TI
.ends
1 Like

I have updated this given your recommendations:

And using @paulvdh model. However, when I attempt to run a simulation, I get the following error:

Circuit: KiCad schematic
Error on line:
a$poly$e.xu1.xtl074a.egnd %vd [ vcc 0 vee 0 ] %vd ( xu1.xtl074a.99 0 ) a$poly$e.xu1.xtl074a.egnd
MIF-ERROR - unable to find definition of model a$poly$e.xu1.xtl074a.egnd
Command: esave none

I surmise this is an issue with the DC power circuit? I also don’t think I’m doing the audio input correctly.

That error has been solved by install ngspice.

sudo apt install ngspice