hid/gtk: Call ghid_fill_pcb_polygon via (HID_DRAW *)->fill_pcb_polygon()
[geda-pcb/pcjc2.git] / doc / gs / fb-led.texi
blobf24cbbe1dcd96939a12da62fb91885423404860b
1 @node LED Board
2 @section LED Board
4 This first board will show you the basic operation of @code{pcb}.
5 Each new command or operation that is introduced will be described in
6 full the first time, but not subsequent times.  Many operations can be
7 invoked either by a menu option, like @mnuu{File,Quit Program} to
8 select the ``Quit'' option in the ``File'' menu, or by a keyboard
9 shortcut, like @kbd{Ctrl-Q}.  When we say @kbd{Ctrl-Q} we mean to hold
10 the @key{Ctrl} key while pressing the @key{Q} key.  When we say
11 @kbd{Shift-Q} we mean to hold either @key{Shift} key while pressing
12 the @key{Q} key.
14 For example, the first time we describe the Quit command, we'd say,
15 ``now exit @code{pcb} by using the Quit command (@mnuu{File,Quit} or
16 @kbd{Ctrl-Q})''.  Any other time, we'd just say ``now Quit.''
18 The first step in this project is to run @code{pcb}.  Since @code{pcb}
19 defaults to using the current directory for its files, it's a good
20 idea to create a new subdirectory for this project, @code{cd} into it
21 in a terminal window, and then run pcb from there:
23 @center @image{fb-led-1} @image{fb-led-2}
25 Now is a good time to practice that Quit command :-)
27 Also, if you ever ask for @code{pcb} help from someone else, they'll
28 probably want to know what version and GUI you're using.  To see this,
29 use the About command (@mnuu{Window,About...}).
31 Note that when @code{pcb} starts, it creates not only its main window
32 (pictured above), but two additional windows.  One is the ``PCB
33 Library'', which we'll talk about later, and the other is the ``PCB
34 Log'' that contains all the messages - warnings, errors, etc.  For
35 now, you can just move these out of the way.  If you close these, you
36 can re-open them using @mnuu{Window,Library} and @mnuu{Window,Message
37 Log}.
39 For any board you create, one of the first things you need to decide
40 on is how big the board is going to be.  If you want it to be ``as
41 small as possible'', then you can create it bigger than you need and
42 change the size later.  For this simple board, we can guess - we want
43 it to be one inch by one inch.  The board size controls are located in
44 the Preferences window (@mnuu{File,Preferences}), which contains both
45 board-specific and user-specific preferences.  We want the @b{Sizes}
46 preferences, so click on the word @b{Sizes}.  The window should look
47 like this:
49 @img{fb-led-3}
51 We won't be using the Text Scale or DRC preferences yet.  Note that
52 the units are mils, so the default board size is six inches wide and
53 five inches high.  Change these numbers to @code{1000.0} each:
55 @img{fb-led-4}
57 We will next set up our layers, which define how many copper layers
58 we'll have and what they'll be called.  Select the @b{Layers}
59 preferences.  You'll see three tabs along the top; click on the
60 @b{Groups} tab to show the layer group preferences.  For this project,
61 all we want to do is make sure that the solder layer is on the solder
62 side, and the component layer is on the component side.  Click in the
63 boxes to make ``component'' and ``component side'' in group 1, and
64 ``solder'' and ``solder side'' in group 2, then click on @b{OK}:
66 @img{fb-led-6}
68 There's a couple of settings you'll want to set up now, as they get
69 saved with the board.  First, let's turn on the grid
70 (@mnuu{View,Enable visible grid} if it isn't already checked) and set
71 it to 0.1" or 100 mil (@mnuuu{View,Grid Size,100 mil}).  The grid is
72 drawn as a field of tiny dots, which may be hard to see on our board
73 but would be easier to see if there were more of them.  For example,
74 switch to a 10 mil grid and note the difference (don't forget to
75 switch back to 100 mil).
77 Next, we want to make sure any new traces we create won't
78 automatically connect with any polygons we might add - for example,
79 adding a ground plane or ``flood fill''.  The @b{Settings} menu has
80 many settings in it, but for now, just make sure that @b{New lines,
81 arcs clear polygons} and @b{Crosshair snaps to pins and pads} are
82 checked, and @b{Auto enforce DRC clearance} is not checked.
84 Now that we've set up our board, it's a good time to save it.  Use the
85 Save command (@mnuu{File,Save layout}).  Since this is the first time,
86 it will ask you for a layout name.  We're going to call this layout
87 @code{fb-led.pcb} so type that in where it says @b{Name} and click OK.
88 Now that your board has a file associated with it, you can just
89 @mnuu{File,Save layout} whenever you want to save your work.
91 Now we'll start adding the actual circuit.  This circuit will be a
92 simple LED in series with a resistor, and a header for a battery.  We
93 won't need schematics, we'll just add the parts and connections
94 manually.  The first step is to choose a @emph{route style} for your
95 new traces.  The lower left corner lists the four available route
96 styles.  Make sure @b{Signal} is selected, then click @b{Route Style}
97 to bring up the route style window.  We're going to use fairly large
98 traces, which is typical of a simple board.  In that window, set the
99 Line width to 20, Via hole to 36, Via size of 76, and Clearance to 20;
100 then click @b{OK}:
102 @center @image{fb-led-7} @image{fb-led-8}
104 Next we'll add the three parts we need.  In larger projects, this will
105 be done by @code{gsch2pcb} but you'll need to know the footprint names
106 for that.  Find the library window (if you left it open) or open it
107 (if you closed it) with @mnuu{Window,Library}.  Click on the triangle next
108 to @b{pcblib} to open the pcblib library.  Scroll down to @b{~geda} and
109 click on it, to open the ~geda library.
111 @center @image{fb-led-9} @image{fb-led-10} @image{fb-led-11}
113 When you choose the parts out of the library, notice that there is
114 some text in square brackets - this is the footprint name you'll need
115 for @code{gsch2pcb}.  The first we want is the LED.  We'll use
116 @code{RCY100P} for the LED, which is a radial cylinder, polarized, 100
117 mil spacing.  Scroll down until you find it, and click on it.  When
118 you move the cursor back to the @code{pcb} window, you'll see that it
119 now carries the outline of the part with it:
121 @img{fb-led-12}
123 Press the left mouse button to place a part on your board.  We'll move
124 it later.  Do the same for an @code{ACY400} footprint for the
125 resistor, and a @code{HEADER2_1}.  Your board should now look
126 something like this:
128 @img{fb-led-13}
130 We will use the selection and rotate tools to position the parts where
131 we want them.  The palette of tools is just above the route styles, on
132 the left.  The two we want are @b{SEL} and @b{ROT}:
134 @img{fb-led-14}
136 First click on the ROT (rotate) tool.  The cursor should change shape to act as
137 a hint that you'll rotate whatever you click on.  Position the cursor
138 over the square pad on the header and click the left mouse button:
140 @center @image{fb-led-15} @image{fb-led-16}
142 Now click on the SEL (selection) tool, also known as the ``arrow
143 tool''.  You move parts by pressing the left mouse button while the
144 cursor is over the part, and moving the mouse while holding the mouse
145 button down.  The part itself doesn't move; instead, a wire-frame
146 outline of the part is moved (much like when placing parts).  When you
147 release the mouse button, the part is moved.
149 @center @image{fb-led-17} @image{fb-led-18} @image{fb-led-19}
151 Move the header so that the square pin is at 200,600 (the crosshair's
152 coordinates are shown in the upper right corner of the window), the
153 resistor's square pin at 400,400, and the LED's square pin at 500,700.
154 Your board should now look like this:
156 @img{fb-led-20}
158 Now is a really good time to save your layout.
160 Next we'll start adding the traces that connect the parts.  We'll use
161 the LINE tool to add them.  Since this is a simple board, it's likely
162 to be built as a single-sided board, with the traces on the ``back''
163 side, so we want the @b{solder} layer to be the drawing layer.  On the
164 left side of the window is a collection of buttons named after various
165 layers in your board.  One of them is named @b{solder}.  To the left
166 of that button is a small indicator.  Click on it.  Don't click on the
167 button itself - that changes the visibility of the layer.  Click on
168 the indicator.
170 @center @image{fb-led-21} @image{fb-led-22}
172 The way the line tool works is that you click on the starting point,
173 move the crosshair to the end point, and click again.  By not
174 requiring you to hold the mouse button down, you have the ability to
175 scroll and zoom to find the endpoint.  You can also click on
176 intermediate points to make lines with multiple corners.  To end the
177 trace, or start a new trace elsewhere, press the @kbd{Esc} key.  If
178 you press the @kbd{Esc} key again, you return to the selection tool.
180 If you attempt to connect two points that aren't on the same vertical,
181 horizontal, or diagonal line, the line tool will create a pair of
182 traces to connect them.  One will be either vertical or horizontal,
183 and the other will be diagonal.  The vertical/horizontal segment will
184 be connected to the starting point, and the diagonal segment will
185 follow the crosshair.  If you look in the status bar, you'll see a
186 @code{_/} symbol that indicates this:
188 @img{fb-led-23}
190 Pressing the @kbd{/} key changes this mode.  If it says @code{\_} the
191 diagonal will attach to the starting point, and the
192 vertical/horizontal will attach to the crosshair.  If it says neither,
193 only one segment at a time will be drawn, instead of two.  Also, you
194 can use the @kbd{Shift} key to temporarily toggle between @code{\_}
195 and @code{_/} modes.
197 @center @image{fb-led-24} @image{fb-led-25} @image{fb-led-26}
199 So let's add the three traces we need.  Press the @kbd{/} key until
200 @code{_/} is shown (this is the default when you start @code{pcb}) and
201 connect the left resistor pin to the top header pin.  Click, move,
202 click, @kbd{Esc}.  Connect the left LED pin to the bottom header pin.
203 Connect the right resistor pin to the right LED pin.
205 @center @image{fb-led-27} @image{fb-led-28}
207 Next we'll make some adjustments to our PCB.  Unless you have your own
208 library that you've tweaked to be ``just right'', it's likely that
209 you'll need to adjust some things during the board layout process.
210 For example, you might need to make room for a trace between two pins.
211 In our case, we're going to make some adjustments that are appropriate
212 for home-made boards.  We're going to make the pads bigger, in case we
213 drill off-center.  There is a generic ``change size'' command that's
214 tied to the @kbd{S} key.  Place the crosshair over one of the pins and
215 type @kbd{S} and the pin gets bigger.  Press @kbd{Shift-S} and the pin
216 gets smaller.  You can change the size of pins, pads, traces, and even
217 silk this way.  However, if you want to change a lot of things at
218 once, there's a simpler way.  Use the @mnuu{Select,Select all visible
219 objects} menu entry to select everything.  Now you can use the
220 @mnuu{Select,Change size of selected objects} menu to change all the
221 selected things at once.  In our case, we want the @mnu{Pins +10 mil}
222 option to make our pins a little bigger.  After clicking that, see
223 that all the pins are a little bigger.  Now you can
224 @mnuu{Select,Unselect all objects} to unselect them all.
226 You can also use the Select tool (@b{SEL}) to select and deselect.  To
227 select, either click with the left mouse button on the object you want
228 to select, or drag a rectangle around a group of things.  To deselect,
229 just click somewhere where there isn't anything.  You can also
230 Shift-click to select something without deselecting anything else,
231 like if you wanted to select two or three things that aren't grouped
232 nicely.
234 Next we will label our components.  Each element has three text
235 strings it can display; you choose which through a @mnu{View} menu
236 option.  The default is to display the reference designator (refdes),
237 which is what we want for now.
239 Since both pins and elements can have labels, turn off the grid so we
240 can select the elements (@mnuuu{View,Grid size,No Grid}).  Now
241 select the @mnuuu{Edit,Edit name of,text on layout} menu.  Most of
242 the GUI goes ``grey'' and @code{pcb} asks you to @b{Select an Object}.
243 Left-click on the resistor (on the body, not on the pins).  A dialog
244 box pops up asking you for the new name.  Make sure it says
245 ``Element'' and not ``Pin'', and type in @code{R1}:
247 @center @image{fb-led-29} @image{fb-led-30} @image{fb-led-31}
249 You can now drag and drop the name to where you want it, being careful
250 to pick up the label and not any traces:
252 @img{fb-led-32}
254 You can also use keyboard shortcuts.  Position the crosshair over the
255 LED, but not over the pins, and press the @kbd{n} key (for ``name'').
256 Type in @code{D1}.  Set the name of the header to @code{J1} and arrange
257 the names so they look like this:
259 @img{fb-led-33}
261 Don't forget to save your work occasionally.  @code{pcb} will normally
262 save a copy automatically every once in a while, but it's a good habit
263 to save it manually when you're at a good stopping point.
265 We can also add additional text to the silkscreen and copper layers.
266 Let's add some text to the header, so we know which way to plug the
267 battery in.  We want to use the text tool:
269 @img{fb-led-34}
271 We also want the silkscreen layer to be the default drawing layer:
273 @img{fb-led-35}
275 Now, click below the header's square pin, and enter @code{+} in the
276 dialog that pops up.  Use the @kbd{S} key a whole bunch of times to
277 make it bigger, then use the selection tool to move it in place.  Do
278 the same for the @code{-} label.
280 @center @image{fb-led-36} @image{fb-led-37} @image{fb-led-38}
282 Now that we're done with the labels, set the grid back to 100 mil in
283 case you move any of the traces or parts; once they're off-grid it's
284 hard to get them back on to the grid.
286 We're done editing the board now, so if you haven't already, save your
287 work.  But now that the board is done, what do we do with it?  Well,
288 that depends on how you're going to make your board.  If you want to
289 do it yourself, you probably want to send it to your printer.  If you
290 want someone else to make it, they'll probably want gerber files.
292 In your @mnu{File} menu, there are three options we're interested in.
294 @img{fb-led-39}
296 The @mnu{Print Layout...} option prints your layout, but note that it
297 will print 11 pages of board layers!  This probably isn't what you
298 normally want, but let's do it anyway.
300 @img{fb-led-40}
302 There are a lot of options there, but there's only a couple you need
303 to worry about right now.  Select ``fill-page'' and ``ps-color'' and
304 click @b{OK}.  ``Fill-page'' zooms your prints to fill the page.
305 ``PS-color'' causes each layer to be printed in the same color as you
306 see on the screen.  If you're making boards at home using toner
307 transfer, you want these options @emph{off}, and you want ``mirror''
310 In most cases, you don't want to just print the whole design.  Usually
311 you'll use the @mnu{Export Layout...} option to export your layout in
312 a format that others can use.  When you export, a list of possible
313 export types is offered:
315 @img{fb-led-41}
317 Click on @mnu{gerber} so we can create some Gerber (RS-274X) files,
318 which are industry standard file for describing circuit boards.
320 @img{fb-led-42}
322 Click on @b{verbose} then @b{OK}.  You'll see something like this in
323 your terminal:
325 @smallexample
326 Gerber: 5 apertures in fb-led.front.gbr
327 Gerber: 5 apertures in fb-led.back.gbr
328 Gerber: 3 apertures in fb-led.frontmask.gbr
329 Gerber: 3 apertures in fb-led.backmask.gbr
330 Gerber: 2 apertures in fb-led.plated-drill.cnc
331 Gerber: 3 apertures in fb-led.frontsilk.gbr
332 Gerber: 3 apertures in fb-led.fab.gbr
333 @end smallexample
335 For a single sided board, most fab houses will need the back,
336 backmask, plated-drill, frontsilk, and fab files.  @code{pcb} always
337 produces ``positive'' gerbers in case the fab asks.
339 For home fabrication, you'll want to print (see above) without the
340 ps-color or fill-page options.  For this simple board, printer
341 calibration is not needed.  If you're drilling your own holes, you may
342 want to select the @b{drill helper} option, which reduces the diameter
343 of the holes in the copper wherever you're drilling to help you center
344 the drill properly.  If you use the @b{ps} exporter, selecting the
345 ``multi-file'' option puts each layer in a separate file.  That way,
346 you can print only the layers you're interested in.
348 So let's see what we've produced.  Exit from @code{pcb} with
349 @mnuu{File,Quit Program} and find your terminal again.  I use the free
350 programs @code{gv} and @code{gerbv} to view my exported files;
351 @code{gv} is GhostScript, but your desktop probably knows what to do
352 if you double click on a .ps file in your file browser.  @code{gerbv}
353 is a gerber file viewer that's part of gEDA:
355 @smallexample
356 $ gerbv fb-led.*.gbr fb-led.*.cnc
357 @end smallexample
359 @img{fb-led-43}
361 That's it!  The next step is to actually make board (or have them
362 made), which is beyond the scope of this tutorial.