"Timestep too small" error in simulation

Hi, I am trying to simulate a speaker amplifier as a project for an Analog 101 class. I have manufactured this in hardware and am trying to narrow down on a bug for which I want to see the simulation more closely.

Frequency response (AC sweep) seems to work, but I keep running into this error when trying to get a transient response (AC voltage 1 V at 1 kHz, 10 us time step, 10 ms run time):

doAnalyses: TRAN:  Timestep too small; time = 1.00285e-07, timestep = 1.25e-17: trouble with node "e.xu1.eh#branch"
run simulation(s) aborted

Obviously, I tried with higher time steps but that doesn’t help. From places where this topic has been discussed before, I tried the suggestions of making sure that my schematic is correct, pin assignments are correct, libraries are imported correctly etc. That doesn’t help either. Please tell me how to proceed.

Schematic:

Please note that parts outlined by an orange box are for simulation only, and not part of the PCB. Additionally, R21 and R22 (feedback resistors) are also for simulation only.

Source files:

GitHub repo: GitHub - eccentricOrange/bt-speaker at bb109891162d04ee20b69f71db7035d7aeed9169
Please clone/download the entire repo, as library imports to KiCAD are specified by relative file paths. Look into pcbs/analog-audio/ for the KiCAD project.

Schematics and PCB design are provided as PDF files in the releases section.

I have never used Spice to simulate more complicated things than having may be 10 elements. At your place I would divide this circuit in parts and try to simulate each of them. There is a chance that you will find that way a problematic in simulation segment, and having it small it is easier that you will find how to solve problems.
My simulations were mainly the supply filters when I wanted to see the effect of element imperfections up to GHz so I have never used ideal capacitors/inductors. Using ‘ideal’ capacitors can be a problem in transient simulation when they are connected to voltage sources as currents can go to infinity.
It looks the problem is in far beginning of simulation. Who knows may be capacitors in supply start from having 0V and are loaded to supply voltage in 0 ns time.

  1. Try if changing in transient checkbox about using initial conditions change something.
  2. Try to add 0.1 ohm in serie with your capacitors in supply, or delete this capacitors at all. If they are connected to ideal voltage sources than they have no effect in simulation, as if they are or not voltage is ideal.
1 Like

The “initial conditions” checkbox solved my issue, thank you! I still have to add parasitic resistance for higher frequencies, however.

I have never used Spice to simulate more complicated things than having may be 10 elements.

How do you handle such complex circuits, then?

In 1982 being a student I designed and build the analog oscilloscope. It was the only way for me those time to have oscilloscope.
I have written about it an article (I send it in November 1982) you can see my schematics here:

It should open in 4/84 number at the right page, you can go backward and forward to see the rest of schematics. It is my whole oscilloscope except power supplies I didn’t saw in them anything interesting to show.
Those time I had no PC and Spice and was able to design and count how it will work and it work as I expected. I still have it, but not use.
Now you can simulate my circuits if you want.
Everything in electronic is practically countable with enough precision. You design it such a way that all element non-linearities can be compensated by feedback (and in feedback you have linear elements).
If you have transistor amplifier without feedback it can be hard to exactly know how it behaves. Elements have too big parameter tolerances and non-linearities. But if you reduce amplifier having gain of 1000 to 10 with feedback you get result enough close to what you set.
In my oscilloscope amplifiers each amplifying stage gain is decided not by non-linear transistors but by resistors.

So general answer: Everything in electronic works as you expect :slight_smile:

But if you add to each L its parasitic R and C and to each C its parasitic L and R and you have many filtering stages. Looking from IC: LC near it, then CLCLC on volage regulator output and then CLCLC before regulator and you want to know how much 10MHz … 1GHz IC generated noise is practically filtered it was easier to simulate than to count. But last time I used Spice it was about 10+ years ago and decisions I made those time are simply still valid so I don’t use spice.
Few days ago I started to try to use KiCad Spice:

and from those my experiments I know about [v] Use initial condition.
If you asked a week ago I would not know about it.

I’m 99% sure your capacitors started from being 0V. But after changing that checbox they started from being loaded to supply voltage so there were no problem with loading them with 10000 kA current.

