Friday, April 8, 2011

ULN2803

A ULN2803 is an Integrated Circuit (IC) chip with a High Voltage/High Current Darlington Transistor Array. It allows you to interface TTL signals with higher voltage/current loads. In English, the chip takes low level signals (TLL, CMOS, PMOS, NMOS - which operate at low voltages and low currents) and acts as a relay of sorts itself, switching on or off a higher level signal on the opposite side.

A TTL signal operates from 0-5V, with everything between 0.0 and 0.8V considered "low" or off, and 2.2 to 5.0V being considered "high" or on. The maximum power available on a TTL signal depends on the type, but generally does not exceed 25mW (~5mA @ 5V), so it is not useful for providing power to something like a relay coil. Computers and other electronic devices frequently generate TTL signals. On the output side the ULN2803 is generally rated at 50V/500mA, so it can operate small loads directly. Alternatively, it is frequently used to power the coil of one or more relays, which in turn allow even higher voltages/currents to be controlled by the low level signal. In electrical terms, the ULN2803 uses the low level (TTL) signal to switch on/turn off the higher voltage/current signal on the output side.

The ULN2803 comes in an 18-pin IC configuration and includes eight (8) transistors. Pins 1-8 receive the low level signals, pin 9 is grounded (for the low level signal reference). Pin 10 is the common on the high side and would generally be connected to the positive of the voltage you are applying to the relay coil. Pins 11-18 are the outputs (Pin 1 drives Pin 18, Pin 2 drives 17, etc.).

Transistor Circuits


Types of transistor


NPN and PNP transistor symbols
Transistor circuit symbols
There are two types of standard transistors, NPN and PNP, with different circuit symbols. The letters refer to the layers of semiconductor material used to make the transistor. Most transistors used today are NPN because this is the easiest type to make from silicon. This page is mostly about NPN transistors and if you are new to electronics it is best to start by learning how to use these first.
The leads are labelled base (B), collector (C) and emitter (E).
These terms refer to the internal operation of a transistor but they are not much help in understanding how a transistor is used, so just treat them as labels!
A Darlington pair is two transistors connected together to give a very high current gain.
In addition to standard (bipolar junction) transistors, there are field-effect transistors which are usually referred to as FETs. They have different circuit symbols and properties and they are not (yet) covered by this page.



Transistor currents

transistor currents The diagram shows the two current paths through a transistor. You can build this circuit with two standard 5mm red LEDs and any general purpose low power NPN transistor (BC108, BC182 or BC548 for example).
The small base current controls the larger collector current.
When the switch is closed a small current flows into the base (B) of the transistor. It is just enough to make LED B glow dimly. The transistor amplifies this small current to allow a larger current to flow through from its collector (C) to its emitter (E). This collector current is large enough to make LED C light brightly.
When the switch is open no base current flows, so the transistor switches off the collector current. Both LEDs are off.
A transistor amplifies current and can be used as a switch.
This arrangement where the emitter (E) is in the controlling circuit (base current) and in the controlled circuit (collector current) is called common emitter mode. It is the most widely used arrangement for transistors so it is the one to learn first.



Functional model of an NPN transistor

Functional model of NPN transistor The operation of a transistor is difficult to explain and understand in terms of its internal structure. It is more helpful to use this functional model:
  • The base-emitter junction behaves like a diode.
  • A base current IB flows only when the voltage VBE across the base-emitter junction is 0.7V or more.
  • The small base current IB controls the large collector current Ic.
  • Ic = hFE × IB (unless the transistor is full on and saturated)
    hFE is the current gain (strictly the DC current gain), a typical value for hFE is 100 (it has no units because it is a ratio)
  • The collector-emitter resistance RCE is controlled by the base current IB:
    • IB = 0 RCE = infinity transistor off
    • IB small RCE reduced transistor partly on
    • IB increased RCE = 0 transistor full on ('saturated')
