Date Archives August 2011

Configuring Thunderbird to Work and Play Nice with GMail

This tutorial is going to explain how to configure Thunderbird 3 to work the best with GMail. In Thunderbird 3, the account creating wizard makes it easy to connect to GMail, but there are a lot of different settings that need to be adjusted to make the program work even better. This tutorial will explain how to adjust all the settings so that Thunderbird will works as smooth and properly as possible with GMail.
As example of a problem, if you don’t specify your search and folder settings properly, you will get duplicate messages making it hard to find aynthing when you search. Another example is that when you delete items through Thunderbird, it will create an additional Trash label in GMail.

One more thing to note: For security reasons, I will not be using any extensions or plugins for Thunderbird. Let’s get started!

  1. Configuring your GMail Account
  2. Adding your GMail Account to Thunderbird 3
  3. Configuring Thunderbird 3 for the Best Settings

Configuring your GMail Account

The first thing you have to do is configure your actual GMail account. To do this, log into your GMail and then click on the gear icon in the top right corner of your email, then Mail settings. For some reason Google decided to use a nearly identical icon as the settings icon in Internet Explorer 9, so do not confuse the two. You can see where to click in the screenshot below.


Now that you are in the settings, click on the Forwarding and POP/IMAP tab. The settings you want to choose are Enable IMAP, Auto-Expunge on, and Do not limit the number of messages in an IMAP folder. You can see the correct settings in the screenshot below.

Make sure to push Save Changes when you are done with this tab


The last settings we need to change are located under the labels tab. Under System labels you can see your usual GMail labels. In Thunderbird these will show up as folders. For each label that you want to appear in Thunderbird, you need to check the corresponding Show in IMAP checkbox. Under the System labels, check the Inbox, Starred, Sent Mail, Drafts, All Mail, and Spam. Un-check all of the other boxes unless you want them to appear in Thunderbird as a separate folder. I decided to un-check some GMail features like their Important and Chats labels, because part of the reason I use Thunderbird is to get away from all the feature bloat, social networking, and advertising that Google keeps throwing in my face.

Make sure, however, that the all the labels with arrows (except for Starred which is up to you) are checked.


Return to Top

Adding your GMail Account to Thunderbird 3

Now that your GMail account is all set up and ready for Thunderbird, we are ready to add the account in Thunderbird. Click on Tools > Account Settings…


Next click on Account Actions > Add Mail Account…


Now type in your gmail settings and push Continue. Thunderbird will automatically configure the server deails, and unless something went wrong, you should see the screenshot below. Make sure that IMAP (remote folders) is selected, and press Create Account.


Return to Top

Configuring Thunderbird 3 for the Best Settings

Now that your account is created, you could technically start using Thunderbird for your email. But we will make sure that all the settings are set in the best way possible to make work nicely. If you just added your account, the Account Settings window should still be open. If it is not, click on Tools > Account Settings… from the main menu.

Server Settings

To start, click on the Server Settings item. The first thing we will do is make sure that deleting messages is handled properly. Under When I delete a message choose Remove it immediately. If you leave it as Move to this folder: Trash, GMail will remove still get rid of the messages from your Inbox, but it will also create a new label called something like Gmail/Trash and tag all of your deleted messages with it. This won’t ruin anything, but why have an extra label that does nothing.

The other settings under Server Settings like Check for new messages at startup, or Check for new messages ever X minutes don’t matter because in IMAP, everything happens in real time automatically. Here is how I have it set:


Copies & Folders

Next, click on Copies & Folders. This page is important. Just look at my settings in the image below and set it exactly the same. What you are doing here is telling Thunderbird not to save copies of sent messages, becaues GMail automatically does that for you, and automatically places it in the Sent folder. I am not sure what Message Archives does, but I know that you don’t need it. By setting the Drafts options, we are telling Thunderbird that to save any unfinished emails in to GMail’s Drafts folder on the web. If we left it as the default settings, when you save an un-finished message, it would store locally on your computer. This means that if you logged into GMail from a different computer, the saved message would not be there. I don’t use Templates, so I just set it to GMail so that if I ever did, they would be synced with the GMail server.

