Electrochemical Actuator Testing and Control System
A unified web interface for controlling, monitoring, and recording experiments involving electrochemical actuators (ECAs). Coordinates multiple laboratory instruments including digital multimeters, DC power supplies, relay boards, and cameras for precise, reproducible actuator measurements.
- Real-time Data Visualization: Live voltage graphs from two DMMs with adjustable scales
- Synchronized Control: Coordinated control of power supply, relays, and camera
- Programmable Stages: Configure up to 10 voltage/relay stages with precise timing
- Data Logging: Automatic CSV logging with timestamped sessions
- REST API: Full API access for automation and integration
- WebSocket Streaming: Real-time data push for live monitoring
- Modern UI: Built with React, Next.js, and shadcn/ui components
- FastAPI server with REST and WebSocket endpoints
- Instrument drivers for DMMs, power supply, relay board
- Data logger for CSV recording and session management
- Camera controller bridge to C++ camera service
- Async scheduler for precise timing control
- Next.js with TypeScript
- shadcn/ui component library
- Recharts for live data visualization
- WebSocket client for real-time updates
- C++ executables for Canon camera control
- Python HTTP bridge for API integration
| Instrument | Model | Communication | Purpose |
|---|---|---|---|
| DMM ×2 | Keithley 2110 | VISA/USB | Voltage measurement |
| Power Supply | IT6412 | VISA/USB | Programmable voltage output |
| Relay Board | Devantech USB-RLY08C | USB Serial | Channel switching |
| Camera | Canon 2000D DSLR | USB (via C++ SDK) | Video recording |
- uv package manager
- VISA drivers (NI-VISA or compatible)
- USB drivers for instruments
- Node.js 18 or higher
- npm or yarn
- Canon EDSDK (for camera control)
- C++ compiler (Visual Studio or MinGW on Windows)
git clone https://github.com/yourusername/eca-actuation-test.git
cd eca-actuation-testUsing uv:
# Install dependencies
cd eca-actuation-test
uv synccd frontend
npm installSee camera/README.md for compilation instructions.
# From project root
cd eca-actuation-test
uv run run_backend.pyThe backend will start on http://localhost:8000
In a separate terminal:
cd camera
uv run camera_service.pyThe camera service will start on http://localhost:8001
In another terminal:
cd frontend
npm run devThe frontend will start on http://localhost:3000
Navigate to http://localhost:3000
When finished, stop all services:
Windows:
.\stop.ps1Linux/Mac:
./stop.sh-
Connect Instruments
- Connect DMMs, power supply, and relay board via USB
- Ensure instruments are powered on
- The webapp will auto-detect available VISA resources
-
Configure Test
- Enter a test name
- Select VISA IDs for DMMs and power supply
- Select serial port for relay board
- Set sampling rate (default: 10 Hz)
-
Set Up Stages (Optional)
- Add voltage stages for power supply (up to 10)
- Add relay stages for channels 1 and 2 (up to 10 each)
- Configure start time, end time, and values
-
Start Measurement
- Click "Start Measurement"
- Camera begins recording (if available)
- DMMs start logging data
- Voltage/relay stages execute automatically
-
Monitor Progress
- Watch live voltage graphs
- Check camera recording status
- View elapsed time
-
Stop Measurement
- Click "Stop Measurement"
- Camera stops recording
- Data is saved to CSV
- Session folder created in
data/
Each measurement session creates a timestamped folder in data/:
data/
└── 2025-10-13_14-30-15_test1/
├── readings.csv # Time, DMM1, DMM2 voltages
├── config.json # Test configuration
├── log.txt # Session log
└── video.mp4 # Camera recording (manual transfer)
POST /api/start_measurement
Content-Type: application/json
{
"config": {
"test_name": "test1",
"dmm1_visa_id": "USB0::0x05E6::0x2110::...",
"dmm2_visa_id": "USB0::0x05E6::0x2110::...",
"power_supply_visa_id": "USB0::...",
"relay_port": "COM3",
"voltage_stages": [
{"start_time": 0, "end_time": 5, "voltage": 0.2},
{"start_time": 5, "end_time": 10, "voltage": 0.4}
],
"relay_ch1_stages": [
{"start_time": 0, "end_time": 5, "state": "closed"}
],
"relay_ch2_stages": [],
"sampling_rate_hz": 10
}
}POST /api/stop_measurementGET /api/statusGET /api/list_instrumentsGET /api/sessionsGET /api/session/{session_id}/dataConnect to ws://localhost:8000/api/live for real-time DMM readings:
const ws = new WebSocket('ws://localhost:8000/api/live');
ws.onmessage = (event) => {
const reading = JSON.parse(event.data);
// { time: 1.23, dmm1_voltage: 0.45, dmm2_voltage: 0.67 }
};The system can run in development mode without physical instruments:
- Mock VISA resources: Backend will simulate instruments if none detected
- Mock camera: Camera service runs in mock mode without C++ executables
- Data logging: CSV logging still works with simulated data
eca-actuation-test/
├── camera/ # Camera control C++ code and service
│ ├── StartRecord.cpp
│ ├── StopRecord.cpp
│ ├── camera_service.py
│ └── README.md
├── eca-actuation-test/ # Python backend
│ ├── instruments/ # Instrument drivers
│ │ ├── dmm.py
│ │ ├── power_supply.py
│ │ └── relay_board.py
│ ├── app.py # FastAPI application
│ ├── api_models.py # Pydantic models
│ ├── camera_controller.py # Camera service bridge
│ ├── data_logger.py # Data logging
│ └── measurement_controller.py
├── frontend/ # Next.js frontend
│ ├── src/
│ │ ├── app/ # Next.js app directory
│ │ ├── components/ # React components
│ │ │ ├── ui/ # shadcn/ui components
│ │ │ ├── DMMGraph.tsx
│ │ │ ├── VoltageStageConfigurator.tsx
│ │ │ └── RelayStageConfigurator.tsx
│ │ └── lib/ # Utilities
│ ├── package.json
│ └── next.config.js
├── data/ # Measurement data (auto-created)
├── docs/ # Documentation
│ └── PRD.md # Product Requirements Document
├── labview/ # Legacy LabVIEW code
├── pyproject.toml # Python dependencies
└── README.md # This file
If you see Module not found: Can't resolve '@/lib/utils':
- The
frontend/src/lib/utils.tsfile is required for shadcn/ui components - Ensure
npm installcompleted successfully in thefrontend/directory - If the file is missing after cloning, it should be created during first build
- Verify the file exists:
frontend/src/lib/utils.ts
If instruments are not detected:
- Install NI-VISA or compatible driver
- Verify instruments appear in NI MAX (National Instruments Measurement & Automation Explorer)
- Check USB connections
- Restart instruments
The webapp works without the camera in mock mode. To use real camera:
- Compile C++ executables (see camera/README.md)
- Ensure Canon EDSDK DLLs are in PATH
- Connect camera via USB and power on
- Start camera service
If port 8000 or 3000 is busy:
- Backend: Edit
app.pyand changeuvicorn.run(app, port=XXXX) - Frontend: Edit
package.jsondev script:next dev -p XXXX
Ensure backend is running on localhost:8000 before starting frontend.
- DMM Sampling: Up to 100 Hz per channel (configurable)
- WebSocket Update: 10 Hz default
- Data Logging: Buffered writes, no data loss
- Timing Precision: <10 ms drift for voltage/relay stages
- Voltage Limits: Verify voltage stages are within safe limits for your setup
- Current Protection: Always set appropriate current limits on power supply
- Emergency Stop: Stop button immediately halts all operations
- Relay Ratings: Do not exceed relay board specifications
- Supervision: Always supervise experiments, especially with new configurations
- Oscilloscope integration
- Function generator support
- Cloud data logging
- Multi-session comparison and analytics
- Real-time impedance measurements
- AI-driven experiment optimization
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
See LICENSE file for details.
For issues, questions, or suggestions:
- Open an issue on GitHub
- Check docs/PRD.md for detailed specifications
- Built with FastAPI, Next.js, and shadcn/ui
- Instrument control via PyVISA and pyserial
- Camera control via Canon EDSDK
Made for electrochemical actuator research and testing