marulaberry kicad ebook

23
KiCad: Install Welcome to the first in a series of tutorials on KiCad, the electronic design automa- tion (EDA) package. This tutorial contains a short overview of KiCad, followed by a section on getting KiCad installed on your Windows or Linux PC. Overview The KiCad suite is a group of programs for electronic design automation. It is available for the following operating systems: FreeBSD Linux Most Unix-like operating systems Microsoft Windows family of operating systems The KiCad program is a project manager that groups various programs and files together to allow for the capture of schematic drawings and layout of PCBs. The package includes: Eeschema - the schematic editor Pcbnew - the PCB editor Cvpcb - to associate schematic components with physical modules (sym- bols/footprints) Gerbview - to visualise Gerber files Copyright c Guy van den Berg 2012 - Creative Commons Attribution Share-Alike 3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Upload: phan-ha

Post on 28-Nov-2015

60 views

Category:

Documents


4 download

DESCRIPTION

Kicad tutorial

TRANSCRIPT

KiCad: Install

Welcome to the first in a series of tutorials on KiCad, the electronic design automa-tion (EDA) package. This tutorial contains a short overview of KiCad, followed bya section on getting KiCad installed on your Windows or Linux PC.

Overview

The KiCad suite is a group of programs for electronic design automation. It isavailable for the following operating systems:

• FreeBSD• Linux• Most Unix-like operating systems• Microsoft Windows family of operating systems

The KiCad program is a project manager that groups various programs and filestogether to allow for the capture of schematic drawings and layout of PCBs. Thepackage includes:

• Eeschema - the schematic editor• Pcbnew - the PCB editor• Cvpcb - to associate schematic components with physical modules (sym-

bols/footprints)• Gerbview - to visualise Gerber files

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Each project will generate a series of files as you progress through the EDA work-flow. They are grouped together via the project file (*.pro). Files that make upyour KiCad project include:

• *.pro - project file• *.sch - schematic file• *.brd - printed circuit board file

All files are ASCII text. This is useful because it enables you to write scripts toautomate mundane tasks.

Installation

Lets get down to installing KiCad on your system. The KiCad home page is locatedat www.kicad-pcb.org. From the home page you will find a download link on theright. The download page contains official builds for Windows and Linux. There arealso official distribution packages for various Linux, BSD and Unix-like distributions.Snapshots are available for Mac OSx.This tutorial will focus on binary installations. Building KiCad from source is nothard, but is beyond the scope of this tutorial.

Ubuntu

KiCad is in the Ubuntu universe repository and can be installed by issuing thefollowing command from the console:

sudo apt-get install kicad

Fedora

KiCad is in the RPM Fusion repository and can be installed by issuing the followingcommand from the console as root:

yum install kicad

Windows

Download the Windows installer from the official build on the KiCad download page.Save the executable to the local machine and run it to install KiCad.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

KiCad: Project Manager

The KiCad (kicad) executable is the project manager of the KiCad suite. It coordi-nates the EDA workflow.

Above is the KiCad version in the Ubuntu 12.04 repository. I am not sure ofthe version number. The latest stable version is KiCad-2012-01-19. There is achange to the look and feel of KiCad in the development source code repository.The functionality is the same, with a few added tools. Just the look and feel ismodernised. Below is the development head version.

I am running the development head version so it may look slightly different to whatyou are running.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Project Manager

The project manager lists the project files on the left hand side in a file tree. Theright hand panel contains 5 icons which represent the various tools that make upthe KiCad suite. Clicking on them launches the associated tool. They are, fromleft to right:

• Eeschema - the schematic editor• Cvpcb - to associate schematic components with physical modules (sym-

bols/footprints)• Pcbnew - the PCB editor• Gerbview - to visualise Gerber files• Bitmap2Component - to import logos (bitmaps) into Eeschema

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

KiCad: Schematic Capture

Up until now we have been dealing with the periphery of KiCad. We are readyto start our Kicad tutorial in earnest. Your EDA workflow begins with schematiccapture. This is where you design your circuit or simply capture it, if it is alreadydesigned. The design of a circuit is beyond this tutorial. Here we will capture asimple circuit and become familiar with the concept of schematic capture.

When you first launch Eescheem you will get an info message box informing you thatno schematic (*.sch) file exists for the project. Press the OK button to continue.Before we begin capture, a quick overview of the toolbars & menus.

