# AON3D M2+ Wiring Instructions
## BTT Octopus Pro v1.0.1 with External DM542T Drivers

---

## Overview

This guide covers wiring your AON3D M2+ IDEX printer with:
- **Controller**: BTT Octopus Pro v1.0.1
- **Stepper Drivers**: External DM542T (8 units)
- **Host**: Raspberry Pi 4/5 running FluiddPi

### Total Connections Required

| Category | Count | Items |
|----------|-------|-------|
| Motor Drivers | 8 | X, X2, Y, Y1, Z, Z1, E0, E1 |
| Endstops | 4-6 | X-min, X-max, Y-min, (Y-max), Z-min, (Z-max) |
| Thermistors | 4 | Extruder 0, Extruder 1, Bed, Chamber |
| Heaters | 4 | Extruder 0, Extruder 1, Bed, Chamber |
| Fans | 1+ | Enclosure fan (+ optional part cooling) |
| Probe | 1 | Bed probe |
| Power | 2 | 24V main, USB to Pi |

---

## PART 1: Power Supply Connections

### 1.1 Main Power Input (24V DC)

Connect your 24V power supply to the Octopus Pro:

```
Power Supply              Octopus Pro
============              ===========
+24V ─────────────────────► VIN (+)
GND  ─────────────────────► VIN (-)
```

**Location**: Large screw terminals on the edge of the board labeled "POWER" or "VIN"

**Wire Gauge**: Use 14-16 AWG for main power

### 1.2 DM542T Driver Power

Each DM542T driver needs its own power connection (typically 24-48V DC):

```
Power Supply              DM542T Driver
============              =============
+24V to +48V ─────────────► V+ (or VCC)
GND ──────────────────────► V- (or GND)
```

**Important**:
- All DM542T drivers can share the same power supply
- Use appropriately rated power supply (calculate total motor current)
- Typical: 48V power supply for better high-speed performance

---

## PART 2: Stepper Motor Connections (DM542T Drivers)

### 2.1 Understanding the Signal Flow

```
┌─────────────┐     Step/Dir/Enable     ┌─────────────┐     4-wire     ┌─────────────┐
│  Octopus    │ ───────────────────────►│   DM542T    │───────────────►│   Stepper   │
│    Pro      │    (low current)        │   Driver    │  (high current)│    Motor    │
└─────────────┘                         └─────────────┘                └─────────────┘
```

### 2.2 Octopus Pro Motor Header Pinout

Each MOTOR header on the Octopus Pro has this pinout:

```
    ┌───┬───┬───┬───┐
    │ 1 │ 2 │ 3 │ 4 │
    └───┴───┴───┴───┘
      │   │   │   │
      │   │   │   └── EN (Enable)
      │   │   └────── DIR (Direction)
      │   └────────── STEP (Step pulse)
      └────────────── GND (Ground)
```

### 2.3 Motor-to-Driver Assignments

| Octopus Header | Klipper Section | Function | STEP | DIR | EN |
|----------------|-----------------|----------|------|-----|-----|
| MOTOR0 | [stepper_x] | X Carriage 0 | PF13 | PF12 | PF14 |
| MOTOR1 | [dual_carriage] | X Carriage 1 (IDEX) | PG0 | PG1 | PF15 |
| MOTOR2 | [stepper_y] | Y Axis | PF11 | PG3 | PG5 |
| MOTOR3 | [stepper_y1] | Y1 Axis (2nd motor) | PG4 | PC1 | PA0 |
| MOTOR4 | [stepper_z] | Z Axis | PF9 | PF10 | PG2 |
| MOTOR5 | [stepper_z1] | Z1 Axis (2nd motor) | PC13 | PF0 | PF1 |
| MOTOR6 | [extruder] | Extruder 0 | PE2 | PE3 | PD4 |
| MOTOR7 | [extruder1] | Extruder 1 | PE6 | PA14 | PE0 |

### 2.4 Wiring Each DM542T Driver

For **EACH** of the 8 motor drivers, make these connections:

```
Octopus Pro MOTOR Header          DM542T Driver
============================      =============

Pin 1 (GND) ──────────────────────► PUL- (Pulse negative)
                              ├───► DIR- (Direction negative)
                              └───► ENA- (Enable negative)

Pin 2 (STEP) ─────────────────────► PUL+ (Pulse positive)

Pin 3 (DIR) ──────────────────────► DIR+ (Direction positive)

Pin 4 (EN) ───────────────────────► ENA+ (Enable positive)
```