Here are the proper settings:


Here is how you set the Drafts folder:


Junk Settings

The next thing we have to fix is the spam/junkmail settings. Click on the Junk Settings page and make the settings how I have them in the screenshot below. GMail already has built in spam control which works very well, so we don’t need to use the Thunderbird built in spam control. I have my email posted right on my website, free for anyone to see (including spam-bots crawling the web to harvest emails) and I rarely have a single spam message slip through. Under Move new junk messages to, choose Other and set it to the Spam folder on GMail. This makes any messages marked as Junk (the terminology Thunderbird uses) go into GMail’s spamp folder. This way if a spam message ever slips through, you can mark it as spam simply by clicking the Mark as Junk button within Thunderbird. If you didn’t set this up, marking messages as spam from within Thunderbird has no effect.

Here are the proper settings:


Here is how you set the Spam folder:


Synchronization & Storage

Next open the Synchronization & Storage page. Here we are going to make sure that Thunderbird downloads all the messages, regardless of their age, and stores them forever. This way you will have access to all of your email messages, even if you don’t have an active internet connection. It also means that Thunderbird won’t have to re-download the messages if you try to open something that hasn’t been downloaded before. The last thing this does, is that it makes searching from within Thunderbird work very well, since what would be the point of searching if you were only looking at 10 percent of your messages?

Below are the proper settings:


Now we are done with the Account Settings menu, so click on the OK button.

Options Menu

Next we have to do some finishing touches in the Options menu. Click Tools > Options to open it up. Click on the Security icon, and then the Junk tab. Check the box next to When I mark messages as junk > Move them to the account’s “Junk” folder. For some reason, unless you do this, when you mark a message as spam, it will get marked as spam, and just sit there… This makes it so that if you mark a message, it immediately gets tossed in the Spam folder and it’s gone. Here is a screenshot of the settings:


Now while the Options menu is still open, click on the Composition icon, and then the General tab. I left everything here as default for my personal setup, but here is where people might want to change settings. Where it says Auto Save every X minutes, some people like to put it to something more frequent, for example save every minute. The problem with setting it too low is that because Thunderbird is saving the message to the GMail Drafts folder, you will get a message that it is sending something every time it backs up your draft. It can get annoying very fast. Click the OK button to save and exit out of the Options menu.

Search Settings

We are nearly done! The last thing we need to do is make sure that when you are searching for messages, that you don’t have duplicate messages coming up. If you have a message in the Inbox, it will automatically also be in All Mail. So when you search, Thunderbird will actually find both, and show you both. To make sure that this doesn’t happen, one by one, perform the following procedure on every folder except All Mail, Drafts, and Sent Mail.

Right click on the folder located in the bar on the left of the program and select Properties. Un-check the box next to Include messages in this folder in Golabl Search results. Push OK.


When you are doing the Spam folder, you should also click on the Synchronization tab, and then un-check Select this folder for offline use. This will keep Thunderbird from download hoards of useless Spam and taking up space on your hard drive. Keep in mind that you will still be able to look inside of this folder just like you would any other folder. The only difference is that you might not be able to do it offline, and sometimes it might take a little longer to load.

Favorite Folders

The last thing to do is completely optional, but you can right-click on a folder, and mark it as a Favorite Folder. This way you can mark all the folders you use as favorites, and then you can click the black triangle shaped arrows (I marked it with a red arrow) to change your view.


Keep clicking the arrow until it says Favorites and only shows the folders you marked as a favorite. Doing this lets you hide the Spam folder, which will eventually fill up with hundreds of unread spam messages, and you have to keep right-clicking on it, and then doing Mark Folder Read if you are as compulsive about it as me! Here is how the final setup should look. Nice and neat, and functional.


Finishing Touches

The last thing you might want to do is log back into GMail, and delete any of the labels that Thunderbird automatically created before you had it configured like this.

Wow this was long! Hopefully it was worth it and will help you configure Thunderbird to play nice with GMail! If you have any questinos (or if you have some tips that I missed which you would like to share) feel free to leave a comment!

