|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
||Thread Tools||Search this Thread|
|15th August 2014, 11:00 AM||#1|
Installing and using LTspice. From beginner to advanced.
1/ Installation. Post #1 (you are here)
2/ Running a simple DC simulation. Post #2 and #3 HERE
3/ Running a simple AC simulation. Post #7 HERE
4/ Simulating a one transistor Amplifier. Post #14 and 16. HERE
5/ Distortion and FFT's. Post #19 and 20 HERE
6/ Squarewave Testing. Post #31 Here
7/ Measuring AC voltages. Post #35 Here
8/ Setting up multiple signal sources and running two simulations in parallel. Post #39 Here
9/ Adding ripple to the PSU. Post #51 Here
10/ Simulating a simple PSU. Post #59 Here
11/ Adding and simulating a voltage doubler and regulator. Post #67 Here
12/ Testing under load and dynamically. Post #71 Here
13/ Adding models to use in a simulation. Post #85 Here
14/ Adding a PSpice 3rd party model to a simulation. Post #146 Here
15/ Measuring amplifier output impedance. Post #214 Here
16/ Stepping a component value. Post #222 Here
17/ Stepping the bias of an amplifier. Post #225 Here
Subsection... Ideas and Tutorials submitted by diyAudio members
A/ Using LTSpice simulation command for a DC sweep for resistors. For a worked example see post # 560 Here
(submitted by pr)
The purpose of this thread is to show how to both install and to use LTspice, hereafter just referred to as LT, the free circuit simulation program from Linear Technology. I consider myself very much at the beginner end of the spectrum, but I'm hoping that as the thread develops we can gather input from those more seasoned users amongst you all...
A picture... or two or three... are worth a thousand words.
Can you believe it took me many days to figure out how to include a simple model for a device into a simulation. For a newbie it needs to be a click by click instruction with pictures.
Credits... firstly to Bob Cordell and his excellent book "Audio Power Amplifiers". I can say with certainty that I would still be staring at the blank grey workspace of LT had it not been for Bobs excellent introduction to this fantastic program. I would urge anyone with an interest in simulating amplifiers to "go buy the book". You won't regret it.
Thanks also to Keantoken who has a prety comprehensive WIKI on the site. Take a wander over when you've a few minutes spare and have a read.
So lets get started.
LT is best downloaded from Linear Technology itself.
Linear Technology - Design Simulation and Device Models
There is a Windows and Mac version with this thread being based on the Windows version.
Install LT as you would any other program. On Windows the installer will probably say you have UAC (user account control) enabled and that it may cause issues with file paths. I have used LT on Vista, W7 and W8.1 with no unresolvable issues by leaving UAC on.
When you have installed LT you should find you have a desktop icon to open it... the usual stuff. What you should now is change the icon (or whatever means you yourself use to open programs) to run as administrator. This is important because LT will not run and update correctly if this is not done.
To do this, right click the icon and using the <properties> tab, change the shortcut to "Run as administrator". This picture show it for Windows 8.1, W7 and Vista are similar.
Next thing we do is open LT and set a few basic options. Setting these options as shown ensures that LT doesn't accumulate a lot of temporary files... even then its not foolproof... we'll cover that later.
Nearly there, but first lets get to know where LT lives on your PC and how it handles files and folders. This is important in order to keep your system tidy and to make it easy to keep track of things.
Depending on your operating system, go to the run box and type C:\Program Files.
You should see something like this with LTC being the folder of interest. Click your way through the folder to open it. You will see this.
The <scad3> line is the program shortcut. If you are using W8.1 then this is probably the best place to alter the settings mentioned above to "run as admin". There is a folder of examples in there too, as well as all the models and files LT needs to run.
I recommend that you DONT add to, or change anything in those folders at this stage.
Lets just jump ahead of ourselves at this point because there is something worth mentioning. If you run a simulation (such as from one of the examples), or you create one of your own, then LT by default wants to save it back in the LTC folder in program files when your done or when you close it. My advice... dont let it. Save all your work in a normal folder in your documents. This then leaves all the program files untouched. If you want to use an example as a starting point then I recommend the first thing you do is save the simulation again under a different name and as suggested, save it to documents or some dedicated area away from the LT folder in program files. Doing that preserves the original installation and leaves all the files and examples untouched.
So if you are creating your own simulation and design then I suggest just opening LT first and then click <file> followed by <new schematic> followed by <file> once again and then <save as> giving your intended design both a name and then saving the blank workspace somewhere such as your documents folder.
So we now have LT installed, we can move on to actually using it to do something useful. This will be your first simulation.
Note on updating LTspice. Updates to the library files are frequent. By default LT seems to warn you after 60 days have elapsed that you have not updated the installation. These updates are mainly for database of models adding new ones as they become available. The updates are incremental and simply add new items to the already installed files. The update typically takes around 3 minutes to complete, however you must be logged on as an administrator (in Windows) for the update to run correctly.
To manually check for and install updates
1/ Open LT with elevated privileges. In Windows this means right clicking the icon you use to launch the program and selecting the 'run as admin' option.
2/ Under 'Tools' there is a dropdown menu. Select 'Sync release to allow LT to check for and install updates.
When the update is complete the program automatically closes with a message saying the update was successful.
(note... this thread isn't something that can be completed quickly. I shall add things to it as and when I have the time)
|15th August 2014, 01:21 PM||#2|
Running a simple DC simulation.
Our first simulation will be a simple DC circuit. Something like this will help familiarise you with LT's basic component handing properties and show how you place items on the workspace.
So this is what we do... and I would recommend that you now create a folder in your documents called LTspice.
1) Open LTspice.
2) Goto <file> at the top left and then click <new schematic>
3) Now click <file> again and this time click <save as>. A window will open. At the top is a drop down that allows you to browse for a location to save your simulation. I suggest you name it "DC Simulation" and save it in documents within the new folder (LTspice) that we have just created.
Depending on your PC, it may complain when you open a simulation file so lets see what happens on your own set up. Close LT and browse to the newly created file in the above folder. You should see a symbol like this,
Click it and check that it opens LT correctly. W7 and W8.1 may give a brief warning warning message but complete the operation anyway.
Thats one way to open a file. The other is to open LT from its icon and then either use <file> and <open> or you can right click the blank workspace and your last 10 simulation files are displayed.
So open our blank DC simulation file and lets create the first sim. This is the circuit... simple isn't it.
What we have to do now is recreate that as a working simulation. Click the component symbol on the top line,
and have a good browse and see what is on offer. We are going to start with the voltage source, which will become our 10 volt supply. So click <voltage> and then <OK> and you will be returned to the workspace with a symbol that you can seemingly drop anywhere. Move it to the left and left click to drop it. Then right click to clear the symbol which is still attached to the cursor. Now we need two resistors. Wwe can get these either from the component library again or, as these are common parts, straight from the top line of LT. Do you see the resistor symbol. Just click it and drop two resistors onto the workspace. It should look something like this.
Now we wire it up using the <wire> symbol from the top line. This looks like a pencil. Click it and you have a crosshair cursor appear. Move that over a component node and left click. Then drag the wire up/down/left/right etc left clicking each time you want to change direction.
Next up is our Ground. This is important. LT can not run without a ground. So click the ground symbol (top line) and drop the ground symbol onto the correct point of the circuit, the zero volt line. You can drop the ground below this and attach it with a wire which looks better.
Next we right click the voltage source and set it to 10 volts and click OK.
Your circuit should like the above although the placement of the parts doesn't matter but we can tidy it up. Look on the top line. There is a small and a big hand. Click the small one and drag it over components. Click the part with the hand and drag them to where you want.
Do the same for the wires.
Now use the scissors symbol to tidy those loose ends. It takes practice.
For information... if you make a mistake you can use the <edit> tab at the tob left where there is an <undo> and a <redo> option.
And we need to assign values for the resistors. Right click each in turn and type the value as shown. Click OK.
At this point we should have a complete simulation ready to run... but how ? That comes next.
|15th August 2014, 01:45 PM||#3|
Running the simulation.
Open the completed simulation file and right click a blank area of the workspace. Click the <edit simulation CMD> line and a new window opens. Select the <DC op pnt> tab and click OK. You now have a little box attached to the cursor which when you drop it onto the circuit will display as .op
You can move the text by using the hand symbol as we did before so put it somewhere neat on the diagram.
Now right click the workspace again and select <run>. A window opens with all the circuit nodes together with their currents and voltages but tbh, its not very intuitive, certainly not on a complex diagram. Note... you can also run the simulation by clicking the running man on the top line.
Now close that window and move your cursor over various points on the diagram. As you move over wires you will read the voltages (displayed at bottom left). Move over the resistor and you will see both the current and the power dissipated in that resistor.
That covers a very basic DC simulation. We will build on this to look at other aspects of LT.
|16th August 2014, 02:56 PM||#4|
Join Date: Feb 2008
Very Cool Stuff Mooly !!!
Just as a note, I would like to add that for anyone using Linux it does run using WINE as well !!
|16th August 2014, 06:38 PM||#6|
Thanks for the info guys. I've never used Linux tbh.
Hopefully in the next day or two I'll get around to continuing the thread.
|17th August 2014, 11:05 AM||#7|
Running a simple AC simulation.
Next up and we can try a simple AC simulation. What we are going to do first is rename the original DC simulation file so that we can retain both files.
Firstly, open the DC simulation file and go to <file> at the top left and using <save as> resave the file under a new name (such as AC simulation). Check the location is correct and that it is saved in the folder you decided on at the start of the tutorial.
So, starting with the AC simulation file open in LTspice we are now going to change the supply voltage source to an AC source. To do this we right click the voltage source and select <Advanced>
Select <Sine> and fill in the following settings. Be sure to click OK at the bottom. The word Sine an a lot of numbers will sprawl across the diagram. Use the hand symbol (covered in part 1) to move the text somewhere out of the way.
For information... the scroll wheel of the mouse zooms the diagram in and out. If you right click the blank workspace there is a ZOOM TO FIT option which will automatically best fit the image to your screen.
You can right click the voltage source at any time to review and alter the settings.
So what have we actually done here.
The DC offset value (entered as zero) ensures the sine wave is centred around the zero point.
The amplitude sets the PEAK value. This means the waveform will go 1 volts ABOVE and 1 volts BELOW ground as we shall see in a moment.
Frequency is self explanatory.
Time delay (which we set at zero) would be a time you want to wait before the sine wave starts.
Theta... I have never researched so I don't know
Phi or phase angle is the number of degrees into the cycle that you want it to start. 360 degrees to one full cycle remember.
Cycles is the number of complete cycles the voltage source will generate.
So now you should have something that looks like this,
Maths we keep to a minimum but you need to know a couple of basics. To view the waveforms on LT's oscilloscope means you need to know how to set the scope settings in the first place. This is something you have to understand and be confident in calculating... but its easy...even I can do it.
So we have 1000Hz as voltage source that is set to generate 10 cycles of the signal. The time period of this is found by taking the reciprocal. So all you do is divide 1000 into 1. That gives 0.001 That quantity is time. One cycle of 1Khz lasts for 1 millisecond. Now we decide how many cycles we would like to see on the screen. Well we set the voltage source for 10 cycles so let us display all those. Ten cycles of 1ms (milliseconds) each is 10ms in total.
To set LT to do this, first right click the workspace and select <Edit simulation>. A new window opens. Select the <Transient> tab and enter a stop time of 10ms. Click OK. You now have a new command attached to the cursor to drop neatly on the diagram. As before, use the hand symbol to tidy things up.
However you arrange things, it should have all these ingredients.
Now right click the workspace and select run.
You should hopefully see something like this. A red probe appears. Move over the top of the voltage source with the probe and click anywhere on connection to R1. You see the input voltage as it would be on a scope. Click the junction of the two resistors and a second trace is overlaid... you get the idea. What about current ? Mouse over a resistor and left click. The current is displayed. Notice the scale changes automatically. Double clicking anywhere you want to measure brings just that one value into focus with just that trace displaying.
What about RMS voltages ? We know we have 1 volt peak which equates to 0.707 volts RMS (1 divided by root 2). We can get LT to display that. Run the sim and display the voltage source output. Hold the CTRL key and left click V(n001)which is the name of the current trace displayed.
|17th August 2014, 11:12 AM||#8|
Join Date: Jul 2004
Location: Scottish Borders
Please explain the sine(0 1 1000 0 0 0 10) and similarly for pulse and others.
How do we supply two signals?
Can we change from one signal type to another and back again?
Can we gate a sine ON and OFF? and start at different parts of the waveform eg max +ve voltage, max -ve voltage, or zero voltage or some other?
same for a stream of pulses that needs repeating?
And a big Thank You !!!!
regards Andrew T.
Sent from my desktop computer using a keyboard
|17th August 2014, 11:35 AM||#9|
I know I haven't got all the answers hopefully we can figure things out and ask as we go along.
The (0 1 1000 0 0 0 10) is non intuitive but is in fact a group of seven numbers corresponding to the seven options available while setting the sine waveform.
Changing from waveform type to another can be done (and there might be easier ways than this) by either setting up two (or more) voltage sources on your diagram and manually connecting each as required or by using the time delay line in the settings box to start waveforms in sequence. They would then have to be mixed (as you would in a real circuit perhaps with a resistive divider) and fed to your circuit under test.
Gating a sine can be done with simple circuitry (say a FET) and applying a pulse of the required timings to turn it on and off.
We can come to all that though... and if anyone has any better methods then please join in.
Edit... I noticed the DC offset in the last two pictures was showing 0.1 That was me trying something. Set it to 0 for your sim.
|18th August 2014, 06:10 AM||#10|
Join Date: Jun 2012
Location: NSW, Australia
Blog Entries: 13
You're doing yet another nice job, Karl - good on you! As a general thought, LTspice rewards the power user - there are almost always multiple ways of doing things, some of them pretty nifty; there will very few times where one is really stymied ...
|Thread||Thread Starter||Forum||Replies||Last Post|
|Meistersinger VFA-200, A beginnerís first try in LTSpice||nattawa||Solid State||34||29th January 2016 01:58 PM|
|Need help installing LTSpice||rif||Software Tools||4||30th May 2013 01:59 AM|
|BSC with 2 way advanced PI?||F1 FAN||miniDSP||2||14th November 2011 07:26 PM|
|More advanced marketplace||peranders||Swap Meet||0||14th August 2002 08:03 AM|
|New To Site?||Need Help?|