6. Electronics design¶

Before going deep into electronics design, I decided to refresh my understanding of basic chemistry and physics. I reviewed atomic structure, electricity, and magnetism to strengthen my foundation. from this book Electronic fundamentals
An atom is the smallest unit of an element. It is made of protons, neutrons, and electrons. The atomic number (Z) is the number of protons. The mass number (A) is the number of protons plus neutrons. In a neutral atom, the number of electrons is equal to the number of protons. When an atom loses an electron, it becomes positively charged. When it gains an electron, it becomes negatively charged.
Electricity is the movement of electrons. When many electrons move together through a conductor like copper wire, this creates electrical current. If electrons move toward positive charges, energy is transferred. This movement of charge is what we call electricity.
When current flows through a wire, it creates a magnetic field around the wire. This is the basic principle behind motors and generators. Electricity and magnetism are closely connected.
Direct Current (DC) flows in only one direction. Current (I) is the amount of charge flowing per second and is measured in amperes. Voltage (V) is the electrical pressure that pushes electrons. Power (P) is the work done and is calculated as P = V × I. Resistance (R) is the opposition to current flow. Ohm’s Law states that V = I × R.
Electricity can be generated in different ways. Batteries use chemical reactions to produce current. Generators use magnetic fields and motion to create electricity. Heat can also produce voltage when two different metals are joined together.
Alternating Current (AC) changes direction periodically. It is produced by rotating a coil inside a magnetic field and is the type of electricity used in homes.
An electrical circuit is a path that allows current to flow. Circuits can be in series, parallel, or a combination of both. Electronics is the study of how electrons behave and how we use them to control signals and information.
A pulse is a sudden change in voltage or current.
A wave is a repeating change in voltage or current.

A signal is a waveform that carries information. The process of creating a waveform that carries information is called modulation.

Reviewing these basics helped me better understand how electronic components work together.
Electronic Design¶
In Neil’s class, we were introduced to different electronic components and their functions. We learned about surface-mount buttons (normally closed and normally open), switches, resistors, capacitors (polarized and unpolarized), diodes, bipolar transistors, MOSFETs, EDA tools, design rules, and simulations. He also introduced us to KiCad, which is used for schematic design and checking design rules.

In our local session, my instructor Rico went deeper into electronic design. He explained how to read microcontroller datasheets, how to arrange components properly, and how to use KiCad to design circuits.

After the classes, I started my own design. I first made a hand sketch. My idea was to create a simple access control logic where the LED blinks only after pressing the push button three times.
I used:
Seeed XIAO ESP32-C3
Four-leg push button
LED
Resistor
I started by reading the ESP32-C3 datasheet to understand the pin arrangement. Then I created header pin connections for the required pins.

In my first trial, I realized I had connected GND in the VCC position because I was using a power header pin. I had to redraw the sketch.

In the final sketch, I removed the power header and connected directly to the controller to avoid confusion.
!
Installing KiCAD¶
I installed KiCad from Download KiCad
I used the fabcouds for the setup tututorial including adding KiCad FabLibrary from setup tutorial
{ width=”400” }
After installing i installed the KiCad FabLib by clicling the plugin and content manager under library tab 
{ width=”400” }
After clicking install you click apply all pending changes. Now i have fab lugins and libraries installed.
Now it is time to create project by under files then new project I chose schemtaic editor and not PCB editor. and and start my designing.
{ width=”400” }
Use CTRL+ A to fetch all symbols, i typed xiao esp32-c3 to get my controller
{ width=”400” }
I needed to use 2.54 mm pitch male horizontal header pins in configurations of 1x3, 1x5, and 1x6. The 2.54 mm pitch is a standard spacing used in through-hole components and is compatible with jumper wires and breadboards, making it ideal for prototyping and external connections. When I searched in the Fab library using the Add Symbol tool (A) in KiCad, I only found a 1x6 header that matched the required pitch. Since I needed different pin counts, I saved a copy of the 1x6 symbol and edited it instead of modifying the original library component. This is important because editing system libraries can cause issues in future projects or affect other designs. I removed the extra pins to create custom 1x3 and 1x5 versions and saved them into my own library named “Custom Library.” Creating a personal library ensures reusability, better organization, and protection of default libraries.

