Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PPK2 Power Profiler

A high-performance PPK-2 (Power Profiler Kit II) control application built with ImGui and ImPlot for real-time current measurement visualization.

Features

  • High Performance: Optimized C implementation with efficient circular buffer for handling 100k samples/second
  • Real-time Visualization: Smooth plotting with ImPlot, capable of displaying millions of samples
  • Nordic Semiconductor Branding: Built-in Nordic blue color scheme with easy customization
  • Dark/Light Mode: Toggle between dark and light themes
  • Source & Ampere Modes: Full support for both PPK2 measurement modes
  • Configuration Menu: Collapsible menu for device settings
  • Statistics: Real-time min/max/average calculations
  • Cross-platform Ready: CMake build system with stubs for Windows/macOS

Requirements

Linux

  • CMake 3.15+
  • GCC or Clang with C11/C++17 support
  • GLFW3
  • OpenGL 3.0+
  • pkg-config

Installation (Ubuntu/Debian)

sudo apt-get install cmake build-essential libglfw3-dev libgl1-mesa-dev pkg-config

Installation (Fedora/RHEL)

sudo dnf install cmake gcc-c++ glfw-devel mesa-libGL-devel pkgconfig

Installation (Arch)

sudo pacman -S cmake gcc glfw-x11 mesa pkgconf

Building

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)

Debug Build

cmake .. -DCMAKE_BUILD_TYPE=Debug
make -j$(nproc)

Running

./ppk2-viewer

Default device port is /dev/ttyACM0. Change this in the Control Panel or modify the source.

Keyboard Shortcuts

  • TAB: Toggle Control Panel (perfect for tradeshow presentations)
  • SPACE: Start/Stop measurement (when connected)
  • CTRL+T: Toggle Dark/Light theme
  • CTRL+P: Toggle Presentation Mode (hides technical details)
  • CTRL+H: Show keyboard shortcuts help

Debugging

GDB

gdb ./ppk2-viewer

Valgrind

# Enable valgrind support in CMake
cmake .. -DENABLE_VALGRIND=ON
make valgrind

Or manually:

valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind.log ./ppk2-viewer

Customizing Colors

The Nordic color scheme can be easily modified in src/ui_theme.c:

// Primary: Nordic Blue #00A9CE -> {0.00f, 0.66f, 0.81f, 1.00f}
// Accent: Nordic Teal #00C1DE -> {0.00f, 0.76f, 0.87f, 1.00f}

Or programmatically using the API:

ui_theme_set_color("primary", 0.0f, 0.66f, 0.81f, 1.0f);
ui_theme_set_color("accent", 0.0f, 0.76f, 0.87f, 1.0f);

Project Structure

.
├── CMakeLists.txt          # Build configuration
├── include/                # Header files
│   ├── ppk2_serial.h      # Serial communication interface
│   ├── ppk2_protocol.h    # PPK2 protocol implementation
│   ├── ui_theme.h         # Theme management
│   └── data_buffer.h      # Circular buffer for samples
├── src/                    # Source files
│   ├── main.c             # Entry point
│   ├── ppk2_serial.c      # Serial communication (Linux/Windows/macOS)
│   ├── ppk2_protocol.c    # PPK2 command protocol
│   ├── ui_theme.c         # Theme implementation
│   ├── data_buffer.c      # Circular buffer implementation
│   └── ui_main.cpp        # ImGui UI implementation
├── lib/                    # Third-party libraries
│   ├── imgui/             # Dear ImGui
│   └── implot/            # ImPlot
└── README.md

PPK2 API Reference

Connection

ppk2_device_t* device = ppk2_init("/dev/ttyACM0");
ppk2_get_modifiers(device);  // Read calibration data

Configuration

ppk2_set_mode(device, PPK2_MODE_SOURCE);  // or PPK2_MODE_AMPERE
ppk2_set_source_voltage(device, 3300);     // mV (800-5000)
ppk2_toggle_dut_power(device, true);       // Enable DUT power

Measurement

ppk2_start_measuring(device);

float samples[1024];
int count = ppk2_read_samples(device, samples, 1024);
// samples are in microamperes (µA)

ppk2_stop_measuring(device);
ppk2_cleanup(device);

Performance Characteristics

  • Sample Rate: 100,000 samples/second (PPK2 hardware limit)
  • Buffer Capacity: 1,000,000 samples (10 seconds at full rate)
  • Display Window: Configurable (10k, 50k, 100k, 500k, 1M samples)
  • Memory Usage: ~4MB for full buffer + ImGui overhead
  • Frame Rate: 60 FPS with VSync

Known Limitations

  • Linux implementation only (Windows/macOS stubs provided)
  • No data export functionality yet
  • No trigger support yet
  • Serial port must be specified manually

License

This project uses ImGui (MIT License) and ImPlot (MIT License). PPK2 protocol based on ppk2-api-python (GPL V2).

Contributing

Contributions welcome! Areas for improvement:

  • Windows and macOS serial port implementations
  • Data export (CSV, binary)
  • Trigger functionality
  • Digital channel visualization
  • More configuration options

About

a fast ppk2 viewer

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages