PROMPT TO DEEPSEEK I need a complete step-by-step guide for designing a capacitive touch sensor PCB in KiCad that I can fabricate on a CNC milling machine. The board should have two independent touch pads in custom shapes (I want to use the Aquarius constellation symbol), each connected to a 4-pin header with shared ground and power for connecting to another board. The guide should include: 1. The complete circuit design with resistor values and detailed explanation of WHY each resistor is needed and how the values are calculated. 2. Step-by-step KiCad workflow including: - How to create a custom footprint for the Aquarius-shaped touch pads - How to create and link symbols for the touch pads - Complete schematic wiring showing both touch pads, resistors, and headers - PCB layout guidelines including trace widths, component placement, and grounding strategy - How to generate Gerber files and prepare PNGs for CNC milling -------------------------------------------------- DEEPSEEK'S RESPONSE This guide provides a complete workflow for designing and fabricating a capacitive touch sensor PCB with custom Aquarius constellation-shaped pads. You'll learn the circuit theory, KiCad design steps, and CNC milling preparation. --- ## Theory of Operation: How It Works Capacitive touch sensing relies on measuring the tiny change in capacitance when a finger approaches a conductive pad. Your finger acts as the second plate of a capacitor, with the PCB pad as the first plate and the PCB solder mask (or air) as the dielectric. The circuit uses the **RC charge/discharge time method**: 1. A microcontroller pin drives the touch pad through a series resistor 2. The pin is switched to an input to measure how long it takes the voltage to rise (charge time) 3. When a finger touches the pad, the additional capacitance increases this charge time 4. The microcontroller detects this change and registers a "touch" ``` [Microcontroller Pin] ---[Resistor]--- [Touch Pad] | (Finger Capacitance) | [GND] ``` --- ## 1. Circuit Design and Component Selection ### Complete Schematic Your circuit requires: - Two independent touch channels (Aquarius Pad 1 and Pad 2) - One series resistor per channel (R1, R2) - Optional ESD protection components (recommended) - 4-pin header for external connection (Power, Ground, Signal 1, Signal 2) ### Component Values and Calculations | Component | Value | Purpose | Calculation | |-----------|-------|---------|-------------| | **R1, R2 (Series Resistors)** | 1MΩ (1,000,000 Ω) | Forms RC time constant with pad capacitance; limits current for ESD protection | R = t / (C × ln(V/V₀)). With target charge time ~10µs, C ~10pF, R ≈ 1MΩ. Higher R = more sensitivity | | **R3, R4 (Optional Protection)** | 100Ω-470Ω | Current limiting if using external ESD diodes | Not critical; choose based on available parts | | **D1, D2 (ESD Protection)** | BAT54S or similar | Clamps voltage spikes from ESD strikes to power rails | Required for reliable operation with exposed copper | ### Why Each Resistor is Needed **R1 and R2 (1MΩ):** These are the critical sensing resistors. When the microcontroller pin switches from output (charging) to input (measuring), the resistor and pad capacitance form an RC circuit. The charge time τ = R × C. With no touch, C ≈ 10-20pF (pad + trace). With finger touch, C increases by 5-10pF, making τ measurably longer. Without this resistor, the pin would charge instantly and no change could be detected. The 1MΩ value provides: - Adequate sensitivity for finger detection - Protection against ESD by limiting current - Compatibility with most microcontroller input leakage specs **Optional Protection Resistors (R3, R4):** If using external ESD protection diodes, these limit current through the diodes during an ESD event, preventing damage. **Power Supply Decoupling (C1, 0.1µF):** Not shown in simplified schematic but critical for stable operation. Place between VCC and GND close to the header. --- ## 2. KiCad Workflow - Complete Step-by-Step ### Prerequisites - KiCad 7.0 or newer installed - Basic familiarity with the KiCad interface ### Step 1: Create the Custom Touch Pad Footprint 1. **Open Footprint Editor** from the KiCad main window 2. **Create new footprint**: File → New → Name it "Aquarius_TouchPad" 3. **Set footprint properties**: - Set pad type to "SMD" (Surface Mount) - Set layer to "F.Cu" (Front copper) 4. **Import your Aquarius constellation graphic**: - Convert your constellation image to a DXF file using Inkscape or similar - In Footprint Editor: File → Import → Graphics → Select your DXF - Scale to desired size (recommended minimum 10mm × 10mm for reliable sensing) 5. **Convert graphic to copper area**: - Select the imported graphic elements - Right-click → Create from Graphic → Zone - Alternatively, use the "Add Filled Zone" tool and trace the constellation shape by placing points 6. **Add the connection pad**: - Place a small SMD pad (rectangular, ~1.5mm × 1.5mm) near the shape - Connect it to the filled zone by drawing a copper trace - This pad will be the connection point for your routing 7. **Add the solder mask opening**: - Ensure the entire constellation shape has "F.Mask" layer enabled for copper exposure - In the zone properties, verify "Solder mask" is set to "Clearance" to expose copper ### Step 2: Create and Link Schematic Symbols 1. **Open Schematic Editor** in your new project 2. **Create custom symbol** for your touch pads: - Symbol Editor → New Symbol → Name "AQUARIUS_PAD" - Add a single pin (type: Passive, electrical type: Passive) - Draw a simple rectangle for the symbol 3. **Add components from libraries**: - Resistor: use standard R (from Device library) - Header: Conn_01x04 (from Connector library) 4. **Wire the schematic**: - Connect Pad1 → R1 → Header Pin 1 (Signal 1) - Connect Pad2 → R2 → Header Pin 2 (Signal 2) - Connect Header Pin 3 to GND net - Connect Header Pin 4 to VCC net - Add a 0.1µF capacitor between VCC and GND at the header ### Step 3: PCB Layout Guidelines **Design Rule Settings** (for CNC milling compatibility): - File → Board Setup → Net Classes - Set Clearance: 0.4mm (minimum 0.3mm for reliable milling) - Set Track Width: 0.3mm (12 mils) - recommended minimum for 1/64" end mill **Trace Routing Guidelines**: | Parameter | Recommendation | Reason | |-----------|---------------|--------| | Trace width | 0.3mm - 0.5mm | Narrower traces risk breakage during milling | | Trace spacing | 0.4mm minimum | Prevents shorts if milling alignment is slightly off | | Via size | 1.2mm pad, 0.8mm hole | Larger vias are more reliable with CNC drilling | | Corner radius | 0.5mm minimum | Sharp corners can cause milling issues | **Placement Strategy**: 1. **Place the 4-pin header** near one edge for easy access 2. **Place resistors** close to the header (within 10mm) 3. **Position touch pads** away from other components (minimum 5mm spacing) 4. **Keep traces short** from resistors to pads to minimize stray capacitance 5. **Use 45° angles** for traces, never 90° corners **Grounding Strategy**: The most important layout consideration for capacitive touch is managing ground: 1. **Create a ground plane** on the bottom layer (B.Cu) covering most of the board 2. **Avoid placing ground copper directly under touch pads** - this creates unwanted capacitance 3. **Use a "hatched" ground plane** under the pads if needed for mechanical support 4. **Connect all ground points** with short, direct paths **Pouring the Ground Plane**: 1. Switch to B.Cu layer 2. Use "Add Filled Zone" tool 3. Draw a rectangle covering the entire board 4. In zone properties: - Set net to GND - Set clearance to 0.4mm - Choose "Solid fill" for standard copper, or "Hatched" if you need flexibility ### Step 4: Generate Gerber Files and CNC Outputs **Gerber Files (for reference/archiving)**: 1. File → Fabrication Outputs → Gerber (.gbr) 2. Select layers: F.Cu, B.Cu, F.SilkS, F.Mask, Edge.Cuts 3. Click "Plot" **CNC Milling Preparation**: The CNC mill requires black and white PNG images: white = copper to keep, black = copper to remove. 1. **Export F.Cu layer as PNG**: - File → Export → SVG - Select "F.Cu" and "Edge.Cuts" only - Use 1000 DPI resolution for accuracy 2. **Convert to black and white**: - Open SVG in GIMP, Inkscape, or Photoshop - Invert colors (so copper areas become white) - Remove all colors except black/white - Export as PNG 3. **Export the outline separately**: - Create another export with only Edge.Cuts layer - Convert to PNG (copper removed = black, board area = white) - This defines where to cut through the board 4. **Alternative using gerber2img tool** (recommended): - Export standard Gerber files first - Use Quentin's gerber2img tool: http://gerber2img.cba.mit.edu/ - Upload F.Cu.gbr and EdgeCuts.gbr - Select "Black and White" output - Download the generated PNG images --- ## 3. CNC Milling Setup and Parameters ### Machine Preparation 1. **Secure the copper-clad board** with double-sided tape on the bottom 2. **Set the X, Y, and Z origin** using the machine controls 3. **Install the 1/64" end mill** for trace routing ### Generating G-Code with ModsProject 1. **Open modsproject.org** in a browser 2. **Right-click** → Programs → select your machine (e.g., "Roland SRM-20 milling") → "mill 2D PCB" 3. **Configure for trace milling (1/64" bit)** : - Upload the F.Cu PNG file - Select "mill traces (1/64)" from the dropdown - Set parameters: ``` Speed: 3 mm/s Jog height: 5 mm Offset: 4 (for trace isolation) ``` 4. **Calculate and save** the toolpath: - Click "Calculate" to generate preview - Download the resulting .rml or .nc file 5. **Configure for outline milling (1/32" bit)** : - Upload the Edge.Cuts PNG file - Select "mill outline (1/32)" - Set parameters: ``` Speed: 0.5 mm/s (slower to prevent bit breakage) Cut depth: 1.6mm (for standard 1.6mm board) Passes: 2-3 (multiple shallow passes are safer) ``` ### Milling Process 1. **Run trace milling first** with 1/64" bit 2. **Inspect** with magnifier or multimeter for shorts/breaks 3. **Switch to 1/32" bit** for outline cutting 4. **Run outline passes** until board is fully cut through --- ## 4. Soldering and Assembly After milling: 1. **Clean the board** with isopropyl alcohol to remove debris 2. **Solder the resistors** (1MΩ) close to the header 3. **Solder the 4-pin header** 4. **Optional: Add ESD protection diodes** if you have them 5. **Inspect for solder bridges** using magnification --- ## 5. Microcontroller Code Example (Arduino) ```cpp // Capacitive touch sensor for Aquarius constellation pads // Connect Pad1 to pin 2, Pad2 to pin 3 const int TOUCH_PAD_1 = 2; const int TOUCH_PAD_2 = 3; const int THRESHOLD = 50; // Adjust based on testing void setup() { Serial.begin(9600); pinMode(TOUCH_PAD_1, INPUT); pinMode(TOUCH_PAD_2, INPUT); } void loop() { int value1 = readCapacitivePin(TOUCH_PAD_1); int value2 = readCapacitivePin(TOUCH_PAD_2); if (value1 > THRESHOLD) { Serial.println("Aquarius Pad 1 TOUCHED"); } if (value2 > THRESHOLD) { Serial.println("Aquarius Pad 2 TOUCHED"); } delay(50); } // Modified from http://playground.arduino.cc/Main/CapacitiveSensor uint8_t readCapacitivePin(int pinToMeasure) { volatile uint8_t* port; volatile uint8_t* ddr; volatile uint8_t* pin; byte bitmask; // Map Arduino pin to AVR registers // [pin mapping code from reference implementation] // Discharge the pin *port &= ~(bitmask); *ddr |= bitmask; delay(1); // Make pin input and measure charge time *ddr &= ~(bitmask); int cycles = 16000; for(int i = 0; i < cycles; i++) { if (*pin & bitmask) { cycles = i; break; } } // Discharge again *port &= ~(bitmask); *ddr |= bitmask; return cycles; } ``` --- ## 6. Troubleshooting Common Issues | Problem | Likely Cause | Solution | |---------|--------------|----------| | No touch detection | Resistor value too low | Increase to 2.2MΩ or 10MΩ | | False triggers | Stray capacitance | Add ground plane, shorten traces | | Milling shorts | Clearance too small | Increase to 0.4mm minimum | | Traces lifting | Feed rate too fast | Reduce speed to 2-3 mm/s | | ESD damage | No protection | Add BAT54S diodes or use solder mask over pads | --- ## Summary Checklist - [ ] Design Aquarius constellation footprint in Footprint Editor - [ ] Create schematic with two channels, resistors, and 4-pin header - [ ] Assign footprints to all components - [ ] Layout PCB with 0.3mm traces, 0.4mm clearance - [ ] Add bottom ground plane - [ ] Run Design Rule Check (no errors) - [ ] Export Gerbers for reference - [ ] Export F.Cu and Edge.Cuts as PNG at 1000 DPI - [ ] Generate G-code in modsproject for 1/64" and 1/32" bits - [ ] Mill traces first, inspect, then mill outline - [ ] Solder components and test The completed PCB will feature two custom Aquarius constellation touch pads that respond reliably to finger proximity. The design can be fabricated entirely in-house using a desktop CNC milling machine without requiring professional PCB fabrication services. ---- SOURCES CITED BY DEEPSEEK https://fabacademy.org/2024/labs/barcelona/students/andrea-rubio/assignments/w11-inputs.html https://www.electronicdesign.com/technologies/analog/article/21756171/series-resistors-body-capacitance-scan-16-buttons-with-two-mcu-pins https://learn.bela.io/tutorials/trill-sensors/designing-a-custom-flex-sensor/#1-download-the-kicad-trill-flex-libraries https://fab.cba.mit.edu/classes/863.24/people/HyeJunYoun/week6/week6.html https://hester.mtholyoke.edu/idesign/SensorTouch.html https://forum.kicad.info/t/exposed-copper-touch-button/34844/13 https://fab.cba.mit.edu/classes/863.23/CBA/people/Cayden/week6.html https://forum.kicad.info/t/capacitive-touch-sensor-design/43723/10 https://news.eeworld.com.cn/mcu/ic485756.html https://forum.kicad.info/t/exposed-copper-touch-button/34844/6