Week 06 Electronics Design

Objectives

assignment:-Use the test equipment in your lab to observe the operation of a microcontroller circuit board

Individual assignment:-Use an EDA tool to design a development board that uses parts from the inventory to interact and communicate with an embedded microcontroller extra credit: try another design workflow extra credit: design a case for it

Group Assignment

In our group assignment, we learned how to use various essential lab instruments for testing and analyzing electronic circuits. We worked with the ZOYI ZT301 digital multimeter to measure voltage, current, resistance, continuity, and diodes. We used the GW Instek AFG-2125 function generator to produce different waveforms and observed how changing frequency affected an SMD LED's blink rate. With the GW Instek GPD-3303D bench power supply, we tested voltage and current outputs on a resistor-LED circuit, exploring its modes and safety features. Using the OWON TAO3104A oscilloscope, we analyzed signal waveforms, calibrated probes, and captured PWM signals from a MEMS microphone. Finally, we used the Saleae Logic Pro 8 logic analyzer to examine digital I2C signals from a XIAO RP2040 microcontroller, gaining insights into protocol decoding and signal timing.

To know more, visitGroup Assignment.

Electronic components

Electronic components are the fundamental building blocks of electronic circuits, designed to control the flow of electricity in a system. They can be active (such as transistors and diodes) or passive (such as resistors and capacitors), each serving a specific function within a circuit. When connected on a printed circuit board (PCB), these components work together to form functional electronic devices.

Active and passive components

Active and passive components are the two main types of electronic components used in circuits. Active components require an external power source to function and can amplify, switch, or generate electrical signals. Common examples include transistors, diodes, and operational amplifiers. In contrast, passive components do not need an external power source and mainly resist, store, or control the flow of electricity without amplification. Examples of passive components include resistors, capacitors, and inductors. Both active and passive components are essential for building and operating electronic circuits.

Source.

Resistor

A resistor is a passive electronic component that limits or regulates the flow of electric current in a circuit. It is commonly used to control voltage levels, divide currents, and protect components from excessive current. Resistors are made from materials like carbon, metal film, or wire-wound ceramics, depending on their application. The resistance value is measured in Ohm (Ω). They come in different types, including fixed, variable (potentiometers), and surface-mount resistors (SMRs) for compact circuits.SMD (Surface Mount Device) resistors are small, flat components designed for direct mounting onto the surface of a PCB, making them ideal for compact, high-density circuits. In contrast, through-hole resistors have leads that pass through holes in the PCB and are soldered on the other side, providing strong mechanical bonds and easier handling.

Image.

Capacitor

A capacitor consists of two or more parallel conductive plates that are electrically separated by an insulating material called the dielectric. These plates do not touch each other, and the dielectric can be made of air, waxed paper, mica, ceramic, plastic, or a liquid gel (as found in electrolytic capacitors). When connected to a voltage source, a capacitor stores electrical charge on its plates, creating an electric field between them. The ability of a capacitor to store charge is measured in farad (F), the SI unit of capacitance, where 1 farad (F) = 1 coulomb per volt (C/V). Since capacitors do not allow direct current (DC) to pass, they are widely used for energy storage, filtering, and signal processing in electronic circuits.

Image.

Inductor

An inductor is a passive electronic component that temporarily stores energy in a magnetic field when an electric current passes through its coil. It consists of two terminals and a coil of insulated wire, which can either loop through the air or wrap around a core material that strengthens the magnetic field. Inductors play a key role in managing fluctuations in electrical current within a circuit. The standard unit of inductance is the henry (H).

Image.

Transistor

A transistor is a semiconductor device that plays a vital role in amplifying or switching electronic signals and electrical power. It is composed of three layers of semiconductor material, where the flow of current or voltage between two layers is controlled by applying an electric current or voltage to the third layer. As a fundamental component in modern electronics, transistors are integral to the operation of devices such as radios, computers, and complex integrated circuits. They are available in different types, including bipolar junction transistors (BJTs), field-effect transistors (FETs), and MOSFETs, each designed for specific applications based on its distinct properties and working principles.