All toolbars will display a tool-tip if you hover your mouse over them. This willhelp you identify the correct toolbar item as we progress in the tutorial. The leftvertical toolbar contains GUI display properties. The right vertical toolbar is usedto manipulate the schematic. The top horizontal toolbar has a number of functionswhich I will discuss as we get to them.

We are going to capture a very simple circuit. It will consist of a battery, an LED,a resistor and a switch. In the next tutorial, Component Design, we will moveon to a more advanced circuit, that includes a used defined component. A quickword on terminology. In KiCad, the symbol you place on a schematic is called acomponent. The physical footprint of that component that you place on a PCB iscalled a module. Below is the circuit we are going to capture.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Placing Components

Towards the top of the right hand toolbar is a Place a component button. Hover overthe icons to find the correct one. When the tool is selected, it will be highlighted.Move the cursor over the page and left mouse click. The Component Selectiondialog will appear. To start with we are going to use the Select by Browser option.When you become familiar with component names, there are quicker ways to dothis. But for now we will take the long way around.

In the Component Selection dialog click on the Select by Browser button. This willbring up the Library Browser.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

The Library Browser shows the libraries in the far left list. Next it lists the compo-nents from the currently selected library. Finally a symbol for the currently selectedcomponent is displayed on the right. You will slowly become familiar with thestandard libraries & build a lot of your own libraries.

For this tutorial, all used components are going to come out of the device library,which contains discrete. Find the BATTERY component and then click the insertcomponent into schematic button, which is highlighted in the image. Again, hov-ering over buttons shows their tooltips. Your cursor will now contain the batterysymbol. Click somewhere on your schematic to place it.

While you are working in the schematic capture you can right click to bring upa context menu at any time. If you do not want to place the currently selectedcomponent, right click, while the symbol is active and choose cancel.

To manipulate already placed components, select the pointer icon from the top ofthe right hand toolbar, hover the mouse over the component and right click to bring

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

up its context menu. You will also see a number of shortcut keys listed to the rightof each menu option. For instance, the Delete Component menu option has theword delete to the right of it. To use the shortcut key, hover the pointer over thecomponent and press the shortcut key (no mouse click). To delete the duplicateBATTERY component, hover over it and press the delete key on the keyboard.These shortcut keys are something I find very useful and for me make KiCad apleasure to work with compared to other EDA packages that I have used.

Time for you to place a number of components. Remember, they all come fromthe device library. Place one of each on your schematic, using the Library Browseras discussed.

• BATTERY• SW PUSH• LED• R

You should end up with something like this. Use the context menu to move thecomponents. If you want to use the shortcut it is M. After you have your componentsplaced we will begin to wire up the circuit.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Before we can wire, we need to rotate our BATTERY component. Use the contextmenu to rotate the component. Choose Orientate Component then Rotate +. Youcan also use the shortcut key R.

Wiring

To wire your component, you use the Place a Wire button from the right handtoolbar. Once selected, click on a component pin and draw a wire to anothercomponent pin. Once you have completed this, you should have our basic circuitcompleted.

You may have noticed that your component references are values such as BT?,D? & R?, while in the picture they have numbers assigned to them. We need toAnnotate our schematic.

Annotation & Netlists

The connection between your schematic & PCB layout is the netlist. A netlist isa file that uniquely identifies all the pins of all the components on a schematicand the connections between them. In order to identify the components, they eachmust have a unique reference. KiCad can automatically assign references to eachcomponent in the schematic. On the top toolbar (towards the right) is a buttonAnnotate the Components in the Schematic. Use the tooltips to identify it andclick it to bring up the Annotate Schematic dialog.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Leave all the defaults and click the Annotation button in the Annotate Schematic di-alog. A confirmation dialog will appear. Accept it with OK button. Your schematiccomponents will now all have a unique reference on them. You can now close theAnnotate Schematic dialog with the Close button,

Final step is to generate the netlist. In a bigger schematic you would first perform anElectrical Rules Check. That is beyond the scope of this tutorial. I will be coveringthat at my course at House4Hack and may write a tutorial on it at a later date.On the top toolbar, find the Generate Netlist button and click it to bring up theNetlist dialog. Leave all the default and click the Netlist button. A Save NetlistFile dialog will appear. Again accept the defaults and click the Save button.

