saltylab-firmware/docs/wiring-diagram.md
2026-03-01 14:51:56 -05:00

184 lines
9.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# SaltyLab Wiring Diagram
## System Overview
```
┌─────────────────────────────────────────────────────────────────────┐
│ ORIN NANO SUPER │
│ (Top Plate — 25W) │
│ │
│ USB-C ──── STM32 CDC (/dev/stm32-bridge, 921600 baud) │
│ USB-A1 ─── RealSense D435i (USB 3.1) │
│ USB-A2 ─── RPLIDAR A1M8 (via CP2102 adapter, 115200) │
│ CSI-A ──── ArduCam adapter → 2× IMX219 (front + left) │
│ CSI-B ──── ArduCam adapter → 2× IMX219 (rear + right) │
│ M.2 ───── 1TB NVMe SSD │
│ Pin 8 ──┐ │
│ Pin 10 ─┤ UART fallback to FC (ttyTHS0, 921600) │
│ Pin 6 ──┘ GND │
│ │
└─────────────────────────────────────────────────────────────────────┘
│ USB-C (data only) │ UART fallback (3 wires)
│ 921600 baud │ 921600 baud, 3.3V
▼ ▼
┌─────────────────────────────────────────────────────────────────────┐
│ MAMBA F722S (FC) │
│ (Middle Plate — foam mounted) │
│ │
│ USB-C ──── Orin (CDC serial, primary link) │
│ │
│ USART2 (PA2=TX, PA3=RX) ──── Hoverboard ESC (26400 baud) │
│ UART4 (PA0=TX, PA1=RX) ──── ELRS RX (CRSF, 420000 baud) │
│ USART6 (PC6=TX, PC7=RX) ──── Orin UART fallback │
│ UART5 (PC12=TX, PD2=RX) ─── Debug (optional) │
│ │
│ SPI1 ─── MPU6000 IMU (on-board, CW270) │
│ I2C1 ─── BMP280 baro (on-board, disabled) │
│ ADC ──── Battery voltage (PC1) + Current (PC3) │
│ PB3 ──── WS2812B LED strip │
│ PB2 ──── Buzzer │
│ │
└─────────────────────────────────────────────────────────────────────┘
│ USART2 │ UART4
│ PA2=TX → ESC RX │ PA0=TX → ELRS TX
│ PA3=RX ← ESC TX │ PA1=RX ← ELRS RX
│ GND ─── GND │ GND ─── GND
▼ ▼
┌────────────────────────┐ ┌──────────────────────────┐
│ HOVERBOARD ESC │ │ ELRS 2.4GHz RX │
│ (Bottom Plate) │ │ (beside FC) │
│ │ │ │
│ 2× BLDC hub motors │ │ CRSF protocol │
│ 26400 baud UART │ │ 420000 baud │
│ Frame: [0xABCD] │ │ BetaFPV 1W TX → RX │
│ [steer][speed][csum] │ │ CH3=speed CH4=steer │
│ │ │ CH5=arm CH6=mode │
└────────────────────────┘ └──────────────────────────┘
┌────┴────┐
▼ ▼
🛞 LEFT RIGHT 🛞
MOTOR MOTOR
## Wire-by-Wire Connections
### 1. Orin ↔ FC (Primary: USB CDC)
| From | To | Wire Color | Notes |
|------|----|-----------|-------|
| Orin USB-C port | FC USB-C port | USB cable | Data only, FC powered from 5V bus |
- Device: `/dev/ttyACM0` → symlink `/dev/stm32-bridge`
- Baud: 921600, 8N1
- Protocol: JSON telemetry (FC→Orin), ASCII commands (Orin→FC)
### 2. Orin ↔ FC (Fallback: Hardware UART)
| Orin Pin | Signal | FC Pin | FC Signal |
|----------|--------|--------|-----------|
| Pin 8 | TXD0 | PC7 | USART6 RX |
| Pin 10 | RXD0 | PC6 | USART6 TX |
| Pin 6 | GND | GND | GND |
- Jetson device: `/dev/ttyTHS0`
- Baud: 921600, 8N1
- Voltage: 3.3V both sides (no level shifter needed)
- **Cross-connect:** Orin TX → FC RX, Orin RX ← FC TX
### 3. FC ↔ Hoverboard ESC
| FC Pin | Signal | ESC Pin | Notes |
|--------|--------|---------|-------|
| PA2 | USART2 TX | RX | FC sends speed/steer commands |
| PA3 | USART2 RX | TX | ESC sends feedback (optional) |
| GND | GND | GND | Common ground |
- Baud: 26400, 8N1
- Protocol: Binary frame — `[0xABCD][steer:int16][speed:int16][checksum:uint16]`
- Speed range: -1000 to +1000
- **Keep wires short and twisted** (EMI from ESC)
### 4. FC ↔ ELRS Receiver
| FC Pin | Signal | ELRS Pin | Notes |
|--------|--------|----------|-------|
| PA0 | UART4 TX | RX | Telemetry to TX (optional) |
| PA1 | UART4 RX | TX | CRSF frames from RX |
| GND | GND | GND | Common ground |
| 5V | — | VCC | Power ELRS from 5V bus |
- Baud: 420000 (CRSF protocol)
- Failsafe: disarm after 300ms without frame
### 5. Power Distribution
```
BATTERY (36V) ──┬── Hoverboard ESC (36V direct)
├── 5V BEC/regulator ──┬── Orin (USB-C PD or barrel jack)
│ ├── FC (via USB or 5V pad)
│ ├── ELRS RX (5V)
│ ├── WS2812B LEDs (5V)
│ └── RPLIDAR (5V via USB)
└── Battery monitor ──── FC ADC (PC1=voltage, PC3=current)
```
### 6. Sensors on Orin (USB/CSI)
| Device | Interface | Orin Port | Device Node |
|--------|-----------|-----------|-------------|
| RealSense D435i | USB 3.1 | USB-A (blue) | `/dev/bus/usb/...` |
| RPLIDAR A1M8 | USB-UART | USB-A | `/dev/rplidar` |
| IMX219 front+left | MIPI CSI-2 | CSI-A (J5) | `/dev/video0,2` |
| IMX219 rear+right | MIPI CSI-2 | CSI-B (J8) | `/dev/video4,6` |
| 1TB NVMe | PCIe Gen3 ×4 | M.2 Key M | `/dev/nvme0n1` |
## FC UART Summary (MAMBA F722S)
| UART | Pins | Baud | Assignment | Notes |
|------|------|------|------------|-------|
| USART1 | PB6=TX, PB7=RX | — | SmartAudio/VTX | Unused in SaltyLab |
| USART2 | PA2=TX, PA3=RX | 26400 | Hoverboard ESC | Binary motor commands |
| USART3 | PB10=TX, PB11=RX | — | Available | Was SBUS default |
| UART4 | PA0=TX, PA1=RX | 420000 | ELRS RX (CRSF) | RC control |
| UART5 | PC12=TX, PD2=RX | 115200 | Debug serial | Optional |
| USART6 | PC6=TX, PC7=RX | 921600 | Jetson UART | Fallback link |
| USB CDC | USB-C | 921600 | Jetson primary | `/dev/stm32-bridge` |
## Data Flow
```
┌──────────────┐
│ ELRS TX │ (in your hand)
│ (2.4GHz) │
└──────┬───────┘
│ radio
┌──────▼───────┐
│ ELRS RX │ CRSF 420kbaud
└──────┬───────┘
│ UART4
┌────────────▼────────────┐
│ MAMBA F722S │
│ │
│ MPU6000 → Balance PID │
│ CRSF → Mode Manager │
│ Safety Monitor │
│ │
└──┬──────────┬───────────┘
USART2 ─────┘ └───── USB CDC / USART6
26400 baud 921600 baud
│ │
▼ ▼
┌────────────────┐ ┌───────────────────┐
│ Hoverboard ESC │ │ Orin Nano Super │
│ │ │ │
│ L motor R motor│ │ SLAM / Nav2 / AI │
│ 🛞 🛞 │ │ Person following │
└────────────────┘ │ cmd_vel → FC │
└───────────────────┘
```