Additional notes:
  • A resistor is often needed in series with the base connection to limit the base current IB and prevent the transistor being damaged.
  • Transistors have a maximum collector current Ic rating.
  • The current gain hFE can vary widely, even for transistors of the same type!
  • A transistor that is full on (with RCE = 0) is said to be 'saturated'.
  • When a transistor is saturated the collector-emitter voltage VCE is reduced to almost 0V.
  • When a transistor is saturated the collector current Ic is determined by the supply voltage and the external resistance in the collector circuit, not by the transistor's current gain. As a result the ratio Ic/IB for a saturated transistor is less than the current gain hFE.
  • The emitter current IE = Ic + IB, but Ic is much larger than IB, so roughly IE = Ic.
There is a table showing technical data for some popular transistors on the transistors page.



Darlington pair
touch switch circuit
Touch switch circuit

Darlington pair

This is two transistors connected together so that the current amplified by the first is amplified further by the second transistor. The overall current gain is equal to the two individual gains multiplied together:
Darlington pair current gain, hFE = hFE1 × hFE2
(hFE1 and hFE2 are the gains of the individual transistors)
This gives the Darlington pair a very high current gain, such as 10000, so that only a tiny base current is required to make the pair switch on.
A Darlington pair behaves like a single transistor with a very high current gain. It has three leads (B, C and E) which are equivalent to the leads of a standard individual transistor. To turn on there must be 0.7V across both the base-emitter junctions which are connected in series inside the Darlington pair, therefore it requires 1.4V to turn on.
Darlington pairs are available as complete packages but you can make up your own from two transistors; TR1 can be a low power type, but normally TR2 will need to be high power. The maximum collector current Ic(max) for the pair is the same as Ic(max) for TR2.
A Darlington pair is sufficiently sensitive to respond to the small current passed by your skin and it can be used to make a touch-switch as shown in the diagram. For this circuit which just lights an LED the two transistors can be any general purpose low power transistors. The 100kohm resistor protects the transistors if the contacts are linked with a piece of wire.



Using a transistor as a switch

transistor and load When a transistor is used as a switch it must be either OFF or fully ON. In the fully ON state the voltage VCE across the transistor is almost zero and the transistor is said to be saturated because it cannot pass any more collector current Ic. The output device switched by the transistor is usually called the 'load'.
The power developed in a switching transistor is very small:
  • In the OFF state: power = Ic × VCE, but Ic = 0, so the power is zero.
  • In the full ON state: power = Ic × VCE, but VCE = 0 (almost), so the power is very small.
This means that the transistor should not become hot in use and you do not need to consider its maximum power rating. The important ratings in switching circuits are the maximum collector current Ic(max) and the minimum current gain hFE(min). The transistor's voltage ratings may be ignored unless you are using a supply voltage of more than about 15V. There is a table showing technical data for some popular transistors on the transistors page.
For information about the operation of a transistor please see the functional model above.

Protection diode for a relay

Protection diode

If the load is a motor, relay or solenoid (or any other device with a coil) a diode must be connected across the load to protect the transistor from the brief high voltage produced when the load is switched off. The diagram shows how a protection diode is connected 'backwards' across the load, in this case a relay coil.
Current flowing through a coil creates a magnetic field which collapses suddenly when the current is switched off. The sudden collapse of the magnetic field induces a brief high voltage across the coil which is very likely to damage transistors and ICs. The protection diode allows the induced voltage to drive a brief current through the coil (and diode) so the magnetic field dies away quickly rather than instantly. This prevents the induced voltage becoming high enough to cause damage to transistors and ICs.


When to use a relay


Relay, photograph © Rapid Electronics
Relay, photograph © Rapid Electronics
Relays Photographs © Rapid Electronics
Transistors cannot switch AC or high voltages (such as mains electricity) and they are not usually a good choice for switching large currents (> 5A). In these cases a relay will be needed, but note that a low power transistor may still be needed to switch the current for the relay's coil!
Advantages of relays:
  • Relays can switch AC and DC, transistors can only switch DC.
  • Relays can switch high voltages, transistors cannot.
  • Relays are a better choice for switching large currents (> 5A).
  • Relays can switch many contacts at once.
Disadvantages of relays:
  • Relays are bulkier than transistors for switching small currents.
  • Relays cannot switch rapidly, transistors can switch many times per second.
  • Relays use more power due to the current flowing through their coil.
  • Relays require more current than many ICs can provide, so a low power transistor may be needed to switch the current for the relay's coil.




