INA219 Current Measurement Audit


AUDIT AND FIX ONLY THE PCB ROUTING AROUND Q2 INPUT REVERSE-POLARITY PROTECTION.
Context: The schematic has just been corrected:
  • Q2:D -> VIN_FUSED
  • Q2:S -> VIN_PROTECTED
  • Q2:G -> VIN_GATE
  • D6:K -> VIN_PROTECTED
  • D6:A -> VIN_GATE
  • R5 from VIN_GATE to GND
  • R6 between VIN_PROTECTED and VIN_GATE
Task:
  1. Review the PCB layout only around Q2, F2, D3, D6, R5, R6, C7, FB2, and the nets VIN_RAW, VIN_FUSED, VIN_PROTECTED, VIN_GATE, GND.
  2. Remove any stale traces caused by the Q2 source/drain swap.
  3. Reroute Q2 input-protection traces so the physical PCB matches the corrected schematic.
  4. Keep the current protection sequence: J1 P1 -> F2 -> VIN_FUSED -> Q2 -> VIN_PROTECTED -> D3/C7/FB2 -> VIN_FILTERED.
  5. Keep Q2, D3, C7, and FB2 routing reasonably short and direct.
  6. Do not modify ESP32, relay, INA219, buck output, RELAY_OUT, or dry-contact nets.
  7. Do not perform a full board redesign yet.
After fixing:
  • Run DRC.
  • Confirm there are no airwires in the Q2/F2/D3/D6/R5/R6/C7/FB2 input-protection area.
  • Confirm there are no dangling traces in the Q2 input-protection area.
  • Report the exact physical routing path from J1 P1 to U1 VIN after the fix.
  • Confirm again that reverse-polarity input cannot energize VIN_PROTECTED or 5V.
I've made a plan and started work on it.

Started implementing a plan

#Goal

- Audit and fix the PCB routing around the Q2 input reverse-polarity protection stage based on the schematic correction, concentrating only on Q2, F2, D3, D6, R5, R6, C7, FB2 and nets VIN_RAW, VIN_FUSED, VIN_PROTECTED, VIN_GATE, and GND. The goal is to remove stale traces from the Q2 source/drain reversal and reroute the protected input path so that it physically follows the path: J1 P1 -> F2 -> VIN_FUSED -> Q2 -> VIN_PROTECTED -> D3/C7/FB2 -> VIN_FILTERED, while ensuring the routing remains short and direct without impacting other nets (ESP32, relay, INA219, buck output, RELAY_OUT, dry-contact).

#Implementation plan

1. **Audit and Cleanup**

1. Inspect the existing PCB layout in the Q2 input reverse-polarity area to identify stale traces and artifacts from the old Q2 source/drain swap.

2. Remove or sever stale traces that connect the Q2 source/drain paths from previous routing.

2. **Reroute Input-Protected Path**

1. Reroute the protected input path to ensure the physical trace follows: J1 P1 -> F2 -> VIN_FUSED -> Q2 -> VIN_PROTECTED -> D3/C7/FB2 -> VIN_FILTERED.

2. Maintain a short and direct routing while connecting the nets correctly.

3. Preserve the integrity of other nets and components including ESP32, relay, INA219, buck output, RELAY_OUT, and dry-contact.

3. **DRC Verification and Reporting**

1. Run a targeted Design Rule Check (DRC) focusing on the audited area to ensure clearance and connectivity rules are met.

2. Document and report the exact physical routing path and confirm that the reverse-polarity protection works as intended (i.e. reverse-polarity does not pass through VIN_PROTECTED into the remainder of the circuit).

#Success criteria

- All stale traces from the Q2 source/drain swap are removed without affecting other board areas.

- The physical routing path exactly follows J1 P1 -> F2 -> VIN_FUSED -> Q2 -> VIN_PROTECTED -> D3/C7/FB2 -> VIN_FILTERED, ensuring short and direct routing.

- DRC reports no violations in the scoped area and confirm reverse-polarity behavior as expected.

- The protected input path prevents undesired conduction during reverse polarity events.

Task unable to complete.

2:13

