PCBS Coding Help   <<--BACK                           HOME                        NEXT-->>   Demo1
side4linux, a simple integrated development environment!

PCBS Overview     Tour of the  'Sample1' project, a CPU board for the Machine Controller


Purpose:  To provide a basic introduction to PCB schematic 'capture' and PCB 'layout' in the GNOME environment using 'side4linux' and the 'gEDA'/'pcb' software suite. We will review the design of a small plug in board that will provide the Central Processing Unit (CPU) for the Machine Controller. This board will be based on the Atmel AVR Mega-128 which is a 'Microcontroller' chip (that is a complete computer on a chip as distinct from a 'Microprocessor' which requires support components such as program ROM and data RAM). You may of course not be interested in our Machine Controller. This is OK as side4linux can build anything you wish! We simply ask that you follow this overview and Demo's as an introduction on how to use the IDE and all of it's Toolset. Note also that you may have many invocations of the side4linux IDE open so you may wish to use one to show this Help while using another to do the Practicals. You could also print out this page to have some hard copy available for reference (very good if you are teaching a group of students as they may all have a photo copy). There is a lot on this page to grasp so perhaps a quick run through and then you could come back and do it in detail. Please keep in mind that this is an overview, the actual printed circuit board of the Machine Controller is to be presented in a later Demo.


Requirements: Make sure that the 'GNOME' build environment is installed correctly, if not then read 'setup C build environment.txt' and also
'setup GNOME build environment.txt'.