Connecting a transistor to the output from an IC

Most ICs cannot supply large output currents so it may be necessary to use a transistor to switch the larger current required for output devices such as lamps, motors and relays. The 555 timer IC is unusual because it can supply a relatively large current of up to 200mA which is sufficient for some output devices such as low current lamps, buzzers and many relay coils without needing to use a transistor.
A transistor can also be used to enable an IC connected to a low voltage supply (such as 5V) to switch the current for an output device with a separate higher voltage supply (such as 12V). The two power supplies must be linked, normally this is done by linking their 0V connections. In this case you should use an NPN transistor.
A resistor RB is required to limit the current flowing into the base of the transistor and prevent it being damaged. However, RB must be sufficiently low to ensure that the transistor is thoroughly saturated to prevent it overheating, this is particularly important if the transistor is switching a large current (> 100mA). A safe rule is to make the base current IB about five times larger than the value which should just saturate the transistor.

Choosing a suitable NPN transistor

The circuit diagram shows how to connect an NPN transistor, this will switch on the load when the IC output is high. If you need the opposite action, with the load switched on when the IC output is low (0V) please see the circuit for a PNP transistor below.
The procedure below explains how to choose a suitable switching transistor.
NPN transistor switch
NPN transistor switch
(load is on when IC output is high)
Using units in calculations
Remember to use V, A and ohm or
V, mA and kohm.

  1. The transistor's maximum collector current Ic(max) must be greater than the load current Ic.
    load current Ic = supply voltage Vs
    load resistance RL
  2. The transistor's minimum current gain hFE(min) must be at least five times the load current Ic divided by the maximum output current from the IC.
    hFE(min) > 5 × load current Ic
    max. IC current
  3. Choose a transistor which meets these requirements and make a note of its properties: Ic(max) and hFE(min).
    There is a table showing technical data for some popular transistors on the transistors page.
  4. Calculate an approximate value for the base resistor:
    RB = Vc × hFE where Vc = IC supply voltage
    (in a simple circuit with one supply this is Vs)
    5 × Ic
    For a simple circuit where the IC and the load share the same power supply (Vc = Vs) you may prefer to use: RB = 0.2 × RL × hFE
    Then choose the nearest standard value for the base resistor.

  5. Finally, remember that if the load is a motor or relay coil a protection diode is required.

Example
The output from a 4000 series CMOS IC is required to operate a relay with a 100ohm coil.
The supply voltage is 6V for both the IC and load. The IC can supply a maximum current of 5mA.

  1. Load current = Vs/RL = 6/100 = 0.06A = 60mA, so transistor must have Ic(max) > 60mA.
  2. The maximum current from the IC is 5mA, so transistor must have hFE(min) > 60 (5 × 60mA/5mA).
  3. Choose general purpose low power transistor BC182 with Ic(max) = 100mA and hFE(min) = 100.
  4. RB = 0.2 × RL × hFE = 0.2 × 100 × 100 = 2000ohm. so choose RB = 1k8 or 2k2.
  5. The relay coil requires a protection diode.


PNP transistor switch
PNP transistor switch
(load is on when IC output is low)

Choosing a suitable PNP transistor

The circuit diagram shows how to connect a PNP transistor, this will switch on the load when the IC output is low (0V). If you need the opposite action, with the load switched on when the IC output is high please see the circuit for an NPN transistor above.
The procedure for choosing a suitable PNP transistor is exactly the same as that for an NPN transistor described above.



Using a transistor switch with sensors


