Skip to the content
PCBKitNew board
4 layers172.3 × 57.5 mmPCBDesign, the printed circuit board in 3D

Raspberry Pi multifunction instrumentation — digipot SAR ADC, ±12 V rail, function gens, KiCad Pi HAT (ECSE 2920).

Size
172.3 × 57.5 mm
Copper layers
4
Thickness
1.6 mm
Parts
103
Nets
143
Pads
380
Tracks, vias
801, 30
Pours
3
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
12 Jul 2026
Updated
28 Oct 2026

Overview

PCBDesign is an open-source printed circuit board by nmahadevan12, from the nmahadevan12/MIS repository on GitHub. It is a 4-layer board of 172.3 × 57.5 mm with 103 parts on 143 nets, routed with 801 tracks and 30 vias.

It is built around the TL081, LM339 and 1N4148WT, with the IRF5305PBF and IRFZ34N among its other parts. Its parts include 57 resistors, 21 ICs, 12 capacitors, 9 connectors and 2 diodes.

Main components

5

README

README.md

Multifunction Instrumentation System (M.I.S.)

A portable, Raspberry Pi–powered electronic test bench that replaces six lab instruments — ohmmeter, voltmeter, DC reference, square/sine function generator, and frequency meter — with one integrated DAQ platform.

Platform Language Hardware


Table of Contents


Overview

The Multifunction Instrumentation System integrates oscilloscopes, function generators, and multimeters into a single-board computer platform using the Raspberry Pi 4 as the central processing unit. Custom analog front-end circuits handle signal conditioning, comparison, and generation; Python firmware orchestrates measurement, waveform output, and a responsive menu-driven UI from a single application.

Final test bench assembly

[!TIP] Documentation convention: Images show only schematics, photos, and oscilloscope captures. All objectives, theory, and figure captions are written as markdown text below each image.

At a Glance
ControllerRaspberry Pi 4 (sole processor — no external MCU)
Interface20×4 I²C LCD + KY-040 rotary encoder with pushbutton
Analog front-endTL084/TL081 op-amps, LM339 comparators, MCP4131/MCP4231 digipots
Power24 V DC input → ±12 V virtual-ground split-rail supply
Firmware~970 lines of Python — SAR measurement, hardware PWM, pigpio edge detection
PCB4-layer KiCad hierarchical design with Gerber manufacturing files
Project Objectives
  1. Instrument design

    • Ohmmeter (500 Ω – 10 kΩ)
    • Voltmeter (−5 V to +5 V)
    • DC reference (−5 V to +5 V)
    • Sine wave frequency measurement (1 – 10 kHz)
    • Function generator — square wave (100 Hz – 10 kHz, ±10 V) and sine wave (1 – 10 kHz, 0 – 10 V pk)
  2. System integration

    • ±12 V power supply from 24 V input
    • Software-driven successive-approximation measurement (digipot + comparator)
    • Rotary-encoder UI on 20×4 LCD
  3. PCB layout

    • Full KiCad schematic and 4-layer board design sized to the Raspberry Pi footprint
Design Constraints
CategoryConstraint
SoftwareAll logic in Python; pigpio daemon for timing-critical PWM and edge detection
ControllerRaspberry Pi 4 only — no external microcontrollers
DigipotsMaximum of 4 digital potentiometers (MCP4131 ×3, MCP4231 ×1 dual-channel)
PowerAll analog power derived from 24 V DC (LCD powered separately); Pi via USB-C
MechanicalPi Hat required — all GPIO routed through hat connector

Instrument Summary

InstrumentRangeAccuracyMethod
🔵 Ohmmeter500 Ω – 10 kΩ±10%GPIOs
🟢 Voltmeter−5 V to +5 V±0.2 VGPIOs
🟡 DC Reference−5.00 V to +4.80 V (32 steps)±0.2 VGPIOs
🟠 Square Wave100 Hz – 10 kHz, ±10 V pk±0.1 V amplitude / ±1% freqPWM
🟣 Sine Wave1 – 10 kHz, 0 – 10 V pk±0.1 V amplitude / ±1% freqAudio
🔴 Frequency Meter1 – 10 kHz±1%GPIOs

System Architecture