Return to Top

Adding Spice Models to LTspice

Finally… a new tutorial. Who could have ever guessed that life in the real world would be so busy (note the sarcasm!)? This tutorial is going to cover adding custom Spice models into your LTspice simulations and library. While it is very easy once you know how to do it, there are a couple pitfalls that nearly caused me to go crazy and rip my hair out in the past. Hopefully this will save you some time and stress, and possibly a hole in your monitor. Now let’s get started!

  1. Finding and Downloading the Spice Model
  2. Adding the Spice Model to your LTspice Library
  3. Using the Spice Model in a Circuit
  4. Conclusion and tl;dr (too long;didn’t read)

Finding and Downloading the Spice Model

It might seem obvious, but the first thing you need to do is find a suitable Spice model. This can usually be done in one of two ways. The easiest method is to simply Google the phrase “[part I am looking for] spice model”. If the part is popular enough and isn’t some incredibly complex part, your search will usually turn up some hits. The second method is to directly search the part manufacturer’s web page for the part. Sometimes you will have to switch tabs, or it will simply be link on their part’s web page such in the following screenshot:

screenshot of download website

An unfortunate characteristic of the Spice world is that over time it has become fairly fragmented. Different design tools use different versions of Spice, hence, part manufacturers will often have the Spice file for their part available in a couple different formats. The best format to use is the Spice3 model, however the PSpice model will usually work in LTspice as well.

Once you have found the model you want to use, you need to make sure it is in the correct format with the correct extension. A Spice model file is nothing more than a text file with a different extension. In the case of LTspice, if the model file contains only a single model, it should be named with the .sub extension. If the file contains multiple models, then the file should be named with the .lib extension.

I’m not going to go into depth on renaming text file extensions, however one method to do it is to first open up the model in notepad (in Windows 7, right click on the file > open with > notepad). Next, go to file > save as. Where you type the file name in the file name text box, type the exactly desired file name in quotes, and the program will name it exactly that. For example you could type 1N4148.sub. If you tried typing the file name without the quotes you would get 1N4148.sub.txt instead of the desired 1N4148.sub.

Return to Top

Adding the Spice Model to your LTspice Library

For this tutorial we will be using a Spice model for a made up diode called the 1NADAM, named after your beloved engineer, me! You can either download the file here (righ click on link > save as), or simply copy the code below, paste it into a text document, and save it with the .sub (or .lib) extension as explained in the previous section.

*Spice model for a made up diode used in
*my LTspice adding models tutorial at
R1 1 2 5E+9 
+ IS = 7.0E-9 
+ N = 1.5 
+ BV = 30 
+ IBV = 0.00025
+ RS = 0.20
+ CJO = 5.0E-13 
+ VJ = 0.80 
+ M = 0.030 
+ FC = 0.50
+ TT = 3.0E-9 

As you can see, inside of the file for the 1NADAM there are .SUBCKT and .MODEL statements. Most Spice models downloaded from the internet will have .SUBCKT statements, because often time a simple .MODEL statement will not sufficiently model the complex behavior of modern parts. I am assuming that the reader knows the difference between a .SUBCKT and .MODEL (explaining those thoroughly is a topic for another tutorial). In short, however, a .MODEL statement will provide the model for an existing Spice primitive (i.e. a capacitor, resistor, transistor, diode, and so on). While .MODEL statements will work for simple simulations and old parts, it will not be very accurate for newer, smaller parts. For example, transistors have become so small and non-ideal, that the equations which we all learned in textbooks do not provide sufficient accuracy for good simulation results.

This is one case where a .SUBCKT model becomes very useful. This allows a manufacturer or engineer to create a more complex model using more than a single Spice primitive, which will lead to better results. This also allows manufacturers and engineers to create models which take into account any peculiarities or quirks that the component might have. You will be hard pressed to find a model for a real part which uses a single .MODEL statement for the Spice model. Therefore this tutorial assumes a .SUBCKT type model but will point out the difference where applicable.

