System Integration

Back to Home

Goals

assignment

Assignment

1. System Overview and Objective

1.1 Background & Motivation

In the natural world, many organisms possess an instinct for “approaching benefits and avoiding harm.” When a threat appears in their environment, they often respond with rapid avoidance through sensing, decision-making, and immediate action.

This project aims to simulate such biological behavior by building a quadruped robot prototype that can detect human approach direction → quickly evade → trigger light warning, through embedded system-level integration.

This is not only a technical integration exercise but also an exploration of how biologically inspired intelligent behaviors can be reproduced in robotic systems. The project integrates perceptual input (sensors), motion output (servos), emotional expression (RGB lighting), and decision-making control (microcontroller programming) to create an embedded system that can react to environmental changes and be applicable in real-world scenarios.


1.2 Project Goals & Capabilities

This system integrates multiple sensors and actuators to build a responsive robotic system with quadruped mobility, human proximity perception, and visual status feedback. Specific goals include:


1.3 System Behavior Flowchart

            ┌────────────────────┐
            │   System Initialization   │
            └────────────┬────────────┘
                        ↓
            ┌────────────────────────────┐
            │ Initialize Servos and RGB Ring │
            └────────────┬────────────────┘
                        ↓
            ┌────────────────────────────┐
            │  Set RGB Ring to Blue Breathing │
            └────────────┬────────────────┘
                        ↓
            ┌──────────────────────┐
            │ Read Left and Right PIR Sensors │◄────────────┐
            └────────────┬─────────┘             │
                        ↓                       │
                ┌──────────────┐   No Person Detected
                │  Evaluate Sensor Input  │─────────────┘
                └─────┬──────────┬──────┘
                        │          │
            Left Triggered   Right Triggered
                ↓                 ↓
            ┌────────────┐     ┌────────────┐
            │ Move Right │     │ Move Left  │
            └─────┬──────┘     └─────┬──────┘
                ↓                  ↓
            ┌────────────────────────────┐
            │ Switch RGB Ring to Red Flashing │
            └────────────┬──────────────────┘
                        ↓
            ┌──────────────────────────────┐
            │ Stop Movement, Return to Sensor Check │→→→→ (Loop)
            └──────────────────────────────┘
            

Flowchart Annotations


1.4 System Architecture

The overall system structure is illustrated as follows:

                    ┌────────────┐
                    │ Left PIR Sensor │
                    └──────┬──────┘
                            ↓
                    ┌──────────────────────┐
                    │ XIAO ESP32S3 Microcontroller │
                    └────┬────┬────┬────────────┘
                        │    │    │
                ┌──────┘    │    └──────────────┐
                ↓           ↓                   ↓
            Right PIR     Servo Control      RGB LED Ring (WS2812)
            (Digital In)  (PWM D1~D8)         (Data Out D10)
            

1.5 Behavior Flow


1.6 Highlight Features

Project Highlight Description
Biological Behavior Simulation Simulates animal-like logic of "threat perception → escape", enabling autonomous reactive behavior.
Multi-Module Integration Integrates PIR sensors, SG90 servos, RGB LED ring, and microcontroller into a tightly coordinated system.
Dynamic Visual Expression Uses RGB lighting effects to express “calm vs alert” states, enhancing human-robot interaction.
Expandable Structure Allows easy replacement or upgrade to other sensors like cameras or ultrasonic modules for extended perception.


2. Detailed Hardware Description

This system is based on the XIAO ESP32S3 development board and integrates multiple input/output modules to detect human proximity and trigger corresponding robot movements. Each module has a clear function and collaborates in real time to form a complete interactive smart system. The main hardware components are described in detail below:


2.1 Main Control Unit: XIAO ESP32S3 (Camera Version)


2.2 Servo Drive System: 8 × SG90 Servos


2.3 PIR Sensor Modules: 2 × Passive Infrared Sensors


2.4 RGB LED Ring Module: WS2812


2.5 Power Management


2.6 Expansion Connector Board (Custom + Breadboard)


2.7 Mechanical Structure & Mounting


2.8 Tools and Equipment


However, during assembly testing, I encountered a serious issue: the dimensional tolerance of the FDM prints was too large, especially the servo mounting holes. The connection plates for the claws could either not fit at all or were too loose in the horizontal and vertical directions.

I tried the following adjustments:

Despite these attempts, the print precision still failed to meet the requirements of the mechanical structure.

2. Precision Parts Switched to SLA Printing

Eventually, I switched all mechanical claw components—i.e., parts requiring high-precision fit with servos—to SLA resin printing. Details are as follows:

The results were very satisfying: extremely high print accuracy, perfect snap-fit, smooth surface with no layer lines, and tight, seamless assembly.


3. Central Structure and Leg Assembly

I completed the assembly of all parts and ensured the following:



Part 2: Automation and Application

1. Control System Architecture Selection

After completing the structural assembly and standing stability test, I moved on to the second phase of the quadruped robot project: making the structure move and implementing basic motion logic through automated control.

1.1. Control Platform Selection and Rationale

For this phase, I chose the following setup:


Reasons for selection:


