CSV2Move

Robot Arm Controller

Overview

csv2move.py is a precision controller for continuous rotation servo-based robot arms using CSV input files. It handles PWM signal generation via I2C PCA9685 controllers with exact 20ms frame timing.

Key Features

  • Dry-run Mode: Simulate movements without hardware

  • Calibration Support: Per-servo duty cycle configuration

  • CSV Validation: Auto-skip malformed frames

  • Emergency Stop: Instant halt via keyboard interrupt

  • Frame Timing: Precise 50Hz (20ms) execution

Installation

pip install adafruit-circuitpython-pca9685 board

Usage

python csv2move.py [OPTIONS] CSV_FILE

Command Options

Option

Description

Default

--calibration

Calibration JSON file

Built-in

--dry-run

Simulation mode (no hardware)

False

--verbose

Show detailed frame info

False

--safe-delay

Startup safety delay (seconds)

2.0

CSV Format Requirements

servo1,servo2,servo3,servo4,servo5,servo6
-100.00,50.00,0.00,75.30,-20.50,100.00
0.00,0.00,0.00,0.00,0.00,0.00
  • Header row (optional but recommended)

  • 6 comma-separated values per line

  • Values range: -100.00 to 100.00

  • One frame = 20ms movement

Calibration Configuration

[
  {
    "min_duty": 1792,    // -100% speed (0x0700)
    "max_duty": 8448,    // +100% speed (0x2100) 
    "stop_duty": 5120     // Stop (0x1400)
  },
  // ... Repeat for servos 1-5
]

Execution Flow

CSG Generator -> CSV File -> csv2move.py -> PCA9685
     (traj2csv/speed2csv)         |            |
                               Dry-run Mode  Hardware Control

Example Session

# Run with safety checks
python csv2move.py movement.csv --safe-delay 3.0

# Dry-run verification
python csv2move.py complex.csv --dry-run --verbose

# Emergency stop during execution
[Ctrl+C] -> "EMERGENCY STOP TRIGGERED!"

Error Handling

Error Type

Response

CSV Read Error

Skip frame, continue

Value Range Exceeded

Clamp to (-100, 100)

Missing Servo Calibration

Use built-in defaults

Hardware Failure

Automatic PCA9685 shutdown

Safety Features

  1. Startup Delay: Allows system stabilization

  2. Duty Cycle Clamping: Never exceed min/max values

  3. Signal Validation: Reject non-numeric values

  4. Power Monitoring: (Future implementation)

Troubleshooting

Symptom

Solution

Jerky movements

Check CSV frame timing

Servo not responding

Verify calibration values

I2C errors

Run with --dry-run

Unexpected stop

Check for missing CSV frames


Note: Always test new CSVs with --dry-run before hardware execution. Maintain emergency stop access during operation.