Author Topic: Fantastic New AC Simulator! WIP  (Read 3079 times)

0 Members and 1 Guest are viewing this topic.

Online T3sl4co1lTopic starter

  • Super Contributor
  • ***
  • Posts: 21679
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Fantastic New AC Simulator! WIP
« on: June 24, 2017, 05:25:48 am »
I've been working on this for the past two months or so.  ~3.3kLOC later, and it's far enough along to give an idea about the basic functionality:

https://www.seventransistorlabs.com/Calc/Filter1~.html

Most number inputs can be click-and-drag adjusted.  The schematic area has hover buttons (and tool tips) for modifying it.

Already spotted a few bugs and quirks that I'm addressing.  I'm just happy to see curves plotted, and want to share! :D

(The curves are actually calculated from impedances, but only of the source / load components.  The middle stuff isn't done yet.  I'll be filling that in soon!)

The network itself is not functional right now, nor are the storage traces or the load/save functions below (those will be much later).

Send hype and support, and they'll get implemented faster... 8)

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: BravoV

Online T3sl4co1lTopic starter

  • Super Contributor
  • ***
  • Posts: 21679
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fantastic New AC Simulator! WIP
« Reply #1 on: June 24, 2017, 06:10:38 am »
Yeah, that's a little more ambitious than this! :P The only reason I began this is because AC steady state is just linear algebra; and at that, this is a straight ladder network, nothing arbitrary, so it's really easy.

I'd love to expand it to arbitrary networks, but that would require schematic entry, which is a big project all its own.  (Netlist entry would be easy, but not very friendly.)  But if that's done, the analysis isn't too bad (one NxN matrix inversion, IIRC).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online T3sl4co1lTopic starter

  • Super Contributor
  • ***
  • Posts: 21679
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Updated
« Reply #2 on: June 24, 2017, 07:13:07 pm »
Give it a refresh, it should be just barely usable now!

The transformer still isn't implemented, but the shunt and series types look to be behaving (just make sure to work out which components need to be open/short when you're, say, entering a filter that only uses one component per branch!).  All the trace output settings are now operational.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online T3sl4co1lTopic starter

  • Super Contributor
  • ***
  • Posts: 21679
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fantastic New AC Simulator! WIP
« Reply #3 on: June 25, 2017, 05:38:35 am »
Yeah.  That'd be the easiest to develop, but it's a two step process.  It would be nice to have the schematic right there, like with Falstad or the other web client schematic capture tools that are out there.  If you don't know netlist syntax yourself, every iteration of the schematic is an export, copy and paste; and if it doesn't drop in seamlessly from $tool, you're kind of screwed.

Worse yet, I'm comfortable with netlist syntax, so I have no reason to test that work flow. :P

I don't think dropping in SPICE is worthwhile.  Once the netlist is parsed, it's just a matrix inversion: easy enough to write by hand, or drop in any of the handy modules out there like Math.js.  The parser might be handy, and postprocessing is very handy.

There are web interfaces for that sort of thing already: http://www.ngspice.com/ for instance. :)  But as usual, it's a batch run, not real time.

I don't think SPICE is normally fast enough to do real-time analyses.  That could just be overhead in the programs that I've used.  AC analysis is certainly faster than the others.  And yeah, one could easily delve into the source and streamline an implementation... which would also have to be ported to JS to run in the browser... ew...

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online T3sl4co1lTopic starter

  • Super Contributor
  • ***
  • Posts: 21679
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fantastic New AC Simulator! WIP
« Reply #4 on: June 25, 2017, 12:07:55 pm »
Hmm, this looks interesting:
http://spinningnumbers.org/circuit-sandbox/index.html
may be a good starting point for that kind of thing.  It's three times the size, though :o

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14195
  • Country: de
Re: Fantastic New AC Simulator! WIP
« Reply #5 on: June 25, 2017, 12:16:42 pm »
For a simple linear circuit, like the ones in question here spice is well fast enough. It might be a slight issue if you real want real time feeling with adjusting values with a slider and than redo the calculations in real time (e.g. < 10 ms). One would still need the plotting part - the pure simulation is only a part of the solution.

With suitable filter templates such a specialized simulation still has its benefits.

Writing such a simple simulation is still fun. I have done that too - long time ago. Though no graphical interface (kind of netlist only) and this was before the internet. Today spice is likely faster than the old home computer was.
 

Online T3sl4co1lTopic starter

  • Super Contributor
  • ***
  • Posts: 21679
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Fantastic New AC Simulator! WIP
« Reply #6 on: June 26, 2017, 01:02:44 pm »
Hey, it works!  Sort of.  The reactive source/load options I don't think are working right (setting them to minimum values is a good idea), and there's some numerical instability with having very large or very small values (likely causing a NaN cascade, breaking the output).

Here's a filter you'll never see in any textbook:



The prototype could be described thus:
Port 1: High resistance (10kohm) or unterminated.  Shunt branch, minimum capacitance 1pF.
Port 2: Terminated.  Load 450 ohms.  Shunt branch, minimum capacitance 5.1pF.
Prototype: Asymmetrical bandpass.  2nd order highpass, 5th order lowpass.
Center frequency: 115MHz
Passband: 100-130MHz, +/- 1dB or better
Cutoff: 95 and 135MHz, -3dB
Asymptotes: at least -40dB below 40MHz, -80dB above 220MHz.
Two zeroes in HF asymptote.
Optimize for maximum power gain.
Add to port 1: capacitor impedance transformer, step-down ratio.

I'm not aware of any synthesis tool that can implement a spec this complicated, so I solved the above circuit with lots of tweaking.  Notice the passband only has three peaks, not the four a 5th order passband should have.

(Note that an unequally terminated network can exhibit voltage or current gain, as a result of impedance transformations.  High power gain results from presenting a high impedance to a CCS, or low impedance to a CVS.  Ideal CCS or CVSs can deliver infinite power, which is undesirable in a real circuit (e.g., a SMPS cannot survive switching into a zero-ohm filter!).  An infinite impedance ratio is also only possible at zero bandwidth, but the bandwidth is limited by the spec here.  Therefore, there is a compromise between reasonable (but not maximal) power output, and nominal bandwidth: a gain-bandwidth limit.)

After entering it in this tool, and tweaking the values further, I obtained this:



Note: the load impedance changed, to higher resistance and somewhat lower capacitance.  This is allowable for the application (the following stage is a common-emitter amplifier; the input impedance is roughly inverse to gain, so that it can simply be set for lower gain -- higher R_E -- to load the filter less.  In exchange, the filter can deliver somewhat more gain, so that it's kind of a wash, in the end; or at least, it's not obvious which direction (more filter or amplifier gain) would yield a better total result.

The inductors also changed, from standard values to non-standard, high-Q values (these would be custom, but definitely realizable).

I didn't get a zoom on the passband, unfortunately.  In setting the axis range, I entered wrong numbers and made it freeze... ::) On the upside, another bug fixed.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf