Skip to content

Week 6: Electronics Design

Week 6 Assignment:
  1. Group Assignment

    1. Use the test equipment in your lab to observe the operation of an embedded microcontroller
  2. Individual Assignment

    1. Simulate a circuit
    2. Use an EDA tool to design an embedded microcontroller system using parts from the inventory, and check its design rules for fabrication
  3. Extra credits:

    • Try another design workflow
    • Design a case
Learning
  • Electronic design automation (EDA) -> software tools used to design electronic system such as circuit boards. Example: KiCad.
  • Printed Circuit Broad (PCB): a flat board made of insulating material with copper traces that electrically connect electronic components and also organizes the circuit neatly (instead of using many loose wires)
  • Plated-Through Hole (PTH): holes in the PCB that has copper plating inside the hole wall, which electrically connect different layers of the PCB
  • Surface Mount Technology (SMT): a method of mounting electronic components directly onto the surface of a PCB -> in Fab Lab we will use SMT for the PCB

GROUP ASSIGNMENT

For the group assignment, we learned how to use multimeter, oscilloscope and DC power supply.

Multimeter

Description

Multimeter is a measuring instrument to measure various electrical properties, including Voltage (Volts, V), Current (Amps, A) and Resistance (Ohms, Ω).

Oscilloscope

Description

Oscilloscope is a device used to visualize electrical signals as waveforms. It shows Voltage on the vertical axis (Y-axis) and Time on the horizontal axis (X-axis).

DC Power Supply

Description

DC power supply is an instrument that provides a stable direct current (DC) voltage to power electronic circuits. It converts alternating current (AC) into direct current (DC), which flows consistently in one direction. Most electronic circuits require DC voltage to operate properly.

INDIVIDUAL ASSIGNMENT

THE IDEA:

2D Design Since my final project will involve using buttons, I chose to incorporate them into this week’s assignment in order to practice and better understand how they work.

Information

For this assignment, I used Wokwi to simulate the circuit and KiCad Version 9.0.7 to design the printed circuit board (PCB). Additionally, I used the KiCad FabLib plugin (KiCad component library based on the the Fab Inventory) to assist with PCB design.

Installing Kicad Fablib plugin

Installing from KiCad Plugin Repository:

  1. Open KiCad
  2. Go to Tools -> Plugin and Content Manager
  3. Select Libraries tab -> search for KiCad FabLib (the logo is a purple Dinosaur)
  4. Click Install
  5. Click Apply Pending Changes

1st Design Workflow

Simulate a Circuit

I used Wokwi to simulate the circuit. These are the components I used:

  • 1 × Seeed Studio XIAO ESP32-C3
  • 5 × LEDs
  • 5 × Buttons
  • 5 × Resistors

I want each button to turn one LED on and off (toggle switch):

LED Button
LED1 D0 -> BUTTON1 D9
LED2 D1 -> BUTTON2 D8
LED3 D2 -> BUTTON3 D7
LED4 D3 -> BUTTON2 D6
LED5 D4 -> BUTTON3 D5

The following video shows the simulation in Wokwi:

This is the code generated by ChatGPT:

// LED pins
const int led1 = D0;
const int led2 = D1;
const int led3 = D2;
const int led4 = D3;
const int led5 = D4;

// Button pins
const int button1 = D9;
const int button2 = D8;
const int button3 = D7;
const int button4 = D6;
const int button5 = D5;

// LED states (remember ON or OFF)
bool ledState1 = false;
bool ledState2 = false;
bool ledState3 = false;
bool ledState4 = false;
bool ledState5 = false;

// Previous button states
bool lastButton1 = HIGH;
bool lastButton2 = HIGH;
bool lastButton3 = HIGH;
bool lastButton4 = HIGH;
bool lastButton5 = HIGH;

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);

  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  pinMode(button3, INPUT_PULLUP);
  pinMode(button4, INPUT_PULLUP);
  pinMode(button5, INPUT_PULLUP);
}