A note on the Save Netlist File dialog. It creates a new netlist file, if the file doesnot exist. It updates the existing file if it does exist. It does not overwrite existingfiles. This is important to remember. We will be using this feature later on to movebetween schematic and PCB editing.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Wrap Up

Save you work from the file menu. We are done for now. In the next tutorial, wewill build a more advanced circuit that will include user defined components. Laterwe will use the generated netlist file in PCB layout.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

KiCad: Component Design

In the last tutorial we performed schematic capture on a simple circuit. We are nowgoing to expand on what we learned, creating a more complex schematic which willinclude components that are not available in the standard component library.

We will look at creating our own components. To make the tutorial more tangible,I am going to use the House4Hack aquaponics project as an example. We are goingto capture the schematic of the aquaponics controller. Not only will this introducecomponent creation. It will also introduce the power symbols and demonstrate howto group portions of the schematic into logical blocks.

This is the schematic that we are going to capture. The L78M05ACDT-TR linearregulator and the ATTINY85 components do not exist in the standard library. Weare going to create them.

Lets get started by adding all the components that do exist to a schematic in anew project. From the KiCad project manager, click File then New from the menu.Choose a suitable location and save the new project as aquaponics.pro. Once thatis complete, open Eeschema and add the following components to the schematic. Iam using the references from the image above, also providing the standard libraryname and component name.

• P1, P3: library=conn, component=CONN 2• P2: library=conn, component=CONN 4• C3, C4: library=device, component=C• D1: library=device, component=BRIDGE• D2: library=device, component=LED• D4: library=device, component=DIODE• Q1: library=device, component=NPN

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

• R1, R2, R3, R4, R5, RC: library=device, component=R

Place the components in the rough position and orientation as seen in the image.To move a component remember the M shortcut key. To rotate the componentorientation remember the R shortcut key. Another shortcut key that is useful is theC shortcut key to copy a component. Instead of going back to the Library Browserevery time you need to place a resistor, hover over an existing one, press C andthen click to place the copy. Remember to have the pointer selected to access thecontext menu. Once you are complete, you should have something that looks asfollows:

Component Creation (new library)

Lets start with a component for the linear regulator. We need to read the datasheetof the new component to identify the component pins. You can find the datasheetfor this regulator on RS components website (L78M05ACDT-TR). Click the PDFlink towards the bottom of the page under Product Details.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Above is the pinout extracted from that datasheet. The pins have no numbers sohow are we going to number our schematic component. If you use a KiCad standardmodule library module (during PCB creation), then the pinout must correspond. Ifyou are going to make your own module footprint then it does not matter, so longas your custom component, custom module and the datasheet match. Don’t worryabout it now. Once you have completed this series of tutorials and produced a PCByou will understand. For now, accept that the pinouts are: 1 INPUT, 2 OUTPUT& 3 GROUND.

Lets start creating our custom component. In Eeschema, find the top horizontaltoolbar button Library Editor - create and edit components by mousing over thetoolbar and looking at the tooltips. Clicking this button will bring up the ComponentLibrary Editor: no library selected window.

From the horizontal toolbar in this new window click the Create a new componentbutton. This will bring up the Component Properties dialog.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

The component must be named. Give it a Component name of L78M05ACDT-TR. You can leave the rest of the dialog on its defaults. Press the OK button tocontinue. If you zoom in you will see the name and a references have been placedin the middle of the page.

A quick note on navigating around the page. One of the fastest ways to movearound the page is zoom out / zoom in. Use the wheel of your mouse to zoom.When zooming in, you can place the cursor at the point where you want to centrethe zoom action. This is far quicker than using the scroll bars to move around. Thisworks in all the tools of the KiCad suite.

I normally move the name and reference out of the way and off to the side. You canuse the M shortcut key or the right click context menu. Lets add our first pin to thenew component. On the right verticle toolbar find the Add pins to the componentbutton by hovering the mouse and reading the tooltips. Select the tool and clicksomewhere in the page. The Pin Properties dialog appears.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