Further requirements: Make sure that the latest PCBS support package is installed correctly.
  1. Open 'side4linux' and click on Project>Open Project in the Main Menue.
  2. Double click on the 'DEMOS' Product Area,
  3. Double click on the 'SIDEdemos' Product,
  4. In the file dialog double click the  'PCBS' folder. This takes you to where PCB projects are kept.
  5. Double click on 'Sample1', this opens the 'Sample1' project folder.
  6. Double click on 'sample1.prf'. This opens the 'Sample1' project file.
  7. Notice that the left bottom status bar window says 'Project: Sample1' which is the Project Name.
  8. Notice that the next window says 'Ptype: PCBS' which is the Project Type.
  9. Try clicking on 'Project' on the Main Menue, you will notice that 'Close Project' is now active.
  10. Notice that project names are set to be an upper case letter followed by lower case letters (easier on the IDE's Project routines).
  11. Click on the 'File Explorer' 'Files' tab on the left and view what schematic files are actually in the Project.

Practical 1: Open a schematic file in 'gEDA' the graphical schematic editor to view a schematic file graphically,
1/. Click on the 'Open-SCH' tool bar button and open the file 'cpu.sch'
This action will launch the schematic capture program 'gEDA' with the 'cpu.sch' schematic file as follows,

CPU Schematic in gEDA
Screenshot of the CPU schematic in gEDA
  1. Keep in mind that this is only a copy of the file on disk, if you make changes then you must 'Save' them. 
  2. Close the small 'Status' window and click on the top right hand "Maximize Window' button to make the window full size.
  3. Right click in the window to bring up the 'Popup Dialog' window and left click on 'Zoom Extents'.
  4. Move the mouse cursor to the center and while holding down the middle mouse button, drag the drawing a bit and let go.
  5. Place the mouse cursor over a crystal at the bottom ( U203 )  and zoom in/out by rolling the mouse wheel.
  6. Move the drawing using the window sliders on the right and bottom of the window.
  7. Notice that the pins of components are connected together by conducting wires called 'Nets' such as 'PE0' and 'RESET'.
  8. Notice that these 'Nets' are named and are kept neat by enclosing them in conduits/pipes called 'Buses'.
  9. Notice that the 'Bus' on this page is called 'Ports' ( the name is in the I/O 'off page connector at the right hand end).
  10. Notice the 'Net' 'AVcc' connected to pin 64 of the 'ATMega128' micro-controller chip ( U202 ).
  11. Keep in mind that 'Net Names' are 'Global' to the Project.
  12. So the Net on the 'cpu.sch' page called 'AVcc' is the same wire as Net 'AVcc' on the 'power.sch' page.
  13. Take note that 'Buses' and the off page connector have no electrical significance, it is just an information guide.
  14. Notice that each component has an ID code called a 'Reference Designator' or 'Ref-Des' such as U102 or C101.
  15. Reference designators must be unique.
  16. If you use the 'Renumber' Button on the IDE Toolbar they increment by 100 for each page in the Project e.g. page 3 start at 301.
  17. Notice the 'footprint' tags e.g. to the right of C201 is the footprint of '0805' which is an 0805 surface mount package (SMT).
  18. Footprints are the physical pads/holes used by the PCB program. Each schematic decal needs a physical footprint assigned to it.
  19. Notice the footprint for U202 is a TQFP64 which is a surface mounted Thin Quad Flat Package with 64 pads.
  20. Footprints can be found by opening the Symbol Library in the 'pcb' layout program.
You will notice the components are displayed graphically. They consist mainly of the AVR Mega-128 decal and some support chips. Where is the rest you may ask as this is just one page of many that we will use to build this product. The paradigm is simple! You provide schematic pages, each of a different function which together will make one printed circuit board. You may well be wondering why we do not just put everything on the one page, the answer is re-usability. By using this 'object' type approach one can build up a large library of schematic pages which can be quickly assembled by adding them to the Project so that it is possible to create many different Projects. One Project may require the addition of 'RS232 Serial' ports, another 'Ethernet' and even our Machine Controller will require different output driver boards and interfaces to different position feedback sensors etc. etc. So take another look in the 'Files' tab of the 'File Explorer' You will see that this Project has only pages for power, cpu (the one we are currently looking at) and a connector page for three dual inline 20 pin male connectors. That is because this Project is a 'Daughter Board' that will eventually be plugged into a 'mother board'. From this introduction you will see the completion of this CPU unit (pictures are included at the end) as part of a larger Project, the 'Machine Controller'. Our aim is to build the Machine Controller using plug in daughter boards onto a larger 'mother board' and at a later date we will just leave out the connector schematic pages and produce a single board Machine Controller!


Practical 2: Open a 'Layout' file in 'pcb' the graphical PCB editor to do some editing,

Close down the 'gEDA' program and now click on 'TOOLS>PCBS>Run PCB' in the IDE to launch 'pcb' the PCB layout program. Once the 'pcb'  layout program is loaded select a component 'footprint'
in the smaller 'PCB library' window 'pcblib>~geda>TQFP64_14' by left clicking on it and move the cursor into the main pcb window to see the outline in red as shown in the following graphic,

Select component footprint
Screenshot of the 'pcb' component library with selected footprint in red.

This component footprint is a
'TQFP64' which is a surface mounted Thin Quad Flat Package with 64 pads. Notice the actual footprint name is at the end inside the square brackets as 'TQFP64_14'. When you assign footprints to a schematic page you must make sure that the correct footprint name is put into the schematic file (we will do this in Demo1) or the schematic to pcb program will not work properly as it will lock up endlessly looking for a non existent footprint!

Now press the escape key 'Esc' to release the library component footprint as we will not need it here then minmise the library window and maximise the main window of the 'pcb' program.

Take note that there are many parts to a printed circuit board! Some of them are,
  1. Layout file (the actual layout of physical components such as chips, resistors, connectors etc.)
  2. Netlist file (the file containing the actual connections to pins, pads etc.)
  3. Pcb file ( the combination of the Layout and Netlist files that make up a PCB ).
  4. Output files (Gerber 'gbr' for the PCB maker, PS 'ps' postscript for your printer etc.)
  5. Annotation (altering the schematics in gEDA and forwarding the changes to your PCB drawing.)
  6. Drill files (the 'Excelon' format 'cnc' drill file used by your PCB maker to drill holes for IC's etc.)
  7. A 'ratsnest' is the unrouted connections from the 'netlist' file which you must load after the 'layout file'.
  8. Default values e.g. it is a good idea to set the board size prior to the initial load of the layout file!
OK we are now ready to start laying out the actual board so set the board size (only needed at the intial loading of the layout file).
Go to 'File>Preferences>Sizes>Board Size' and set both 'Width' and 'Height' to 1800.0 (1800 mils = 1.8 inches).
Now load the initial 'Layout' file . Click on 'File>Load Layout' in the 'pcb' program and open the original board layout file
'board.pcb'.
You can edit it to produce the following graphic, s
tart with 'Select>Disperse all elements'.

Take note of,
  1. The 'Layer' selector (the rainbow coloured column in the top left corner).
  2. The 'Editing State' selector below it (changes 'Selection' to another state such as 'Rotate' or 'Line').
  3. The 'Route Style' selector in the bottom left corner (signal, power etc.).
Note that clicking on the 'radio button' makes that layer 'active' in the Layer Selector and clicking on the coloured bar (e.g. 'Component') toggles that layer's visibility

Save this layout under the name of 'Try.pcb'
'File>Save layout as' and keep saving as you progress so as not to loose everything by mistake or system failure. To now continue you will need to manually pull the components apart by holding down the left mouse button and dragging them. You will also need to change 'editing state' from 'Selection' to 'Rotate' to rotate some components (click on 'ROT' in the 'Editing State' selector and left click on the component) to match the following view. When you have something like what is shown below click on 'File>Load netlist file' to load the connections netlist file 'board.net' which must be routed. Now press the 'o' letter on the keyboard to show the ratsnest that we will later show as routed tracks. (Notice that keyboard commands are 'case sensitive' therefore 'o' works but 'O' is a different command and a lot different from the zero key '0' !!!!  Try manually routing a trace by clicking on the 'Component' button at the top of the 'Layer Selector' and changing the 'Editing State' to 'Draw Line' mode by clicking on 'LINE' in the 'Editing State' selector (you can return to 'Selection' by clicking on 'SEL'). Now start a line on one of the nets by left clicking with the mouse on the start point and left clicking at each corner. Once you have reached the other end press the escape key on the keyboard 'Esc'. The ratnest line under the routed line should now disappear when you reorganise the ratsnest by pressing the 'o' key. Remove your new trace by holding the mouse cursor over the trace segments one at a time and pressing the delete key on the keyboard 'Delete' or 'Del'. You could then try auto routing by clicking 'Connects>Auto route All nets'.

PCB ratsnest graphic
Screenshot of the CPU components with the ratsnest prior to routing.

Close the 'pcb' program and restart using '
TOOLS>PCBS>Run PCB' and now load the 'cpu.pcb' file and you should see the following,

Sample1 layout completed graphic
Screenshot of the CPU completed ready for the production of the 'Gerber' and 'drill' files that will go to your PCB maker.

Overlay view of the CPU
Screenshot of the Component Overlay (derived from the pcb print file)

Practical 3: Creating some output

Now that we have a PCB 'Layout' we need to view it as,
  1. Gerber 'gbr' files suitable to be sent to a board vendor of your choice or,
  2. As a Postscript file that can be printed as a mask for home manufacture or,
  3. As an isolation file that can be milled in a CNC milling machine.
We will cover the first two options here and isolation in a later Demo.

So firstly in the 'pcb' program click on 'Files>Export Layout' and export as Gerber then export as Postscript (ps). You can now close the 'pcb' program or move to another workspace and reopen the Project 'Sample1' in a new invocation of side4linux. Now we will to look at the '*.gbr' files which are send to your PCB vendor along with any 'drill' files '*.cnc''. We can view these files with 'gerbv' the supplied Gerber file viewer by clicking on Tools>PCBS>Gerber Viewer' and then selecting all layers by clicking on the 'On' button top right hand side of 'gerbv'. This will bring up a graphic similar to the following (be aware that clicking on any of the coloured Layer buttons allows you to hide or show separate layers),

PCB gerbv Screenshot

As an exercise convert your Postscript file (which contains around ten pages) to PDF file using the "ps2pdf" facility from a terminal

'ps2pdf yourPostscriptFile.ps output.pdf' 

[Note: If 'ps2pdf' is not available then fire up the 'Package Manager' and load it from your Linux 'Distribution Disk'] then print your track layout to printer using Acroread or Xpdf or whatever your favourite PDF reader. You could create an etch exposure mask by picking the recommended overhead projection plastic for your printer and printing the track layout on it. Pcb production at home would then be done using photo-sensitive single sided PCB, the correct light source for exposure and developer/fixer fluid to create an etch resistant film on the pcb ready for the etching solution that dissolves off unwanted copper to leave the tracks and pads. Another process which comes later will be an 'isolation' file program that will allow you to machine off the unwanted copper on the pcb blank in a CNC milling machine. If you are new to board making then by all means contact a local board maker and search the Internet for useful do it yourself sites (Google "pcb" "making" etc.).


Some Photo's of the original prototype

We will now view a couple of photo's of the CPU daughter board and the 'mother board' along with a serial communication module (keep in mind that you can use side4linux for any Project you like so please view this Project in that context),

PCB Bare Board
Picture of the bare pcb for the CPU daughter board, notice that the copper for this single sided board is facing up (component side) due to the use of surface mounted components.

Topview of Machine Controller Prototype
Top view of prototype Machine Controller
Motherboard (top left is the CPU daughter board we are using in this 'Overview', next to it is the Serial Port daughter board). The "Motherboard" is just a punched hole wire wrapping board purchased from a local electronics shop. This board will only be wire wrapped, only the completed Machine Controller pcb will be released to the General Public due to the motherboard's prototype classification (subject to continual change depending on experimentation).

PCB Top View of Prototype with CPU turned over
Top view of Prototype Motherboard with CPU turned over (lower left corner) to show male headers and the mating female sockets. Also shown is another CPU board before components are added (to the
lower right hand corner). Naturally we will be removing the header and sockets and integrating the parts that we need (such as the Serial Port Board) into one single board. These unified boards all have the power interface to the axis motors separate to suit the particular machine.




In Demo-1 we will create a new PCBS Project based on 'Sample2' and complete the schematics.



  We will provide other demos as 'side4linux' develops to cover integration into a real world machine controller.