- C# 67.2%
- C++ 32.8%
|
|
||
|---|---|---|
| .github/workflows | ||
| firmware | ||
| windows | ||
| .gitignore | ||
| adaptivelog.txt | ||
| ARCHITECTURE.md | ||
| CLAUDE.md | ||
| DOCUMENTATION_STATUS.md | ||
| KNOWN_ISSUES.md | ||
| LinTool_Debug_20260227_153931.log | ||
| log.txt | ||
| powers.txt | ||
| README.md | ||
LinTool - Measurement Automation System
LinTool is a comprehensive measurement automation system consisting of a Windows desktop application and Raspberry Pi Pico firmware for controlling precision measurements with automated motor control.
System Overview
The system consists of two main components:
-
Windows Application - A standalone .NET 8 WPF application that:
- Controls automated measurements by interacting with a target desktop application via UI Automation
- Communicates with the Pico via USB serial to control motor movements
- Orchestrates the complete measurement workflow
-
Raspberry Pi Pico Firmware - Arduino-based firmware that:
- Controls a stepper motor via TMC2209 driver
- Receives commands from the Windows application
- Provides precise motor positioning and movement
Features
Windows Application
-
Parameter Configuration:
- Low Power setting (default: 3.0)
- High Power setting with "maximum reachable power" option
- Power Steps (default: 5.0)
- Attenuation range selection (0dB-30dB in 2dB steps)
-
Automated Workflow:
- Iterates through attenuation levels
- Adjusts motor position to achieve target power readings
- Takes measurements at specified power increments
- Stops at maximum power or when no change detected
-
USB Serial Communication:
- Connects to Raspberry Pi Pico via COM port
- Sends motor control commands
- Receives position and status updates
Pico Firmware
-
TMC2209 Driver Control:
- 16 microsteps for smooth operation
- StealthChop mode for quiet operation
- Configurable current settings (default: 1000mA RMS)
-
Serial Command Protocol:
MOVE:<steps>- Move by specified stepsMOVE_HALF- Move half rotationSTOP- Emergency stopGET_POS- Get current positionRESET_POS- Reset position counterSET_SPEED:<rpm>- Set motor speed
Hardware Requirements
Raspberry Pi Pico Setup
- Raspberry Pi Pico
- TMC2209 stepper motor driver
- NEMA 17 stepper motor (200 steps/rev)
- 12V or 24V power supply for motor
Pin Connections:
- GPIO 2 → TMC2209 STEP
- GPIO 3 → TMC2209 DIR
- GPIO 4 → TMC2209 EN
- GPIO 8 → 1K resistor → BTT board RX pin (UART TX to PDN_UART)
- GPIO 9 → BTT board RX pin (UART RX from PDN_UART, direct)
- Pico GND → TMC2209 GND (common ground)
- Pico 3.3V → TMC2209 VIO (logic voltage)
UART Wiring (Single-Wire via BTT board RX pin): Both Pico GPIO 8 (TX) and GPIO 9 (RX) connect to the same BTT TMC2209 board "RX" header pin. A 1K resistor on GPIO 8 prevents bus contention. The BTT board's "TX" header pin is not used.
TMC2209 Power:
- VM → Motor power supply positive (12V or 24V)
- GND → Common ground (shared with Pico and power supply)
- Motor terminals → Stepper motor coils
See firmware/README.md for detailed hardware setup instructions.
Installation
Windows Application
Option 1: Download Pre-built Release
- Go to the Releases page
- Download the latest
LinTool-Windows-x64.exe - Run the executable (no installation required)
Option 2: Build from Source
Requirements:
- .NET 8 SDK
# Clone repository
git clone <repository-url>
cd LinTool
# Build
dotnet build windows/LinTool.sln --configuration Release
# Publish standalone executable
dotnet publish windows/LinTool/LinTool.csproj \
--configuration Release \
--runtime win-x64 \
--self-contained true \
--output bin \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true
# Executable will be in bin/LinTool.exe
Pico Firmware
Requirements:
- Arduino IDE 2.x or newer
- Raspberry Pi Pico board support
- TMCStepper library
See firmware/README.md for detailed installation instructions.
Usage
1. Setup Hardware
- Connect TMC2209 driver to Raspberry Pi Pico according to pin diagram
- Connect stepper motor to TMC2209 driver
- Connect motor power supply to TMC2209
- Connect Pico to Windows PC via USB
2. Upload Firmware
- Open
firmware/LinTool_Pico/LinTool_Pico.inoin Arduino IDE - Select "Raspberry Pi Pico" board
- Select the correct COM port
- Upload firmware
3. Run Windows Application
- Launch LinTool.exe
- Select the Pico's COM port from dropdown
- Click "Connect"
- Configure measurement parameters:
- Set Low Power, High Power, and Power Steps
- Select Starting and Ending Attenuation levels
- Click "Start Measurement"
4. Monitor Progress
- Status log shows real-time progress
- Progress indicator displays current attenuation level
- Connection status shows serial port state
Measurement Workflow
For each attenuation level in the specified range:
- Set Attenuation: Select attenuation value in target application dropdown
- Add User Comment: Click user comment button and enter attenuation value
- Adjust to Low Power: Move motor until power reading equals low power setting
- Initial Measurement: Click measure button
- Increment and Measure:
- Move motor to increase power by power step amount
- Take measurement
- Repeat until stopping condition met
- Stopping Conditions:
- If "maximum reachable power" is checked: Stop when half rotation produces no power change
- Otherwise: Stop when high power value is reached
Architecture
Windows Application Structure
windows/LinTool/
├── Models/ # Data models
│ ├── MeasurementParameters.cs
│ └── AttenuationLevel.cs
├── Services/ # Business logic
│ ├── MotorControlService.cs # Serial communication
│ ├── UIAutomationService.cs # UI automation (placeholders)
│ └── MeasurementOrchestrator.cs # Main workflow
└── ViewModels/ # MVVM view models
└── MainViewModel.cs
Pico Firmware Structure
firmware/LinTool_Pico/
├── LinTool_Pico.ino # Main Arduino sketch
├── MotorController.h/.cpp # TMC2209 motor control
└── SerialProtocol.h/.cpp # Command parsing
Development
Building Windows Application Locally
# Restore dependencies
dotnet restore windows/LinTool.sln
# Build in debug mode
dotnet build windows/LinTool.sln --configuration Debug
# Run application
dotnet run --project windows/LinTool/LinTool.csproj
CI/CD Pipeline
GitHub Actions automatically builds the Windows application on:
- Push to main/master/develop branches
- Pull requests
- New releases
Artifacts are uploaded and attached to releases automatically.
UI Automation Notes
The UIAutomationService.cs currently contains placeholder implementations. To complete the integration:
-
Use a tool like Inspect.exe (Windows SDK) or UI Automation Verify to identify UI elements in the target application
-
Update the element identifiers in
UIAutomationService.cs:AttenuationDropdown- AutomationId or Name of attenuation dropdownUserCommentButton- AutomationId or Name of user comment buttonUserCommentTextbox- AutomationId or Name of text inputMeasureButton- AutomationId or Name of measure buttonPowerReadingText- AutomationId or Name of power reading display
-
Uncomment and adapt the example implementation code in each method
Troubleshooting
Windows Application
- Serial port not found: Make sure Pico is connected and drivers are installed
- Connection timeout: Verify Pico firmware is uploaded and running
- Command errors: Check serial communication baud rate (115200)
Pico Firmware
- Motor not moving: Check TMC2209 EN pin (should be LOW when enabled)
- Motor stuttering: Adjust RMS current setting in MotorController.cpp
- Serial not responding: Verify UART pins (GPIO 8, 9) are correctly configured
License
[Add your license here]
Contributing
[Add contribution guidelines here]
Support
For issues and questions:
- Open an issue on GitHub
- Check existing documentation in
/firmware/README.md