diff --git a/README.md b/README.md index a67df97..f73b59c 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,16 @@ -# Multi-Functional Controller (MFC) & 4WD RC Vehicle +# Multi-Functional Controller (MFC) [](https://github.com/espressif/esp-idf) -[](https://www.espressif.com/en/products/socs/esp32-s3) -[](#32-rc-vehicle-receiver-node) +[](https://www.espressif.com/en/products/socs/esp32-s3) [](https://www.kicad.org/) [](https://en.wikipedia.org/wiki/C_(programming_language)) [](https://www.freertos.org/) ## 1. Project Overview & Aim -- **Primary Goal:** Engineer a high-performance, bare-metal handheld remote controller (**MFC**) from scratch using an **ESP32-S3-N16R8**, paired with a custom **4WD RC Vehicle** controlled by an **ARM Cortex-M3 (`GD32F103C8T6`)**. -- **Secondary Objectives:** Extend the controller's capabilities to include a **cloud-connected AI voice assistant** (`MAX4466`), **local FAT32 SD card telemetry logging**, and **PC Gamepad (`USB HID / Bluetooth`)** support. -- **Tech Stack:** C/C++, ESP-IDF v5.x (FreeRTOS), bare-metal register manipulation, SPI, I2C, Hardware Pulse Counter (`PCNT`), and One-Shot `ADC1`. +- **Primary Goal:** Engineer a high-performance, bare-metal Multi-Functional Controller (**MFC**) from scratch using an **ESP32-S3-N16R8** for low-latency 2.4 GHz RF control (such as custom RC platforms) and **PC Gamepad (`USB HID / Bluetooth`)** support. +- **Secondary Objectives:** Extend the controller's capabilities to include a **cloud-connected AI voice assistant**, **local FAT32 SD card telemetry logging**, and **multi-transducer acoustic feedback**. +- **Tech Stack:** C/C++, ESP-IDF v5.x (FreeRTOS), bare-metal register manipulation, SPI, Hardware Pulse Counter (`PCNT`), and One-Shot `ADC1`. --- @@ -20,12 +19,12 @@ > [!NOTE] > **Early Prototype Notice (Rev 0.1 Carrier Build):** > The photographs and schematic below represent the **very early initial stage** of the physical hardware build. At this stage, only the core carrier foundation is soldered onto the 6×9 cm perfboard: the **ESP32-S3-N16R8 microcontroller**, **nRF24L01+ 2.4 GHz radio module**, **100 µF electrolytic burst-smoothing capacitor**, **signal male pin headers**, and **power rail male headers**. -> The repository's firmware (`firmware/main/mmcontroller.c`) and schematic (`hardware/mfc-1.kicad_sch`) are intentionally kept matched to this verified **Rev 0.1 hardware baseline**. As the new modules (`1.8" ST7789 TFT`, `K-Silver PS5 Hall-Effect Joysticks`, `MicroSD`, `MAX4466`, `2N2222` buzzer stage, and enclosure) are physically integrated, both the hardware photos and firmware will be updated step-by-step. +> The repository's firmware (`firmware/main/mmcontroller.c`) and schematic (`hardware/mfc-1.kicad_sch`) are intentionally kept matched to this verified **Rev 0.1 hardware baseline**. As the new controller modules (`1.8" ST7789 TFT`, `K-Silver PS5 Hall-Effect Joysticks`, `MicroSD`, `MAX4466`, `2N2222` buzzer stage, and enclosure) are physically integrated, both the hardware photos and firmware will be updated step-by-step. - **Controller Prototype (Rev 0.1):** Prototyped on a **6×9 cm perfboard**. The `ESP32-S3-N16R8` communicates over a shared `SPI2_HOST` bus with a Nordic `nRF24L01+` 2.4 GHz transceiver and a temporary benchtop 1.3" SH1106 OLED display connected via the male breakout headers. - **Current Baseline Firmware:** A deterministic FreeRTOS state machine (`firmware/main/mmcontroller.c`) handles hardware quadrature decoding (`PCNT`) for a `KY-040` rotary encoder menu UI, `300 ms` software button debouncing, and live 2.4 GHz RF channel configuration (`0–125`). - **Display Hardware Pivot (`1.3" OLED` $\rightarrow$ `1.8" ST7789 TFT`):** Bench testing revealed that the 7-pin 1.3" OLED module lacks a physical Chip Select (`CS`) pin (hard-tied to GND internally), causing SPI bus collisions when sharing the bus. We are upgrading to a **1.8" ST7789 Color TFT LCD** (which exposes a dedicated hardware `CS` pin on `GPIO 10`) to share the SPI bus safely without bus contention. -- **Manufacturing & Enclosure Status:** Paused cutting the rigid ABS plastic project box (`DT-100`, `190 × 137 × 59 mm`) until next month when a variable 3-speed rotary tool (`Dremel/E108`) and `2.35 mm` diamond cutting wheels arrive to ensure clean, professional cutouts without melting the ABS plastic. +- **Manufacturing & Enclosure Status:** Paused cutting the rigid ABS plastic enclosure (`DT-100`, `190 × 137 × 59 mm`) until next month when a variable 3-speed rotary tool (`Dremel/E108`) and `2.35 mm` diamond cutting wheels arrive to ensure clean, professional cutouts without melting the ABS plastic.
@@ -55,11 +54,11 @@
---
-## 3. Dual-Node System Architecture & Bill of Materials (BOM)
+## 3. Controller Hardware Architecture & Bill of Materials (BOM)
```mermaid
flowchart LR
- subgraph TX["Node 1: Handheld Controller (ESP32-S3-N16R8)"]
+ subgraph MFC["Multi-Functional Controller (ESP32-S3-N16R8)"]
MCU["ESP32-S3-N16R8 (FreeRTOS Dual-Core)"]
HALL["2x K-Silver PS5 Hall-Effect Joysticks"] -->|ADC1| MCU
MIC["MAX4466 Electret Mic Pre-Amp"] -->|ADC1| MCU
@@ -67,21 +66,10 @@ flowchart LR
MCU -->|SPI2_HOST + CS GPIO10| TFT["1.8-inch ST7789 Color TFT"]
MCU -->|SPI2_HOST + CS GPIO18| SD["MicroSD Card (FAT32)"]
MCU -->|2N2222 NPN Drivers| BUZ["1x Passive + 2x Active Buzzers"]
- MCU -->|SPI2_HOST + CSN GPIO14| NRF_TX["nRF24L01+ 2.4GHz TX"]
+ MCU -->|SPI2_HOST + CSN GPIO14| NRF_TX["nRF24L01+ 2.4GHz Transceiver"]
end
-
- subgraph RX["Node 2: 4WD RC Vehicle (GD32F103C8T6)"]
- NRF_RX["nRF24L01+ PA+LNA (1km SMA Antenna)"] -->|SPI| GD32["GD32F103C8T6 (ARM Cortex-M3)"]
- IMU["MPU9250 9-DOF IMU"] -->|I2C| GD32
- TOF["VL53L0X ToF / HC-SR04"] -->|I2C / Divider| GD32
- GD32 -->|Closed-Loop PID PWM| MOT["4x JGB37-520 12V 333RPM Encoder Motors"]
- end
-
- NRF_TX <-->|"2.4 GHz RF Link (Ch 0-125)"| NRF_RX
```
-### 3.1 Handheld Controller (MFC — Transmitter Node)
-
| Subsystem | Component | Technical Details & Role | Build State |
| :--- | :--- | :--- | :---: |
| **MCU** | **Espressif ESP32-S3-N16R8** | Dual-core Xtensa® LX7 @ 240 MHz, 16 MB Quad SPI Flash, 8 MB Octal PSRAM. | **Installed (Rev 0.1)** |
@@ -93,18 +81,9 @@ flowchart LR
| **Voice AI** | **MAX4466 Electret Microphone Module** | Analog pre-amplifier with adjustable gain for cloud-connected AI voice assistant input. | **Next Upgrade** |
| **Data Logging** | **Arduino Micro SD Card Module** | SPI interface, formatted `FAT32` for local telemetry and configuration logging. | **Next Upgrade** |
| **Audio Output** | **1× Passive Buzzer + 2× Active Buzzers** | Passive buzzer for melodies + 2× active buzzers for percussive UI clicks, driven by **2N2222 NPN Transistors**. | **Next Upgrade** |
-| **Power System** | **Dual 18650 Li-ion + TP4056 + MT3608** | Dual 18650 cells, `TP4056` charger, `MT3608` DC-DC boost converter (5V rail), `1N5817` Schottky & `1N4001` diodes, `100 nF` ceramic caps. | **Next Upgrade** |
-
-### 3.2 RC Vehicle (Receiver Node)
-
-| Subsystem | Component | Technical Details & Role |
-| :--- | :--- | :--- |
-| **MCU** | **GD32F103C8T6 Mini Board** | 32-bit ARM® Cortex®-M3 real-time vehicle controller. |
-| **RF Telemetry** | **nRF24L01+ PA+LNA Module** | High-power 2.4 GHz transceiver with Power Amplifier, Low-Noise Amplifier, and external SMA antenna (~1 km range). |
-| **IMU / Navigation**| **MPU9250 9-DOF Sensor** | 3-axis Gyroscope, 3-axis Accelerometer, and 3-axis Magnetometer (I2C) for tilt-compensated heading. |
-| **Drivetrain** | **4× JGB37-520 12V 333 RPM Gear Motors** | High-torque 12V DC gear motors with built-in quadrature encoders for closed-loop PID velocity control. |
-| **Chassis / Box** | **DT-100 Project Box** | Rigid black ABS enclosure (`190 × 137 × 59 mm`). |
-| **Power System** | **12V Battery + Motor Drivers** | 12V traction battery pack, heavy-duty H-bridge motor drivers, and **12–24V Waterproof Main Switch**. |
+| **Enclosure** | **DT-100 Project Box** | Rigid black ABS desktop/console instrument enclosure (`190 × 137 × 59 mm`). | **Next Upgrade** |
+| **Switches** | **Waterproof Main + KTS-303 Toggle + Slide** | 12–24V illuminated push-button switch, KTS-303 3-pin toggle switch, and 180° vertical slide switch. | **Next Upgrade** |
+| **Power System** | **Dual 18650 Li-ion + TP4056 + MT3608** | Dual 18650 cells (4800 mAh), `TP4056` charger, `MT3608` DC-DC boost converter, `1N5817` Schottky & `1N4001` diodes, `100 nF` ceramic caps. | **Next Upgrade** |
---
@@ -130,7 +109,7 @@ flowchart LR
### 4.2 Planned Pin Allocation for Phase 2 Modules (Safe ESP32-S3 Matrix)
-To avoid ESP32-S3 Octal Flash/PSRAM pins (`GPIO 26–37`), USB-OTG pins (`GPIO 19–20`), strapping pins (`GPIO 0, 3, 45, 46`), and `ADC2` Wi-Fi conflicts, the remaining modules map cleanly to:
+To avoid ESP32-S3 Octal Flash/PSRAM pins (`GPIO 26–37`), USB-OTG pins (`GPIO 19–20`), strapping pins (`GPIO 0, 3, 45, 46`), and `ADC2` Wi-Fi conflicts, the remaining controller modules map cleanly to:
| Upcoming Module | Signal | Recommended GPIO | Hardware Resource |
| :--- | :--- | :---: | :--- |
@@ -148,19 +127,18 @@ To avoid ESP32-S3 Octal Flash/PSRAM pins (`GPIO 26–37`), USB-OTG pins (`GPIO 1
1. **Enclosure Machining RPM Rule:** Do **NOT** use standard fixed `16,000 RPM` rotary tools on the `DT-100` ABS plastic enclosure; high friction melts ABS instead of cutting it. Machining is paused until the variable 3-speed rotary tool with `2.35 mm` diamond cutting discs arrives.
2. **Hall-Effect Gimbal Polarity Protection:** Do **NOT** wire the K-Silver (KS) PS5 Hall-effect joystick `VCC` backward. Unlike passive carbon potentiometers, these are active 3.3V CMOS magnetic sensors and will burn out immediately under reverse polarity.
-3. **5V Sensor Level Shifting on GD32:** Do **NOT** wire a 5V `HC-SR04` ultrasonic `ECHO` pin directly to the 3.3V `GD32F103C8T6` without a resistor voltage divider (or use the 3.3V `VL53L0X` I2C Time-of-Flight sensor instead).
-4. **nRF24L01+ Burst Decoupling:** Always keep the `100 µF` electrolytic capacitor across the `nRF24L01+` `VCC`/`GND` pins (alongside a `100 nF` ceramic cap for high-frequency noise) to prevent 3.3V rail brown-outs during PTX transmission bursts.
-5. **2N2222 Base Resistor & Flyback Protection:** Always place a **`1 kΩ` series resistor** between the ESP32-S3 GPIO pin and the Base (`B`) of each `2N2222` NPN transistor (an unresisted BJT base clamps the GPIO to `0.7V` and draws excessive current). Place a **`1N4001` flyback diode** in reverse-parallel across inductive buzzer coils.
-6. **Multi-Slave SPI Bus Initialization Rule:** When sharing `SPI2_HOST` across `nRF24L01+` (`GPIO 14`), `TFT Display` (`GPIO 10`), and `MicroSD` (`GPIO 18`), configure all three `CS` pins as outputs and drive them **HIGH (`1`)** prior to initializing the first SPI device so uninitialized slaves do not corrupt `MISO` (`GPIO 13`).
+3. **nRF24L01+ Burst Decoupling:** Always keep the `100 µF` electrolytic capacitor across the `nRF24L01+` `VCC`/`GND` pins (alongside a `100 nF` ceramic cap for high-frequency noise) to prevent 3.3V rail brown-outs during PTX transmission bursts.
+4. **2N2222 Base Resistor & Flyback Protection:** Always place a **`1 kΩ` series resistor** between the ESP32-S3 GPIO pin and the Base (`B`) of each `2N2222` NPN transistor (an unresisted BJT base clamps the GPIO to `0.7V` and draws excessive current). Place a **`1N4001` flyback diode** in reverse-parallel across inductive buzzer coils.
+5. **Multi-Slave SPI Bus Initialization Rule:** When sharing `SPI2_HOST` across `nRF24L01+` (`GPIO 14`), `TFT Display` (`GPIO 10`), and `MicroSD` (`GPIO 18`), configure all three `CS` pins as outputs and drive them **HIGH (`1`)** prior to initializing the first SPI device so uninitialized slaves do not corrupt `MISO` (`GPIO 13`).
---
## 6. Immediate Next Steps & Engineering Roadmap
-1. **1.8" ST7789 TFT Migration:** Rewrite the display initialization and frame buffer logic using ESP-IDF's `esp_lcd` component to replace the custom 5×8 monochrome OLED driver once the CS-equipped TFT module is wired. *(Note: Verify whether the 1.8" PCB uses the `ST7789` or `ST7735S` driver IC on arrival; both use identical SPI wiring and `esp_lcd` panel APIs).*
+1. **1.8" ST7789 TFT Migration:** Rewrite the display initialization and frame buffer logic using ESP-IDF's `esp_lcd` component to replace the custom 5×8 monochrome OLED driver once the CS-equipped TFT module is wired.
2. **MicroSD Card SPI & FATFS Setup:** Configure the Arduino MicroSD card module on the shared SPI bus and initialize the `FATFS` virtual filesystem (`VFS`) for reading/writing telemetry logs.
3. **NVS Hall-Effect Joystick Calibration:** Write the calibration routine for the K-Silver PS5 Hall-effect joysticks—measuring resting center, minimum, and maximum voltages and saving them persistently to ESP32-S3 Non-Volatile Storage (`NVS`) flash.
-4. **GD32F103C8T6 Vehicle Receiver Firmware:** Structure the ARM Cortex-M3 C codebase to poll the `nRF24L01+ PA+LNA` module, read `MPU9250` 9-DOF I2C telemetry, and run closed-loop PID motor control on the 4× `JGB37-520` encoder motors.
+4. **USB HID & Bluetooth Gamepad Stack:** Expose the calibrated Hall-effect axes and buttons as a standard gamepad interface over the ESP32-S3 native USB-OTG port and BLE.
---