↵to select↓↑to navigateescto close
AI SPIDER DOCSEARCH
03 Electrical & power
// ON THIS PAGE
1. Power distribution architecture2. Electrical isolation principles3. Microcontroller pinout specificationsESP32-S3 motion and audio controller pinout (s3-main)ESP32-CAM vision and illumination pinout (cam-main)4. PCA9685 channel allocation and pulse staggering5. Current ripple mitigation and phase staggering proofMathematical staggering derivation

Power distribution and microcontroller pinouts

Dual-rail power regulation, common ground isolation, complete MCU pinouts, and PCA9685 phase-staggering.

The electrical subsystem provides isolated, low-noise power delivery across 18 high-torque servo actuators, two ESP32 microcontrollers, and an I2S digital audio amplifier.

1. Power distribution architecture

flowchart TD
    POWER_IN["DC Power Source<br/>(Regulated 5.30V DC / 8A Bench Rail or 3S LiPo)"]
    
    subgraph HighCurrentRail ["High-Current Actuation Rail (5.30V DC)"]
        BUCK1["300W 20A / XL4015 Buck Regulator #1<br/>(Tuned 5.30V @ 5A Continuous)"]
        BUCK2["300W 20A / XL4015 Buck Regulator #2<br/>(Tuned 5.30V @ 5A Continuous)"]
        PCA0_V["PCA9685 #1 V+ Rail (0x40)<br/>Right Quadrant Servos (0–8)"]
        PCA1_V["PCA9685 #2 V+ Rail (0x41)<br/>Left Quadrant Servos (9–17)"]
    end

    subgraph LogicRail ["Isolated 3.3V / 5.0V Logic Rail"]
        ESP_LDO["ESP32-S3 Internal LDO / 5V Ingress"]
        CAM_LDO["ESP32-CAM 5V Ingress & AMS1117 LDO"]
        AMP_V["MAX98357A VDD & Logic Supply"]
    end

    subgraph GroundSystem ["Common Ground Reference Bus"]
        GND["Shared Low-Impedance Ground (0V Reference)<br/>Ties ESP32-S3, ESP32-CAM, Pi 4, Both PCA9685, and Buck Regulators"]
    end

    POWER_IN --> BUCK1
    POWER_IN --> BUCK2
    POWER_IN --> ESP_LDO
    POWER_IN --> CAM_LDO

    BUCK1 --> PCA0_V
    BUCK2 --> PCA1_V
    ESP_LDO --> AMP_V

    PCA0_V -.-> GND
    PCA1_V -.-> GND
    ESP_LDO -.-> GND
    CAM_LDO -.-> GND
    AMP_V -.-> GND

2. Electrical isolation principles

  1. Dedicated actuation power: The 18 micro servos draw between 4.5A4.5\text{A} and 6.0A6.0\text{A} cumulative stall current during rapid gait transitions. Servos must never draw current directly from the ESP32-S3 development board 5V5\text{V} or 3.3V3.3\text{V} LDO output pins.
  2. Unified common ground: A shared low-impedance ground plane connects the power supply, buck converters, ESP32-S3, ESP32-CAM, Raspberry Pi 4B, and both PCA9685 driver boards. Floating grounds cause logic potential drift, corrupting high-speed I2C and UART communications.
  3. Calibrated voltage rails: Actuator buck regulators are calibrated to 5.30V DC5.30\text{V DC}. This maximizes available stall torque (2.2 kg⋅cm2.2\text{ kg}\cdot\text{cm}) while remaining safely within the absolute maximum 6.0V6.0\text{V} threshold of the MG90S servo control electronics.

3. Microcontroller pinout specifications

ESP32-S3 motion and audio controller pinout (s3-main)

Peripheral subsystemPhysical signalESP32-S3 GPIOOperating voltageInterface constraints
I2C bus (PCA9685 drivers)SDAGPIO 413.3V Logic400 kHz Fast-Mode, external 4.7kΩ pull-up
SCLGPIO 423.3V Logic400 kHz Fast-Mode, external 4.7kΩ pull-up
OE (Output Enable)GPIO 133.3V LogicActive-LOW; pulled HIGH on boot for Limp state
I2S audio (MAX98357A)BCLK (Bit Clock)GPIO 403.3V Logic705.6 kHz (22050 Hz×16 bits×2 channels22050\text{ Hz} \times 16\text{ bits} \times 2\text{ channels})
LRC / WS (Word Select)GPIO 393.3V Logic22,050 Hz Left/Right channel framing clock
DIN (Serial Data Out)GPIO 383.3V LogicMSB-First 16-bit Mono PCM audio data stream
UART hardware telemetryTXD0GPIO 433.3V TTLSerial debug output console @ 115,200 Baud
RXD0GPIO 443.3V TTLSerial debug input console @ 115,200 Baud
Inter-board serial linkTXD1 / RXD1GPIO 4 / GPIO 53.3V TTLDirect host bridge UART link (Optional fallback)

ESP32-CAM vision and illumination pinout (cam-main)

Peripheral subsystemCamera signalESP32-CAM GPIOOperational role
Flashlight LED illuminationLAMP_PWMGPIO 4White LED; LEDC Channel 1, 5 kHz PWM dimming
Camera power and resetCAM_PIN_PWDNGPIO 32Power-down control line
CAM_PIN_RESETNC (-1)Hardware reset pulled permanently HIGH internally
CAM_PIN_XCLKGPIO 0Master Clock input (20 MHz via LEDC Timer 0)
SCCB / I2C busCAM_PIN_SIODGPIO 26Serial Camera Control Bus (Data)
CAM_PIN_SIOCGPIO 27Serial Camera Control Bus (Clock)
DVP parallel pixel busY9 .. Y235, 34, 39, 36, 21, 19, 18, 58-bit parallel digital video pixel interface
DVP frame synchronizationVSYNCGPIO 25Vertical frame synchronization
HREFGPIO 23Horizontal line reference
PCLKGPIO 22Pixel clock input

4. PCA9685 channel allocation and pulse staggering

flowchart TD
    subgraph S3_MCU ["ESP32-S3 (I2C Master)"]
        I2C_BUS["I2C Bus: GPIO 41 (SDA) / GPIO 42 (SCL)"]
    end

    subgraph Board0 ["PCA9685 Board 0 (Address: 0x40) - Right Quadrant"]
        direction TB
        RF["Leg 0: Right Front (RF)<br/>Ch 0 (Coxa), Ch 1 (Femur), Ch 2 (Tibia)"]
        RM["Leg 1: Right Middle (RM)<br/>Ch 4 (Coxa), Ch 5 (Femur), Ch 6 (Tibia)"]
        RR["Leg 2: Right Rear (RR)<br/>Ch 8 (Coxa), Ch 9 (Femur), Ch 10 (Tibia)"]
    end

    subgraph Board1 ["PCA9685 Board 1 (Address: 0x41) - Left Quadrant"]
        direction TB
        LR["Leg 3: Left Rear (LR)<br/>Ch 0 (Coxa), Ch 1 (Femur), Ch 2 (Tibia)"]
        LM["Leg 4: Left Middle (LM)<br/>Ch 4 (Coxa), Ch 5 (Femur), Ch 6 (Tibia)"]
        LF["Leg 5: Left Front (LF)<br/>Ch 8 (Coxa), Ch 9 (Femur), Ch 10 (Tibia)"]
    end

    I2C_BUS --> Board0
    I2C_BUS --> Board1
