No description
  • C++ 65.7%
  • C 31.1%
  • Objective-C 3.2%
Find a file
2026-08-28 13:54:01 +01:00
.vscode docs: add fan controller and portable USBasp upload 2026-07-21 19:33:31 +01:00
docs add calibrated output lead compensation 2026-08-28 13:54:01 +01:00
firmware/backups docs: capture tested ADS-ready working baseline 2026-07-21 15:15:26 -06:00
lib fix: restore ADS1115 ready interrupt acquisition 2026-07-21 14:46:54 -06:00
src add calibrated output lead compensation 2026-08-28 13:54:01 +01:00
.gitattributes docs: capture tested ADS-ready working baseline 2026-07-21 15:15:26 -06:00
.gitignore chore: make PlatformIO project portable 2026-07-21 19:15:56 +01:00
AGENTS.md docs: preserve v1.4.0 device baseline and roadmap 2026-07-21 20:10:45 +01:00
platformio.ini add calibrated output lead compensation 2026-08-28 13:54:01 +01:00
README.md add calibrated output lead compensation 2026-08-28 13:54:01 +01:00

Pocket DC Supply

Firmware and hardware documentation for a compact adjustable DC power supply based on an ATmega328P and an XL4015 buck converter.

The fast constant-voltage and constant-current loops are implemented in analog hardware. The firmware provides the user interface, setpoint DAC control, measurements, slow output correction, fan control, temperature monitoring, and operating modes.

Main hardware

  • ATmega328P-AU, 16 MHz, 5 V
  • XL4015 buck converter
  • two MCP4725 DACs for voltage and current setpoints
  • ADS1115 ADC for output measurements
  • LM75 temperature sensor
  • 16x2 HD44780-compatible LCD with an I2C backpack at 0x3F
  • separate I2C fan-control module at 0x31
  • USBasp ISP programmer

The current hardware schematic is available at docs/hardware/Circuit.png. Read the accompanying hardware notes, because two labels in this schematic do not describe the assembled unit. The separate fan controller is documented in docs/hardware/Fan_control.png.

Repository structure

Pocket_DC_supply/
├── .vscode/                 VS Code extension recommendation
├── docs/                    architecture, build, and hardware documentation
├── firmware/backups/        immutable as-read recovery artifacts
├── lib/                     project-local third-party libraries
├── src/                     firmware source code
│   └── Menu locations/      screens for the current flat menu
├── AGENTS.md                rules and context for coding agents
└── platformio.ini           portable PlatformIO configuration

Build

Install Visual Studio Code and the official PlatformIO IDE extension, open the repository folder, then use the PlatformIO Build task. From a PlatformIO terminal the equivalent command is:

pio run

Upload through USBasp:

pio run --target upload

No dependency on Z:\SERVER_projects\Libraries or on a separately installed AVRDUDESS directory remains. Details are in docs/BUILDING.md.

Firmware map

  • src/main.cpp — initialization and main loop
  • src/debug_uart.h — compile-time TX-only UART diagnostics
  • src/lead_compensation.h — automatic lead-resistance calibration and compensation
  • src/control.h — encoder/button handling and current menu editing
  • src/measurements.h — ADC conversion, DAC output, and slow CV/CC correction
  • src/display.h — LCD setup and screen dispatch
  • src/settings.h and src/eeprom_operation.h — persistent settings
  • src/fan.h and src/temp_check.h — cooling and temperature
  • src/Menu locations/ — individual UI screens

See docs/ARCHITECTURE.md before changing control or regulation behavior. Planned work is ordered in docs/ROADMAP.md, and the proposed UART debug connection is in docs/DEBUGGING.md. ADS1115 conversion and ALERT/RDY details are documented in docs/ADS1115.md, and the fail-safe power-on sequence is documented in docs/SAFE_STARTUP.md.

Recovery baseline

The Flash image and fuse configuration read from the working physical device are indexed in firmware/backups. The current dated baseline contains tested v1.4 Debug Flash and a complete EEPROM capture that match source commit d7c8d06. An older v1.5.0 Flash-only recovery image is also preserved, but its matching source is unavailable. Read each baseline's metadata before restoring it.

Hardware validation records are indexed in docs/test-results.

Project status

The assembled supply has been used under different loads for approximately two years. Firmware V.1.16 retains the fail-safe startup, calibrated ADS1115 voltage ranges, and V2 diagnostic protocol from earlier revisions. Dynamic Arduino String use was removed, and the Debug build now uses a compact integer formatter plus a polling TX-only UART. These footprint changes do not alter the release regulation algorithm. A persistent Vtrim range setting now scales the existing voltage-dependent AUTO-correction envelope from 50% to 200%. The earlier ADS1115 repair and CV/CC baseline remain documented separately. It also adds a bounded CONTINUITY TEST mode for unpowered boards, using 0.50 V, a 20 mA current limit, a variable resistance tone, and protected restoration of normal supply setpoints. Runtime fault handling, regulation refinements, and menu refactoring will be handled in later reviewable commits.

Every output-OFF path now closes the MOS gate and commands both DACs to zero. The requested U/I values remain in RAM/EEPROM and are restored to both DACs before the gate can reopen. ADC regulation is suspended while the gate is low so background measurements cannot reapply a nonzero DAC code.

V.1.16 adds optional two-lead voltage-drop compensation. A guided calibration uses a bounded 0.25 V / 0.25 A test, detects a shorted lead pair, waits three seconds, averages 20 resistance samples, and stores the loop resistance in milliohms. In CV mode the firmware adds I * Rlead to the connector voltage, bounded to 1 V and the existing input/20 V and power limits. See docs/LEAD_COMPENSATION.md.