Spice simulation - Page 101 - diyAudio
Go Back   Home > Forums > Design & Build > Software Tools

Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 7th February 2011, 01:28 PM   #1001
diyAudio Member
 
Join Date: Jan 2011
Quote:
Originally Posted by unclejed613 View Post
winetricks trick: load only one download at a time. if a dll or something messes up wine, you know which one did it...
Now you tell me, uncle Jed!

Anyway, Dimitri from Russia told me to change my comctl32 dll setting from native to builtin (that's in winecfg -> Libraries). Sure enough, that fixed my problem.

Thanks guys.

Last edited by Buckeye; 7th February 2011 at 01:44 PM.
  Reply With Quote
Old 9th February 2011, 12:56 PM   #1002
diyAudio Member
 
Join Date: Jan 2011
Default Simulating THD

I'm looking at the total harmonic distortion results from my simulation and am a little perplexed. I'm getting really high numbers at low frequencies... like over 70% THD. THD is around 0.5% at 1kHz. So I tried the "audioamp.asc" example that keantoken referenced, and I get similar results. I'm using a 100Hz signal in a 100ms transient analysis for a full 10 cycles.

Any ideas why the results are like this? Should they be?

In the audioamp.asc example circuit that keantoken posted, what is the purpose of V4? Is it just measuring point A? Is that the same as replacing V4 with a wire, and adding a net labeled "A" to the top of R14?

On another topic...

Uncle Jed recommended the Linux gEDA suite for schematic/simulation/layout in an older thread. Is this still a good recommendation? Any comments? I've searched diyaudio and have seen people mention it, but would like to hear something from people who actually use it.

Does gEDA have an autoplace / autorouter? I thumbed through the docs and didn't see any mention of that.

many thanks
  Reply With Quote
Old 9th February 2011, 07:19 PM   #1003
diyAudio Member
 
keantoken's Avatar
 
Join Date: Aug 2006
Location: Texas
Blog Entries: 2
V4 is used to measure the open-loop gain of the amplifier. There are two loopgain.asc files in the examples folder, which will tell you how to do this.

Attached is the setup I use for testing my amplifiers. This turns off compression, doubles bit accuracy, uses Gear integration method for RF accuracy, and sets the number of samples automatically depending on FFT size, test frequency, and number of cycles to run. It will also automatically make a THD measurement, as long as the output node on your circuit is named Vout.

Copy the simulation commands and input sources to your amplifier (after deleting the commands you've already put there). It is likely you'll have questions, no need to refrain.

If this doesn't fix your problem, we will need to see the schematic...

- keantoken
Attached Files
File Type: txt ampsim2.asc.txt (3.3 KB, 72 views)
  Reply With Quote
Old 9th February 2011, 08:26 PM   #1004
diyAudio Member
 
Join Date: Jan 2011
I will try to work on what you posted yet tonight, but it will be later. I doubt it's a settings issue.

The circuit I'm using is the one you mentioned earlier in this thread. It's the audio amp in the example / education files that came with the LTspice install. The settings I'm using are the same as in the example. The only thing I changed was the frequency to 100 Hz.

What kind of THD do you get in your circuit simulations?
  Reply With Quote
Old 9th February 2011, 10:45 PM   #1005
diyAudio Member
 
Join Date: Mar 2004
Location: UK
Try the attached, at 100Hz you should measure 0.290691% THD

As well as adding the parameters suggested by keantoken I also reduced the input level to 0.75V (1V runs this design into clipping) and changed the input source to use the frequency specified by the parameters. Look in the spice error log once you have run the simulation - THD is the sum of the first 9 harmonics.
Attached Files
File Type: txt audioamp.asc.txt (5.7 KB, 15 views)
  Reply With Quote
Old 10th February 2011, 02:28 AM   #1006
diyAudio Member
 
unclejed613's Avatar
 
Join Date: Dec 2006
the gEDA suite is made up of several different programs, that use a common set of files. the documentation you read is probably for the schematic editor gschem, which produces the schematic, then there are tools for converting the schematic into a netlist, and then the PCB layout editor uses the netlist. there are auto placement and autorouting commands within the PCB program. unfortunately, if you have a very large schematic with several hundred wires, and most of them terminate at a 196 pin BGA chip, it seems like the autorouter gives up without trying... i haven't tried NgSpice yet to try an analog simulation of an amp, but apparently it can do several different common types of simulation, including Verilog digital sims. but these tools aren't as simple and seamless as some of the windows based packages out there, and require a steep learning curve. for instance, if you plan on making a PCB from a schematic, you must take meticulous care to properly label wire names, pin names and numbers, and pre specify device footprints correctly. in a project i'm working on i had to create new device footprints and schematic symbols using text files and scripts. once past the learning curve, and with proper entry of data into the schematic, things tend to go rather smoothly after that...

i'm still using LTSpice for analog sims. setting the correct options, such as turning off data compression, will allow you to get the distortion figures down. if you run a plot on just a pure sine wave across a resistor, you can see how the compression has a big effect on distortion. with compression on, for instance, a sine wave source can show 2nd and 3rd harmonics as bad as -30 to -50db (depending also on time step settings and how many cycles the sim is run) if you're not thinking about it, you'll probably think something is seriously amiss with your design, that is until you measure the voltage source and find it's almost as badly distorted as your circuit output.

Quote:
Originally Posted by Buckeye View Post
I'm looking at the total harmonic distortion results from my simulation and am a little perplexed. I'm getting really high numbers at low frequencies... like over 70% THD. THD is around 0.5% at 1kHz. So I tried the "audioamp.asc" example that keantoken referenced, and I get similar results. I'm using a 100Hz signal in a 100ms transient analysis for a full 10 cycles.

Any ideas why the results are like this? Should they be?

In the audioamp.asc example circuit that keantoken posted, what is the purpose of V4? Is it just measuring point A? Is that the same as replacing V4 with a wire, and adding a net labeled "A" to the top of R14?

On another topic...

Uncle Jed recommended the Linux gEDA suite for schematic/simulation/layout in an older thread. Is this still a good recommendation? Any comments? I've searched diyaudio and have seen people mention it, but would like to hear something from people who actually use it.

Does gEDA have an autoplace / autorouter? I thumbed through the docs and didn't see any mention of that.

many thanks
__________________
Vintage Audio and Pro-Audio repair ampz(removethis)@sohonet.net
spammer trap: spammers must die

Last edited by unclejed613; 10th February 2011 at 02:37 AM.
  Reply With Quote
Old 10th February 2011, 02:47 AM   #1007
diyAudio Member
 
keantoken's Avatar
 
Join Date: Aug 2006
Location: Texas
Blog Entries: 2
If you think compression is causing false distortion readings, you can check by taking an FFT of the input voltage. This trace must be directly across the voltage source pins and the source cannot have an internal series resistance.

This can be done automatically by adding the following command:

.four {freq} V(Vin)

Where Vin is the input node of your amplifier. The input source should not have internal series resistance and the negative terminal should be connected directly to ground. Rarely will this not be the case.

- keantoken
  Reply With Quote
Old 11th February 2011, 03:14 AM   #1008
diyAudio Member
 
Join Date: Jan 2011
Thanks again for the replies. They were very illustrative and saved me a week of reading. I was able to figure out that my big issue was the wrong <frequency> in the .four command. I did not change it to 100 from 1k. By only changing that value my THD went from 73.4% to 0.621%. It only makes sense.

Adding the options:

.options plotwinsize=0
.options method=gear
.options numdgt=7

Lowers the simulated THD by about half to 0.317%.

I really appreciate the examples that show how to compute the fourier parameters based on frequency, and especially learning that you can use the variable {Freq} inside the signal generator. That is really cool and simplifies much.

I have one question, why is FFT=32786? I would have expected a power of two which would be 32784.

Uncle Jed, thank you for the great synopsis of gEDA. It does not sound like the tool set for me. After a bit of research, I picked DIPtrace. Something about its interface works the way I think. I've been able to enter some schematics and get it through PCB -- nothing as complex as the 196-pin BGA. But if I have to lay out a 196-pin BGA, all I can say is someone's got the wrong man for the job! :

What I want to avoid is drawing the schematic twice. DIPtrace can import netlists, and LTspice can export them. Unfortunately, I haven't been able to get much of that to work. Period.
  Reply With Quote
Old 11th February 2011, 11:27 AM   #1009
diyAudio Member
 
unclejed613's Avatar
 
Join Date: Dec 2006
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768...



__________________
Vintage Audio and Pro-Audio repair ampz(removethis)@sohonet.net
spammer trap: spammers must die
  Reply With Quote
Old 11th February 2011, 12:07 PM   #1010
diyAudio Member
 
Join Date: Jan 2011
OK, I got the power of 2 wrong, but the examples both Jon & kean posted show .param FFT=32786. This is also not a power of 2 as your list shows. My question is, was this intentional or is everyone copying a transpose error?
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with Spice simulation overmind Everything Else 4 23rd December 2002 04:58 PM


New To Site? Need Help?

All times are GMT. The time now is 05:39 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2