void loop() {

  // ----- BUTTON 1 -----
  bool currentButton1 = digitalRead(button1);

  if (lastButton1 == HIGH && currentButton1 == LOW) {
    ledState1 = !ledState1;          // TOGGLE
    digitalWrite(led1, ledState1);
    delay(200);                      // debounce
  }
  lastButton1 = currentButton1;

  // ----- BUTTON 2 -----
  bool currentButton2 = digitalRead(button2);

  if (lastButton2 == HIGH && currentButton2 == LOW) {
    ledState2 = !ledState2;
    digitalWrite(led2, ledState2);
    delay(200);
  }
  lastButton2 = currentButton2;

  // ----- BUTTON 3 -----
  bool currentButton3 = digitalRead(button3);

  if (lastButton3 == HIGH && currentButton3 == LOW) {
    ledState3 = !ledState3;
    digitalWrite(led3, ledState3);
    delay(200);
  }
  lastButton3 = currentButton3;

  // ----- BUTTON 4 -----
  bool currentButton4 = digitalRead(button4);

  if (lastButton4 == HIGH && currentButton4 == LOW) {
    ledState4 = !ledState4;
    digitalWrite(led4, ledState4);
    delay(200);
  }
  lastButton4 = currentButton4;

  // ----- BUTTON 5 -----
  bool currentButton5 = digitalRead(button5);

  if (lastButton5 == HIGH && currentButton5 == LOW) {
    ledState5 = !ledState5;
    digitalWrite(led5, ledState5);
    delay(200);
  }
  lastButton5 = currentButton5;
}

EDA Tool: KiCad

I used Kicad to design the schematic and PCB layout. These are the tools in KiCad:

Schematic Design

  1. I started by creating a new project on Schematic Editor.

  2. Then, I used the KiCad FabLib plugin to add the components from the inventory to the schematic and arrange them.

    • XIAO ESP32-C3

    • Buttons Switch_Tactile_Omron

    • LEDs LED_1206

    • Resistors R_1206

    • Ground PWR_GND

    The component assemblies are shown below:

  3. After connecting the components according to the circuit design, I ran the Electrical Rules Checker (ERC) to ensure there were no errors in the schematic.

PCB Layout Design
  1. After completing the schematic design, I moved to the PCB Editor

  2. Then I clicked Update PCB from Schematic

  3. The Update PCB from Schematic window opened and showed if there were any errors

  4. After updating, the PCB layout appeared like this:

    Use Route Single Track to create the connected traces:

  5. Arrange the components:

  6. Next, we need to create the edge line. First, we set the origin to help with measurements.

    Select Select, choose where you want the origin, press Space, and the origin will be set to (0,0) at that point.

  7. Use Draw Lines to create the edge line, and select Appearance -> Edge Cuts from the right menu. I started drawing the line from the origin.

  8. I added text with my name. I set the layer to F.Silkscreen and adjusted the size and font type.

  9. I placed the text at the bottom right of the PCB.

  10. Here is the 3D view of my PCB design:

Design Rules

Note

Design rules exist to ensure that the board you design can actually be manufactured, assembled, and function reliably.

How to Set Up Design Rules in KiCad:

  1. Open KiCad and choose PCB Editor from the right-hand menu.

  2. Click File -> Board Setup. The Board Setup window will appear. In the left-hand menu, select Design Rules → Constraints.

  3. Adjust the design rules according to the specifications of your CNC cutting machine or your PCB manufacturer’s design rules

PCB Layout RE-DESIGN

MISTAKE!

Make sure to set the design rules at the beginning. I set them after finishing my design, and when I ran the Design Rule Checker, I found sooo many errors.....

All of the errors are indicated by arrows :

Therefore, I needed to rearrange all of the traces:

Sometimes there are tiny traces left behind that are hidden under the components…

I was left with two errors, and I am not sure whether they will cause a problem or not:

Here is my final design:

And here is the 3D view of the PCB:

Adding Logo on PCB

BEAR I added this bear logo (size 1 × 1 cm) that I made in Adobe Illustrator to the PCB design.

The process is not direct, but it is relatively easy. You need to convert the logo image into a PCB footprint first, and then you can add your logo to the board.

How to add logo to a PCB?

  1. Use Image Converter from the right-hand menu:

  2. Click Load Source Image, then insert your image. You can adjust the size, and also create several different sizes (you can do this from the right-hand menu).

  3. Next, export the footprint. On the right-hand menu:

    • Under Output Format, choose Footprint (.kicad_mod file)
    • Choose F.Silkscreen
    • Click Export to Clipboard
    • Create a new folder (for example, “Logos”)
    • Export the image into the “Logos” folder

    Create a Folder

    While exporting the file, make sure you create a separate folder specifically for your image. In the next step, when you add the footprint to the libraries, the program only detects folders

  4. Go to PCB Editor, click Preferences -> Manage Footprint Libraries, then select the “Logos” folder.

  5. Click Place Footprints or press A, then search for your image/logo.

  6. Position your image/logo on your PCB.