After completing my first schematic design, I ran the Electrical Rules Check (ERC). The ERC reported warnings and power-related errors, specifically indicating that a power input pin was not driven by any power output pin. This error occurs when KiCad detects a power net, such as VCC or GND, but cannot determine where the power is being supplied from. Even if components are connected to GND symbols, KiCad needs a defined power source to validate the schematic electrically.


To resolve this, I consulted my instructor Rico, who explained the importance of using power flags (PWR_FLAG). The power flag tells KiCad that a specific net is being powered intentionally, especially when power comes from an external source like a header pin rather than a voltage regulator symbol.

After placing the appropriate power symbols and adding a PWR_FLAG to the power net, I ran ERC again and confirmed that there were no warnings or errors.

For my improved and final design, I am going to use global labels and make use of fab libray to make the schematic cleaner and more organized.
Now using the global labels this is how my desing looks like,

After completing the schematic, I opened the PCB Editor and went to Board Setup to define the design constraints. Because I am milling the board using a Roland machine with a 1/64” end mill, I set the minimum clearance and minimum track width to 0.4 mm. This ensures that there is enough spacing between traces for the milling bit to pass without cutting unintended copper. If the clearance is smaller than the diameter of the end mill, the tool may remove adjacent traces and cause short circuits or damaged tracks. I left the connection width at 0 so that KiCad follows the rules defined in the net classes instead of applying a fixed global width. Setting these constraints first ensures the board is manufacturable and avoids routing problems later.

After defining the constraints, I created Net Classes for Power, Signals, and Default. Net classes allow different groups of nets to follow different routing rules. For example, power traces can be wider to safely carry more current and reduce voltage drop, while signal traces can remain thinner to save space. I then assigned each pin to its appropriate net class. This ensures consistent trace widths, proper isolation, and better electrical reliability. Defining net classes improves organization and helps maintain design standards throughout the PCB layout process.

During this week, arranging components on my PCB was challenging due to limited space and complex pin connections. To solve this, I did not include the connected global pins in the pin header. Instead, I connected them directly to the components, specifically D1 and D0. After this, I refreshed both the schematic and PCB editors and ensured that footprints were correctly linked to the schematic symbols using the update schematic from PCB feature. This step ensures that all references and connections between the schematic and PCB remain consistent.

In the PCB editor, I drew the board shape according to the required dimensions. The shape can be customized freely. I arranged all components to provide space for the USB port and ensure no part blocks another. To adjust components, I hovered over them and pressed M to move and R to rotate to the correct orientation. Under the Edge.Cuts layer, I finalized the board outline.


For routing, I pressed X to start routing a track between components. I followed design rules, avoiding sharp corners and using 45-degree angles to reduce interference and improve manufacturability.

After finishing the routing, I went to the tools menu and clicked 3D view. This allowed me to see a 3D model of my PCB, verify the component placement visually, and confirm that the design was ready for export.

Moving forward, I intend to refine my design by routing most connections on the bottom layer of the board and replacing horizontal pin headers with vertical ones to optimize space and component alignment.
PCB Export for Milling
After completing the PCB layout, I exported the design as Gerber files by clicng files-fabrication output then gerber. During export, I carefully marked the layers as follows:
F.Cu (Front Copper): for all the copper traces.
Edge.Cuts: to define the outline of the board.
These exported Gerber files are now ready for fabrication. I will use Roland CAM software to prepare the files for CNC milling, which will produce the physical PCB.



Simulation¶
I used Wokwi to simulate a circuit. To start visit wokwi.com then choose esp32, under it go to xiao esp32-c3 and start designing your circuit. I click the + button to add components.
{width=”300”}
{width=”300”}
{width=”300”}
{width=”300”}
{width=”300”}