Servo Motor Wiring
Connect servo motors to PCA9685 channels for panel actuation
Learn how to connect and organize servo motors to the PCA9685 controller.
About MG996R Servo Motors
Specifications
- • Torque: 10 kg·cm @ 4.8V, 11 kg·cm @ 6V
- • Speed: 0.17 sec/60° @ 4.8V
- • Voltage: 4.8V - 6V (5V optimal)
- • Current: ~500mA stall, ~200mA idle
- • Rotation: 180° (0° to 180°)
- • Connector: 3-pin standard servo connector
Wire Color Code
Orange/Yellow
Signal (PWM control)
Red
Power (+5V)
Brown/Black
Ground (−)
Servo Channel Assignments
The PCA9685 has 16 channels (0-15). Each channel controls one servo motor. Channel assignment determines which motor moves when the code executes. Map your servos to channels based on your physical panel layout.
Standard 4×3 Grid Layout (7 Active Motors)
Default configuration for cloth folding robot. Motor numbering starts from top-left, going row by row.
| Channel # | Panel Name | Panel Type | Physical Location |
|---|---|---|---|
| 0 | Motor 1 | Motorized Module | Top-Left |
| 1 | Motor 2 | Motorized Module | Top-Center-Left |
| 2 | Motor 3 | Motorized Module | Top-Center-Right |
| 3 | Motor 4 | Motorized Module | Top-Right |
| 4 | Motor 5 | Motorized Module | Middle-Left |
| 5 | Motor 6 | Motorized Module | Middle-Right |
| 6 | Motor 7 | Motorized Module | Bottom-Center |
| 7-15 | Unused | Available for expansion | — |
💡 Tip: You can customize this mapping for different layouts. The motion plans inconfig.py reference channel numbers, not physical locations.
Wiring Procedure
- Step 1: Prepare Servo Connectors
- • Servos come with 3-pin female connectors (fits PCA9685 pin headers)
- • Check wire colors match standard: Orange/Yellow (signal), Red (power), Brown/Black (ground)
- • If colors differ, consult servo datasheet before connecting
- Step 2: Identify PCA9685 Channel Headers
- • 16 servo output headers labeled 0-15 on the board
- • Each header has 3 pins arranged vertically
- • Pin arrangement (top to bottom): Signal (yellow), V+ (red), GND (black)
- Step 3: Connect Servos to Channels
- • Ensure power supply is disconnected
- • Align servo connector with channel header (noting wire color positions)
- • Firmly press connector onto header pins (should click into place)
- • Repeat for all servos according to your channel mapping
- Step 4: Verify Connections
- • Check each servo connector is fully seated (no exposed pins)
- • Verify wire colors align with PCA9685 pin labels
- • Ensure no connectors are inserted backwards
- • Tug gently on each connector to confirm secure fit
Servo Connection Diagram
PCA9685 Servo Driver Board
┌─────────────────────────────────┐
│ │
│ Channel Headers (3-pin each) │
│ ┌───┬───┬───┬───┬───┬───┐ │
│ │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │... │
│ ├───┼───┼───┼───┼───┼───┤ │
│ │ S │ S │ S │ S │ S │ S │ S │ ← Signal (Orange/Yellow)
│ │ + │ + │ + │ + │ + │ + │ + │ ← V+ (Red)
│ │ − │ − │ − │ − │ − │ − │ − │ ← GND (Brown/Black)
│ └─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┘ │
│ │ │ │ │ │ │ │
└────┼───┼───┼───┼───┼───┼───────┘
│ │ │ │ │ │
│ │ │ │ │ │
┌────▼┐ ┌▼──┐ ┌▼──┐ ┌▼──┐ ┌▼──┐ ┌▼──┐
│Srv 0│ │Sr1│ │Sr2│ │Sr3│ │Sr4│ │Sr5│
│(M1) │ │M2 │ │M3 │ │M4 │ │M5 │ │M6 │
└─────┘ └───┘ └───┘ └───┘ └───┘ └───┘
Each servo receives:
• PWM signal on orange/yellow wire (0-180° position control)
• 5V power on red wire (from external power supply via V+ terminal)
• Ground on brown/black wire (common with Pico and power supply)
📷 Servo Wiring Photo Placeholder
Photo showing multiple servos connected to PCA9685 will be added here
Cable Management Tips
Organization
- • Route servo cables along panel frame edges
- • Use zip ties or cable clips every 10-15cm
- • Group cables by row or section
- • Leave slack (5-10cm) at servo end for panel movement
- • Label each cable with channel number
Extension Cables
- • Use servo extension cables if servos are far from PCA9685
- • Maximum recommended length: 1 meter per cable
- • Longer cables may cause signal degradation
- • Match extension cable polarity (colors align)
- • Avoid running extensions near power wires
Testing Individual Servos
Single Servo Test
- 1. Connect only ONE servo to Channel 0
- 2. Power on the system (USB + 5V power supply)
- 3. Upload the Fabrica code to Pico
- 4. Servo should initialize to 0° position on startup
- 5. Press Button 1 to trigger motion plan for Channel 0
- 6. Servo should rotate 0° → 180° → 0° smoothly
Troubleshooting Servo Issues
Check power connections, verify servo connector polarity
Insufficient power supply current, add capacitor, reduce servo count
Calibrate SERVO_MIN_PULSE and SERVO_MAX_PULSE in config.py
Best Practices
✅ Do
- • Test each servo individually before full assembly
- • Use high-quality servos (metal gears recommended)
- • Secure servo cables to prevent pulling on connectors
- • Keep spare servos for quick replacement
- • Document your channel mapping
❌ Avoid
- • Forcing servo rotation beyond 180° (damages gears)
- • Hot-swapping servos while powered on
- • Using damaged or stripped servo connectors
- • Running all servos at max load simultaneously without adequate power
- • Mixing different servo models (different speeds/torques)
Code Configuration
Servo settings are defined in config.py:
# Servo Channel Configuration
NUM_SERVOS = 7 # Total servos connected (0-15 max)
# Servo Calibration (MG996R defaults)
SERVO_MIN_PULSE = 500 # Minimum pulse width (0°)
SERVO_MAX_PULSE = 2400 # Maximum pulse width (180°)
SERVO_FREQ = 50 # PWM frequency in Hz
# Motion Control
SERVO_SPEED = 100 # Degrees per second
SERVO_ACCELERATION = 50 # Smoothing for starts/stops
# Channel Mapping (customize for your layout)
CHANNEL_MAP = {
0: "Motor 1 (Top-Left)",
1: "Motor 2 (Top-Center-Left)",
2: "Motor 3 (Top-Center-Right)",
3: "Motor 4 (Top-Right)",
4: "Motor 5 (Middle-Left)",
5: "Motor 6 (Middle-Right)",
6: "Motor 7 (Bottom-Center)"
}Adjust MIN_PULSE and MAX_PULSE if your servos have different rotation range.