|
| 1 | +# openUC2 Xiao AI Microscope hardware control PCB |
| 2 | + |
| 3 | +**Overview:** |
| 4 | + |
| 5 | +This PCB connects a Seeed Studio Xiao ESP32S3 module to the openUC2 modular cube system. It features a range of components for illumination and control of motors or servos, providing an I2C bus for integration with the UC2 ecosystem. The board is primarily designed for controlling a motorized system such as peristaltic pumps and driving Neopixel LEDs, with additional support for PWM-driven components and touch inputs. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +### **Components:** |
| 10 | + |
| 11 | +1. **Microcontroller:** |
| 12 | + - **Seeed Studio Xiao ESP32S3**: A small ESP32-based microcontroller module, mounted via header sockets. The microcontroller is responsible for handling the firmware (UC2-ESP) and communicating with the peripherals. |
| 13 | + |
| 14 | +2. **Power:** |
| 15 | + - Powered via **5V** input from the Xiao USB port, with a power distribution setup across the board. |
| 16 | + - **Voltage regulators and capacitors** (such as 100uF, 16V) ensure stable power to the motors and peripherals. |
| 17 | + |
| 18 | +3. **Neopixel LED:** |
| 19 | + - **WS2812B Neopixel** mounted on the PCB, connected to the Xiao (TX/A6 pin). |
| 20 | + - **Optional extension connector** for additional Neopixels, allowing external LED strips or panels to be driven. |
| 21 | + - A **cuttable solder jumper** disables the onboard Neopixel if needed. |
| 22 | + |
| 23 | +4. **Touch Buttons:** |
| 24 | + - Two **touch-sensitive fields** are connected to specific GPIO pins (marked TOUCH_1 and TOUCH_2). |
| 25 | + - These buttons allow for interactive input, triggering various functions (e.g., illumination control or motor activation) via the UC2-ESP firmware. |
| 26 | + |
| 27 | +5. **Motor Drivers:** |
| 28 | + - **Two DRV8837C H-bridge motor drivers** are included on the board, providing control for two DC motors or a peristaltic pump. |
| 29 | + - Each driver has connections for **IN1, IN2**, and **OUT1, OUT2**, with bulk capacitors (100uF, 16V) ensuring stable operation. |
| 30 | + - The motors are powered directly from the 5V system, with a maximum load current of 200mA per driver. |
| 31 | + |
| 32 | +6. **Servo/PWM Ports:** |
| 33 | + - **Two servo headers** (3-pin 2.54mm pitch) for connecting servos or other PWM-driven devices. |
| 34 | + - Each header provides power, ground, and a PWM signal from the Xiao, supporting standard 9g servos or similar devices. |
| 35 | + - Dedicated **servo PWM pins** are used to send signals to the connected servos. |
| 36 | + |
| 37 | +7. **I2C Interface:** |
| 38 | + - **I2C headers (J701, J702)** provide connections for the UC2 bus system, enabling the integration of additional peripherals (such as sensors or other cubes). |
| 39 | + - **I2C pull-up resistors (2.2kΩ)** are included onboard, with optional solder jumpers for enabling or disabling these pull-ups. |
| 40 | + |
| 41 | +### **Key Connections:** |
| 42 | + |
| 43 | +1. **Microcontroller:** |
| 44 | + - Pin PA4_A1_D1: Connects to motor driver IN1. |
| 45 | + - Pin PA5_A2_D2: Connects to motor driver IN2. |
| 46 | + - Pin PB08_TX: Connects to Neopixel DIN for LED control. |
| 47 | + - I2C_SDA (PA8_A4) and I2C_SCL (PA9_A5) pins are connected to the I2C bus for external communication. |
| 48 | + |
| 49 | +2. **Peripherals:** |
| 50 | + - Neopixel connected to **TX/A6** of Xiao. |
| 51 | + - **Touch inputs** connected to dedicated pins on the Xiao. |
| 52 | + - **Motor drivers** controlled via IN1 and IN2 lines from the Xiao, providing forward/reverse motor control. |
| 53 | + - **Servo connectors** provide power and PWM signals to connected servos. |
| 54 | + |
| 55 | +### **Power Management:** |
| 56 | + - **5V input** powers the Xiao and is distributed to the other components, with onboard voltage regulation. |
| 57 | + - Capacitance to handle high inrush current (max. 470uF). |
| 58 | + |
| 59 | +### **Firmware Integration:** |
| 60 | + - The board runs on the UC2-ESP firmware, leveraging the ESP32S3's capabilities to control motors, Neopixel LEDs, and servos while communicating over I2C. |
| 61 | + - Firmware includes support for both **manual control** via touch inputs and **automated sequences** for driving motors and lighting. |
| 62 | + |
| 63 | +### **Usage Notes:** |
| 64 | + - Ensure all components are connected before powering the system via USB. |
| 65 | + - The onboard Neopixel can be extended by attaching an external strip to the **Neopixel Extend** port. |
| 66 | + - For higher power requirements, ensure adequate power supply via the USB connection. |
| 67 | + |
| 68 | +This PCB design provides a versatile platform for integrating the Seeed Xiao ESP32S3 into the UC2 modular system, enabling advanced control of motors, servos, and lighting, with seamless integration into the UC2 bus system. |
| 69 | + |
| 70 | +## Mounting inside a cube |
| 71 | + |
| 72 | +It gets as easy as placing the PCB inside a cube. Et voila: |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +## Schematics |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +## Pin Table |
| 94 | + |
| 95 | + |
| 96 | +| **ESP32S3 Pin** | **PCB Port/Component** | **Function** | |
| 97 | +|------------------------|-------------------------------------------|-------------------------------------------| |
| 98 | +| **PA02 (A0/D0)** | Motor Driver 1 (IN1) | Motor control (Input 1) | |
| 99 | +| **PA04 (A1/D1)** | Motor Driver 1 (IN2) | Motor control (Input 2) | |
| 100 | +| **PA10 (A2/D2)** | Motor Driver 2 (IN1) | Motor control (Input 1) | |
| 101 | +| **PA11 (A3/D3)** | Motor Driver 2 (IN2) | Motor control (Input 2) | |
| 102 | +| **PA08 (A4/D4/SDA)** | I2C SDA | I2C Data Line | |
| 103 | +| **PA09 (A5/D5/SCL)** | I2C SCL | I2C Clock Line | |
| 104 | +| **PB08 (A6/TX)** | Neopixel LED (DIN) | Neopixel Data Line | |
| 105 | +| **PB09 (D7/RX)** | Neopixel Extend (DIN) | Extension for external Neopixel LED | |
| 106 | +| **PA05 (A9/D9/MISO)** | Touch Button 1 (TP103) | Touch input 1 | |
| 107 | +| **PA06 (A10/D10/MOSI)** | Touch Button 2 (TP104) | Touch input 2 | |
| 108 | +| **PA07 (A8/D8/SCK)** | Servo Connector 1 (PWM) | PWM signal for Servo 1 | |
| 109 | +| **PA11 (D3)** | Servo Connector 2 (PWM) | PWM signal for Servo 2 | |
| 110 | +| **3.3V** | Power Supply | Powers Xiao and connected components | |
| 111 | +| **5V** | Power Supply (Neopixel and Motor Drivers)| Powers high-power components like motors | |
| 112 | +| **GND** | Ground | Common ground for all components | |
| 113 | + |
| 114 | +## Sample Programm for the Arduino IDE |
| 115 | + |
| 116 | +Here’s a simple Arduino sketch for the ESP32S3 on the Seeed Studio Xiao module. This sketch will test the Neopixel LED, motor drivers, touch buttons, servos, and I2C functionality on the PCB. You need the required libraries installed (`Adafruit_NeoPixel`, `Wire` for `I2C`, and `ESP_Servo` for servo control). The sketch assumes the UC2-ESP firmware isn't running. |
| 117 | + |
| 118 | +```cpp |
| 119 | +#include <Adafruit_NeoPixel.h> |
| 120 | +#include <Wire.h> |
| 121 | +#include <ESP32Servo.h> // ESP32-specific servo library |
| 122 | + |
| 123 | +// Pin definitions for Xiao ESP32S3 (using D1, D2, etc.) |
| 124 | +#define NEOPIXEL_PIN D6 // Neopixel data pin (TX) |
| 125 | +#define TOUCH_PIN_1 D1 // Touch Button 1 (GPIO1) |
| 126 | +#define TOUCH_PIN_2 D2 // Touch Button 2 (GPIO2) |
| 127 | +#define MOTOR_1_IN1 D0 // Motor 1 IN1 (GPIO0) |
| 128 | +#define MOTOR_1_IN2 D9 // Motor 1 IN2 (GPIO9) |
| 129 | +#define MOTOR_2_IN1 D10 // Motor 2 IN1 (GPIO10) |
| 130 | +#define MOTOR_2_IN2 D3 // Motor 2 IN2 (GPIO3) |
| 131 | +#define I2C_SDA D4 // I2C SDA (GPIO4) |
| 132 | +#define I2C_SCL D5 // I2C SCL (GPIO5) |
| 133 | +#define SERVO_PIN_1 D8 // Servo 1 PWM (GPIO8) |
| 134 | +#define SERVO_PIN_2 D11 // Servo 2 PWM (GPIO11) |
| 135 | + |
| 136 | +// Motor driver setup |
| 137 | +#define MOTOR_SPEED 255 // Max PWM value for motors |
| 138 | + |
| 139 | +// Neopixel setup |
| 140 | +#define NUMPIXELS 1 // Number of neopixels |
| 141 | +Adafruit_NeoPixel neopixel(NUMPIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800); |
| 142 | + |
| 143 | +// Servo setup |
| 144 | +Servo servo1; |
| 145 | +Servo servo2; |
| 146 | + |
| 147 | +// I2C test address |
| 148 | +const int i2cAddress = 0x3C; // Example I2C address (adjust for your setup) |
| 149 | + |
| 150 | +// Test variables |
| 151 | +int touchState1 = 0; |
| 152 | +int touchState2 = 0; |
| 153 | + |
| 154 | +void setup() { |
| 155 | + // Initialize Serial for debugging |
| 156 | + Serial.begin(115200); |
| 157 | + |
| 158 | + // Initialize Neopixel |
| 159 | + neopixel.begin(); |
| 160 | + neopixel.setBrightness(50); // Adjust brightness (0-255) |
| 161 | + |
| 162 | + // Initialize touch pins |
| 163 | + pinMode(TOUCH_PIN_1, INPUT); |
| 164 | + pinMode(TOUCH_PIN_2, INPUT); |
| 165 | + |
| 166 | + // Initialize motor pins |
| 167 | + pinMode(MOTOR_1_IN1, OUTPUT); |
| 168 | + pinMode(MOTOR_1_IN2, OUTPUT); |
| 169 | + pinMode(MOTOR_2_IN1, OUTPUT); |
| 170 | + pinMode(MOTOR_2_IN2, OUTPUT); |
| 171 | + |
| 172 | + // Initialize I2C |
| 173 | + Wire.begin(I2C_SDA, I2C_SCL); |
| 174 | + |
| 175 | + // Initialize servos |
| 176 | + servo1.attach(SERVO_PIN_1); |
| 177 | + servo2.attach(SERVO_PIN_2); |
| 178 | +} |
| 179 | + |
| 180 | +void loop() { |
| 181 | + // Test Neopixel LED |
| 182 | + neopixelTest(); |
| 183 | + |
| 184 | + // Test Touch Buttons |
| 185 | + touchTest(); |
| 186 | + |
| 187 | + // Test Motor Drivers |
| 188 | + motorTest(); |
| 189 | + |
| 190 | + // Test Servo Motors |
| 191 | + servoTest(); |
| 192 | + |
| 193 | + // Test I2C Communication |
| 194 | + i2cTest(); |
| 195 | + |
| 196 | + delay(2000); // Wait 2 seconds before the next test cycle |
| 197 | +} |
| 198 | + |
| 199 | +// Neopixel Test: Cycles through colors |
| 200 | +void neopixelTest() { |
| 201 | + Serial.println("Testing Neopixel..."); |
| 202 | + neopixel.setPixelColor(0, neopixel.Color(255, 0, 0)); // Red |
| 203 | + neopixel.show(); |
| 204 | + delay(500); |
| 205 | + neopixel.setPixelColor(0, neopixel.Color(0, 255, 0)); // Green |
| 206 | + neopixel.show(); |
| 207 | + delay(500); |
| 208 | + neopixel.setPixelColor(0, neopixel.Color(0, 0, 255)); // Blue |
| 209 | + neopixel.show(); |
| 210 | + delay(500); |
| 211 | +} |
| 212 | + |
| 213 | +// Touch Button Test: Reads touch inputs |
| 214 | +void touchTest() { |
| 215 | + touchState1 = digitalRead(TOUCH_PIN_1); |
| 216 | + touchState2 = digitalRead(TOUCH_PIN_2); |
| 217 | + |
| 218 | + Serial.print("Touch Button 1: "); |
| 219 | + Serial.println(touchState1); |
| 220 | + Serial.print("Touch Button 2: "); |
| 221 | + Serial.println(touchState2); |
| 222 | +} |
| 223 | + |
| 224 | +// Motor Test: Drives both motors forward and backward |
| 225 | +void motorTest() { |
| 226 | + Serial.println("Testing Motor 1..."); |
| 227 | + // Motor 1 Forward |
| 228 | + digitalWrite(MOTOR_1_IN1, HIGH); |
| 229 | + digitalWrite(MOTOR_1_IN2, LOW); |
| 230 | + delay(1000); |
| 231 | + // Motor 1 Backward |
| 232 | + digitalWrite(MOTOR_1_IN1, LOW); |
| 233 | + digitalWrite(MOTOR_1_IN2, HIGH); |
| 234 | + delay(1000); |
| 235 | + |
| 236 | + Serial.println("Testing Motor 2..."); |
| 237 | + // Motor 2 Forward |
| 238 | + digitalWrite(MOTOR_2_IN1, HIGH); |
| 239 | + digitalWrite(MOTOR_2_IN2, LOW); |
| 240 | + delay(1000); |
| 241 | + // Motor 2 Backward |
| 242 | + digitalWrite(MOTOR_2_IN1, LOW); |
| 243 | + digitalWrite(MOTOR_2_IN2, HIGH); |
| 244 | + delay(1000); |
| 245 | + |
| 246 | + // Stop both motors |
| 247 | + digitalWrite(MOTOR_1_IN1, LOW); |
| 248 | + digitalWrite(MOTOR_1_IN2, LOW); |
| 249 | + digitalWrite(MOTOR_2_IN1, LOW); |
| 250 | + digitalWrite(MOTOR_2_IN2, LOW); |
| 251 | +} |
| 252 | + |
| 253 | +// Servo Test: Sweep both servos back and forth |
| 254 | +void servoTest() { |
| 255 | + Serial.println("Testing Servos..."); |
| 256 | + for (int pos = 0; pos <= 180; pos++) { |
| 257 | + servo1.write(pos); |
| 258 | + servo2.write(pos); |
| 259 | + delay(15); // Wait for the servo to reach the position |
| 260 | + } |
| 261 | + for (int pos = 180; pos >= 0; pos--) { |
| 262 | + servo1.write(pos); |
| 263 | + servo2.write(pos); |
| 264 | + delay(15); |
| 265 | + } |
| 266 | +} |
| 267 | + |
| 268 | +// I2C Test: Scans for I2C devices |
| 269 | +void i2cTest() { |
| 270 | + Serial.println("Scanning for I2C devices..."); |
| 271 | + Wire.beginTransmission(i2cAddress); |
| 272 | + if (Wire.endTransmission() == 0) { |
| 273 | + Serial.println("I2C device found."); |
| 274 | + } else { |
| 275 | + Serial.println("No I2C device found."); |
| 276 | + } |
| 277 | +} |
| 278 | +``` |
| 279 | + |
| 280 | +## Troubleshoot |
| 281 | + |
| 282 | +If you have any questions, please feel free to reach out to us using the Forum: openuc2.discourse.group. |
0 commit comments