mermaid
flowchart LR
    subgraph UI["🖥️ User Interface"]
        LCD["20×4 I²C LCD"]
        ENC["Rotary Encoder"]
    end

    subgraph SW["🐍 Python Firmware"]
        MENU["Menu State Machine"]
        SAR["SAR Engine"]
        PWM["Hardware PWM"]
        FREQ["Edge Detection"]
    end

    subgraph HW["⚡ Analog Front-End"]
        PS["±12V Supply"]
        MEAS["Ohm / Volt"]
        GEN["Wave Gen"]
        DCREF["DC Ref"]
    end

    ENC --> MENU --> LCD
    MENU --> SAR & PWM & FREQ
    SAR & PWM & FREQ --> HW
    PS --> HW

Software Architecture

Software is the core of the system — it links the user interface to hardware modules, converts raw comparator signals into resistance/voltage values, controls waveform timing, and keeps the LCD updated.

Platform & Libraries
LayerTechnology
OSRaspberry Pi OS
ExecutionStandalone Python script (Main Code/16.py)
GPIO / PWMRPi.GPIO, pigpio (hardware PWM + µs edge timestamps)
SPIspidev — MCP4131 / MCP4231 digital potentiometers
I²Csmbus2, RPLCD — 20×4 character LCD
UI inputgpiozero — rotary encoder + button callbacks
Navigation & Main Loop

The interface is a stack-based menu tree with automatic hardware cleanup on back-navigation. Measurement modes sample every 500 ms; the LCD refreshes on a 50 ms display flag with thread-safe writes.

To ensure a highly responsive user interface, the 500 ms hardware measurement routines run asynchronously or utilize non-blocking sleep intervals. This prevents the synchronous 8-bit SPI SAR sweeps from blocking encoder interrupt callbacks or delaying the 50 ms LCD UI refresh cycle.

text
while True:
    if display_needs_update → render_interface()
    if measurement_mode     → sample hardware every 500 ms
    if leaving_mode         → cleanup GPIO / stop waveforms
    sleep(0.05)
Per-Instrument Firmware
InstrumentKey Implementation
Square waveHardware PWM GPIO 12 + MCP4231 amplitude/offset over SPI
Sine wavePi audio jack + speaker-test; MCP4131 amplitude (CS GPIO 17)
Ohmmeter8-iter SAR on MCP4131; R = R_known × (step / (128 − step))
VoltmeterSAR on GPIO 6; lookup table + linear interpolation
DC Reference5-bit R-2R on GPIO 14, 15, 18, 23, 24
Frequencypigpio edge callbacks GPIO 25; 100-period buffer, >2σ outlier reject

[!IMPORTANT] All waveform and DC outputs automatically disable when leaving a menu — a built-in safety interlock.


Hardware Design

4.1 ±12 V Power Supply

Power supply schematic

Figure 4.1.1: Power Supply Schematic

Power Supply — Theory & Integration

Objective: Split a +24 V DC input into symmetric +12 V and −12 V rails to power op-amps throughout the system. Rails must remain stable under varying load.

Theory of Operation: Virtual ground from a 24 V source. TL081 unity-gain follower at the 12 V midpoint drives IRFZ34N + IRF5305 push-pull stage. Virtual ground tied to Pi GND → +12 V above, −12 V below. The virtual ground node acts as the absolute 0 V reference point for all analog measurements. To prevent heavy analog return currents from injecting noise into the digital plane, the Raspberry Pi GND is tied to this virtual ground at a single star-ground point right at the power entry terminal.

  1. Voltage reference: Matched 10 kΩ divider + Zener clamping → 12 V at TL081 pin 3
  2. Unity-gain buffering: 100 kΩ feedback drives MOSFET gates
  3. Push-pull output: NMOS sources / PMOS sinks load current at virtual ground
  4. Output stabilization: 220 µF bulk caps per rail

Physical Integration: Breadboard; ±12 V via terminal blocks. GPIO: None — analog only.

Power Supply — Test Results
Test ConditionNegative RailPositive RailCurrent
Both loads connected−12.04 V+12.05 V~12 mA each
No load−12.05 V+12.06 V—
Negative load only12.05 V—12.10 mA
Positive load only—12.06 V12.08 mA

