Ajout prise en charge ESP-Display
This commit is contained in:
203
WIRING_ESP32-2432S028R.md
Normal file
203
WIRING_ESP32-2432S028R.md
Normal file
@@ -0,0 +1,203 @@
|
||||
# ESP32-2432S028R Wiring Guide
|
||||
|
||||
## Overview
|
||||
This document describes the external connections needed for the DCC-Bench project using the ESP32-2432S028R module.
|
||||
|
||||
## Built-in Components (No Wiring Needed)
|
||||
The ESP32-2432S028R module includes:
|
||||
- ✅ ILI9341 TFT Display (320x240)
|
||||
- ✅ XPT2046 Touch Controller
|
||||
- ✅ MicroSD Card Slot
|
||||
- ✅ USB-C Power/Programming
|
||||
|
||||
## External Connections Required
|
||||
|
||||
### 1. LM18200 H-Bridge Driver (Universal DC/DCC Output)
|
||||
|
||||
The LM18200 serves as **BOTH** the DC motor controller AND DCC signal booster.
|
||||
It's the same hardware - the ESP32 just sends different signals depending on mode:
|
||||
- **DC Mode**: ESP32 sends PWM + direction signals
|
||||
- **DCC Mode**: ESP32 sends DCC digital signals
|
||||
|
||||
```
|
||||
ESP32 GPIO 18 (PWM/DCC_A) ──→ LM18200 PWM Input
|
||||
ESP32 GPIO 19 (DIR/DCC_B) ──→ LM18200 Direction Input
|
||||
ESP32 GPIO 23 (BRAKE) ──→ LM18200 Brake Input
|
||||
ESP32 GND ──→ LM18200 GND
|
||||
ESP32 5V ──→ LM18200 Logic VCC
|
||||
Power Supply (12-18V) ──→ LM18200 Motor Power
|
||||
```
|
||||
|
||||
**LM18200 Outputs (to Track):**
|
||||
```
|
||||
0.1Ω 1W Current Sense
|
||||
LM18200 OUT1 ──→ ───┬──────╱╲╲╲────── Track Rail 1
|
||||
│
|
||||
├── 1kΩ ──┬──── GPIO 35 (ADC - ACK Detect)
|
||||
│ 10kΩ
|
||||
│ │
|
||||
LM18200 OUT2 ──→ ───┴──────────┴──── Track Rail 2 (GND)
|
||||
```
|
||||
|
||||
**How it Works:**
|
||||
- **DC Analog Mode**: GPIO 18 outputs PWM for speed, GPIO 19 sets direction
|
||||
- **DCC Digital Mode**: GPIO 18 outputs DCC signal A, GPIO 19 outputs DCC signal B (inverted)
|
||||
- The LM18200 amplifies whichever signal type to track voltage
|
||||
- GPIO 23 (BRAKE) can force both outputs LOW for emergency stop
|
||||
- **Programming Track**: Current sense resistor (0.1Ω) detects 60mA ACK pulses from decoder
|
||||
|
||||
### 2. 2-Rail/3-Rail Relay Module
|
||||
|
||||
```
|
||||
ESP32 GPIO 4 ──→ Relay Module Signal Input
|
||||
ESP32 GND ──→ Relay Module GND
|
||||
ESP32 5V ──→ Relay Module VCC
|
||||
```
|
||||
|
||||
**Relay Outputs:**
|
||||
Configure the relay to switch between 2-rail and 3-rail track wiring:
|
||||
- **2-Rail Mode** (Relay OFF): Standard two-rail configuration
|
||||
- **3-Rail Mode** (Relay ON): Center rail + outer rails configuration
|
||||
|
||||
### 3. Power Supply
|
||||
|
||||
The ESP32-2432S028R can be powered via:
|
||||
- **USB-C**: 5V from USB (programming and operation)
|
||||
- **5V Pin**: External 5V power supply (500mA minimum)
|
||||
|
||||
**Recommended Setup:**
|
||||
```
|
||||
12-18V Power Supply ──→ DC-DC Buck Converter ──→ 5V @ 1A ──→ ESP32 5V Pin
|
||||
└──→ Motor Controller Power
|
||||
└──→ DCC Booster Power
|
||||
```
|
||||
|
||||
## Pin Summary Table
|
||||
|
||||
| Connection | ESP32 Pin | External Device | Notes |
|
||||
|------------|-----------|-----------------|-------|
|
||||
| PWM/DCC_A | GPIO 18 | LM18200 PWM | DC mode: 20kHz PWM / DCC mode: DCC signal A |
|
||||
| DIR/DCC_B | GPIO 19 | LM18200 DIR | DC mode: Direction / DCC mode: DCC signal B |
|
||||
| Brake | GPIO 23 | LM18200 BRAKE | Active LOW brake / Emergency stop |
|
||||
| Relay Control | GPIO 4 | Relay Module IN | HIGH=3-Rail |
|
||||
| ACK Detect | GPIO 35 | Current Sense | ADC input for programming track ACK |
|
||||
| Ground | GND | All GNDs | Common ground |
|
||||
| Power | 5V | Logic Power | 500mA-1A |
|
||||
|
||||
## Safety Notes
|
||||
|
||||
⚠️ **IMPORTANT SAFETY WARNINGS:**
|
||||
|
||||
1. **Electrical Isolation**: Keep low-voltage control circuits (ESP32) separated from high-voltage motor/track circuits
|
||||
2. **Common Ground**: Ensure all components share a common ground reference
|
||||
3. **Power Rating**: Motor controller must be rated for your locomotive's current draw
|
||||
4. **Fusing**: Install appropriate fuses on track outputs
|
||||
5. **Emergency Stop**: Implement physical emergency stop button if needed
|
||||
6. **Polarity**: Double-check DCC booster polarity before connecting to track
|
||||
|
||||
## Track Connection
|
||||
|
||||
The LM18200 outputs connect directly to the track in both modes:
|
||||
|
||||
```
|
||||
LM18200 OUT1 ──→ Track Rail 1
|
||||
LM18200 OUT2 ──→ Track Rail 2
|
||||
```
|
||||
|
||||
**Operation:**
|
||||
- **DC Mode**: LM18200 outputs PWM voltage (polarity sets direction)
|
||||
- **DCC Mode**: LM18200 outputs amplified DCC square wave signals
|
||||
- Same physical connections, different signal types
|
||||
|
||||
## Testing Procedure
|
||||
|
||||
1. **Power Up Test**
|
||||
- Connect only USB power
|
||||
- Verify display shows UI
|
||||
- Touch screen should be responsive
|
||||
|
||||
2. **Relay Test**
|
||||
- Toggle 2-Rail/3-Rail button
|
||||
- Listen for relay click
|
||||
- Verify relay LED changes state
|
||||
|
||||
3. **DCC Signal Test** (use oscilloscope)
|
||||
- Select DCC mode
|
||||
- Power ON
|
||||
- Measure GPIO 18 and 19 for square wave signals
|
||||
- Verify ~58μs for '1' bits, ~100μs for '0' bits
|
||||
- Signals should be inverted relative to each other
|
||||
- Check LM18200 outputs for amplified signals (track voltage)
|
||||
|
||||
4. **DC Motor Test** (without load)
|
||||
- Select DC Analog mode
|
||||
- Power ON
|
||||
- Adjust speed slider
|
||||
- Measure PWM on GPIO 18 with multimeter (average voltage should increase with speed)
|
||||
- Measure LM18200 outputs for amplified PWM
|
||||
|
||||
5. **Track Test** (with locomotive)
|
||||
- Start with low speed (10-20%)
|
||||
- Gradually increase speed
|
||||
- Test direction change
|
||||
- Verify emergency stop (Power OFF button)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problem | Possible Cause | Solution |
|
||||
|---------|----------------|----------|
|
||||
| Display blank | No power | Check USB/5V power connection |
|
||||
| Touch not working | Wrong calibration | Adjust TS_MIN/MAX values in code |
|
||||
| No DCC signal | Not powered on | Press Power button in UI |
|
||||
| Motor not running | Wrong mode | Verify DC Analog mode selected |
|
||||
| Relay not switching | No 5V power | Check relay module power |
|
||||
| Erratic behavior | Ground loop | Ensure single common ground point |
|
||||
|
||||
## Component Recommendations
|
||||
|
||||
### H-Bridge Driver (DC & DCC):
|
||||
- **LM18200T** (3A continuous, 6A peak) - **RECOMMENDED**
|
||||
- Single chip handles both DC and DCC modes
|
||||
- Built-in thermal shutdown
|
||||
- Built-in current limiting
|
||||
- **L298N module** (2A per channel)
|
||||
- Readily available, inexpensive
|
||||
- Less efficient than LM18200
|
||||
- **BTS7960 motor driver** (43A capable)
|
||||
- Overkill for most model trains
|
||||
- Good for large scale locomotives
|
||||
|
||||
### Relay Module:
|
||||
- 5V single-channel relay module
|
||||
- Optocoupler isolated
|
||||
- Active HIGH trigger
|
||||
|
||||
## Schematic Reference
|
||||
|
||||
```
|
||||
┌─────────────────┐
|
||||
│ ESP32-2432S028R│
|
||||
│ (Built-in) │
|
||||
│ - TFT Display │
|
||||
│ - Touch Screen │
|
||||
└────────┬────────┘
|
||||
│
|
||||
┌───────────────┬────────┼────────┬───────────────┐
|
||||
│ │ │ │ │
|
||||
GPIO 17 GPIO 16 GPIO 18 GPIO 19 GPIO 4
|
||||
(DCC_A) (DCC_B) (PWM) (DIR) (RELAY)
|
||||
│ │ │ │ │
|
||||
┌─────▼─────┐ │ │ │ ┌─────▼─────┐
|
||||
│ DCC │◄────────┘ │ │ │ Relay │
|
||||
│ Booster │ │ │ │ Module │
|
||||
└─────┬─────┘ │ │ └─────┬─────┘
|
||||
│ ┌─────▼────────▼─┐ │
|
||||
│ │ Motor Driver │ │
|
||||
│ │ (LM18200) │ │
|
||||
│ └────────┬───────┘ │
|
||||
│ │ │
|
||||
┌─────▼──────────────────────────┼─────────────────────▼─────┐
|
||||
│ Track Output │
|
||||
│ (DCC or DC Analog depending on mode selection in UI) │
|
||||
└──────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
Reference in New Issue
Block a user