**Visual Diagram**:
```
Octopus MOTOR0                           DM542T #1 (X Axis)
┌─────────────┐                         ┌─────────────────┐
│ GND  ●──────┼────────┬───────────────►│ PUL-            │
│ STEP ●──────┼────────┼───────────────►│ PUL+            │
│ DIR  ●──────┼────────┼───────────────►│ DIR+            │
│ EN   ●──────┼────────┼───────────────►│ ENA+            │
└─────────────┘        │               ┌┤ DIR-            │
                       ├───────────────►│ ENA-            │
                       │                │                 │
                       │                │ A+  ●───────────┼──► Motor Coil A+
                       │                │ A-  ●───────────┼──► Motor Coil A-
                       │                │ B+  ●───────────┼──► Motor Coil B+
                       │                │ B-  ●───────────┼──► Motor Coil B-
                       │                │                 │
                       │                │ V+  ●───────────┼──► +24-48V
                       │                │ V-  ●───────────┼──► GND (Power)
                       │                └─────────────────┘
                       │
                       └─── Common GND (can use single wire daisy-chained
                            or individual wires to each driver)
```

### 2.5 Repeat for All 8 Drivers

| # | Octopus Header | DM542T Label | Motor |
|---|----------------|--------------|-------|
| 1 | MOTOR0 | DM542T-X | X Carriage 0 |
| 2 | MOTOR1 | DM542T-X2 | X Carriage 1 |
| 3 | MOTOR2 | DM542T-Y | Y Motor |
| 4 | MOTOR3 | DM542T-Y1 | Y1 Motor |
| 5 | MOTOR4 | DM542T-Z | Z Motor |
| 6 | MOTOR5 | DM542T-Z1 | Z1 Motor |
| 7 | MOTOR6 | DM542T-E0 | Extruder 0 |
| 8 | MOTOR7 | DM542T-E1 | Extruder 1 |

### 2.6 DM542T DIP Switch Settings

Set the DIP switches on each DM542T to match the Klipper config:

**Microstepping** (SW5-SW8):

| Axis | Microsteps | SW5 | SW6 | SW7 | SW8 |
|------|------------|-----|-----|-----|-----|
| X, X2, Y, Y1 | 16 | OFF | ON | ON | OFF |
| Z, Z1 | 4 | ON | ON | OFF | OFF |
| E0, E1 | 16 | OFF | ON | ON | OFF |

**Current Settings** (SW1-SW3): Set according to your motor specs. Typical settings:
- NEMA 23 motors: 2.0-3.0A
- NEMA 17 extruders: 1.0-1.5A

---

## PART 3: Endstop Connections

### 3.1 Endstop Pinout on Octopus Pro

The DIAG/Endstop headers are 3-pin connectors:

```
    ┌───┬───┬───┐
    │ S │ V │ G │
    └───┴───┴───┘
      │   │   │
      │   │   └── GND (Ground)
      │   └────── +5V (for powered sensors, optional)
      └────────── Signal
```

### 3.2 Endstop Assignments

| Endstop | Function | Octopus Header | Pin | Config |
|---------|----------|----------------|-----|--------|
| X Min | Home position Carriage 0 | DIAG0 | PG6 | `endstop_pin: PG6` |
| X Max | Home position Carriage 1 | DIAG1 | PG9 | `endstop_pin: PG9` |
| Y Min | Y home position | DIAG2 | PG10 | `endstop_pin: PG10` |
| Y1 | Y1 endstop (optional) | DIAG3 | PG11 | `endstop_pin: PG11` |
| Z Min | Z home position | DIAG4 | PG12 | `endstop_pin: PG12` |
| Z1 | Z1 endstop (optional) | DIAG5 | PG13 | `endstop_pin: PG13` |

### 3.3 Wiring Mechanical Endstops

**Normally Open (NO) Switch** - most common:
```
Endstop Switch              Octopus Pro DIAG Header
==============              =======================
COM ──────────────────────► G (Ground)
NO  ──────────────────────► S (Signal)
```
Config: `endstop_pin: PG6`

**Normally Closed (NC) Switch** - add `!` to invert:
```
Endstop Switch              Octopus Pro DIAG Header
==============              =======================
COM ──────────────────────► G (Ground)
NC  ──────────────────────► S (Signal)
```
Config: `endstop_pin: !PG6`

### 3.4 Wiring Optical/Inductive Sensors (3-wire)

```
Sensor                      Octopus Pro DIAG Header
======                      =======================
VCC (Brown/Red) ──────────► V (+5V)
GND (Blue/Black) ─────────► G (Ground)
Signal (Black/Yellow) ────► S (Signal)
```

---

## PART 4: Thermistor Connections

### 4.1 Thermistor Header Pinout

```
    ┌───┬───┐
    │ T │ G │
    └───┴───┘
      │   │
      │   └── GND (Ground)
      └────── Thermistor Signal
```

### 4.2 Thermistor Assignments

| Sensor | Function | Octopus Header | Pin |
|--------|----------|----------------|-----|
| TH0 | Extruder 0 temperature | T0 | PF4 |
| TH1 | Extruder 1 temperature | T1 | PF5 |
| TH2 | Chamber temperature | T2 | PF6 |
| TB | Bed temperature | TB | PF3 |

### 4.3 Wiring Thermistors

Thermistors are not polarized - either wire can go to either terminal:

```
Thermistor (2-wire)         Octopus Pro TH Header
===================         =====================
Wire 1 ───────────────────► T (Signal)
Wire 2 ───────────────────► G (Ground)
```

**Important**: Your M2 uses custom thermistors with voltage-based calibration. The config already includes the correct `adc_temperature` definitions.

---

## PART 5: Heater Connections

### 5.1 Heater Output Specifications

| Output | Function | Pin | Max Current | Connector |
|--------|----------|-----|-------------|-----------|
| HE0 | Hotend 0 | PA2 | 5A | Screw terminal |
| HE1 | Hotend 1 | PA3 | 5A | Screw terminal |
| HE2 | Chamber heater | PB10 | 5A | Screw terminal |
| HB | Heated bed | PA1 | 10A | Large screw terminal |

### 5.2 Wiring Hotend Heaters (HE0, HE1)

```
Heater Cartridge            Octopus Pro HE0/HE1
================            ===================
Wire 1 ───────────────────► + (Positive terminal)
Wire 2 ───────────────────► - (Negative terminal)
```

**Note**: Standard heater cartridges are not polarized.

### 5.3 Wiring Chamber Heater (HE2)

Same as hotend heaters:
```
Chamber Heater              Octopus Pro HE2
==============              ===============
Wire 1 ───────────────────► +
Wire 2 ───────────────────► -
```

### 5.4 Wiring Heated Bed (HB)

**For beds drawing less than 10A** - connect directly:
```
Heated Bed                  Octopus Pro HB
==========                  ==============
Wire 1 ───────────────────► + (Positive)
Wire 2 ───────────────────► - (Negative)
```

**For high-power beds (>10A)** - use SSR (Solid State Relay):
```
Octopus Pro HB              SSR                    Heated Bed
==============              ===                    ==========
+ ────────────────────────► DC+ (Control)
- ────────────────────────► DC- (Control)

                            AC/DC+ (Load) ────────► Bed +
                            AC/DC- (Load) ◄────────┤
                                                   │
Power Supply (+) ──────────────────────────────────┘
Power Supply (-) ─────────────────────────────────► Bed -
```

---

## PART 6: Fan Connections

### 6.1 Fan Header Pinout

```
    ┌───┬───┐
    │ + │ - │
    └───┴───┘
      │   │
      │   └── GND (Negative)
      └────── +24V PWM (Positive, controlled)
```

### 6.2 Fan Assignments

| Fan | Function | Pin | Header |
|-----|----------|-----|--------|
| FAN0 | Part cooling 0 (optional) | PA8 | FAN0 |
| FAN1 | Part cooling 1 (optional) | PE5 | FAN1 |
| FAN2 | Enclosure/Chamber fan | PD12 | FAN2 |
| FAN3 | Hotend fan 0 (optional) | PD13 | FAN3 |
| FAN4 | Hotend fan 1 (optional) | PE4 | FAN4 |

### 6.3 Wiring Fans

```
Fan (2-wire)                Octopus Pro FAN Header
============                ======================
+ (Red) ──────────────────► + (Positive/PWM)
- (Black) ────────────────► - (Ground)
```

**Enclosure Fan** (configured in Klipper):
- Connected to FAN2
- Controlled by chamber heater temperature

---

## PART 7: Probe Connection

### 7.1 Probe Wiring

Your probe connects to the dedicated PROBE header:

**For mechanical probe (2-wire)**:
```
Probe Switch                Octopus Pro PROBE
============                =================
COM ──────────────────────► G (Ground)
NO/NC ────────────────────► S (Signal)
```

**For inductive/capacitive probe (3-wire)**:
```
Probe Sensor                Octopus Pro PROBE
============                =================
VCC ──────────────────────► V (+5V or +24V depending on sensor)
GND ──────────────────────► G (Ground)
Signal ───────────────────► S (Signal)
```