Leg indexAnatomical positionJoint segmentGlobal chPCA boardI2C addrLocal chInverted logicStagger offset (TicksON\text{Ticks}_{\text{ON}})
Leg 0Right Front (RF)Coxa (Hip Pan)0PCA 00x40Ch 0False0 ticks0\text{ ticks}
Femur (Thigh Lift)1PCA 00x40Ch 1True150 ticks150\text{ ticks}
Tibia (Knee Reach)2PCA 00x40Ch 2False300 ticks300\text{ ticks}
Leg 1Right Middle (RM)Coxa (Hip Pan)4PCA 00x40Ch 4False600 ticks600\text{ ticks}
Femur (Thigh Lift)5PCA 00x40Ch 5True750 ticks750\text{ ticks}
Tibia (Knee Reach)6PCA 00x40Ch 6False900 ticks900\text{ ticks}
Leg 2Right Rear (RR)Coxa (Hip Pan)8PCA 00x40Ch 8False1200 ticks1200\text{ ticks}
Femur (Thigh Lift)9PCA 00x40Ch 9True1350 ticks1350\text{ ticks}
Tibia (Knee Reach)10PCA 00x40Ch 10False1500 ticks1500\text{ ticks}
Leg 3Left Rear (LR)Coxa (Hip Pan)16PCA 10x41Ch 0False0 ticks0\text{ ticks}
Femur (Thigh Lift)17PCA 10x41Ch 1True150 ticks150\text{ ticks}
Tibia (Knee Reach)18PCA 10x41Ch 2False300 ticks300\text{ ticks}
Leg 4Left Middle (LM)Coxa (Hip Pan)20PCA 10x41Ch 4False600 ticks600\text{ ticks}
Femur (Thigh Lift)21PCA 10x41Ch 5True750 ticks750\text{ ticks}
Tibia (Knee Reach)22PCA 10x41Ch 6False900 ticks900\text{ ticks}
Leg 5Left Front (LF)Coxa (Hip Pan)24PCA 10x41Ch 8False1200 ticks1200\text{ ticks}
Femur (Thigh Lift)25PCA 10x41Ch 9True1350 ticks1350\text{ ticks}
Tibia (Knee Reach)26PCA 10x41Ch 10False1500 ticks1500\text{ ticks}

5. Current ripple mitigation and phase staggering proof

When 18 servos are driven synchronously with standard in-phase PWM, simultaneous rising edges cause transient current spikes exceeding 4.5A4.5\text{A} (di/dtdi/dt), triggering microcontroller reset loops.

To eliminate this ripple, the firmware offsets the ON tick of each successive channel across the 12-bit register space:

gantt
    title PWM Phase-Staggered Pulse Timing (20ms Period / 4096 Ticks)
    dateFormat X
    axisFormat %s
    section PCA Board 0
    Ch 0 (RF Coxa)   :active, 0, 400
    Ch 1 (RF Femur)  :active, 150, 550
    Ch 2 (RF Tibia)  :active, 300, 700
    Ch 4 (RM Coxa)   :active, 600, 1000
    Ch 5 (RM Femur)  :active, 750, 1150
    Ch 6 (RM Tibia)  :active, 900, 1300
    Ch 8 (RR Coxa)   :active, 1200, 1600
    Ch 9 (RR Femur)  :active, 1350, 1750
    Ch 10 (RR Tibia) :active, 1500, 1900
    section Margin
    Safe Boundary Margin (Ticks 2740 to 4095) :done, 2740, 4095

Mathematical staggering derivation

ON_Tick(ch)=ch×150\text{ON\_Tick}(ch) = ch \times 150 OFF_Tick(ch)=ON_Tick(ch)+Width_Ticks\text{OFF\_Tick}(ch) = \text{ON\_Tick}(ch) + \text{Width\_Ticks}

Where the 50 Hz PWM counter runs from 00 to 40954095 (20 ms20\text{ ms} period). With a maximum possible pulse width of 2393 μs2393\,\mu\text{s} (≈490 ticks\approx 490\text{ ticks}), the maximum counter value on channel 15 reaches:

Max_Tick=(15×150)+490=2250+490=2740<4095\text{Max\_Tick} = (15 \times 150) + 490 = 2250 + 490 = 2740 < 4095

Because Max_Tick=2740<4095\text{Max\_Tick} = 2740 < 4095, pulse widths never wrap around the 12-bit register boundary, distributing inductive surge current evenly across the entire 20 ms duty cycle window.

// FULLSCREEN_VIEWPORT
100%