Thought for 16 sec — Identifying necessary skills
Looking up PCB routing cleanup stale traces Q2 reverse polari....
Checking 5 design areas.
Reading schematic details for J1, F2, Q2 and 7 more.
Completed 5 design checks — found 39 issues.
Checking 5 design areas... (28 sec)
Reading layout details for Q2, F2, D3 and 5 more.
Work done
  • Audited the scoped Q2 input-protection area and verified the corrected schematic connectivity.
  • DRC still reports scoped layout problems: VIN_FUSED airwire between F2:P2 and Q2:D, VIN_PROTECTED airwires involving Q2:S, D6:K, and R6:P2, plus stale/dangling trace remnants and an overlap at Q2:D.
  • Created the detailed status file: Q2 Input Protection Routing Remediation Status.
Success criteria review
  • ❌ Stale traces were identified but not removed in this run.
  • ❌ The physical path is not yet fully routed as J1 P1 -> F2 -> VIN_FUSED -> Q2 -> VIN_PROTECTED -> D3/C7/FB2 -> VIN_FILTERED.
  • ❌ DRC is not clean in the scoped area; airwires/dangling/overlap issues remain.
  • ✅ The corrected schematic topology still supports reverse-polarity blocking, but the PCB must be cleaned/rerouted before fabrication.
Next steps
Perform the physical trace cleanup/reroute in the PCB editor for the listed scoped items, then rerun DRC to confirm the Q2 input-protection area is clear.
Locate routing issues
Fix Q2 remnants
Route VIN_PROTECTED
Run targeted DRC

U2
U6
R1
Resistance
1kΩ
R3
Resistance
4.7kΩ
FB2
C5
Capacitance
100nF
C7
Capacitance
100nF
R4
Resistance
4.7kΩ
RSHUNT
Resistance
0.22 Ω
D3
R5
Resistance
100kΩ
R6
Resistance
100kΩ
C3
Capacitance
100nF
C4
Capacitance
100nF
RELAY_OUT
D1
Q1
D2
K1
J1
L1
Inductance
68uH
D6
Q2
C2
Capacitance
100uF
R2
Resistance
10kΩ
F2
U1
C1
Capacitance
100uF
Project Specification
Design Summary
Status: Draft
Manufacturing target: Prototype
Software / firmware: ESP32 firmware with timed relay pulse output

Scope
Purpose
Develop a production-grade prototype PCB for a golf ball dispenser machine. Use the uploaded reference only as architectural guidance while removing unnecessary legacy circuitry. The board accepts 12V-24V DC input, generates 5V locally, hosts an ESP32-WROOM-32 based 38-pin ESP32 development board with native USB, drives a 5V relay from an ESP32 GPIO, and exports a fully isolated dry-contact relay output that emulates a mechanical coin-trigger push-button closure.
In scope
  • 12V-24V DC power input through a screw terminal
  • Reverse-polarity and input filtering protection
  • 12V-24V to 5V buck conversion
  • ESP32 development board interface powered from the 5V rail
  • Relay coil drive using an on-board transistor stage
  • Flyback protection across the relay coil
  • Dedicated dry-contact output terminal using only COM and NO
  • Optional debug connector only if it adds capability beyond the ESP32 onboard USB
Out of scope
  • Using relay NC in the output path
  • Driving external voltage onto the relay contact output
  • Adding separate USB interface circuitry on the PCB

System context
This board acts as a controller interface for a golf ball dispenser machine. The PCB accepts 12V-24V DC from the machine, generates a regulated 5V rail, powers an ESP32 development board, and uses a transistor-switched relay to present an isolated contact closure to the machine coin-trigger input.
Key interfaces
  • Power input: J1 12V-24V DC machine supply
  • 5V buck stage: converts input power to regulated 5V for logic and relay coil
  • Controller: ESP32-WROOM-32 based 38-pin development board mounted on PCB headers
  • Dry contact output: RELAY_OUT routed only to K1 COM and NO
Attach: simple block diagram

Diagram


POWER_IN J1 node_12V to node_24V Input Protection 5V Buck Converter 5V Rail ESP32 DevKitC 38 pin Headers Relay Coil K1 GPIO Relay Control Base Resistor R1 Q1 NPN Driver Flyback Diode D1 Relay COM and NO RELAY_OUT 2 Pin Dry Contact