Config: `pin: ^PG15` (the `^` enables internal pull-up)

---

## PART 8: Communication Connections

### 8.1 USB to Raspberry Pi

Connect the Octopus Pro to your Raspberry Pi via USB:

```
Octopus Pro                 Raspberry Pi
===========                 ============
USB-C port ◄───────────────► USB port (any)
```

Use a quality USB cable - data + power capable.

### 8.2 Finding the Serial Port

After connecting, run on the Pi:
```bash
ls /dev/serial/by-id/*
```

You should see something like:
```
/dev/serial/by-id/usb-Klipper_stm32f446xx_XXXXXXXXXX-if00
```

Update `printer.cfg` with this path.

---

## PART 9: Complete Wiring Checklist

### Power
- [ ] 24V power supply connected to Octopus Pro VIN
- [ ] 24-48V power supply connected to all DM542T drivers
- [ ] USB cable from Octopus Pro to Raspberry Pi

### Motors (8 total)
- [ ] MOTOR0 → DM542T → X motor (Carriage 0)
- [ ] MOTOR1 → DM542T → X2 motor (Carriage 1/IDEX)
- [ ] MOTOR2 → DM542T → Y motor
- [ ] MOTOR3 → DM542T → Y1 motor
- [ ] MOTOR4 → DM542T → Z motor
- [ ] MOTOR5 → DM542T → Z1 motor
- [ ] MOTOR6 → DM542T → Extruder 0 motor
- [ ] MOTOR7 → DM542T → Extruder 1 motor

### Endstops
- [ ] X endstop → DIAG0
- [ ] X2/Dual carriage endstop → DIAG1
- [ ] Y endstop → DIAG2
- [ ] Y1 endstop → DIAG3 (if used)
- [ ] Z endstop → DIAG4
- [ ] Z1 endstop → DIAG5 (if used)

### Thermistors
- [ ] Extruder 0 thermistor → T0
- [ ] Extruder 1 thermistor → T1
- [ ] Chamber thermistor → T2
- [ ] Bed thermistor → TB

### Heaters
- [ ] Extruder 0 heater → HE0
- [ ] Extruder 1 heater → HE1
- [ ] Chamber heater → HE2
- [ ] Heated bed → HB (or via SSR)

### Fans
- [ ] Enclosure fan → FAN2

### Probe
- [ ] Bed probe → PROBE header

---

## PART 10: First Power-On Procedure

### Before Applying Power
1. Double-check all wiring against this guide
2. Verify no short circuits (use multimeter)
3. Ensure DM542T DIP switches are set correctly
4. Confirm power supply voltages are correct

### Power-On Sequence
1. **DO NOT** connect motors yet (just signals)
2. Power on the Octopus Pro only
3. Verify it appears on USB (`ls /dev/serial/by-id/`)
4. Flash Klipper firmware (see below)
5. Start Klipper and check for errors
6. Test endstops: `QUERY_ENDSTOPS`
7. Test thermistors: check temperatures in Fluidd
8. **Then** connect motor power and test movement

### Flashing Klipper Firmware

```bash
cd ~/klipper
make menuconfig
```

Settings for Octopus Pro v1.0.1:
- Micro-controller: **STMicroelectronics STM32**
- Processor model: **STM32F446**
- Bootloader offset: **32KiB bootloader**
- Clock Reference: **12 MHz crystal**
- Communication: **USB (on PA11/PA12)**

```bash
make clean
make
```

Copy `out/klipper.bin` to SD card as `firmware.bin`, insert into Octopus, power cycle.

---

## Troubleshooting

### Motor doesn't move
1. Check DM542T has power (LED on?)
2. Verify step/dir/enable wiring
3. Check DIP switch settings
4. Try inverting enable pin: `enable_pin: PF14` → `enable_pin: !PF14`

### Motor moves wrong direction
- Invert the DIR pin in config: `dir_pin: PF12` → `dir_pin: !PF12`

### Endstop always triggered or never triggers
- Check `QUERY_ENDSTOPS` output
- Try inverting: `endstop_pin: PG6` → `endstop_pin: !PG6`
- Verify wiring (NO vs NC switch)

### Thermistor shows wrong temperature
- Check wiring continuity
- Verify correct `sensor_type` in config
- The custom `adc_temperature` definitions should match your sensors

### Heater doesn't heat
- Check for "HEATER_ERROR" in Klipper logs
- Verify heater wiring
- Check thermistor is working (needs valid temp reading)