First, the schematic is drawn quite neatly. Each of the blocks are drawn with attention to detail and following sensible conventions such as signal flow from left to right and voltages from top to bottom, but all the separate blocks are just a randomly thrown together puzzle. You have to chase around and read the text to find out where and what the input and output connector are. It is quite a puzzle to reconstruct the general signal flow. My first assumption (stereo amplifier) turned out to be wrong, The block order appears to be:

  1. Audio jack ( With L/R channel selection jumper).
  2. Crossover Filter section.
  3. Opamp amplification.
  4. High current section.
  5. Output connectors.

I have a very strong dislike for drawing rectangles around all schematic sections. (And I’m not the only one in this). The rectangles achieve nothing that whitespace does not do better (i.e. indicating separation). These things also tend to suck up a lot of time during schematic design and revisions.

It is also always a bit of a struggle to find the best compromise between using wires, and using labels for connections. Your wish to put everything into neat rectangular blocks resulted here in more labels and less wires than you should have used.

LM741 has been obsolete for over 30 years. Please do not use that anymore. That one gave using opamps in audio circuits a bad name because it’s specifications are not good enough for “decent” audio.\

I also have a strong doubt about your power section. With R19 and R20 you create a very weak “GND” level with just 10k resistors. Combining that with DC coupling all the way from input to output (Except for C2 in the crossover). You amplify the opamp input offset, put that directly into the speakers, and probably overwhelm R19 and R20. Maybe this is by design to reduce DC current thought the speakers because of this offsets? (But you have two opamps).

Your amplifier also performs better if you put the high current drivers inside the feedback loop of the opamps.

Next is the lack of hierarchical schematic design. Quite a big part of the schematic is drawn twice (copied). This duplication is bad for maintenance. It’s too easy to make a modification on one channel and forget the other.

I have tinkered a bit with your schematic:

  1. Deleted the rectangles
  2. Put the duplicated section on it’s own hierarchical sheet.
  3. Connected the thing in order with wires.

The main section of the root sheet now looks like:

The hierarchical sheet with the amplifier section now looks like:

And a .ZIP with the changes:
2024-05-25_analog-audio.zip (128.7 KB)

This has clear signs of a beginners project, I was a bit surprised the youtube link was to a video from the signal path. Shariariar’s video is not really meant to design a real circuit, but it’s more to explain principles of how things work. In real life for example it would be unusual to use TO220 packages for the pre drivers. If you are interested in analog audio, I can highly recommend the book “Audio Power Amplifier Design” from Douglas Self. And "Designing Audio Power Amplifiers from Bob Cordell.

1 Like

Hi Paul, thank your very much for your detailed feedback, I wasn’t quite expecting this. I especially didn’t expect anyone to take the time to actually rework our schematic. I’ll check out the books you suggested at the first chance I get.

Arrangement

You have to chase around and read the text to find out where and what the input and output connector are. It is quite a puzzle to reconstruct the general signal flow.

I agree with you here, it is quite the jigsaw puzzle. In my defence, it was intended to be read along with the following diagram, which my friend and I have included in the final report. I tried embedding this in the main post too, but I’m only allowed one media file as a new user.

That said, I do understand that schematics should generally be readable, and I’ll try to improve that going forward.

Lables

It is also always a bit of a struggle to find the best compromise between using wires, and using labels for connections. Your wish to put everything into neat rectangular blocks resulted here in more labels and less wires than you should have used.

Haha, I was wondering how to deal with that. When my friend and I were designing this initially, we simulated in LTSpice; we didn’t realise KiCAD could do SPICE at the time. I had segmented out at least the power amplifier at the time, but couldn’t figure this out in KiCAD. So, thanks for your help there.

Choice of op-amp

LM741 has been obsolete for over 30 years. Please do not use that anymore.

Fair enough. We also found the same, and will switch to something else for a later revision. For now, we wanted to stick with something familiar (as 741 is part of our syllabus).

Power

I also have a strong doubt about your power section. With R19 and R20 you create a very weak “GND” level with just 10k resistors.

I am struggling with that :smiling_face_with_tear:

Measuring across R19 gives me about 17 V and R20 gives me about 7 V. I’m still trying to figure out how to fix this.

Amplifiers in loop

Your amplifier also performs better if you put the high current drivers inside the feedback loop of the opamps.

I did not know about this, will definitely read up here.

Hierarchical schematic design

Next is the lack of hierarchical schematic design. […] I have tinkered a bit with your schematic

Damn, that’s a lot of effort, thank you! I’ll certainly rework the schematic.

You must be new to the KiCad forum :slight_smile: