Skip to main content
This guide provides detailed port assignments, connection diagrams, and safety considerations for wiring the robotic arm system.

Port Assignment Overview

VEX IQ Brain Port Map

PortComponentDirectionNotes
PORT1Base MotorReversed360° rotation with inertial feedback
PORT2Shoulder MotorReversedMax torque: 95%, bumper safety
PORT3Elbow MotorReversedMax torque: 95%
PORT4Gripper MotorReversedCurrent sensing: 0.3-0.5A

Wiring Diagram

Motor Connections

Motor Configuration Code

From vex_brain/src/main.py:169-178:
class ControlModule:
    def __init__(self, sensor_module: SensorModule):
        # Motor initialization (True = reversed direction)
        self.base_motor = Motor(Ports.PORT1, True)
        self.shoulder_motor = Motor(Ports.PORT2, True)
        self.elbow_motor = Motor(Ports.PORT3, True)
        self.gripper_motor = Motor(Ports.PORT4, True)
        
        # Safety torque limits (95% to prevent damage)
        self.elbow_motor.set_max_torque(95, PERCENT)
        self.shoulder_motor.set_max_torque(95, PERCENT)

Motor Direction Settings

All motors are configured with reversed=True. This is specific to the mechanical assembly. If your motors rotate in the wrong direction, toggle the True/False parameter.
Testing Motor Direction:
# Test each motor individually
self.base_motor.spin(FORWARD, 50, RPM)      # Should rotate clockwise (top view)
self.shoulder_motor.spin(FORWARD, 30, RPM)  # Should raise arm
self.elbow_motor.spin(FORWARD, 30, RPM)     # Should extend arm
self.gripper_motor.spin(FORWARD, 20, RPM)   # Should open gripper

Motor Torque Settings

MotorMax TorqueReason
Base100% (default)Low load, smooth rotation
Shoulder95%High load, prevent gear damage
Elbow95%High load, prevent gear damage
Gripper100% (default)Current sensing used instead
The shoulder and elbow motors are limited to 95% torque to prevent mechanical damage during unexpected collisions or high-load situations.

Sensor Connections

Sensor Configuration Code

From vex_brain/src/main.py:63-71:
class SensorModule:
    def __init__(self):
        self.brain = Brain()
        self.inertial = Inertial()
        self.gripper_distance = Distance(Ports.PORT7)
        self.touchled = Touchled(Ports.PORT8)
        self.base_distance = Distance(Ports.PORT9)
        self.bumper = Bumper(Ports.PORT10)

Distance Sensor Mounting

Location: Mounted on gripper, facing forwardOrientation: Sensor should point toward the center of the gripper openingDetection Zone: 0-40mm directly in front of gripperPurpose: Detects when object is within grasp rangeWiring: Use shortest VEX smart cable to avoid interference
Cable Management for Base Sensor: The base rotates 360°. Ensure the cable has enough slack and is routed through the center of rotation to prevent disconnection.

Bumper Sensor Mounting

PORT10: Bumper
  • Location: Mounted at maximum shoulder extension point
  • Trigger: Should activate only when shoulder reaches mechanical limit
  • Safety: Prevents shoulder from exceeding safe range of motion
  • Wiring: Route cable along shoulder joint, secure to prevent snagging

TouchLED Placement

PORT8: TouchLED
  • Location: Visible location on robot body (front or top)
  • Purpose: Visual status feedback for debugging and operation
  • View: Should be visible from normal viewing angle
  • Wiring: Short cable, can be mounted near brain

Serial Communication Setup

Hardware Connection

Cable Specifications

  • Type: Standard USB A to Micro-USB cable
  • Length: 1-2 meters recommended for flexibility
  • Quality: Use shielded cable to minimize EMI

Port Configuration

Device Path: /dev/serial1Initialization (vex_brain/src/main.py:32-36):
def initialize(self):
    try:
        self.serial_port = open('/dev/serial1', 'rb+')
    except:
        raise Exception('serial port error')
Settings:
  • Baud rate: Not specified (USB CDC virtual serial)
  • Data format: 8N1 (default)
  • Flow control: None

Message Protocol

Format: JSON messages terminated with newline (\n) Structure:
{
  "type": "service_name",
  "data": { /* service-specific data */ }
}
Example - Scan Service Request:
{"type": "scan_service", "data": {"speed": 20}}
Example - Scan Service Response:
{
  "type": "scan_service",
  "data": {
    "state": "detected",
    "angle": 127.5,
    "distance": 180,
    "size": 342
  }
}

Troubleshooting Serial Connection

Check connected devices:
ls /dev/ttyACM*
Possible outputs:
  • /dev/ttyACM0 - Use this instead
  • No output - VEX Brain not detected
Solutions:
  1. Try different USB port
  2. Check USB cable (must support data, not just power)
  3. Verify VEX Brain is powered on
  4. Check dmesg for connection errors:
    dmesg | tail -20
    
Check:
  1. VEX Brain program is running
  2. Serial port opened correctly on both sides
  3. Message format is valid JSON
Debug VEX side:
# Add to VEX main.py
self.sensor.print_screen("Serial OK", 1, 1)
Debug Raspberry Pi side:
# Enable debug logging
import logging
logging.basicConfig(level=logging.DEBUG)
Possible causes:
  1. Baud rate mismatch (should be 115200)
  2. Buffer overflow from too many messages
  3. Cable quality/EMI issues
Solution:
# Both sides validate JSON before processing
try:
    data = json.loads(message)
except json.JSONDecodeError:
    log.error(f'Invalid JSON: {message}')
    continue

Camera Connection

USB Camera Setup

Connection: USB camera → Raspberry Pi USB port Configuration (perception/vision/camera/main.py:6-9):
class CameraManager:
    def __init__(self, camera_index: int = 0, width: int = 1280, height: int = 720):
        self.cap = cv2.VideoCapture(camera_index)
        self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
        self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
Camera Index:
  • 0: First camera (built-in or first USB)
  • 1: Second camera
  • /dev/video0: Specific device path
Test Camera:
# List available cameras
ls /dev/video*

# Test camera with v4l2
v4l2-ctl --list-devices

# Capture test image
fswebcam -r 1280x720 test.jpg

Power Considerations

Raspberry Pi Power

Supply: 5V 3A USB-C (Pi 4/5) or micro-USB (Pi 3)Consumption:
  • Idle: ~2.5W
  • With camera: ~3.5W
  • With AI inference: ~5-7W
Recommendation: Official Raspberry Pi power supply or equivalent quality

VEX Brain Power

Supply: VEX IQ Battery (rechargeable)Capacity: Typically 2000mAhRuntime: 1-2 hours depending on motor usageRecommendation: Keep spare battery charged
Do NOT attempt to power the Raspberry Pi from the VEX Brain or vice versa. Each requires its own independent power supply.

Grounding and EMI

Common Ground

The USB connection between Raspberry Pi and VEX Brain provides a common ground reference. No additional grounding is required.

EMI Considerations

Potential interference sources:
  • Motor PWM signals
  • Switching power supplies
  • Long unshielded cables
Mitigation:
  1. Use shielded USB cable for serial connection
  2. Route power cables away from sensor cables
  3. Secure all connections to prevent intermittent contact
  4. Use cable ties for strain relief

Safety Guidelines

Electrical Safety
  • Never hot-swap motor or sensor connections
  • Power off VEX Brain before changing wiring
  • Inspect cables for damage before operation
  • Ensure all connections are fully seated
Mechanical Safety
  • Verify bumper sensor triggers before full operation
  • Test emergency stop procedures
  • Keep fingers clear of moving parts
  • Secure loose cables away from rotating base

Emergency Stop Procedure

Software Emergency Stop (vex_brain/src/main.py:200-202):
def general_stop(self):
    for m in [self.base_motor, self.shoulder_motor, 
              self.elbow_motor, self.gripper_motor]:
        m.stop()
Hardware Emergency Stop: Power off VEX Brain

Verification Checklist

1

Visual Inspection

  • All motors connected to correct ports (1-4)
  • All sensors connected to correct ports (7-10)
  • USB cable connected between Pi and VEX Brain
  • Camera connected to Raspberry Pi USB
  • Both devices have independent power supplies
  • No cables obstructing moving parts
2

Power-On Test

  • VEX Brain powers on (screen lights up)
  • Raspberry Pi powers on (LED activity)
  • TouchLED lights up (white on init)
  • Camera detected (ls /dev/video*)
3

Hardware Check Service

Run the check service:
robot.serial_manager.send_message('check_service', {})
Expected response:
{"type": "check_service", "data": {"state": "approved"}}
  • Check service passes
  • All motors respond
  • All sensors read values
4

Communication Test

  • Serial connection established (/dev/ttyACM1)
  • Messages sent successfully
  • Responses received
  • No JSON decode errors
5

Safety Test

Run the safety service:
robot.serial_manager.send_message('safety_service', {})
  • Shoulder raises until bumper pressed
  • LED turns red on collision
  • Shoulder retracts automatically
  • Gripper opens fully
  • LED turns green when complete

Wiring Best Practices

Cable Management

  • Use cable ties to secure bundles
  • Leave slack for moving joints
  • Route through center of rotating base
  • Label cables for easy identification

Strain Relief

  • Secure cables near connectors
  • Avoid sharp bends
  • Use clips or guides for routing
  • Test full range of motion

Connector Care

  • Push connectors fully until click
  • Don’t pull on cables, hold connector
  • Check for bent pins
  • Clean contacts if intermittent

Documentation

  • Take photos of final wiring
  • Mark port assignments on robot
  • Keep wiring diagram accessible
  • Note any custom modifications

Next Steps

Software Architecture

Learn how the hardware components are controlled by software

Communication Protocol

Deep dive into the serial communication protocol

Quick Start Tutorial

Get your system running with a step-by-step tutorial

Build docs developers (and LLMs) love