[!WARNING] MOSFETs run warm under heavy load. Observe electrolytic capacitor polarity on each rail.


4.2 Ohmmeter

Ohmmeter schematic

Figure 4.2.1: Ohmmeter Schematic

Ohmmeter — Theory & GPIO

Objective: High-accuracy auto-ranging digital ohmmeter for 500 Ω to 10 kΩ.

Theory of Operation: Voltage divider with unknown resistor vs. 7-bit MCP4131 programmable reference. Successive approximation across 128 wiper steps; LM339 comparator on GPIO 21. LCD updates every 500 ms with ±10% tolerance. A fixed series current-limiting resistor (R_limit = 1 kΩ) is placed in series with the unknown device under test (DUT). This keeps the maximum current through the MCP4131 wiper well below its absolute maximum rating of 2.5 mA even when measuring low resistances down to 500 Ω.

SignalGPIOComponent Pin
Chip Select (CS)8MCP4131 Pin 1
SPI Clock (SCK)11MCP4131 Pin 2
SPI Data (SDI/SDO)10MCP4131 Pin 3
Comparator Output21LM339 Output

[!NOTE] SAR performance (8-bit search): Each iteration writes one MCP4131 wiper step over SPI (1 MHz, 2-byte frame ≈ 16 µs), waits 5 ms for the divider/comparator to settle (sleep(0.005)), then reads GPIO 21. Eight bisection steps → ≈40 ms per resistance reading, well under the 500 ms LCD refresh cadence. Quantization is set by the 128-step digipot (7-bit effective range); resistance resolution is non-linear with step (R = R_known × step / (128 − step)) and tightest near the matched mid-scale point. Because the voltage-divider topology yields a non-linear resolution across the 128-step digipot, measurement precision peaks when the unknown resistance closely matches the internal reference (R_known). Near the outer bounds (500 Ω and 10 kΩ), step-size quantization broadens, which accounts for the specified worst-case ±10% tolerance.


4.3 Voltmeter

Voltmeter schematic

Figure 4.3.1: Voltmeter Schematic

Voltmeter — Theory & GPIO

Objective: Measure −5 V to +5 V at ±0.2 V accuracy. Dual-source: external input or internal DC reference verification.

Theory of Operation:

  1. U2 — Inverting summing amp: Maps −5 V to +5 V → 0 V to −10 V
  2. U1 — Inverting amp: Gain −1/3 → 0 to +3.3 V
  3. U3 — MCP4131: 128-step programmable reference via SPI
  4. U5A — LM339: Comparator with 10 kΩ pull-up
  5. GPIO 6: Binary search until reference matches test voltage
SignalGPIOComponent Pin
Chip Select (CS)8MCP4131 Pin 1
SPI Clock (SCK)11MCP4131 Pin 2
SPI Data (SDI/SDO)10MCP4131 Pin 3
Comparator Output6LM339 Pin 13

[!NOTE] SAR performance (8-bit search): Same 8-iteration binary search as the ohmmeter — one SPI wiper write + 5 ms settle per step → ≈40 ms total sweep, safely below the 500 ms display refresh rate. The ±10 V input span maps to 128 comparator steps, giving a theoretical ≈78 mV/step (10 V / 128 ≈ 78 mV); linear interpolation between calibrated lookup points improves display accuracy to ±0.2 V.

Calibration & Testing: Verified against reference multimeter across full range. SAR converges in 8 iterations. ±0.2 V accuracy; best precision near 0 V.


4.4 DC Reference

DC reference schematic

Figure 4.4.1: DC Ref Schematic

DC Reference — Theory

Objective: Programmable DC output −5 V to +5 V in 0.625 V steps (32 levels).

  1. R-2R DAC: GPIO 14, 15, 18, 23, 24 → binary-weighted divider
  2. U2 — Non-inverting amp: Gain ≈ 3.03 scales 0–3.3 V → 0–10 V
  3. U3 — Difference amp: +5 V bias → −5 V to +5 V output

Calibration & Testing: Output verified across all 32 steps with a reference multimeter. Monotonic response confirmed from −5 V to +5 V.

Previous Design Iteration (Figure 4.4.2)

Previous DC reference schematic

Figure 4.4.2: Previous DC Ref Schematic