The pin should be named and numbered. Enter Vin as the name and 1 as thenumber. The lower right of the dialog will display a preview of what the pin willlook like. The small circle on the pin indicates the wire connection point. The nametext will appear inside the component outline. Play around with the Orientationdropdown and see this preview change. This first pin will have Right orientation.Drop down the Electrical type and have a look at the options. The Electrical typeof the pin will come from the parts datasheet. It will be used during Electrical RulesCheck (ERC) to ensure that you have not made wiring mistakes. Pin 1 is going tobe a Power input pin. Leave the remainder of the dialog fields on the defaults andpress the OK button. Now left click somewhere on the sheet to place the pin.

This component has 3 pins. Follow the steps outlined above to add all the requiredpins. Use the M shortcut to move the pins around until they match the imagebelow. The pins to add are:

• Pin 1 Vin : orientation=right, electrical type=Power input• Pin 2 Vout : orientation=left, electrical type=Power output• Pin 3 GND : orientation=up, electrical type=Power input

If you place a pin with incorrect orientation or want to edit some of its properties,you can get back to the Pin Properties dialog in a number of ways. With the arrowtool selected from the right hand toolbar you can: 1) double click a pin, 2) rightclick it to bring up the context menu and choose Edit Pin or 3) hover over it anduse the E shortcut key.

Now draw a rectangle around the component and move the component name andreference. To draw the rectangle, find the rectangle button on the right hand toolbarentitled Add graphic rectangle to component body. Select it and left mouse clicktowards the top left of the component. Now move the mouse towards the bottomright of the component. A rectangle will follow. Once at the correct location, leftmouse click again to place the rectangle. Finally use the M shortcut to move thecomponent name and reference to the correct location. When you are done, yourcomponent should look like the image below.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Two steps remain outstanding. We need to save our component into a library andthen tell Eeschema to use our new library. For this first component, we will create anew library (aquaponics.lib). For the second component (ATTINY85) we will add itto the existing aquaponics.lib. Still in the Component Library Editor find the buttonon the top toolbar labelled Save current component to new library. Click this andthe New Library dialog appears. Rename the library to aquaponics.lib. Make sureyou are in the correct directory (project directory) and press the Save button. Youwill get an information dialog saying that the new library will not be available untilit is loaded by Eeschema. Dismiss this with the OK button.

We can now exit the Component Library Editor with the menu File then Quit.

Component Library Path

EEschema needs to know where to find libraries that you are using in your schematic.The library we just created is not yet available to EEschema. In EEschema go tothe Preferences then Library menu. The following dialog will appear.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Press the top Add button. Notice that there are two add buttons. One for compo-nent libraries and a second for the library search path. I am not going to deal withsearch paths in this tutorial but they are pretty simple. Just add a directory to thepath where you store your custom libraries. We don’t need to do this right now.

Once you have clicked the Add library button, the Library files: dialog will appear.Navigate the file system and find aquaponics.lib which we created in the last step.Finally click the Open button to add the library. Then click the Ok button todismiss the library preferences dialog.

Component Creation (existing library)

We still need to create the ATTINY85 component. We will create this in an existinglibrary (aquaponics.lib). From Eeschema select the Library Editor: create and editcomponent toolbar button from the top toolbar. It may open with our previouslycreate L78M05ACDT-TR component in it.

From the Component Library Editor window, find the top toolbar button labelledSelect working Library. Clicking it brings up the Select library dialog. Navigate thisdialog and find the aquaponics library and click OK to dismiss the dialog.

Now find the top toolbar button Create a new component. Click it and name thenew component ATTINY85. Move the name and reference off to the side. The

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

ATTINY85 is an 8 pin device. Add the 8 pins required. Arrange the pins and place arectangle around the component. Move the name and reference to the appropriatelocations. The pins to add are as follows:

• Pin 1 PB5 : orientation=right, electrical type=bidirectional• Pin 2 PB4 : orientation=right, electrical type=bidirectional• Pin 3 PB3 : orientation=right, electrical type=bidirectional• Pin 4 GND : orientation=right, electrical type=Power input• Pin 5 PB0/MOSI : orientation=right, electrical type=bidirectional• Pin 6 PB1/MISO : orientation=right, electrical type=bidirectional• Pin 7 PB2/SCK : orientation=right, electrical type=bidirectional• Pin 8 VCC : orientation=right, electrical type=Power input• Pin 5 PB0/MOSI : orientation=right, electrical type=bidirectional

