118 lines
4.1 KiB
Markdown
118 lines
4.1 KiB
Markdown
# Simplified Wiring Diagram
|
|
|
|
## The Key Insight: One Driver for Everything! 🎯
|
|
|
|
**You only need ONE LM18200 H-Bridge driver** - it handles both DC and DCC modes.
|
|
|
|
The ESP32 just sends different signals to the same pins depending on which mode you select:
|
|
|
|
```
|
|
ESP32-2432S028R
|
|
┌─────────────┐
|
|
│ │
|
|
GPIO 18 ─┤PWM / DCC_A │───┐
|
|
GPIO 19 ─┤DIR / DCC_B │───┤
|
|
GPIO 23 ─┤BRAKE │───┤
|
|
GPIO 4 ─┤RELAY │───┼──→ To Relay Module
|
|
GND ─┤ │───┤
|
|
5V ─┤ │───┤
|
|
└─────────────┘ │
|
|
│
|
|
↓
|
|
LM18200 H-Bridge
|
|
┌──────────────┐
|
|
GPIO 18 ───┤ PWM Input │
|
|
GPIO 19 ───┤ DIR Input │
|
|
GPIO 23 ───┤ BRAKE │
|
|
GND ───┤ GND │
|
|
5V ───┤ VCC (logic) │
|
|
12-18V ───┤ VS (power) │
|
|
│ │
|
|
│ OUT1 OUT2 │
|
|
└───┬──────┬───┘
|
|
│ │
|
|
↓ ↓
|
|
Track Rail 1 & 2
|
|
```
|
|
|
|
## How It Works
|
|
|
|
### DC Analog Mode
|
|
When you select **DC Analog** mode in the UI:
|
|
- GPIO 18 outputs **20kHz PWM** (0-100% duty cycle for speed)
|
|
- GPIO 19 outputs **HIGH or LOW** (sets direction: FWD or REV)
|
|
- LM18200 amplifies this to create variable DC voltage on the track
|
|
- Your DC locomotive responds to the voltage
|
|
|
|
### DCC Digital Mode
|
|
When you select **DCC** mode in the UI:
|
|
- GPIO 18 outputs **DCC Signal A** (square wave: 58μs or 100μs pulses)
|
|
- GPIO 19 outputs **DCC Signal B** (inverted version of Signal A)
|
|
- LM18200 amplifies these to create DCC waveform on the track
|
|
- Your DCC decoder locomotive responds to the digital commands
|
|
|
|
## Complete Connection List
|
|
|
|
### LM18200 to ESP32
|
|
| LM18200 Pin | ESP32 GPIO | Purpose |
|
|
|-------------|------------|---------|
|
|
| PWM Input | 18 | Speed (DC) / DCC Signal A (DCC) |
|
|
| Direction Input | 19 | Direction (DC) / DCC Signal B (DCC) |
|
|
| Brake Input | 23 | Emergency stop |
|
|
| GND | GND | Ground reference |
|
|
| VCC (logic) | 5V | Control logic power |
|
|
|
|
### LM18200 Power & Outputs
|
|
| LM18200 Pin | Connection | Purpose |
|
|
|-------------|------------|---------|
|
|
| VS (motor power) | 12-18V supply + | High current power |
|
|
| GND (power) | 12-18V supply - | Power ground |
|
|
| OUT1 | Track Rail 1 | Amplified output |
|
|
| OUT2 | Track Rail 2 | Amplified output |
|
|
|
|
### Relay Module (2-rail/3-rail switching)
|
|
| Relay Pin | ESP32 GPIO | Purpose |
|
|
|-----------|------------|---------|
|
|
| Signal IN | 4 | Relay control |
|
|
| VCC | 5V | Relay power |
|
|
| GND | GND | Ground |
|
|
|
|
### Power Supply Connections
|
|
```
|
|
12-18V Power Supply
|
|
├─→ LM18200 VS (motor power)
|
|
├─→ DC-DC Buck Converter → 5V → ESP32 + Relay + LM18200 VCC
|
|
└─→ GND (common ground)
|
|
```
|
|
|
|
## Why This Works
|
|
|
|
The LM18200 is just an amplifier. It doesn't care if you're feeding it:
|
|
- PWM signals (for DC speed control)
|
|
- DCC square waves (for digital commands)
|
|
|
|
It simply takes the 3.3V logic signals from the ESP32 and amplifies them to track voltage (12-18V).
|
|
|
|
**In DC mode**: The amplified PWM creates variable DC voltage
|
|
**In DCC mode**: The amplified square waves create the DCC signal
|
|
|
|
## Safety Notes
|
|
|
|
✅ **Always power OFF before switching modes** (automatic in the UI)
|
|
✅ **Common ground** - All GND connections must be tied together
|
|
✅ **Heat sink** - LM18200 can get hot, use appropriate heat sinking
|
|
✅ **Fusing** - Add fuse on track output for overcurrent protection
|
|
|
|
## No Separate DCC Booster Needed!
|
|
|
|
You do **NOT** need:
|
|
- ❌ Separate DCC booster circuit
|
|
- ❌ Different outputs for DC vs DCC
|
|
- ❌ Mode selection switches in hardware
|
|
|
|
Everything is handled in software by the ESP32 touchscreen UI.
|
|
|
|
---
|
|
|
|
**Bottom Line**: Wire up ONE LM18200, and you're done. The ESP32 software handles the rest!
|