Original binary-weighted DAC with per-GPIO comparator buffers suffered cross-loading. R-2R ladder maintains uniform 2R impedance regardless of bit pattern. The R-2R ladder ensures the digital pins always see a constant output impedance of R (or 2R depending on the node), preventing the voltage sag and non-monotonicity caused by varying pin source impedances in the previous binary-weighted layout.


4.5 Square Wave Generator

Square wave generator schematic

Figure 4.5.1: Square Wave Schematic

Square Wave — Theory & GPIO

Objective: Variable square wave centered at 0 V, up to ±10 V, high-Z output for oscilloscope use.

Theory: Pi hardware PWM GPIO 12 → MCP4231 amplitude + offset → difference amplifier (gain 10) → ±10 V. The hardware PWM output from GPIO 12 passes through a dedicated RC low-pass filter stage to smooth high-frequency switching transients and stabilize the signal envelope before amplitude scaling, maintaining waveform integrity across the 100 Hz to 10 kHz band.

SignalGPIOMCP4231 Pin
PWM Output12Ch1 Pin B
Chip Select7Pin 1
SPI Clock11Pin 3
SPI Data In10Pin 4

Calibration & Testing:

  • Figure 4.5.2 — ±7 V initial: −7.24 V min / +5.95 V max (miscentered)
  • Figure 4.5.3 — ±5 V @ 100 Hz: Offset ratio 0.45 → ±3% centering
  • Figure 4.5.4 — ±10 V @ 100 Hz: Full swing confirmed
Oscilloscope Captures

Oscilloscope — square wave at 1 kHz during initial characterization

Oscilloscope — ±5 V square wave at 100 Hz, final result

Oscilloscope — ±10 V square wave at 100 Hz, final result


4.6 Sine Wave Measurement (Frequency Meter)

Sine wave measurement schematic

Figure 4.6.1: Sine Wave Measurement Schematic

Frequency Meter — Theory & GPIO

Objective: Measure 0 V to +10 V sine input frequency from 1 kHz to 10 kHz.

Theory: LM339 threshold at +1.65 V → digital edges on GPIO 25 → f = 1/T. 100-period rolling buffer with >2σ outlier rejection.

pigpio edge architecture: On standard Linux (non-real-time), Python thread scheduling would jitter any bit-banged timing. The pigpio daemon sidesteps this by sampling GPIO transitions with hardware-level DMA, stamping each rising edge with a microsecond-accurate tick (pigpio.tickDiff) in a background buffer. The Python callback only appends period samples; compute_frequency() runs on the 500 ms UI loop, decoupling the timing-critical edge capture from GIL contention and kernel scheduling delay.

SignalGPIOComponent Pin
Comparator Output25LM339 Output
External Input—LM339 Non-Inverting Input
Reference (+1.65 V)—LM339 Inverting Input

Calibration & Testing: ±2% tolerance across 1 – 10 kHz.


4.7 Sine Wave Generator

Sine wave generator schematic

Sine Wave Generator — Theory & GPIO

Objective: 0 – 10 V peak sine wave from 1 kHz to 10 kHz.

  1. U3 — TL081 buffer: Pi audio jack + −5 V DC offset
  2. U4 & U5 — Scaling: Normalize to 0–3.3 V. Because the Raspberry Pi audio jack outputs a line-level AC signal (≈1 V pk-pk), U4 is configured as a non-inverting amplifier with a hardware gain of A_v ≈ 3.3 to scale the raw audio voltage up to the required 3.3 V internal logic dynamic range before attenuation.
  3. U10 — MCP4131: Digital attenuation via SPI
  4. U11 & U12 — Output: Reconstruct to 0–10 V
SignalGPIOMCP4131 Pin
Chip Select17Pin 1
SPI Clock11Pin 2
SPI Data10Pin 3

PCB Design (KiCad)

Hierarchical PCB schematic

Figure 5.2.1: Final PCB Schematic

PCB board layout

Figure 5.2.2: Final PCB Board

PCB Design Details
  • CAD tool: KiCad — free, full-featured
  • Schematic: Hierarchical sub-sheets per instrument; max 4 layers
  • Layout: Subsystem grouping, through-hole + SMD passives, 45° routing
  • Manufacturing: DRC-checked Gerbers in PCBDesign/ (designed, not manufactured)

