KiCad Like A Pro: Advanced Projects and Recipes
Mastering PCB design with real-world projects
4th edition covering KiCad 8
By Peter Dalmaris, PhD
Visual Description: KiCad PCB Editor Interface
The cover features a screenshot of the KiCad PCB editor displaying an "ESP32 Clone Devkit-PCB Editor" project. The interface shows various design elements, including component designators (e.g., R23, C14, D6), net names (e.g., GND, RXD), tracks, vias, and silkscreen labels. It highlights features like netclass width settings for tracks and vias, zoom level, and component placement.
Also visible are logos for "HQ NextPCB" with the URL "www.nextpcb.com" and "Elektor" with the tagline "design > share > earn".
Publication Details
This is an Elektor Publication. Elektor is the media brand of Elektor International Media B.V.
PO Box 11, NL-6114-ZG Susteren, The Netherlands
Phone: +31 46 4389444
All rights reserved. No part of this book may be reproduced in any material form, including photocopying, or storing in any medium by electronic means and whether or not transiently or incidentally to some other use of this publication, without the written permission of the copyright holder except in accordance with the provisions of the Copyright Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licencing Agency Ltd., 90 Tottenham Court Road, London, England W1P 9HE. Applications for the copyright holder's permission to reproduce any part of the publication should be addressed to the publishers.
Declaration
The Author and Publisher have used their best efforts in ensuring the correctness of the information contained in this book. They do not assume, and hereby disclaim, any liability to any party for any loss or damage caused by errors or omissions in this book, whether such errors or omissions result from negligence, accident, or any other cause.
All the programs given in the book are Copyright of the Author and Elektor International Media. These programs may only be used for educational purposes. Written permission from the Author or Elektor must be obtained before any of these programs can be used for commercial purposes.
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library.
This third edition of KiCad Like a Pro consists of two books:
- KiCad Like A Pro | Fundamentals and Projects
Getting started with the world's best open-source PCB tool
590 pages
ISBN: 978-3-89576-626-8 (print)
ISBN: 978-3-89576-627-5 (ebook) - KiCad Like A Pro | Advanced Projects and Recipes
Mastering PCB design with real-world projects
492 pages
ISBN: 978-3-89576-628-2 (print)
ISBN: 978-3-89576-629-9 (ebook)
Copyright 2024: Elektor International Media B.V.
Prepress Production: D-Vision, Julian van den Berg
Printed in the Netherlands by Ipskamp Printing, Enschede
Elektor is the world's leading source of essential technical information and electronics products for pro engineers, electronics designers, and the companies seeking to engage them. Each day, our international team develops and delivers high-quality content - via a variety of media channels (including magazines, video, digital media, and social media) in several languages - relating to electronics design and DIY electronics. Visit www.elektormagazine.com.
Table of Contents
Did you find an error? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
About the author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
How to read Kicad Like A Pro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
What will you need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
The book web page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
KiCad 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Foreword by Wayne Stambaugh. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
An introduction: Why KiCad? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
About Tech Explorations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1: Project - Tiny Solar Power Supply
1.1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.2. Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
1.2.1. 1 - Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.2.2. 2 - Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
1.2.3. 2 - Edit Component values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
1.2.4. 3 - Arrange, Annotate, Associate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
1.2.5. 4 - Wiring. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1.2.6. 5 & 6 - Nets and Electrical Rules Check . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1.2.7. 7 - Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
1.3. Layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
1.3.1. 1 - Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
1.3.2. 2 & 3 - Placement and outline. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
1.3.3. 4 - Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
1.3.4. 2 - Refine the outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
1.3.5. 5 - Copper fills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
1.3.6. 6 - Silkscreen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
1.3.7. 7 - Design Rules Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
1.3.8. Two more things: 3D models and mounting holes . . . . . . . . . . . . . . . . . . . 63
1.3.9. 8 - Export and Manufacture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2: Project - A 4 x 8 x 8 LED matrix array
2.1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
2.2. Schematic design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
2.2.1. 1 - Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
2.2.2. 2 - Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
2.2.3. 3 - Arrange, Annotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
2.2.4. 3 - Associate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
2.2.5. 4 - Wiring. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
2.2.6. 5 - Nets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
2.2.7. 6 - Electrical Rules Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
2.2.8. 7 - Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
2.2.9. Last-minute edits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
2.3. Layout design editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
2.3.1. 1 - Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
2.3.2. 2 - Outline and constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
2.3.3. 3 - Place components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
2.3.4. 2 - Refine outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
2.3.5. 3 - Move footprints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
2.3.6. 4 - Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
2.3.7. 4 - Copper fills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
2.3.8. 5 - Silkscreen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
2.3.9. 6 - Design Rules Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
2.3.10. 7 - Manufacture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
2.5. Bonus - 3D shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
2.6. Bonus - Found a bug in the schematic! (and fix). . . . . . . . . . . . . . . . . . . . . . . . 151
2.7. Assembled PCB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
3: Project - MCU datalogger
3.1. Project - Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
3.2. Create the new project and Git repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
3.3. Schematic design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
3.3.1. Schema 1 - Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
3.3.2. Schema 2 - Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
3.3.3. Schema 2 - Sheet two . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
3.3.4. Schema 3 - Arrange, Annotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
3.3.5. Edit component values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
3.3.6. Schema 3 - Associate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
3.3.7. Schema 4 - Wiring of sheet 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
3.3.8. Schema 4 - Wiring of sheet 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
3.3.9. Schema 5 - Nets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
3.3.10. Schema 6 - Electrical Rules Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
3.3.11. Schema 7 - Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
3.4. Create the 2-layer branch in Git . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
3.5. Layout design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
3.5.1. Layout 1 - Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
3.5.2. Layout 2 - Outline and constraints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
3.5.3. Layout 3 - Place components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
3.5.4. Layout 2 - Outline refinement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
3.5.5. Layout 4 - Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
3.5.6. Layout 4 - Copper fills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
3.5.7. Layout 4 - Routing improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
3.5.8. Layout 5 - Silkscreen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
3.5.9. Layout 6 - Design Rules Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
3.5.10. Layout 7 - Manufacture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
3.6. 3D shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
3.7. Merge 2-layer branch to main . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
3.8. Design 4 Layer PCB in new Git branch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
3.9. Four-layer PCB routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
3.10. Four-layer PCB manufacturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
3.11. Updating layout from changes to the schematic with Git . . . . . . . . . . . . . . . . . 234
3.12. Finding and correcting a design defect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
3.12.1. Fix the schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
3.12.2. Fix the 2 layer PCB layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
3.12.3. Fix the 4 layer PCB layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
4: Project - An ESP32 clone
4.1. Project - Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
4.2. Schematic design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
4.2.1. Schema 1 - New KiCad project and Schematic Setup. . . . . . . . . . . . . . . 258
4.2.2. Schema 2 - Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
4.2.3. Schema 3 - Annotate and set component values . . . . . . . . . . . . . . . . . . . 263
4.2.4. Schema 3 - Arrange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
4.2.5. Schema 3 - Associate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
4.2.6. Schema 4 - Wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
4.2.7. Schema 5 - Nets and Net Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
4.2.8. Schema 6 - Electrical Rules Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
4.2.9. Schema 7 - Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
4.3. Layout design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
4.3.1. Layout 1 - Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
4.3.2. Layout 2 - Outline and constraints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
4.3.3. Layout 3 - Place components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
4.3.4. Layout 2 - refine outline and DRC errors . . . . . . . . . . . . . . . . . . . . . . . . 297
4.3.5. Layout 4 - Route . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
4.3.6. Layout 4 - Copper fills and keep out areas . . . . . . . . . . . . . . . . . . . . . . . 308
4.3.7. Layout 5 - Silkscreen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
4.3.8. Layout 4 - Routing improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
4.3.9. Layout 6 - Design Rules Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
4.3.10. Layout 7 - Manufacture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
4.4. 3D shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
4.5. Finding and correcting a design defect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
4.5.1. Fix the schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
4.5.2. Fix the layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
5: Recipes
5.1. Interactive delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
5.2. Find and Replace (Schematic editor) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
5.3. Text variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
5.4. Board Setup - pre-defined sizes for tracks and vias . . . . . . . . . . . . . . . . . . . . . 337
5.5. Board Setup - Design rules violation severity . . . . . . . . . . . . . . . . . . . . . . . . . . 341
5.6. Board Setup - Custom design rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
5.7. Schematic Setup - Electrical Rules and violation severity. . . . . . . . . . . . . . . . . . 348
5.8. Schematic Setup - Electrical Rules and Pin conflicts map . . . . . . . . . . . . . . . . . . 351
5.9. Import components from Snapeda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
5.10. The Freerouting autorouter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
5.10.1. Freerouting plugin installation and operation. . . . . . . . . . . . . . . . . . . . . 365
5.10.2. Using Freerouting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
5.10.3. Autorouting process and customisation . . . . . . . . . . . . . . . . . . . . . . . . 369
5.11. PCB editor Inspection menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
5.12. Single track and differential pair routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
5.13. Track length tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
5.14. Differential pair skew tuning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
5.15. The footprint wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
5.16. Pin and wire highlighter tool. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
5.17. KiCad project management with Git . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
5.17.1. Install Git . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
5.17.2. Git configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
5.17.3. Create a new KiCad project Git repository . . . . . . . . . . . . . . . . . . . . . . 405
5.17.4. How to ignore files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
5.17.5. Basic Git commands: add, commit. . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
5.17.6. Basic Git commands: branch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
5.17.7. Basic Git commands: merge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
5.18. Sharing your KiCad project on GitHub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
5.19. Customize the editor color scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
5.20. Import an EAGLE, Altium, or Cadstar schematic . . . . . . . . . . . . . . . . . . . . . . . 432
5.21. The circuit simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
5.21.1. Prepare the circuit for simulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
5.21.2. Configure the simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
5.21.3. Simulate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
5.22. KiCad project templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
5.22.1. Using a system project template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
5.22.2. Create a user project template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
5.23. Share projects and configurations with others . . . . . . . . . . . . . . . . . . . . . . . . 458
5.24. Calculate the width of a trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
5.25. Design a custom schematic sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
5.26. Python scripting API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
5.26.1. A simple example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
5.26.2. Make a change to a PCB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
5.26.3. Create a KiCad Action Plugin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
5.26.4. Learning More About KiCad Python Scripting API. . . . . . . . . . . . . . . . . . 487
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488