This is a tutorial for HobECAD.
HobECAD is a schematic capture and printed circuit board (PCB) editing system that is capable of generating industry standard RS274X (i.e. Gerber) files that can be manufactured by a wide variety of PCB manufacturers. It currently runs on Linux under the X11 window system. HobECAD is designed to be a fairly minimal system that has a relatively low learning curve that is suitable for electronics hobbyists.
This document is a tutorial which will introduce you to the HobECAD system. The project that has been selected is a small hobby level digital logic probe. This probe will light a red LED (Light Emitting Diode) if it detects logic "low" and a green LED for logic "high". Neither the red nor green LED's will light up if no logic voltage is present. Indeed, this is a useful enough project that I will probably have it shipped off to be manufactured.
The steps involved in using HobECAD are outlined below:
.zip
file and
shipped off to a PCB manufacturer for
manufacturing.
Over the years, I have learned to organize my projects that use HobECAD into directories and sub-directories. The top level directory is typically a project directory. If the project consists of more than one board, each board gets its own sub-directory. It is extremely rare to get a board right on the first run, I usually have a sub-directory for each revision. This is shown in outline form below:
In addition to the directory structure I use a
program called make to run the the
various programs of the HobECAD system.
The make program is by no means a
favoriate of mine, but it seems to get the job
done. Thus, each file in each directory will
have a Makefile
file that contains
instructions for building things in that
directory.
In addition, there are a number of files that
that are shared across all of the boards and
revisions that live up in the top-level project
directory. The most important of theses is a
file called Makefile_share.mk
.
This file contains a bunch of rules that direct
make in the running of hobecad.
Lastly, the top-level directory also contains
some part management files that are shared
amongst all of the boards and their revisions.
These files have suffixes of .prt
and .pkg.
Now it is time to set things up to use HobECAD:
prompt$ cd .../somewhere prompt$ mkdir myproject prompt$ cd myprojectwhere somewhere is the location on your file system where you have decided to set up you project and myproject is the name you have given your project.
rev_a
is in all lower case.
prompt$ mkdir rev_a
Makefile_share.mk
file and
install it in the top level directory.
prompt$ cp .../hobecad/example.Makefile_share.mk .where
.../hobecad
is the path
to the hobecad directory you unpacked HobECAD
into.
Makefile
. Using your favorite
text editor, create a Makefile
that looks basically like this:
all: cd rev_a; $(MAKE) clean: cd rev_a; $(MAKE) cleanIt is extremely important that the lines that start with
cd rev_a; ...
start
with a tab characters; spaces will not work.
Make is one of the few programs out there that
cares about spaces vs. tabs. The make
program basically insists that the file be
named Makefile
.
prompt$ touch myproject.pkg prompt$ touch myproject.prtThese files will be filled in later on.
prompt$ cd rev_a
Makefile
in the rev_a
directory. Make its
contents look as follows:
BASE := myproject SC_BASES := $(BASE) include ../Makefile_share.mk
prompt$ touch myproject.ptlIt starts out empty and we will fill it in later on.
As a final comment, you are welcome and encouraged to store additional project information into these directories. For example, if you are using a microcontroller, the source code for your microcontroller should live in the same directory. Likewise, any documentation or specifications can also be stored there. In addition, I tend to do all of my projects so that they can be viewed via the web, so all of my HTML (HyperText Markup Language) files live in the same directory structure. Since none of these files are directly related to learning HobECAD, they have been omitted from this tutorial.
Now it is time to enter a schematic for the digital logic probe.
Before starting the schematic, it is useful to have a short discussion of "Why?" There are three important reasons for doing a schematic. First, it provides a human readable diagram of the circuit. Second, it is possible to get HobECAD to verify that the printed circuit board exactly matches the schematic(s). Thus, when you are debugging the circuit, there is high confidence that the schematic actually matches the circuit you are debugging. The third reason is because HobECAD can do a little signal checking to verify things like there is no short between ground and Vcc and the like.
In addition to helping you create the circuit schematic, the hobecad program reads the circuit schematic(s) and generates a wire list that describes which leads of what components are attached to one another. In addition, The hobecad program can also read the printed circuit board and extract a wire list. Since both lists are generated in alphabetical order, the standard Unix style diff program can high light the differences between the two wire lists. When there are no differences between the two lists, the user has high confidence that the printed circuit board implements the schematic(s).
Now that I have explained why you should have a schematic, it is time to actually use hobecad to create one. The project I have selected is an inexpensive digital logic probe. Please follow the following steps:
prompt$ hobecad -c 10 myproject.scThe
-c 10
tells HobECAD to use
10 pixel square cells. The .sc
tells HobECAD to go into s
chematic
c
apture mode.
X connection to :0.0 broken (explicit kill or server shutdown).This message is OK; please do not worry about it. When you click on the `X', editing immediately terminates, any edits you have done are lost forever, and they can not be recovered. (No, this is not considered to be good user interface design, but it is what hobecad does.)
proble.sc
because you exicted without saving.
prompt$ ls {directory listing here}
prompt$ hobecad -c 10 probe.scAgain, we are presented with a blank white windows with a black square in the lower left corner. We are back to where we stared. Cool.
probe.sc
now exits.
probe.sc
:
prompt$ hobecad probe.scYou will note that this time the
-c 10
option is not specified. This is because the
file remembers its cell size when it written
out. It may be tempting to try to edit
schematics at a different cell size, but frankly
there are too many bugs for that to work;
so please do all schematics at a cell size
of 10.
Copyright (c) 2002 by First M. Lastwhere First M. Last is your first name, middle initial, and last name. (Actually, nobody really cares what name you use, so you can be creative here.) As you type in each letter it, the cursor advances one cell to the right. Upper case letters are bold and lower case letters are shown as non-bold upper case letters. There is a good case the text does not fit in the square window. You can resize the window by grabbing any corner with the left mouse button and resizing the window. Now using the mouse, position the cursor above the first line (use left mouse button), change the cursor color (use middle mouse button) to brown, and type:
Digital Logic Probe (Rev. A)The resulting screen should look as shown below:
with the exception of the mark in the upper right and corner (please ignore the artifact for now; it is just a way to trick the software into drawing the window at a reasonable size.) If the characters are black, you should delete them (see next paragraph) and switch them over to brown.
opampthe resulting screen should look as follows:
opamp
, depress the
[Control-X] key. This key code is generated
by holding down one of the keys on the
keyboard labeld [Control] or [Cntrl] and
then depressing the [X] key while still
holding the [Control] key down. There
is no need to touch the [Shift] key. When
you do this, an operational amplifier symbol
shows up pointing down. It should look as
follows:
Notice that the text that spelled out
opamp
has been removed.
opamp>followed by typing [Control-X]. You should wind up with the operation amplifier symbol pointing to the right as shown below:
Whenever a black wire terminates on the side of brown box, hobecad looks for a black label that identifies which lead is being connected to. hobecad will get confused if it sees no black label or two black labels and will generate an error message when the wire list is extracted.
resistor
and the diode
glyph is called diode
.
The glyphs are entered in black at the
approximte locations shown below:
And after you type [Control-X] over each piece of text, you get the following:
And after some black wires and connections have been added and some brown diagonal lines to indicate light emitting diodes you should have the following:
The black labels identify the components and for resistors and the diodes, hobecad "knows" what the leads are named. For resistors, the leads are named "A" and "B" and for diodes they are named "+" and "-". Lastly, the "100K" and "220" specify the resistor value in ohms in brown.
I need to give a few definitions here before we can get into the parts managment topic very deeply.
The purpose of parts management is to keep HobECAD informed about about the relationship between the parts list, schematic, and printed circuit board layout. The symbols in a schematic identify parts in the parts list. The printed circuit board layout needs to know about where the various leads of a component on a board are located. Eventually, HobECAD can scan through a parts list, and generate a corresponding list of vendors, part numbers and costs.
When designing HobECAD, I could not come up with a particularly compelling reason create a fancy graphical user interface for managing parts information. Instead, everything is kept in flat ASCII text files. Yeah, it is boring, but it is fairly simple to learn and manage. There are three file formats:
.ptl
) .prt
.pkg
) All of the file formats use a similar format. First, blank lines are ignored as are any lines that start with a `#'. There are no continuation lines.
Below is the parts list file for the digital logic
probe (probe.ptl
):
# Digital Logic Probe (Revision A): # D1-2: LSG2040 - Green LED [Jameco: 34606] N1: Probe_Wire - Probe wire N2: Terminal2.Probe - 2 Junction Terminal Strip [Jameco: 189675] R1: 100K_Resistor - 100K Ohm 1/4 Watt resistor [Jameco: 29997] R2: 47_Resistor - 47 Ohm 1/4 Watt resistor [Jameco: 31106] U1: LM741 - Operational Amplifier [Jameco: 24539] U2: LM317LZ - Positive Voltage Regulator [Jameco: 23552]The first two lines are comments. It is useful to put the project name and revision information in a comment. Symbol names are constrained to be a sequence of upper case letters followed by a decimal number. If there is a range of parts, this is specified by add a dash followed by the last number in the range. The colon is required. The part name is a a sequence of upper and lower case printing letters with no spaces. Each part name must exactly match one listed in part catalog file. The part name is followed by a hyphen. Everything between the hyphen and optional opening square bracket is a comment and is ignored by HobECAD. A vendor and part number is specified by enclosing the vendor name and part number in square brackets separated by a colon. Everything after the hyphen is optional.
I should mention that there is a bug in HobECAD where it does not complain about extra parts in the parts list. One of these days I will track that down and fix it.
The next file to look at is the part catalog file. The part catalog file for the probe is reproduced below:
# Digital Logic Probe Part Catalog: # H Parts 1 0 P LSG2040 LED1 - Green LED [Jameco:34606;LEDs $.15/10 $.13/100] L + + Other L - - Other P Probe_Wire Wire - Probe wire L 1 1 Other P Terminal2.Probe TerminalStrip2 - 2 Junction Terminal Strip [Jameco:189675;Connectors $.69/1 $.62/10] L 1 1 Other L 2 2 Other P 100K_Resistor Resistor4 - 100K 1/4 Ohm Resistor [Jameco:29997;Resistors $.99/100] L A A Other L B B Other P 47_Resistor Resistor4 - 47 1/4 Ohm Resistor [Jameco:31106;Resistors $.99/100] L A A Other L B B Other P LM741 DIP8 - Operation Amplifier [Jameco:24539;ICs $.29/1 $.25/10] L 1 OFFSET_NULL1 Other L 2 V- Other L 3 V+ Other L 4 GND Other L 5 VOUT Other L 6 OFFSET_NULL2 Other L 7 VCC Other L 8 NC No_Connection P LM317LZ TO92 - Low voltage regulator [Jameco: 25532;ICs $.49/1 $.39/10] L 1 VIN Other L 2 VADJ Other L 3 VOUT OtherAs usual, blank lines and lines that start with a `#' are ignored. A comment at the beginning to explain roughly what is inside is appropriate. The line
H Parts 1 0specifies that it is a parts catalog file. We will now dissect the following part line:
P 100K_Resistor Resistor4 - 100K 1/4 Ohm Resistor [Jameco:29997;Resistors $.99/100]Each part is identified by a line that starts with capital `
P
', followed by the part name
(100K_Resistor
'), followed by a package
name (`Resistor4
'). Next comes the comment
which is a hypen (`-
') followed by some
uninterpreted text. The comment is terminated by either an
end of line or an opening square bracket (`[
').
The optional vendor inforation is contained in the square
brackets (`[
... ]
'). There is
a vendor name (`Jameco
'), followed by a colon
(`:
'), followed by a part number
(`29997
'), followed by an optional
semicolon (`;
') and a correspondingly
optional catalog section name (`Resistors
').
Lastly, there is optional pricing information of the
form of a price (`$.99
'), a slash
(`/
'), and a quantity (`100
').
There can be multiple price and quantity pair specified
separated by one or more spaces.
The part number in the part catalog file
(.prt
.ptl). If they do
not match, an error message is generated.
When HobECAD is being used to generate a final parts list, it sorts all of the required parts by vendor name first, followed by vendor catalog section name, followed by vendor part number. Thus, all of the parts that came from the same catalog section will be grouped together in the parts list. This can simplify parts ordering over the phone. In addition, sometimes it is more cost effective to order more parts than you actually need to get a price break. The HobECAD software will make a recommended quantity as well.
The example above does not show fractional parts.
Sometimes it is appropriate to purchase a part
that can be broken into smaller parts. For example,
a 2×40 male header can be broken into smaller
pieces (e.g. 2×5, 2×13, etc.) The fractional
part is specified by putting a fraction number before
the vendor name (e.g. `10/80
'). The
HobECAD software will add up all of the fractional
pieces and figure how many of the whole pieces are
needed.
After the part name, comes the lead lines. Each lead on the part gets a lead line. A lead line looks as follows:
L
package_lead_name part_lead_name signal_type
where
.pkg
.)
Ground
Vcc
TTL_In
TTL_Out
TTL_Tri_State
Other
The package catalog file (.pkg
) for
the digital logic probe looks as follows:
# Digital Logic Probe Packages: H Packages 1 0 P Wire - A wire for probe tip L 0 0 1* P TerminalStrip2 - 2 Junction Terminal Strip with .2" between leads L 0 0 1* L 0 4 2 P LED1 - LED with .1" between leads L 0 0 +* L 0 2 - P Resistor4 - Resistor with .4" between leads L 0 0 A* L 0 6 B P TO92 - TO92 3 lead package splayed into a "V" with pin 2 pointing down L 0 2 1 L 1 0 2* L 2 2 3
As usual, the package catalog file ignores lines that are blank or starts with a (`#'). The line
H Packages 1 0specifies that the file is a package catalog file.
Each part is specified by a line that starts with
a P
, followed by a package name,
followed by a hyphen (`-
'), followed
by an uninterpreted comment.
After each package line is a list of lead lines. Each lead line has the following form:
L
x y name
where
*
') to mark which
pin on the package is pivoted when the package
is reorient on a printed circuit board.
The package is always entered into the
package catalog file in a pointing down
orientation.
Now once you have entered in the three files
(.ptl
, .prt
, and
.pkgMakefile
has been set up
so that all you have to do is type:
makeand it will run hobecad with the appropriate arguments. The command it runs is:
hobecad -C -w probe_sc.wl probe.sc probe.ptl ../probe.prt ../probe.pkgThe
-C
option turns on checking.
The -w probe_sc.wl
causes the file
wire list file probe_sc.wl
to be
generated from reading the schematic. The
digital logic probe only consists of a single
schematic -- probe.sc
. In addition,
the parts list file (probe.ptl
),
the parts catalog file (probe.prt
),
and the package catalog file (probe.pkg
).
In addition, the files hobecad.prt
and hobecad.pkg
are read from the
same directory that contains the hobecad
executable. The file hobecad.pkg
contains the definition for the DIP8 package.
The resulting wire list file (probe_sc.wl
)
looks as follows:
D1:+ D2:- U1:2 U1:6 D1:- D2:+ R2:B N1:1 R1:B U1:3 N2:1 U1:7 U2:1 N2:2 U1:4 U2:2 R1:A R2:A U2:3Each line in the wire list file corresponds to a single `wire' that interconnects two or more leads on various components. For example the first line says that
D1:+
is
connected to D2:-
, U1:2
,
and U1:6
. The lines in a wire list
file are sorted alphabetically (e.g.
D1:+
, D1:-
,
N1:1
, N2:1
,
N2:2
, R1:A
.)
On a given line, all of the leads are sorted
alphabetically (e.g. N1:1
,
R1:B
, U1:3
.)
When the wire list is extracted from the
printed circuit board layout, it will be
sorted in exactly the same way. The net
result is that when the wire lists exactly
match on a character by character basis,
the printed circuit board layout matches
the schematic.
Now it is time to dig into the layout of a printed circuit board.
prompt$ hobecad probe.pcbThis brings up a window that can be used to edit the probe printed circuit board.
prompt$ make {a bunch of stuff here}Now you should have the printed circuit board wire list in the file myproject
_pcb.wl
.
Makefile
and add the
following line to the end:
all: $(BASE).diff
prompt$ make diff myproject_sc.wl myproject_pcb.lwl {differences listedhere}If there are any differencs between the two wire lists there is either a mistake in the schematic or a mistake in the printed circuit board design. The differences should help to figure what is wrong.
all:
line in the Makefile
to look
as follows:
all: $(BASE).diff ${GERBERS} ${PNGS} $(BASE).parts
prompt$ make {stuff here}}This causes the generation of the gerber files, the generated image files in PNG file format, and the parts list file.
all:
line in
Makefile
to also contain
$(BASE).zip
:
all: $(BASE).diff ${GERBERS} ${PNGS} $(BASE).parts $(BASE).zip
prompt$ make {Generate zip file}This generates the zip file needed to be sent off to the printed circuit board vendor.