transistor and LDR circuit 1
LED lights when the LDR is dark
transistor and LDR circuit 2
LED lights when the LDR is bright
The top circuit diagram shows an LDR (light sensor) connected so that the LED lights when the LDR is in darkness. The variable resistor adjusts the brightness at which the transistor switches on and off. Any general purpose low power transistor can be used in this circuit.
The 10kohm fixed resistor protects the transistor from excessive base current (which will destroy it) when the variable resistor is reduced to zero. To make this circuit switch at a suitable brightness you may need to experiment with different values for the fixed resistor, but it must not be less than 1kohm.
If the transistor is switching a load with a coil, such as a motor or relay, remember to add a protection diode across the load.
The switching action can be inverted, so the LED lights when the LDR is brightly lit, by swapping the LDR and variable resistor. In this case the fixed resistor can be omitted because the LDR resistance cannot be reduced to zero.
Note that the switching action of this circuit is not particularly good because there will be an intermediate brightness when the transistor will be partly on (not saturated). In this state the transistor is in danger of overheating unless it is switching a small current. There is no problem with the small LED current, but the larger current for a lamp, motor or relay is likely to cause overheating.
Other sensors, such as a thermistor, can be used with this circuit, but they may require a different variable resistor. You can calculate an approximate value for the variable resistor (Rv) by using a multimeter to find the minimum and maximum values of the sensor's resistance (Rmin and Rmax):
Variable resistor, Rv = square root of (Rmin × Rmax)
For example an LDR: Rmin = 100ohm, Rmax = 1Mohm, so Rv = square root of (100 × 1M) = 10kohm.
You can make a much better switching circuit with sensors connected to a suitable IC (chip). The switching action will be much sharper with no partly on state.



A transistor inverter (NOT gate)

transistor inverter circuit Inverters (NOT gates) are available on logic ICs but if you only require one inverter it is usually better to use this circuit. The output signal (voltage) is the inverse of the input signal:
  • When the input is high (+Vs) the output is low (0V).
  • When the input is low (0V) the output is high (+Vs).
Any general purpose low power NPN transistor can be used. For general use RB = 10kohm and RC = 1kohm, then the inverter output can be connected to a device with an input impedance (resistance) of at least 10kohm such as a logic IC or a 555 timer (trigger and reset inputs).
If you are connecting the inverter to a CMOS logic IC input (very high impedance) you can increase RB to 100kohm and RC to 10kohm, this will reduce the current used by the inverter.

Common Mistakes, Tips and Tricks

 

  1. All grounds need to be connected together.
  2. TX/RX loop back trick: When in doubt of a serial conversion circuit, short the TX and RX pins together to get an echo.
  3. Normal length wires for breadboard connections: Don't use a 9" wire where a 2" wire will do.
  4. Minimize short potential in your breadboard wiring: Don't expose an inch of wire from the insulation if all you need is 1/4".
  5. You will learn best when you have a *simple* project to work on. Don't create the 'house-pet robot' just yet.
  6. Google is, of course, your friend. When you don't know, go do some research.
  7. for(x = 0 ; x < 400 ; x++) : If x is defined as an 8-bit integer, the for loop will loop forever!
  8. Soldering basics: Wet your @#$% sponge.
  9. Take your time with ground plane solder joints. Do not be fooled by a cold joint.
  10. Never trick yourself into thinking you're that good. Print out a 1:1 and compare the footprints!
  11. Check that TX and RX are wired correctly to all peripherals. TX/RX swap is the one of the greatest causes of PCB failures.
  12. When laying out a PCB with SMD micros, don't forget to include the programming port!
  13. Don't run silkscreen across pads.
  14. Connector PCB footprint mis-numbering: always check the pin number on your connector - they can have very obfuscated schemes.
  15. In Eagle, use vector fonts only!
  16. Review your gerber files before submitting them.

10 - Eagle: Creating a new part

You can dig around the Eagle libraries all you want. Very quickly you will discover that you need to create a new part. This can be very daunting at first. The following tutorial breaks down how we create a new part in Eagle. There are some recommendations here that are good to follow, but we are by no means experts at Eagle. This is going to be very long and painful, just try to get through it. These basics will hopefully form the foundation of all your future project layouts.
You are welcome to use stock Eagle libraries but use them under extreme caution. I rarely use other people's libraries. Trusting someone else' part or footprint can be a sure fire way to render a pile of PCBs worthless. I've done this far too many times! It takes lots of failures to get good at creating decent schematic parts and solderable footprints. You will mess up, but you have tomess up before you can be good at it.
To get 5V out of a 1.5V battery, we use something called a DC to DC step-up converter. This handy part is not in the stock Eagle library so let's create a new part for this controller IC - the NCP1400 (datasheet).
The NCP1400 is a neat little step-up IC - we input a low voltage and get 5V out!
To start your first parts library:
Once the Library Editor is open, hit the Save icon and save your library with your name on it:
Click on create a new symbol. Name it 'NCP1400':
Create a red box by clicking on the 'Wire' button:
Don't worry about centering the box at this time.
Key commands to try out:
  • Scroll the scroll wheel on the mouse to zoom in/out
  • Click the scroll wheel (on the main work area) and hold shift to move the work area around
  • If the work area image looks corrupt, just zoom in/out to refresh the area