GPIO Pin Map (System)

Full GPIO Map — click to expand
GPIOSignalComponentDescription
2, 3SDA, SCLLCDI²C character display
6InputLM339Voltmeter comparator
7SPI CSMCP4231Square wave digipot
8SPI CSMCP4131Ohmmeter / voltmeter digipot
10SPI MOSIMCP4131/4231SPI data
11SPI SCLKMCP4131/4231SPI clock
12HW PWM—Square wave output
13, 19InputKY-040Rotary encoder A/B
14, 15, 18, 23, 24OutputR-2R ladderDC reference (5-bit)
17SPI CSMCP4131Sine amplitude digipot
21InputLM339Ohmmeter comparator
25InterruptLM339Frequency measurement
26InputKY-040Encoder button (3 s hold = back)

Getting Started

[!NOTE] GPIO access requires sudo. The pigpio daemon must be running for PWM and frequency measurement.

Install & Run
bash
sudo apt update && sudo apt install -y python3-pip pigpio python3-pigpio alsa-utils
sudo systemctl enable --now pigpio
pip install -r requirements.txt
sudo python3 "Main Code/16.py"
Controls Cheat Sheet
ActionControl
ScrollRotate encoder
Select / confirmShort press
Back / cancelHold 3 seconds
Edit valueRotate in edit mode, press to confirm

Power Pi via USB-C, analog circuits via 24 V DC. Wait ~20 s after boot.


Demo Videos

Watch demos — click any link
FeatureLink
Power-on & setupYouTube
Menu navigationYouTube
OhmmeterYouTube
Voltmeter (external)YouTube
Voltmeter (internal ref)YouTube
Square waveYouTube
Sine waveYouTube
Frequency measurementYouTube

Future Improvements

[!TIP] Planned next steps: 12–16 bit external ADC, manufactured 4-layer PCB with ground planes, BNC/screw-terminal I/O, on-board regulators, active analog shielding.


Skills Demonstrated

Embedded Systems

  • GPIO, hardware PWM, SPI/I²C
  • pigpio edge detection
  • SAR algorithms
  • Thread-safe concurrent access

Software Engineering

  • State-machine UI
  • Stack navigation
  • Lookup tables
  • ~970 LOC firmware

Analog Design

  • Op-amp conditioning
  • Comparator front-ends
  • R-2R DAC
  • Virtual-ground power

PCB / Systems

  • KiCad hierarchical design
  • 4-layer layout
  • End-to-end HW/SW co-design
  • Safety interlocks

Parts