Once you have the Spice model on your computer, adding it to your LTspice library is very easy. Simply copy the file to your LTC\LTspiceIV\lib\sub folder. Usually the full path to that directory will be either C:\Program Files (x86)\LTC\LTspiceIV\lib\sub on a 64 bit Windows 7 installation or C:\Program Files\LTC\LTspiceIV\lib\sub on a 32 bit (x86) Windows installation.

screenshot of adding model file to correct folder

Return to Top

Using the Spice Model in a Circuit

Now that the Spice model is in your library, there are a couple things you need to do. The first is make the circuit which will contain our part. For example, here is a simple half-wave rectifier I have tossed together.

simple half wave rectifiersimple half wave rectifier

The next is to let LTspice know that you will be using that the newly added file. You do this by placing a Spice directive (s shortcut key, or the .op button on the toolbar) onto the schematic containing .lib FILENAME, using the entire name of the file containing your model. Make sure to include the file extension! This is the first pitfall I was talking about. Here is an example of how to correctly add our new file:

.lib 1NADAM.sub

While the above way is correct, below you can see a common mistake which will not work:

.lib 1NADAM

Here you can see some screenshots showing how to add the spice directive on to the schematic.

adding the .lib directive

.lib directive placed on schematic

In case some of you are wondering what exactly this does, it includes any models included in the specified file into the Spice simulation file. You might also be wondering what the difference between the .LIB and .INC directives is. The .LIB directive will only add models from the specified file. If you had some other directives in there, for example a .TRAN statement, it would be discarded. The .INC directive will include everything in the specified file into your project, regardless if it is a model, directive, netlist, or anything else. So use .LIB just to be safe in case there is some other junk in there (even though there shouldn’t be).

Now that you have added the file, you can simply use any .MODEL or .SUBCKT included in the file as you would with any of the default components. Just right click on a component’s default model (in this case the D right next to the diode), and change its value to the name of the model inside of the file. Alternatively you can hold ctrl then right-click on the symbol and change the value in the Value row). Usually you have to look inside the file using a text editor to see what exactly the author of the Spice file called the model. For example the model for the 1N4148 diode might not actually be called 1N4148 inside of the file.

changing model for diode

Here is also where the second major pitfall comes in.

If you are using a .SUBCKT type model for a Spice primitive, you need to change the Spice prefix on the component!.

What the Spice prefix does is tells LTspice what kind of model to expect for the part. For example, on a diode, the default will be a D because, well, the part is a diode so it expects a diode model. Remember however that we are not using a regular diode model for our diode; we are using a .SUBCKT model. This means that we need to change the Spice prefix to a subcircuit model instead of a diode model. To do this, hold ctrl and then right-click on the symbol in the schematic. Then just double click in the Value cell next to Prefix, and change the value to an X.

changing the prefix

At this point the file should be ready to simulate and look like this:

schematic ready to simulate

Congratulations, everything should be working now! We can run a simulation to see what comes out. Keep in mind that this circuit not meant to be a good rectifier. I purposely chose the values to make it easy to see what this circuit is actually doing just by looking at the output. Here is the result:

simulation results

Return to Top

Conclusion and tl;dr (too long;didn’t read)

This article was much longer than I initially expected, and probably more than was really needed. However, what inspired me to write this tutorial was that when I was just starting to learn LTspice, I would read instructions people posted on forums, but I didn’t exactly understand what all the steps meant or how to perform them. For example I had no idea what “change the Spice prefix to X” meant, and I had no idea that you had to hold ctrl then right-click on the symbol to do it. In summary, here is a quick tl;dr version for people who might already be familiar with Spice and LTspice, and just want the quick and concise procedure. This will also serve as a good recap for people who read the entire article!

  1. Download and rename the Spice model to something that makes sense
  2. Move the Spice model into the sub folder in your LTspice directory
  3. Add a .LIB FILENAME directive onto your schematic
  4. Change the Value field for your symbol to the name of the model inside of your Spice model file
  5. If you are using a .SUBCKT type model for a Spice primitive, hold ctrl then right-click on the symbol and change the Prefix field to X

Good luck! I hope this was helpful!

Return to Top