1. Introduction
This is the second part of my EAGLE Tutorial series, following on from EAGLE Tutorial: Library Part Creation Part 1 - Creating Packages. If you haven't read that article then I recommend you take a look there first as it sets the scene for this part of the tutorial series and gives some general tips on using EAGLE. In this second part, we'll be taking a look at creating library symbols and in particular, our example from part one will continue using the MSP430F22x2 as the basis for demonstration.
Rather than this tutorial showing how quick it can be to create parts in EAGLE, I will take the opportunity to give some advice on creating consistent and clear to use symbols as often the symbols in a lot of the available libraries are untidy, unclear and generally across all available libraries there is no consistency. This last one, consistency is an important factor in being able to create clear and readable schematics. If all the symbols follow different styles and there is no consistency then the resulting schematics will be messy and less readable, potentially leading to maintainability issues in the long run. It is for this reason that I strongly advocate having your own "in-house" library set and not use the libraries that are shipped with EAGLE or downloaded from the internet directly, without first checking them for accuracy and secondly customising them to match your style.
As with the last tutorial, I will refrain from using keyboard accelerators and ULP to speed up the process of creating symbols. In a later tutorial I will go through how we can use these powerful features to create symbols for parts much more efficiently. For now we are going to take the slightly more labour intensive approach of creating everything by hand so you know exactly what is required.
For this follow-on tutorial we are going to create a symbol for a Texas Instruments MSP430F22x2 device. The datasheet of which can be found on the TI website here: http://www.ti.com/lit/ds/symlink/msp430f2232.pdf
2. EAGLE Library recap
As discussed in the previous article, EAGLE libraries (.lbr) consist of three parts. Firstly there is the package which defines the copper placed on the board as well as the silkscreen and assembly drawing information. It is also possible to define keepout and restrict areas to indicate how close other packages can be placed and where routing is not allowed. Secondly there is the symbol(s) which define what is placed within a schematic. Finally there is the device which combines symbols and packages to form a part which maps symbol pins to package pins and defines additional properties, all of which can then be added to a design.
3. Creating a Symbol
3.1. Obtaining the required data
The usual place to go for all the required information for building a symbol is the data sheet for the device. Sometimes for large parts with many variants within the range such as FPGA's the manufacturer may provide spreadsheets which contain all the required signal names for the pins for the different variants of the part. The information required to create the symbol is:
- The list of pin names for the device
- The function and direction of each pin
- The relationship between groups of pins
- Do any of the pins have multiplexed functionality
- Special pins (e.g. for thermal pads which must be connected to GND)
All this information should be easily accessible but sometimes you may need to do a little digging through the datasheet to pull it all together. It often helps too if you have a text editor to hand as this enables you to copy and paste signal names from the datasheet and tidy/sort them out prior to using them in the symbol. I'll give more detail on what I mean by this later on.
3.2. Setting up EAGLE
3.2.1. Configuring EAGLE's grids
EAGLE has two grids available. The main grid which is the one displayed and everything is snapped to by default, and the ALT grid which is not displayed and which everything snaps to when the Alt key is pressed. For schematics we ALWAYS place pins and nets on a 0.1 inch grid. Failure to do so leads to problems with pins which are not connectable we will therefore work with the main grid being set to 0.1 inches. It is sometimes useful to be able to place text on a half grid so we shall go ahead and set the ALT grid to 0.05 inches.
GRID inch 0.1 ON; GRID ALT inch 0.05
3.2.2. Setting the font and alignment for text
Text on the schematic should always use the proportional font and be a consistent size. Usually it will be centred in the vertical but depending on its relative position on the symbol will determine whether it is centre or left aligned in the horizontal. We'll choose left aligned for this example.
CHANGE FONT proportional; CHANGE ALIGN center-left; CHANGE SIZE 0.05
3.2.3 Grouping tips and accessing group functions quickly
NOTE: This section is included for completeness but is the same as discussed in the previous blog in this series on creating packages. If you have already read that then you can skip to the next section.
One aspect of EAGLE which is different from many other packages but can make tasks very much quicker is the use of groups. In EAGLE groups are not the same as they are in other drawing packages such as Microsoft Visio or Microsoft Powerpoint. The these packages you select a number of objects and group them and these then become "stuck together" and are operated on as one and you can have an arbitrary number of groups. In EAGLE there is only one group and it consists of the last items you added to a group. Lets think of it more as a selection group feature rather than a proper group. Nonetheless its is a very powerful feature.
You create a group by clicking on the group button or issuing a GROUP command and then either dragging a box around all the items you wish to group or clicking to draw an arbitrary shaped selection box. Once the group has been created you select the operation you wish to perform on the group, e.g. MOVE, COPY, DELETE, etc. At this point you have a few choices on how to apply this operation to the group. The most obvious way is via the right click context menu. Right click on any of the items within the group and there will be an option to perform the group operation, e.g. Move Group...
There is a quicker way though. If you hold down the Ctrl button (Cmd on macOS) and then right click on a group item then the selected function will be applied to the group.
3.3. Symbol drawing pitfalls (I may get on my soap box a little here!)
Before we start on creating our own symbol for the MSP430F22x2, I want to share with you some of my tips for symbol styles to avoid as they invariably look wrong and lead to schematics which are harder to read.
3.3.1. Symbols which match the shape and pin position of the footprint
The argument for this is that it makes it easier to debug on the board because you know from the schematic where to probe a pin. However, you can also see from the layout and cross probing where to probe a pin and having the schematic logically drawn so the design makes sense will likely lead to less errors which require you to be probing around on the board in the first place. This is particularly bad for large components like processors and FPGA's. Fortunately when they get to a certain size it's impossible to continue this approach as the symbol will require splitting into multiple parts, but then, if you've done the rest of your library like that, you have inconsistency.
3.3.2. Symbols drawn with the "one symbol pin to one package pad" philosophy
This is quite common and some tools even try to force this way of working but it leads to exceedingly large symbols when a device has multiple power and ground rails all with many pins each and it also leads to some really bizarre looking transistor symbols. The argument for it is that you can read every pin number from the schematic, but you can add that information to the symbol if needed anyway, there is the datasheet and, like the previous example, cross probing between the schematic and layout. What it tends to lead to is schematics which take more pages with symbols which are less easy to read at a glance and an overall schematic which is untidy and less legible and maintainable.
3.3.3. Symbols with untidy pin placement and inconsistent pin spacing
It may not be a big deal to everybody but symbols which are made with pins which are just slapped down without paying attention to where they are or making sure they are placed neatly shows a general lack of attention to detail. If I see schematics with symbols like this I can usually find other errors quite quickly as I start to dig a little deeper. It only takes a few moments to think about where things should go and place them neatly.
3.4. Placing the pins
The following sections will give some advice on how to arrange the pins on your symbols. These aren't hard and fast rules, there is a lot of "making a judgement call" involved and often I find myself revising a complex symbol as I start working with it in a schematic as I find that something I had overlooked or an assumption I had made when I drew the symbol made the schematic more difficult. Fortunately it's really easy in EAGLE to update symbols so this process of building and adapting the symbol works quite well. Remember though, once you've got a symbol in a design, if you start using it in another design and then alter it again, if you ever need to go back to the first design you may have issues if you need to update the part there, so I recommend not altering the symbols once you've started using them.
3.4.1. Placement based on pin direction
Generally speaking it's good to try and have a clear signal flow through schematics as this will aid readability and help others understand your design if they need to do so. I try to allocate pins on my schematic symbols so that inputs are on the left side, outputs are on the right side and I/O's can be either with a preference to the right side.
3.4.2. Power and ground pins
I try to keep positive power rails at the top, and negative and GND rails at the bottom so the pins for these rails should be places at the top and bottom of the symbol respectively.
3.4.3. Grouping based on function
I find grouping pins logically leads to more readable schematics. For example, on an MCU I will group the pins for the external memory interface i.e. the address, data, control, and clock pins and within that group I will sort these into subgroups. Another example would be an FPGA. Often these have a number of IO banks and I will group the pins for each bank together (often in separate symbols but that's a topic for another day).
3.4.4. Exceptions to the rules
There are times when the above guidelines cease to make sense. Lets take a few examples to help illustrate:
- An MCU might have the option to connect an external XTAL oscillator. This is driven by two pins which connect to either side of the XTAL and then via two capacitors to ground, and they are usually called something like XIN and XOUT. XIN is an input and XOUT an output so by the above rules you would place XIN on the left of the symbol and XOUT on the right of the symbol. This will lead to a spread out and untidy XTAL circuit however so it makes sense to keep XIN and XOUT together. I would usually place both of these on the left hand side and the XTAL oscillator is an input to the MCU.
- An SPI communications bus. This has usually at least four signals, CLK, SEL, MISO and MOSI. Depending upon whether the device is a SPI master or SPI slave determines the direction of all the pins but generally there is a mix of input and outputs. Again, follow the above guidelines the inputs would go on the left and the outputs on the right. But what you probably want to do on the schematic is run the signals from the IC into a bus to take the signals neatly to elsewhere in the schematic. It therefore makes sense to group things like SPI, I2C, I2S etc together on one side of the device to facilitate easy bus connectivity and much clearer schematics overall.
- Feedback pins on DC-DC converters. When drawing up, for example a simple Buck converter, you have the switch output going through an inductor to one or more capacitors on the output to provide a smooth output. This output is then taken through a resistor divider and brought back to the feedback pin of the driver IC in order for it to regulate the output to the desired voltage. It makes sense for this feedback pin to be on the same (right hand) side of the symbol so the circuit can be drawn up easily without signals being run around the schematic. The same applies to the compensation pins if your converter has these and similarly any VSense pins on fixed output regulators.
3.4.5. Continuing our example
This first thing we need to do is identify all the unique pin names and determine their direction and function. From the diagram in the datasheet we can obtain the following list of pins for the symbol with a couple of simple copy and paste operations.
List of pins on the MSP430F22x2:
TEST/SBWTCK DVCC P2.5/Rosc DVSS XOUT/P2.7 XIN/P2.6 RST/NMI/SBWTDIO P2.0/ACLK/A0 P2.1/TAINCLK/SMCLK/A1 P2.2/TA0/A2 P3.0/UCB0STE/UCA0CLK/A5 P3.1/UCB0SIMO/UCB0SDA P3.2/UCB0SOMI/UCB0SCL P3.3/UCB0CLK/UCA0STE AVSS AVCC P4.0/TB0 P4.1/TB1 P4.2/TB2 P1.7/TA2/TDO/TDI P1.6/TA1/TDI P1.5/TA0/TMS P1.4/SMCLK/TCK P1.3/TA2 P1.2/TA1 P1.1/TA0 P1.0/TACLK/ADC10CLK P2.4/TA2/A4/VREF+/VeREF+ P2.3/TA1/A3/VREF−/VeREF− P3.7/A7 P3.6/A6 P3.5/UCA0RXD/UCA0SOMI P3.4/UCA0TXD/UCA0SIMO P4.7/TBCLK P4.6/TBOUTH/A15 P4.5/TB2/A14 P4.4/TB1/A13 P4.3/TB0/A12
Now, looking at Table 3 in the datasheet we can determine that all of the pins are IO apart from DVCC, DVSS, AVCC and AVSS which are power pins, and TEST/SBWTCK and RST/NMI/SBWTDIO which are input pins. We can also see that for all the IO pins, there are four separate ports labelled P1.x through to P4.x and each of these has 8 bits labelled 0 through 7. We can now arrange the pins into the groups we'll be using for the symbol. We'll go ahead and put them in the logical order now which will make things easier when we come to create the symbol. In addition if we think that we'll probably want to split the IO banks on the symbol such that P1.x and P2.x are on the left side and P3.x and P4.x are on the right side then it'll also pay to take a moment now while in the text editor to just tweak the pin name strings such that P1.x and P2.x are on the left end of the name strings and P3.x and P4.x are on the right side.
Power and ground pins:
AVCC AVSS DVCC DVSS
P1.x pins:
P1.0/TACLK/ADC10CLK P1.1/TA0 P1.2/TA1 P1.3/TA2 P1.4/SMCLK/TCK P1.5/TA0/TMS P1.6/TA1/TDI P1.7/TA2/TDO/TDI
P2.x pins:
P2.0/ACLK/A0 P2.1/TAINCLK/SMCLK/A1 P2.2/TA0/A2 P2.3/TA1/A3/VREF−/VeREF− P2.4/TA2/A4/VREF+/VeREF+ P2.5/Rosc P2.6/XIN P2.7/XOUT
P3.x pins:
UCB0STE/UCA0CLK/A5/P3.0 UCB0SIMO/UCB0SDA/P3.1 UCB0SOMI/UCB0SCL/P3.2 UCB0CLK/UCA0STE/P3.3 UCA0TXD/UCA0SIMO/P3.4 UCA0RXD/UCA0SOMI/P3.5 A6/P3.6 A7/P3.7
P4.x pins:
TB0/P4.0 TB1/P4.1 TB2/P4.2 A12/TB0/P4.3 A13/TB1/P4.4 A14/TB2/P4.5 A15/TBOUTH/P4.6 TBCLK/P4.7
As part of the rearrangement of this set of pins I noticed that, as these will be right aligned, it will look neater with the Ax pin functions on the left of the strings where they exist.
Miscellaneous input pins:
TEST/SBWTCK RST/NMI/SBWTDIO
So now we've completed all the preparatory work to make things easier we'll go ahead and start creating the symbol. First things first lets go ahead and put down some pins:
PIN 'P1.0'
Now click 8 times while placing these in a vertical row 0.1 inch apart downwards in the upper left left quadrant of the window.
PIN 'P2.0'
Repeat as above but placing these in the lower left quadrant of the window.
PIN R180 'P3.0'
Repeat as above but placing these in the upper right quadrant of the window.
PIN R180 'P4.0'
Repeat as above but placing these in the lower right quadrant of the window.
PIN R270 'AVCC'
Place this at the top of the window just to the left of the centre line.
PIN R90 'AVSS'
Place this at the bottom of the window just to the left of the centre line.
PIN R270 'DVCC'
Place this at the top of the window just to the right of the centre line.
PIN R90 'DVSS'
Place this at the bottom of the window just to the right of the centre line.
Finally place two input pins in the bottom left quadrant.
PIN 'TEST'
Click to place the pin.
PIN 'RST'
Click to place the pin.
We named the ports in the way we did above for two reasons; Firstly, so we have a guide for when we copy/paste in the name strings from the text editor. If they are already having the right basic name it makes it easier to see if something is wrong or which you need to paste in next. The second reason, if you just want to get the symbol done quickly, in this instance this would suffice from a pin naming perspective and you could move on to the following sections and add the component body and tidy up the pin placement quickly so you could get on with your schematics. We're going to complete this symbol properly here though so we shall not be cutting any corners today.
Now we'll do a little tidying up of the pins before we move on to the drawing the symbol body. Using the group and move commands, move the P2.x pins to be vertically below the P1.x pins with a 0.2 inch gap between the two groups. Repeat for P3.x and P4.x on the other side. Now move P1/2.x to be roughly centred vertically and 1.2 inches to the left of centre. Repeat for P3/4.x, making these in line with P1/2.x but 1.2 inches right of centre. Now move the TEST and RST pins 0.2 inches below P2.7 with a 0.2 inch gap between them. Finally move AVCC/DVCC to 0.2 inches either side of the centre line and 0.6 inches above the line of P1/3.0 and move AVSS/DVSS to 0.2 inches either side of the centre line and 0.6 inches below the line of RST.
Okay, I appreciate that was all a little long to read and follow along with, hopefully we've got past the most tedious bit now. Here is what you should have at this point:
3.5. Updating the pin names from the text file
Now we'll tile our text editor on the left and our library editor on the right and using the NAME command we'll copy and paste the long name strings from the text file into the library part one at a time.
NAME
Now click the P1.0 pin to edit its value and copy the string from the text file. Rinse and repeat until all the pins have been named. It may seem long winded but once you get into the swing of it it's rather quick, much better than typing all those names in manually. Once completed you should have something that looks like the following:
3.7. Drawing the symbol body
The body of the symbol is made up of lines draw on the Symbols layer.
CHANGE LAYER Symbols; LINE
Now draw a rectangle such that it touches the pins all the way round. My preference is also to draw horizontal lines to segregate the power and ground sections from the main body. In more complicated symbols this concept can be extended to segregate functional segments of a symbol.
One more thing to do before we move to the final part is to ensure the symbol is properly centred. Quickly count how many squares above, below, left, and right of the origin there are. If there is an offset then group the entire symbol and move it so that is it centred correctly on the origin. Once completed you should have something similar to the following:
3.7. Adding text information
Finally, just as we did previously for the package we need to add some textual information to the symbol. There are two built in attributes which we can access via placing TEXT fields containing >NAME on the Names layer and >VALUE on the Values layer.
CHANGE LAYER Names; TEXT '>NAME'
Then click to place this 0.2 inches above the top of they symbol body and 0.1 inches to the right of the DVCC pin.
CHANGE LAYER Values; TEXT '>VALUE'
Again click to place this, this time 0.1 inches below the >NAME text.
After you've done this you should have the following:
4. The Completed Symbol
The result of everything above enables the creation of a clear and usable symbol with relative ease. The video below shows how long it took me to create a complete and accurate symbol for a Texas Instruments MSP430F22x2 microcontroller. In the video, to help clarity and to show what is being done, I don't use any keyboard shortcuts or ULP to accelerate anything and as a result this symbol takes longer to create than it would when using shortcuts and ULP. I'll cover how to speed the process up even further using these methods in a future blog article.
This concludes the second part of my new EAGLE tutorial series. Let me know what you think in the comments below and if you have any questions please feel free to ask!