103
QtyValueFootprintReferences
2510kResistor_SMD:R_0603_1608MetricR1, R2, R3, R5, R17, R18, R20, R21, R33, R34, R37, R39, R42, R46, R48, R49 +9
15TL081Package_DIP:DIP-8_W7.62mmU3, U4, U5, U6, U9, U10, U12, U13, U14, U16, U17, U18, U19, U21, U22
720kResistor_SMD:R_0603_1608MetricR40, R54, R56, R58, R60, R62, R64
610000Resistor_SMD:R_0603_1608MetricR27, R29, R30, R31, R32, R65
6470uFCapacitor_SMD:CP_Elec_4x3C13, C14, C19, C25, C31, C32
41uFCapacitor_SMD:CP_Elec_4x3C11, C12, C17, C18
3100kResistor_SMD:R_0603_1608MetricR19, R35, R36
31kResistor_SMD:R_0603_1608MetricR11, R13, R16
3220Resistor_SMD:R_0603_1608MetricR7, R8, R10
2160Resistor_SMD:R_0603_1608MetricR12, R14
21N4148WTDiode_SMD:D_SOD-523D1, D2
2200µFCapacitor_SMD:C_0603_1608MetricC1, C2
2MCP4131Package_DIP:DIP-8_W7.62mmU2, U7
11.6kResistor_SMD:R_0603_1608MetricR38
11.788kResistor_SMD:R_0603_1608MetricR47
1100Resistor_SMD:R_0603_1608MetricR15
120300Resistor_SMD:R_0603_1608MetricR28
124V DC power SupplyConnector_BarrelJack:BarrelJack_HorizontalJ2
12kResistor_SMD:R_0603_1608MetricR9
130kResistor_SMD:R_0603_1608MetricR4
132.2kResistor_SMD:R_0603_1608MetricR53
15kResistor_SMD:R_0603_1608MetricR41
1AudioJack3Connector_Audio:Jack_3.5mm_CUI_SJ1-3533NG_HorizontalJ8
1DC_VOLTAGE_OUPUTConnector_PinHeader_1.00mm:PinHeader_1x01_P1.00mm_VerticalJ5
1IRF5305Package_TO_SOT_THT:TO-220-3_VerticalQ2
1IRFZ34NPackage_TO_SOT_THT:TO-220-3_VerticalQ1
1LM339Package_DIP:DIP-14_W7.62mmU1
1MCP4131-xxxx-PPackage_DIP:DIP-8_W7.62mmU20
1MCP4231Package_DIP:DIP-14_W7.62mmU11
1PiHeaderFConnector_PinSocket_2.54mm:PinSocket_2x20_P2.54mm_VerticalJ1
1RESISTANCE_INPUTConnector_PinHeader_1.00mm:PinHeader_1x01_P1.00mm_VerticalJ4
1SINE_WAVE_MEASUREMENT_INPUTConnector_PinHeader_1.00mm:PinHeader_1x01_P1.00mm_VerticalJ7
1SINE_WAVE_OUPUTConnector_PinHeader_1.00mm:PinHeader_1x01_P1.00mm_VerticalJ10
1SQUARE_WAVE_OUPUTConnector_PinHeader_1.00mm:PinHeader_1x01_P1.00mm_VerticalJ6
1TL081Package_DIP:DIP-8_W7.62mm_LongPadsU8
1VOLTAGE_INPUTConnector_PinHeader_1.00mm:PinHeader_1x01_P1.00mm_VerticalJ3

Questions

How big is the PCBDesign PCB?

It measures 172.3 × 57.5 mm and has 4 copper layers, 1.6 mm thick.

What parts does the PCBDesign use?

103 parts, built around the TL081, LM339, 1N4148WT and IRF5305PBF. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the PCBDesign KiCad files?

From the nmahadevan12/MIS repository on GitHub, at the commit this page was made from: the board is Individual Components/8 - PCB Design/PCBDesign/PCBDesign.kicad_pcb and its schematic Individual Components/1 - Power Supply/Final_Power_Supply.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the PCBDesign design in my own project?

Its repository states no licence, so its author keeps all rights: ask nmahadevan12 before reusing the design.

Similar boards

  • 2 layers99.7 × 99.7 mmPetpuller, the printed circuit board in 3D

    Petpuller

    Kaminariss/petpuller

    52 parts3
  • 2 layers305 × 107 mmApc smartups420sc, the printed circuit board in 3D

    Apc smartups420sc

    rhowe/apc-smartups420sc

    Reverse engineering the APC SmartUPS 420 SC

    301 parts
  • 2 layersFinalPCB, the printed circuit board in 3D

    FinalPCB

    AndrewPrimi/Group-5

    This repository is used to store coursework, scripts, and supporting materials for our electronics and embedded systems projects throughout the semester.

    70 parts
  • 4 layers184.2 × 169.5 mmSB mini II, the printed circuit board in 3D

    SB mini II

    simonboak/SB-mini-II

    A homebrewed Apple II clone

    97 parts76MIT
  • 2 layers242 × 60 mmRoothubs, the printed circuit board in 3D

    Roothubs

    gkiefer/home2l

    The Home2Ls - Smart Tools for a Private Home

    178 parts21
  • 2 layers160 × 95 mmPlaca Control Fuentes y Carga, the printed circuit board in 3D

    Placa Control Fuentes y Carga

    edgranzella/Placa-de-Corte-TX

    Circuito Impreso de la plaquetita de Corte TX que va apilada sobre el Arduino Nano de la placa Controladora de Fuentes y Carga.

    142 parts
  • 2 layers74.7 × 69.1 mmThrottle tune, the printed circuit board in 3D

    Throttle tune

    Jonny999999/throttle-tune

    onversion of an old gasoline lawn tractor to an electric vehicle

    51 parts