# Flux.ai Design Brief: Integrated 70A ESC + AFHDS 2A Receiver

## Project Overview
Design a single, sealed Printed Circuit Board (PCB) that integrates a 70A / 18.5V (5S LiPo) brushless Electronic Speed Controller (ESC) with a 2.4GHz Flysky AFHDS 2A compatible receiver. The board will be powered directly from a 5S LiPo battery and output 3-phase power to a brushless motor. The design must be optimized for a waterproof RC boat application.

## Reference Designs Provided
This project merges two proven open-source hardware designs. You have been provided with the KiCad schematics and BOMs for both:

1. **ESC Reference:** VESC (Vedder ESC) Hardware v4.12
   - **MCU:** STM32F405RGT6
   - **Gate Driver:** Texas Instruments DRV8302
   - **Power Stage:** 6x N-Channel MOSFETs (e.g., IRFS7530 or similar 60V high-current FETs)
   - **Current Sensing:** Low-side shunt resistors

2. **Receiver Reference:** DIY-Multiprotocol-TX-Module (A7105 Circuit)
   - **RF Transceiver:** AMICCOM A7105
   - **Protocol:** Flysky AFHDS 2A
   - **Antenna:** U.FL connector or PCB trace antenna

## Architecture & Integration Instructions for Flux.ai Copilot

Please execute the following integration steps to merge these circuits into a single schematic and layout:

### 1. Microcontroller Consolidation
- **Do not use two microcontrollers.** The STM32F405RGT6 from the VESC design will handle both motor control and the AFHDS 2A receiver decoding.
- Connect the A7105 RF IC directly to the STM32F405RGT6 via SPI.
- **A7105 SPI Connections to STM32:**
  - SCK (Clock)
  - SDIO (MOSI/MISO multiplexed, or use 3-wire SPI configuration)
  - SCS (Chip Select)
  - GIO1 (Interrupt/Data Ready)

### 2. Power Management (BEC Integration)
- **Do not add a separate BEC IC.** The DRV8302 gate driver includes an integrated synchronous buck converter (DVDD).
- The DRV8302 buck converter accepts the 18.5V (5S) input and outputs **5V at 1.5A**.
- Use this 5V rail to power the STM32F405RGT6 (via its internal 3.3V LDO or a dedicated 3.3V LDO like the standard VESC design) and the A7105 RF IC (which requires 3.3V).
- Ensure proper decoupling capacitors (100nF and 10uF) are placed near the power pins of the A7105 and STM32.

### 3. High-Current Power Stage (70A / 18.5V)
- The input voltage is 18.5V nominal (5S LiPo), peaking at 21V fully charged.
- Select 6x N-Channel MOSFETs rated for at least 60V and >100A continuous (e.g., D2PAK-7 package as in VESC).
- **Layout Constraint:** The power traces (BATT+, GND, and the 3 motor phases) must be designed to carry 70A continuous. Use wide copper pours, polygon fills, and consider exposing the solder mask on these traces to allow for solder thickening or copper busbar reinforcement during assembly.

### 4. Thermal Management — Single-Side Heat Sink Requirement
All components that generate significant heat and require thermal management must be placed on the **same side of the board** (the bottom copper layer / component side designated as the heat sink side). This is a hard layout constraint driven by the application of a water jacket heat sink to the underside of the board for active cooling in a marine environment.

The following components must all be placed on the same board side:

- All 6x power MOSFETs (the primary heat-generating components at 70A)
- The DRV8302 gate driver IC (which also dissipates heat under load)
- Any power inductors or high-current shunt resistors

No heat-generating power components may be placed on the opposite side of the board. The opposite side is reserved for the STM32F405 microcontroller, the A7105 RF IC, passive components, and the servo headers. This ensures the water jacket heat sink can make full, unobstructed thermal contact with all power components through a single flat mating surface.

The exposed thermal pad of the DRV8302 and the drain pads of the D2PAK MOSFETs must have copper pour and thermal vias connecting to the bottom copper layer to maximize heat transfer to the water jacket interface.

### 5. RF Section Isolation
- The A7105 RF section operates at 2.4GHz and is highly sensitive to Electromagnetic Interference (EMI).
- **Layout Constraint:** Place the A7105, its 16MHz crystal, and the antenna matching network as far away from the DRV8302 switching regulator and the high-current MOSFETs as possible.
- Provide a solid, unbroken ground plane under the RF section.
- Ensure there is no copper pour (keep-out zone) directly under the antenna if a PCB trace antenna is used.

### 5. External Connections
The board should have minimal external connections to facilitate waterproofing:
- **Input:** 2x large pads for Battery + and Battery - (18.5V)
- **Output:** 3x large pads for Motor Phase A, B, and C
- **Programming/Debug:** Expose SWD pins (SWDIO, SWCLK, GND, 3.3V) for flashing the STM32.

### 6. Servo Output Channels
In addition to the brushless motor drive, the board must output two standard RC servo PWM signals for a steering servo (Channel 2) and an optional auxiliary servo (Channel 3). These are decoded from the AFHDS 2A IBUS stream by the STM32F405 and output as standard 50Hz PWM signals with 1000–2000 microsecond pulse widths — the universal servo control standard.

- Assign two STM32F405 hardware timer output pins as PWM outputs for Ch2 (steering) and Ch3 (auxiliary).
- Provide two 3-pin servo headers on the board (Signal, 5V, GND) — one for each channel. Use standard 0.1" (2.54mm) pitch headers, which are the universal servo connector pitch.
- Power the servo signal headers from the same 5V BEC rail (DRV8302 DVDD output). The 1.5A capacity of this rail is sufficient for the STM32F405, the A7105, and two standard RC boat steering servos.
- Add a 100nF decoupling capacitor on the 5V line at each servo header to suppress noise from servo motor switching.

The channel assignment follows the standard RC surface and boat industry convention where Channel 1 is always steering and Channel 2 is always throttle. The complete channel assignment for the board is therefore:

| Channel | Source | Function | Output Connector |
|---|---|---|---|
| Ch 1 | AFHDS 2A IBUS | Steering servo PWM | 3-pin servo header |
| Ch 2 | AFHDS 2A IBUS | Throttle — brushless motor speed | 3x motor phase pads (A, B, C) |
| Ch 3 | AFHDS 2A IBUS | Auxiliary servo PWM | 3-pin servo header |

### 7. Battery Voltage Sensing and Multi-Cell Support
The board must support a battery input voltage range of **3S to 5S LiPo**, corresponding to approximately 9.9V (3S discharged) to 21V (5S fully charged). The VESC reference design already supports this range through the DRV8302 and MOSFET ratings, so no hardware changes are required for voltage range compliance.

The battery voltage sensing circuit from the VESC reference design must be preserved exactly as designed. This consists of a resistor voltage divider on the VATT input that scales the battery voltage down to a level readable by the STM32F405 ADC. This circuit enables the firmware to perform the following functions at runtime, all of which are configurable through the VESC Tool software after flashing:

- Automatic cell count detection based on measured voltage at startup
- Low voltage cutoff (configurable start and end thresholds per cell)
- Voltage-scaled motor behavior and current limiting
- Battery state monitoring and protection

Do not modify or remove the voltage sensing divider circuit. Confirm it is present and connected to the correct STM32 ADC pin in the merged schematic.

## Output Requirements
Generate the unified schematic, perform a Design Rule Check (DRC), and prepare the layout for Gerber export. Ensure all components are selected with LCSC part numbers for turnkey assembly where possible.