Add 5 pins to the box:
Press F4 and click on a pin. Name them according to the datasheet.
Pins are named, but we need to clean up how this part is sized and where the center is at. To grab the group press Alt+F7, click and hold, and drag from one corner of the work area to the opposite corner - boxing in the pins and part:
Once you have everything selected (everything should be highlighted red), press F7 and right click to move the group over the center cross. In my example part, I the right side was one block too far over so I sucked in the right side one square.
The image above shows the part centered and symmetrical.
  • NEVER change the grid size in the library editor or in the schematic layout editor. Leave it on 0.1inch steps and don't use the alternate 0.01 step. If you do, you won't be able to hook wires to the pin tie points.
Name and Value tags are always nice. Click on the text button and type '>NAME' and '>VALUE'. (Ok I lied. It's okay to use the alternate step size when moving around non-critical items like text. Hold the Alt key down while your placing the Name and Value tags to get them where you want them):
Once you have Name and Value placed, you'll notice that these are red when they are normally gray in color. Be sure to modify what layer these two strings are on. We need to change the >NAME tag to the Name layer, and >VALUE tag to the value layer. To do this:
Click on the wrench, then Layer.. Choose the layer you'd like to change the object to
Here is the final schematic part, centered and happy. If you want, you can change the pin definitions to indicate which pins are inputs, outputs, pwr, etc. I find these settings useful in a handful of situations. This is a simple enough part, we'll skip it.
Now for the footprint. Remember, when in doubt create your own footprint. Trusting anyone else' footprint without scrutinizing it closely is a very bad idea. If you're lucky, your datasheet will include a recommended footprint for the part you are working with. If it does not, google for the words 'recommended land pattern SOT-23' or whatever package you are looking for. The words 'land pattern' is the key.
Lucky us! The NCP1400 datasheet has a recommend footprint:
This takes some getting used to. There are two numbers from every dimension, and not all the dimensions are indicated?! Lower left corner shows mm/inches meaning the top number is the dimension in mm and the bottom number is that same dimension in inches. Sorry folks, it's a metric world. More and more devices are spec'd in mm only (connectors, ICs, etc). From the Library editor, click on Package and let's start creating the footprint for this device. This is actually a pretty common package type called SOT23-5, so let's use that name:
Throw down 5 pads:
Hmm, some of the layers are not showing - let's turn them all on:
Click 'All' and then 'Ok'. You should now be able to view the solder mask (in Eagle as the 'Top Stop' layer) and solder paste layers (aka 'Top Cream' layer).
Now back in your datasheet you will find the width of each pad to be 0.7mm and the height to be 1.0mm. Before we can go editing the pads, we need to put Eagle into metric mode. Press Alt+F10 and you should see the coordinates in the upper task bar switch to mm. To alter the size of the five pads to 0.7x1.0mm, click on the wrench, then Smd, then '...':
You will then be prompted to enter the X and Y dimensions in mm with an 'x' in between:
Remember the X dimension always comes first.
Now click on all 5 pads. All 5 pads should now be the correct size. I really prefer to center the footprint with the center of the work area. This means we need to work out the various dimensions:
 Let's start with the easy pad - pin #2 will be located at (0,1.2). Before we can start moving pads, we need to adjust the alternate grid so that we can get the the side pads to 0.95mm. Click on the points/grid box:
Change the Alt: box from 0.1 to 0.05 and click on ok. Now lets move pin 2. In the work area, press F7, then hold control and click on a pad:
F7 issues the move command. Holding control while clicking on a pad causes the pad to try to center to the cursor (this way you know that the coordinates displayed in the upper left task bar are displaying where the very center of the pad is at and not where your cursor may have been off when you first clicked on the pad). Because the pads are locked onto the 1mm grid, you'll notice the pad jump from 3mm to 4mm, etc. While holding control, hold alt as well. The pad should now jump on the alternate grid of 0.05mm instead of 1mm. Important buttons to know:
  • Again, the scroll wheel will zoom in/out
  • Clicking the scroll wheel will drag the work area around
  • Holding the shift key will allow you drag the work area further
To position this pad to (0,1.2) I literally had to:
  1. Hold Control and click on the pad
  2. Hold Alt, Shift, and control with one hand
  3. Scroll in with the scroll wheel
  4. Click+drag the scroll wheel to get the work area centered
  5. Release Shift
  6. Move the cursor to position (0,1.2) (Remember to hold alt!)
This sounds really scary but after creating two footprints, you'll have it down without thinking about it.
Nifty
Press F4 and click on each pad renaming them to match the datasheet numbering:
Did you number them wrong? Double check. Make sure you get it right! We need to add a dimensional layer to indicate the size of the device. This is different than a silkscreen indicator. I like to use layer 51 (named 'tDocu' meaning top document layer?). This layer will only be displayed while we're playing on the layout window and won't show up on any production files. This allows us to display the physical size of awkward parts, hopefully avoiding collisions between bulky parts when we go to populate the PCB.
Why should we even care about these layers?
Here is our NCP1400 (label U4) next to three capacitors. See how crazy board layout can get? Notice C1 is next to U4 but the distance between them looks ok? When we add in the tDocu layer:
Whoa! That cap is way too close to the body of the NCP1400. You might be able to get those two components soldered onto the board, but it would be a mash up job. We need to know the rough physical outline of components during layout. To do that, we need to add a frame to our footprint.
Before we add lines to our footprint to indicate the physical size of our part, let's change the layer color - gray is a horrible color to try to see! Click on the 'Display' button, scroll down to layer 51 and double click on the gray box next to 'tDocu':
Then click on the gray 'Color' box and change it to something interesting like lemon yellow, then click ok. Anything you do on this layer will now be yellow.
Click on the 'Wire' button. Select layer 51 (this layer will be yellow in the drop down box the next time you close/open the Library editor).
You should now be able to lay down yellow lines. Put four of them down in a box:
Press escape to stop drawing. Now we need to move the edges of the box to the outside edge of our part. Checking the datasheet again:
Ahh manufacturing tolerances. They can't really tell us how big the B and A dimensions will be, so I always pick a value in the middle of the min/max. A = 3mm, B = 1.5mm. Remember we have to center the frame so the upper right corner of the frame will be at (1.5, 0.75).
Now go back to the footprint, press F7 to issue the move command. Hold the control key and click on the upper right corner of the frame. When you do this, the 1 pad may light up - this is because Eagle does not know which part you are trying to move - the pad or the line? If you left click, Eagle will begin moving the 1 pad because it is highlighted. Right click and the frame should highlight. Now left click and you should be moving the upper right corner of the frame. I know, its really confusing at first. It's actually really handy once you're used to it!
Once you've got the corner at (1.5,0.75), left click to anchor the corner at that location and adjust the other three corners.
I can almost see it now! Notice how the part extends past the edges of the pads? If we would have put a component (like an 0603 resistor) next to pads 3 and 4 the two component may have been bumping into each other. Electrically, the layout would have been fine but when we would go to populate the PCB, this regulator might have been right up against the neighboring part.
Finally, I highly encourage you to add a bit of silkscreen to this part. What does a board look like without silkscreen?
Can you tell where the components go and how they are supposed to get oriented without a silk indicator? I can't.
Add a little silkscreen and it's suddenly very apparent where the NCP1400 is supposed to go.
When you get a PCB with nothing but silver pads, the 4/5 pads on this part look a lot like the spot for an 0805 capacitor! Select layer 21 tPlace. You may notice this layer is gray as well! I hate gray. Re-color this layer to white. When you get your PCBs, the silkscreen is white, right? Might as well make them agree.
I zoomed way in, held alt to get onto the alternate grid, and ran the line from (-0.25, -0.75) to (0.25, -0.75). You really do not want to put silkscreen across your pads. This will negatively affect how the pads react to solder. It would foul a board or anything, it's just best to keep the silkscreen layer away from pads. You could butt the white line right up against the pad, but the silkscreen layers has the worst tolerances and the greatest skew. The white lines in your beautiful layout could end up a couple mm to the left or right when you get your PCBs from the fab house. Besides, 0.25 is such a nice start/finish number!
Create silkscreen lines for the sides as well. Don't worry about itty-bitty silkscreen lines inbetween the upper pads or the little corners. Very small silkscreen lines will either be ignored by the fab house or else they will just flake off.
When we laid out the tDocu layer, the wire thickness was 0.127mm or 0.005". 0.005" is also pronounced as '5 mil'. Time and time again, you will hear that fab houses can handle 8 mil traces and 8 mil spacing for their basic service (aka their cheap service). This means that no trace can be less than 0.008" in thickness and two traces cannot be closer than 0.008" to each other. Well guess what thickness our silkscreen traces are? The 5mil tDocu lines don't matter because they will not be printed or fabbed, but the 5mil silkscreen traces may give some fab houses fits! The fab house may increase the line thickness to 8mil, they may try to print the 5mil line as is and have it come out very thin with no weight, or they may not print it at all! Let's alter the thickness of the silkscreen lines to 8mil so that we are kosher with any fab house.
We're switching back to Imperial units! Press F10. Next click on the wrench, width, and '...':
Why doesn't Eagle have 8mil listed? I have no idea. Enter 0.008 into the box prompt. Click on the three silkscreen lines:
It looks a bit odd, but once you see it on a PCB, it will look great! The last things we need to do (I promise!) is to add a >NAME and >VALUE tag. Review the schematic component section to see how to do this in detail. Add two strings ('>NAME' and '>VALUE') and then modify the layers for these two strings to tName and tValue respectively.
And we're done with the footprint creation for this one part! Now you see why engineers and companies hoard their libraries. The first couple footprints you create will be totally botched and will probably kill your PCB layout. But once you get a part created, and you use it once or twice successfully, the part will be proven and you'll never have to worry about it again! With a collection of 20-30 known good parts, you'll be able to whip up very reliable PCBs in surprisingly little time.
To finish this part in our library, we need to relate the pin numbers on our footprint to the pin identifiers on our schematic part. Save your library and click on the Device button:
Name the new device NCP1400 and then click on the Add button:
Drop the schematic part in the center of the work area. Hit escape twice to get rid of the part window. Now click on the 'New' button in the Package area:
Double click on the SOT23-5 listing.
Notice the yellow exclamation point in the Package area? This means that a footprint is associated with the schematic part but the pins have not yet been assigned. Double click on the 'SOT23-5' text in the Package area:
Review page 1 of the NCP1400 datasheet to know what pins connect to what pad numbers:
Double clicking on a given name on one side will assign it to the highlighted choice on the opposite side. You've done a great job up to this point! Double check that your pad assignments are correct!
Right click on the Package name and click on Rename. Various different footprints can be associated with any given schematic part. To differentiate between parts, you can give the pin assignments different names. I mis-use this function a bit. I often name variants 'SMD', 'A', 'B', '8', '10', or in this case 'NCP1400'. Pick your poison.
It's ok if you do not give this device a variant name, but if you leave the default variant name as " and then try to add a new pad assignment you will get the "Package variant " already defined!" error:
Just rename one of the variants to a different name so that Eagle can add this new variant with the default " name.
Now let's add this newly created part to our schematic. Close the library editor and go back to the Eagle Control Panel. Click on File->New->Project. Name this new project - in this example we'll do 'Simon'. Right click on the Simon project and create a new Schematic:
The schematic editor should open. Now go back to the Eagle Control Panel and open your new Library:
You should see the NCP1400 part and the SOT23-5 footprint. Highlight the NCP1400 part and in the right screen click on ADD. The schematic editor will pop up allowing you to place the NCP1400.
And that's it! You now know how to create a component from scratch. Be sure to do a 1 to 1 print of your layout before sending it to the PCB fab house to verify all the parts against their respective footprints.