Image.

Diode

A diode is a semiconductor device that primarily allows current to flow in one direction while blocking it in the opposite direction. This property makes diodes essential for converting alternating current (AC) to direct current (DC), protecting circuits, and enabling various electronic functions.Diodes operate in two modes:

  • Forward Bias: When the anode is at a higher potential than the cathode, the diode conducts electricity.
  • Reverse Bias: When the cathode is at a higher potential, the diode blocks current, acting as an insulator.
  • Types of Diodes

  • Rectifier Diode : Used for converting AC to DC.
  • Zener Diode : Designed to operate in reverse bias and regulate voltage.
  • Light Emitting Diode (LED) : Emits light when forward-biased.
  • Photodiode : Converts light into electrical current.
  • Image.

    Integrated circuits (IC)

    Integrated circuits (ICs) are essential components in modern electronics, consisting of resistors, capacitors, inductors, diodes, and transistors fabricated onto a single semiconductor chip, usually made of silicon. These components are interconnected to perform specific functions such as amplification, signal processing, computation, and power management. Since the semiconductor material is delicate, ICs are housed in protective plastic, ceramic, or metal packages with metal pins for easy connection to circuit boards. ICs can be categorized into analog, digital, and mixed-signal types, enabling compact, efficient, and reliable electronic devices.

    Image.

    Switch

    A switch is an electrical or electronic device that controls the flow of current in a circuit by connecting or disconnecting it. Switches can be broadly classified into mechanical and electronic (solid-state) switches. Mechanical switches, such as push buttons, toggles, and rotary switches, operate through physical movement and can be categorized based on actuation method, contact configuration, poles and throws, and operating states. Electronic switches, like transistors, MOSFETs, and thyristors, have no moving parts and use semiconductor technology to switch circuits efficiently, making them ideal for applications in automation, motor drives, and HVAC systems.

    Image.

    Wokwi

    Wokwi.

    Wokwi is an online Electronics simulator. You can use it to simulate Arduino, ESP32, STM32, and many other popular boards, parts and sensors.

    First, login to Wokwi

    To begin the simulation process, I created a new project in Wokwi.

    Next, I selected the XIAO ESP32 board in Wokwi to begin the simulation.

    By using the ‘Add’ option in Wokwi, I included all the required components for the simulation

    Next, I added the necessary components individually, including an LED, a resistor, and a push button.

    Here are some commonly used shortcut keys in Wokwi:

  • W → Start wiring (create connection)
  • R → Rotate selected component
  • Ctrl + C → Copy component
  • Ctrl + V → Paste component
  • Ctrl + Z → Undo
  • Ctrl + Y → Redo
  • Shift + Click → Select multiple components
  • Internal pull-up function

    An internal pull-up function refers to a feature in many microcontrollers, where a built-in resistor connects an input pin to the supply voltage (VCC). This internal pull-up resistor ensures that the input pin remains at a stable high logic level (HIGH) when no external component is connected, preventing the pin from "floating" and picking up electrical noise that could lead to unreliable or unpredictable behavior. When a device like a push button is connected between the input pin and ground (GND), pressing the button creates a path to ground, pulling the pin LOW and allowing the microcontroller to detect a clear state change. Enabling the internal pull-up in code (e.g., using pinMode(pin, INPUT_PULLUP) in Arduino) eliminates the need for an external resistor, simplifying circuit design and reducing component count.

    I wrote a program to blink an led using push button

    MicroPython is specifically tailored for microcontrollers and embedded devices, enabling developers to write Python code directly on low-power devices. The program code is given below. To comment a line we need to add "/" in the begining

    // Define pins
    const int ledPin = D2;      // LED connected to GPIO2
    const int buttonPin = D4;   // Button connected to GPIO4
    
    void setup() {
      pinMode(ledPin, OUTPUT);
      pinMode(buttonPin, INPUT_PULLUP);  // Enable internal pull-up
    }
    
    void loop() {
      int buttonState = digitalRead(buttonPin);
    
      // Button pressed = LOW (because of pull-up)
      if (buttonState == LOW) {
        digitalWrite(ledPin, HIGH);  // Turn LED ON
      } else {
        digitalWrite(ledPin, LOW);   // Turn LED OFF
      }
    }
    import machine import time It allows you to access and utilize functions, classes, and variables defined in external files, known as modules. LED_PIN = D2 BUTTON_PIN = D4 led = machine.Pin(LED_PIN, machine.Pin.OUT) button = machine.Pin(BUTTON_PIN, machine.Pin.IN, machine.Pin.PULL_UP) The LED is connected to GPIO2.The button is connected to GPIO14 with an internal pull-up resistor, meaning it reads high (1) when not pressed and low (0) when pressed. while True: if not button.value(): led.on() print("LED ON!") time.sleep(0.5) else: led.off() print("LED OFF!")

    I wrote a program for Led chasser

    I used chatgpt to refer the code.

    promt:-How to code for Led chasser intensity using rp 2040

    The program code is given below

    // LED pins
    const int ledPins[] = {D0, D1, D2, D3};
    const int buttonPin = D4;
    
    const int numLeds = 4;
    
    void setup() {
      Serial.begin(115200);
    
      for (int i = 0; i < numLeds; i++) {
        pinMode(ledPins[i], OUTPUT);
      }
    
      pinMode(buttonPin, INPUT_PULLUP);
    
      Serial.println("XIAO ESP32-C6 LED Chaser Ready");
    }
    
    void loop() {
      int buttonState = digitalRead(buttonPin);
    
      if (buttonState == LOW) {  
        Serial.println("Button Pressed - Running Chaser");
    
        for (int i = 0; i < numLeds; i++) {
          digitalWrite(ledPins[i], HIGH);
          delay(150);
          digitalWrite(ledPins[i], LOW);
        }
      } 
      else {
        for (int i = 0; i < numLeds; i++) {
          digitalWrite(ledPins[i], LOW);
        }
      }
    }
    Key Translation Details:
  • Pin Mapping:In your Arduino code, you used D0 through D4. In MicroPython, these are addressed directly by their GPIO numbers (0, 1, 2, 3, and 4).
  • Logic:The if button.value() == 0 check corresponds to your if (buttonState == LOW) logic.
  • Defines constant integer for button and LED connected these are addressed directly by their GPIO numbers (0, 1, 2, 3, and 4).

    void setup() { pinMode(buttonPin, INPUT_PULLUP); pinMode(ledPin, OUTPUT); Serial.begin(115200); }

    setup() function runs once the ardino is powered on/ reset.Button pin defines pin D4 as input. INPUT_PULLUP enables internal pull up resistor,which keeps the pin value high when the button is not pressed ledPin defines pin D0,D1,D2,D3D4 as output. In Serial.begin(115200) serial communication begins at 115200 bits per second.

    KiCad

    KiCad is a free, open-source Electronic Design Automation (EDA) software suite used for creating schematics and designing printed circuit boards (PCBs). It provides tools for schematic capture, PCB layout, circuit simulation, and generating manufacturing files such as Gerber files. KiCad also includes features like 3D modeling, bill of materials (BOM) generation, and engineering calculations, making it a powerful tool for electronics design.

    Go to the official KiCad website - . Choose your operating system (Windows, macOS, or Linux). Download the installer for the latest stable version.Run the installer and follow the installation instructions.I downloaded and installed KiCad. Now open KiCad . File → New Project . Name your project

    Snap Magic

    Snap Magic - . is a free online platform that provides schematic symbols and PCB footprints compatible with KiCad

    Since the required microcontroller was not available in the default KiCad library, I searched for it in Snap Magic. I downloaded the KiCad files, extracted the ZIP file, and added the symbol and footprint to my project.

    The pin configuration was verified using the datasheet to ensure correct connections.

    I used Snap Magic to find a 2.0 mm pitch, 4-position, right-angle surface-mount header connector. Since it was not available in the default KiCad library, I downloaded the symbol and footprint from Snap Magic and added them to my project.

    After selecting the component I needed, I downloaded the KiCad symbol and footprint files for use in my project

    Next, select the required PCB software format (e.g., KiCad) before downloading the files.

    After selecting the software format, you will receive three file format options, such as symbol, footprint, and 3D model (STL).

    Next, go to the Preferences menu in KiCad to add the downloaded symbol and footprint libraries.

    Select the required library file and load it into KiCad.

    Design 1

    Before adding components to my design, I referred toFabStash -FabStash - a website listing all components available in the Super Fab Lab Kochi inventory and reviewed the relevant datasheets

    Schematic editor

    Instructor Saheen demonstrated how to use KiCad for PCB design with a practical example. We followed along using the component values and design specifications provided by him. In KiCad we have two editors, schematic editor and pcb editor. Open schematic editor.

    Add Components
  • Press A or click the "Place Symbol" tool.
  • Search for the component
  • Click to place it on the canvas.
  • Wire the Components
  • Press W or click the "Place Wire" tool
  • Click on one pin of a component and draw to another pin to connect them.
  • Add Power Symbols
  • Press A, search for VCC, GND, etc., and place them.
  • Add Values and Labels
  • Press E while hovering over a component(or double click at the value) to edit its value (e.g., 220 Ω for a resistor).
  • To add label click the label option on the right pane.
  • I made the connection diagram in schematic editor

    LED

    I placed a red LED in my circuit and powered it with 5 V. I added a 220 Ω resistor in series with the LED to limit the current flowing through it. Without the resistor, the LED could have drawn too much current, potentially damaging itself or the microcontroller. The resistor ensured that the LED operated safely within its current rating, providing stable and reliable illumination. For a standard red LED, the forward voltage is usually around 2 V, and the safe operating current is about 20 mA. so the voltage that needs to drop across the resistor is 3so the voltage that needs to drop across the resistor is 3V. From ohm's law the value of resistor found to be 150 ohm. And we use 220 ohm as standard.

    Switch

    I added a switch to my circuit and connected a resistor between the input pin and 5 V, which made it a pull-up resistor configuration. When the switch was open, the resistor kept the pin at a HIGH state (5 V). When I pressed the switch, it connected the pin to ground, pulling it LOW. The resistor was important because it prevented the pin from floating when the switch was not pressed, ensuring stable and reliable digital readings.

    pin header connector

    This is the schematic symbol of a 2×5 pin header connector (J2) showing power, ground, and signal connections such as D10, D9, RX, and TX.

    JST connector

    This is the schematic symbol of a 4-pin JST connector (J1 – S4B-PH-SM4-TB) used for I2C communication, showing GND, +5V, SDA, and SCL connections.

    PCB editor

    To work with pcb editor first we need to define designrules. Design rules are used for preventing short circuits and interference, ensuring manufacturability, setting standards for trace widths, clearances, and layers. Open pcb editor. From file -> board setup -> Design rules

    This image shows the PCB component placement and net mapping before routing made in KiCad.

  • M1 is the main microcontroller module placed in the center.
  • D1–D4 are LEDs and R1–R4 are current-limiting resistors.
  • SW1 is a push button switch with R5.
  • C1 is a capacitor for power stability.
  • J1 and J2 are connectors for power and signal connections.
  • The blue lines (airwires) show electrical connections that still need routing.
  • 👉 This stage is done before drawing the copper tracks (routing) on the PCB.

    This image shows the PCB after routing designed in KiCad.

  • The red lines are copper traces that electrically connect all components.
  • M1 in the center is the microcontroller module controlling the circuit.
  • D1–D4 LEDs with R1–R4 resistors are connected for LED indication.
  • SW1 is a push button switch connected through R5 for input control.
  • C1 is a capacitor used for voltage stability.
  • J1 and J2 connectors allow external connections like power, communication, or programming.
  • ✅ This layout shows the final routing stage where all electrical connections are completed on the PCB.

    This image shows the Text Properties window in the PCB Editor of KiCad.

    What is happening here

  • you clicked the “T” (Add Text) tool on the right side.
  • The Text Properties dialog opened to add or edit text on the PCB.
  • Important options in this window

  • Text box → Write the text you want to display on the PCB (for example your name or board label).
  • Layer → Select where the text appears (Silkscreen, Edge.Cuts, etc.).
  • Font → Choose the KiCad font style.
  • Width / Height → Controls the size of the text.
  • Thickness → Controls the line thickness of the letters.
  • Position X / Y → Sets the exact location of the text on the PCB.
  • Orientation → Rotate the text.
  • ✅ This tool is used to add labels, names, logos, or board information on the PCB design.

    To add the logo on the PCB, I used Inkscape. I imported the Fab logo, then used the Bitmap Trace tool to convert the image into a vector. After that, I exported the design as a DXF file and imported it into KiCad.

    This is the same process we used in Week 02 to convert images into vector format for use in design.

    To add an image to the PCB, go to File → Import → Import Graphics in KiCad. Then select the DXF file, import it, and set the required dimensions/scale before placing the image on the PCB.

    After importing the DXF file, I used the Ctrl (Control) key to place and adjust the position of the logo on the PCB. This allowed me to move the imported Fab logo to the correct location on the board in KiCad.

  • Double-click the logo or text to open the properties, then change the layer from Edge.Cuts to F.Cu (copper layer) in KiCad.
  • After that, apply copper fill (zone fill) so the logo or text appears as copper on the PCB.
  • This is how my final PCB looks after designing and routing it in KiCad.

    I gave a fillet to the outer edges of the PCB by right-clicking the edge and selecting the fillet option in KiCad.

    After completing the design, I checked the DRC (Design Rule Check) in KiCad, and there were 0 errors.

    This is the 3D view of my PCB generated in KiCad to visualize how the board will look after manufacturing.

    Designing A case for PCB

    I tried to design a case for the PCB in fusion. I exported the file in pcb editor as step file and opened it in fusion.

    To import file in fusion, open file -> open.

    After importing the file, this is how it appears on the screen

    For the enclosure design, I sketched a 50 mm × 70 mm rectangle and extruded it to 15 mm. After that, I applied the shell operation to achieve a uniform wall thickness of 2 mm.

    To provide a cable connection, I created a sketch on the top surface of the enclosure and extruded it to form an opening, following the methods learned in Week 02.

    Finally, I added a 2 mm fillet to the corners to improve grip and enhance the overall finish of the enclosure.

    To enhance both the grip and aesthetics, I created a surface texture using a patterned design and extruded it to a height of 0.1 mm.

    This is the final output after rendering. For the top layer, I am planning to use acrylic, and the remaining body parts will be 3D printed. In the appearance settings, I applied a clear glass material to the top layer to represent acrylic and a standard black finish to the main body

    Conclusion

    In Week 6, I learned PCB design using KiCad, including schematic design and routing. I simulated my circuit in Wokwi before fabrication to test its functionality. After making the PCB, I also designed a protective enclosure for it. This week improved my skills in PCB design, simulation, and integration of electronics with mechanical design.

    HERO SHOT:01

    HERO SHOT:02

    Useful links

  • wokwi - for electronic simulation
  • arduino - codeing
  • RP2040 data sheet - RP2040 data sheet
  • Download Files

  • pcb zip - PCB ZIP
  • pcb case (F3D) - Fusion 360 design file
  • pcb case (STl) - Fusion 360 design file
  • Fab logo (DXF) - Fab Logo design file