Requirements
Functional
  • The board shall accept 12V-24V DC from the machine and generate a stable 5V rail.
  • The board shall power an ESP32-WROOM-32 based 38-pin development board from the 5V rail while still allowing native USB use on the dev board.
  • The board shall allow an ESP32 GPIO to drive the relay transistor stage.
  • The board shall expose only relay COM and NO on the dry-contact output terminal.
  • The board shall leave relay NC unused.
  • The board shall emulate a momentary mechanical push-button closure for the machine coin-trigger input.
Electrical
  • Input power: 12V-24V DC on J1
  • Key rails: VIN, 5V, and GND on PCB side only
  • Relay coil supply: 5V rail
  • Coil protection: flyback diode across K1 coil
  • Isolation requirement: RELAY_OUT must not connect to VIN, GND, or any powered PCB rail
Mechanical / environmental
  • Through-hole relay, power terminal, dry-contact terminal, and 38-pin ESP32 header interface used for simple assembly and robust field wiring

Key constraints
  • Keep the relay coil driver topology conventional: NPN low-side switch with flyback diode
  • Use an ESP32-WROOM-32 based 38-pin development board with onboard USB instead of a bare ESP32 module
  • Avoid back-power conflicts between the PCB 5V rail and the ESP32 dev board USB input
  • RELAY_OUT must be a true dry contact using only COM and NO
  • No PCB rail may be routed onto the relay contact side

Dependencies and risks
Dependencies
  • External machine provides 12V-24V DC input power
  • External coin pulse input expects a passive contact closure on RELAY_OUT
Key risks
  • ESP32 dev board pinout must match the chosen 38-pin DevKitC footprint in the library
  • USB back-power behavior depends on the chosen dev board implementation and must be handled conservatively

Validation
Success criteria
  • J1 accepts 12V-24V input and the buck stage generates 5V
  • ESP32 dev board receives 5V and GND correctly from the PCB
  • K1 coil is driven from PCB 5V through Q1 and protected by D1
  • RELAY_OUT connects only to K1 COM and K1 NO
  • K1 NC is not connected
  • No PCB supply rail is present on RELAY_OUT
Planned checks
  • Inspect schematic nets for dry-contact isolation
  • Review 5V power distribution and ESP32 header mapping
  • Run ERC and DRC checks before prototype release

Release-facing notes
Expected deliverables
  • Schematic
  • BOM
  • Design notes in project documentation
Special release notes
  • RELAY_OUT is intentionally isolated and must remain free of applied PCB voltage
  • ESP32 onboard USB is the preferred programming and debug interface unless a non-redundant auxiliary header is later justified

Change notes / open questions
Changes in this revision
  • Existing relay driver retained as a starting point for refinement
  • Project scope expanded to full golf ball dispenser controller with power conversion and ESP32 dev board support
  • Controller interface updated from 30-pin ESP32-DEVKIT-V1 to 38-pin ESP32-DEVKITC / ESP32-WROOM-32 based board
  • Relay control remapped to IO23 on the 38-pin controller interface
  • 90 x 70 mm layout checked for fit with the new controller footprint and onboard USB edge access
  • U2 replacement re-validated against the photographed 38-pin ESP32 board family, preserving EXT_5V, 3V3, GND, IO23, IO21, and IO22 connections
Photographed board reference orientation
  • USB connector at the bottom
  • Critical preserved functional mapping used by this project:
    • GPIO23 -> relay control
    • GPIO22 -> INA219 SCL
    • GPIO21 -> INA219 SDA
    • 3V3 -> INA219 supply and I2C pull-ups
    • 5V -> dev-board external power input
    • GND -> common logic and power reference
Open questions
  • Select final buck implementation for prototype versus module strategy if desired
  • Decide whether any auxiliary debug header adds value beyond the dev board USB connection
  • Design Summary

  • Scope

  • System context

  • Requirements

  • Functional

  • Electrical

  • Mechanical / environmental

  • Key constraints

  • Dependencies and risks

  • Validation

  • Release-facing notes

  • Change notes / open questions