2. Servo Numbering and Body Mapping

The servo numbering scheme was defined during the structural design phase. The details are as follows (referencing the top-down structural diagram):

Servo ID Controlled Part Function
S1 Left front knee Leg lift
S2 Left front hip Forward swing
S3 Right front knee Leg lift
S4 Right front hip Forward swing
S5 Left rear knee Leg lift
S6 Left rear hip Forward swing
S7 Right rear knee Leg lift
S8 Right rear hip Forward swing

I adopted a layout in which even-numbered servos control knee joints (vertical lift) and odd-numbered servos control hip joints (horizontal swing). This mapping makes it easier to organize and program motion sequences.


3. Motion Logic Design Process

1. Initial Program Structure

I began by creating the following function structure:

These motion functions control each servo individually using esp.servo(Sn, angle).

2. Basic Gait Unit Design

Referring to diagonal gait patterns in real quadrupeds, I defined a full cycle as:

A → B → C → D → (loop)

Frame Core Motion Description
A Lift left front + right rear leg → swing
B Legs land and push forward
C Lift right front + left rear leg → swing
D Legs land and complete forward propulsion

4. Code Implementation & Function Breakdown

1. DF_Initial_state(): Servo Initialization
void DF_Initial_state() {
        esp.servo(S1, 90); // Left front knee
        esp.servo(S2, 90); // Left front hip
        esp.servo(S3, 90); // Right front knee
        esp.servo(S4, 90); // Right front hip
        esp.servo(S5, 90); // Left rear knee
        esp.servo(S6, 90); // Left rear hip
        esp.servo(S7, 90); // Right rear knee
        esp.servo(S8, 90); // Right rear hip
        }
        

Used for zeroing servo positions after power-on to avoid erratic behavior or self-triggering.

2. DF_Standing(): Ready Posture
esp.servo(S1, 135);
        esp.servo(S2, 135);
        esp.servo(S3, 45);
        esp.servo(S4, 45);
        

Forms a balanced, crouched stance for starting the next leg movement.

3. DF_Lying_down(): Crouch Simulation
esp.servo(S1, 90);
        esp.servo(S2, 135);
        

Used to demonstrate controlled resting action and test servo angle limits.

4. Gait Core Motion Frames

[A] Lift left front + right rear → swing

esp.servo(S1, 105);
        esp.servo(S2, 165);
        esp.servo(S7, 15);
        esp.servo(S8, 165);
        

[B] Legs land → push forward

esp.servo(S1, 135);
        esp.servo(S2, 105);
        esp.servo(S7, 45);
        esp.servo(S8, 105);
        

[C] Lift right front + left rear → swing

esp.servo(S3, 15);
        esp.servo(S4, 15);
        esp.servo(S5, 105);
        esp.servo(S6, 15);
        

[D] Legs land → push forward

esp.servo(S3, 45);
        esp.servo(S4, 45);
        esp.servo(S5, 135);
        esp.servo(S6, 75);
        

5. Main Function Execution Flow

void setup() {
            DF_Initial_state();
            delay(2000);
            DF_Standing();
            delay(300);
            DF_Lying_down();
            delay(300);
            DF_Standing();
            delay(300);
            for (int index = 0; index < 5; index++) {
                DF_Move_forward_action_A();
                delay(300);
                DF_Move_forward_action_B();
                delay(300);
                DF_Move_forward_action_C();
                delay(300);
                DF_Move_forward_action_D();
                delay(300);
            }
        }
        

Execution logic:
Initialize → Stand → Lie down → Stand again → Perform 5 full gait cycles → Stop

This sequence demonstrates the robot's full functional flow from power-on to movement, useful for both testing and presentation.




6. Debugging and Troubleshooting

After completing the program logic design and structural assembly, I conducted multiple rounds of debugging. The main goals were:


I recorded and resolved multiple real issues through a layered diagnosis approach:


1. Unresponsive Servos or Angle Errors

Symptoms: S7 and S8 showed no movement during Action A.

Troubleshooting:

Solutions: Changed slot, reconnected firmly, labeled channels


2. Unbalanced Movement, Tilting or Skewed Trajectory

Symptoms: Robot leaned forward and deviated to the left

Troubleshooting:

Solutions: Symmetrical angle table, replaced parts with SLA, reinforced servo mounting


3. Overheating and Buzzing Servos

Symptoms: S2/S8 heated up and buzzed after 2 minutes

Troubleshooting:

Solutions: Limit angles, add buffer frames, use MG90S in future, extend delay()


4. Jerky or Irregular Movements

Symptoms: Frames switched before motion completion

Troubleshooting:

Solutions: Increased delay to 350ms, added intermediate angles, suggest using millis()


5. Glitchy or Unstable Control Logic

Symptoms: Random desynchronization or jitter, restored after reboot

Troubleshooting:

Solutions: Separate power supplies, added 1000uF capacitor, recommend independent DC supply


Debugging Summary

I developed a reliable debugging workflow:


Ultimately, I realized that a stable robotic motion system is built on precise mechanics, reliable power delivery, and synchronized timing—not just correct code.


Quadruped_SG90_Robot_stl.rar