When you are done, you should have something that looks like the image below.To save the new component into the current library choose the Save current libraryto disk button from the top toolbar. You will get a couple of confirmation dialogs.Include last component changes? & Modify library file “aquaponics.lib”? Acceptthem both with Yes.

You can now close the Component Library Editor.

Finishing Our Schematic

Now that we have created our two needed components, we can place them onthe schematic and wire everything up. Remember that the ATTINY85 & theL78M05ACDT-TR will be found in the aquaponics library. Once you have wiredeverything up, your schematic should look like the image below.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

Named Nets (Labels)

Before we go on to placing power components, I want to explain named nets orlabels. Wires on the schematic do not need to be physically connected in order forthem to be logical connected. Obviously, if they are physically connected, then theyare logically connected. The wires, are referred to as nets. In an earlier tutorial,we created a net list. The net list uniquely identifies every component/pin and theconnections between them. In that tutorial we Annotated our schematic. Thatgave every component a unique reference. Every net that is generated also has aunique name. If you have not supplied a name for a net, a randomly generated,unique name is assigned to the net.

The image above contains three explicitly labelled nets. Pin 7, 6 & 5 of the AT-TINY85 are logically joined to pins 1, 2 & 3 of the connector even though they arenot physically joined.

When drawing a wire, you can right mouse click at any point to bring up the contextmenu. From the context menu you can choose Wire End to end the wire withoutconnecting it to another component. This results in an unconnected net. You must

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

now explicitly name the net in order to connect it. The net names in the imageare explicitly set to SCK, MISO and MOSI respectively. On the right hand toolbarfind the button Place a net name (local label). Select it and left mouse click theschematic to bring up the Label Properties dialog box.

Provide a name for the net in the Text field. You can change the Orientation asneeded. Dismiss the dialog with the OK button. Your cursor will now have thenewly created net name attached to it. You will notice a small black square atthe start of the net name. You will also notice a small green square at the end ofthe unconnected net (wire) that you created earlier. Left mouse click the the smallgreen square of the unconnected net to assign the net name to it.

If you want to edit the properties of an already placed label (perhaps its orientationis wrong), you can do it in a number of ways. With the pointer tool selected fromthe right hand toolbar: 1) double left click the label, 2) right click the label andchoose Edit label or 3) hover over the label and use the E shortcut code.

Power Components

Power components are special components within Eeschema. While you can actuallyplace them with the Place a component toolbar button on the right hand toolbar,a quicker way to add them is via the Place a power port on the same toolbar. Allpower components have explicitly named nets. For example, if you place a groundcomponent its net name is GND. A VCC power component has the net name VCC.This means that the power components do not need to be physically connected inorder to be logically connected.

Lets add the remaining power items to the schematic. We are going to add GND,+6V & +5V components. After that we will add power flags (PWR FLAG). I willexplain those shortly. Add GND first. Select the Place a power port tool from theright hand toolbar. Left click somewhere in the schematic. This will bring up theComponent selection dialog.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

This time there is no Select by Browser button. Instead, click the List all button.This will bring up the Select Component dialog. Navigate the dialog and find theGND component. Select it and press OK to dismiss the dialog.

The cursor will now have the GND component attached to it. Left mouse click onthe schematic to place it. Do the same for +6V, +5V & PWR FLAG. Once youare done your schematic should look like the image below.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/

A quick explanation of power flags. If you design a circuit that includes a knownpower source component, such as a battery, the Electric rules checker (ERC) candetermine where the input power for the circuit is derived from. If you have a headerplaced, to which you are going to inject external power into the circuit, the ERCcannot determine where the input power will be coming from. The PWR FLAG isa logical component that will not appear on your PCB. It serves the function oftelling the ERC where input power is derived from.

Wrap Up

You have almost completed you schematic. You still need to annotate it and thengenerate a netlist. Do that now. If you forgot how to do that, look back to theprevious tutorial (KiCad: Schematic Capture) to refresh your memory. Save yourwork when you are done.

In this tutorial a more complex schematic was captured. Custom components wheredesigned. The concept of named nets was introduced. Power components whereexplain. Next time we will associate modules (PCB footprints) to our componentscontained in our netlist. We will also start laying out our PCB.

Copyright c© Guy van den Berg 2012 - Creative Commons Attribution Share-Alike3.0 License - http://creativecommons.org/licenses/by-sa/3.0/