# Wiring

> Every terminal of UPAN Core v2 with pin order, signal levels and wiring examples — motors, drivers in the sockets, external drivers, inputs, outputs, e-stop, RS485, Qwiic and the UPAN Axis module.

All connections to UPAN Core are pluggable terminal blocks in two rows along the long edges of the board, plus USB-C, the antenna socket, a Qwiic socket, the UPAN Axis socket and the light-pipe button. This page lists every terminal with its pin order and gives short wiring examples. Pin numbers count from pin 1 as marked on the board. The board is v2 and the firmware is in development, so treat values marked "not final" as such.

> **Warning:** Wire everything with the power supply switched off at the mains side. Never plug or unplug a motor or a driver module while the supply is on — it destroys the driver. See [Safety](/docs/safety).

## The terminals at a glance

| Row | Terminal | Label | Pitch |
|---|---|---|---|
| top | Motor 1, motor 2 | `MOTOR 1`, `MOTOR 2` | 5.08 mm |
| top | Power | `PWR 12–24V` | 5.08 mm |
| top | External driver, axis 1 and 2 | `AXIS 1 EXT`, `AXIS 2 EXT` | 3.81 mm |
| top | Display | `DISPLAY +5V TX RX GND` | 3.81 mm |
| bottom | Universal inputs | `IN` | 3.81 mm |
| bottom | Fast inputs and sensor supply | `FAST IN` | 3.81 mm |
| bottom | Outputs and e-stop | `OUT / E-STOP` | 3.81 mm |
| bottom | PWM / servo and analog inputs | `PWM / AIN` | 3.81 mm |
| bottom | RS485 | `RS485 A B GND` | 3.81 mm |

Both variants have the same board and the same terminals. UPC2-T2 comes with two TMC2209 drivers in the sockets; on UPC2-T0 the sockets are empty. The labels are the ones printed on the board; the case lettering is not final yet.

## Power

2-pin terminal `PWR 12–24V`, 5.08 mm.

| Pin | Signal | What it is for |
|---|---|---|
| 1 | `+` | supply 12–24 V DC, never above 36 V |
| 2 | `GND` | supply minus |

The input has a 5 A slow-blow fuse, reverse-polarity protection and a 36 V TVS diode. 48 V is not supported. Supply choice and grounding are on the [Power](/docs/power) page.

## Drivers in the sockets

Two StepStick sockets, one per axis. Supported modules: **TMC2209 and TMC2226** in UART mode. The controller sets the motor current and microstepping over UART; there is no potentiometer to turn.

- The sockets are keyed: a module turned the wrong way does not fit. Check that `VM` and `GND` of the module match the marking on the board.
- StepStick modules from different makers differ in a few pins. Solder jumpers next to each socket set the pinout. From the factory they match the supplied drivers (BTT TMC2209 V1.2 layout). The procedure for other makers is not final yet.
- Each driver needs its heatsink. Keep the vents over the sockets free.
- Above about 28 V supply the sockets are switched off; see [Power](/docs/power).

## Motor 1 and motor 2

4-pin terminals, 5.08 mm, one bipolar stepper motor (4 wires) each, driven by the driver in the matching socket.

| Pin | Motor wire |
|---|---|
| 1, 2 | one coil |
| 3, 4 | the other coil |

- Find the two coils with a multimeter: the two wires of one coil show a few ohms between them.
- If the motor turns the wrong way, do not rewire. Set the direction in the axis settings.
- A TMC2209 drives up to about 2 A RMS per motor with its heatsink. For a bigger motor, use an external driver on `AXIS EXT`.
- Two motors that must move as one (the two Y motors of a gantry): one on the socket, the other on an external driver on the `AXIS EXT` terminal of the same channel.

## External driver, axis 1 and 2

8-pin terminals `AXIS 1 EXT` and `AXIS 2 EXT`, 3.81 mm. Each carries the same steps as the matching socket, as 5 V differential signals (RS-422 line driver). Use them for a stepper or servo driver with Step/Dir inputs.

| Pin | Signal | What it is for |
|---|---|---|
| 1 | `STEP+` | step pulse, positive line |
| 2 | `STEP−` | step pulse, negative line |
| 3 | `DIR+` | direction, positive line |
| 4 | `DIR−` | direction, negative line |
| 5 | `EN` | driver disable, 5 V single wire: high = disabled |
| 6 | `+5V` | 5 V out for common-anode inputs, current-limited |
| 7, 8 | `GND` | ground |

- `EN` is a **disable** signal. The device drives it high whenever the e-stop is active or the motion core has not enabled the drivers.
- The socket and `AXIS EXT` of one channel get the same steps. Normally use one of them and leave the socket empty; use both only for two motors that move as one.

### Example: differential inputs (typical stepper driver)

For a driver with opto inputs `PUL+ PUL− DIR+ DIR− ENA+ ENA−` (DM542 type):

| UPAN Core pin | Driver input |
|---|---|
| 1 `STEP+` | `PUL+` |
| 2 `STEP−` | `PUL−` |
| 3 `DIR+` | `DIR+` |
| 4 `DIR−` | `DIR−` |
| 5 `EN` | `ENA+` |
| 7 `GND` | `ENA−` |

### Example: common-anode inputs

| UPAN Core pin | Driver input |
|---|---|
| 6 `+5V` | `COM` (common anode: `PUL+`, `DIR+` joined) |
| 2 `STEP−` | `PUL−` |
| 4 `DIR−` | `DIR−` |

With a common anode, `EN` would work the wrong way round. Leave the driver's `ENA` input open.

### Example: common-cathode inputs

| UPAN Core pin | Driver input |
|---|---|
| 7 `GND` | `COM` (common cathode: `PUL−`, `DIR−`, `ENA−` joined) |
| 1 `STEP+` | `PUL+` |
| 3 `DIR+` | `DIR+` |
| 5 `EN` | `ENA+` |

> **Warning:** When UPAN Core has no power, `EN` is low. Most DM542-type drivers are then **enabled**. Do not rely on `EN` alone to keep an external drive off.

## Fast inputs and sensor supply

8-pin terminal `FAST IN`, 3.81 mm. Four fast inputs for limit switches, homing, a probe or a pulse counter, and the supply pins for sensors.

| Pin | Signal | What it is for |
|---|---|---|
| 1–4 | `IN1`–`IN4` | fast inputs |
| 5 | `COM1` | common of the fast inputs |
| 6 | `+V` | supply voltage out for sensors, 200 mA resettable fuse |
| 7 | `+5V` | 5 V out for sensors, current-limited |
| 8 | `GND` | ground |

All inputs on UPAN Core are opto-isolated and take **5–36 V**. A filter of about 0.5 ms suppresses contact bounce; the fast inputs count pulses up to about 1 kHz.

- **Dry contacts and PNP sensors:** connect them between `+V` (or `+5V`) and the input. `COM1` is joined to `GND` on the board from the factory.
- **NPN sensors:** cut the solder jumper `COM1-GND` on the board and connect `COM1` to the sensor supply (`+V`). The procedure is not final yet.

> **Warning:** `+V` is the supply voltage itself. A sensor rated 10–30 V is fine at 24 V; check its rating before you use a higher supply.

### Example: NC limit switches

| From | To |
|---|---|
| pin 6 `+V` | common (`C`) of both limit switches |
| `NC` of the minimum switch | pin 1 `IN1` |
| `NC` of the maximum switch | pin 2 `IN2` |

Use **normally closed (NC)** contacts: a closed contact means "normal", a pressed switch or a broken wire means "triggered", so a cut cable stops the axis instead of being ignored. Which input is which limit is part of the axis settings in your package.

### Example: 3-wire PNP sensor

| Sensor wire | To |
|---|---|
| brown (+) | pin 6 `+V` |
| blue (−) | pin 8 `GND` |
| black (output) | pin 3 `IN3` |

## Universal inputs

8-pin terminal `IN`, 3.81 mm. Six inputs for buttons, pedals, sensors and switches.

| Pin | Signal | What it is for |
|---|---|---|
| 1–6 | `IN1`–`IN6` | universal inputs, 5–36 V |
| 7 | `COM2` | common of the universal inputs |
| 8 | `GND` | ground |

They work like the fast inputs, NPN or PNP, with their own common and jumper `COM2-GND`. Take the sensor supply from `+V` or `+5V` on `FAST IN`. These inputs are read a little more slowly; use the fast inputs for limits and probes.

### Example: foot pedal on IN1

| From | To |
|---|---|
| `+V` on `FAST IN` | pedal, one side |
| pedal, other side | pin 1 `IN1` |

## Outputs and e-stop

8-pin terminal `OUT / E-STOP`, 3.81 mm.

| Pin | Signal | What it is for |
|---|---|---|
| 1–4 | `OUT1`–`OUT4` | outputs, switch the load to ground, 0.5 A each |
| 5 | `VM` | supply voltage, the plus side of the loads |
| 6 | `ESTOP` | e-stop input |
| 7 | `+5V` | 5 V for the e-stop button |
| 8 | `GND` | ground |

**Outputs:** connect a load (relay coil, valve, lamp, camera trigger through an optocoupler) between `VM` and `OUTn`. The output switches the load to ground, up to 0.5 A, with short-circuit and over-temperature protection. The load runs at the supply voltage: at a 24 V supply, use 24 V loads. The outputs clamp the voltage spike of a coil themselves.

**E-stop:** connect an NC stop button between pin 7 `+5V` and pin 6 `ESTOP`. A pressed button or a broken wire disables all drivers in hardware — the sockets, the external driver terminals and an UPAN Axis — and the firmware stops the program. **Without a button, fit a wire jumper between pins 6 and 7**, otherwise the drivers stay off.

This is a functional stop, not a safety-rated emergency stop. See [Safety](/docs/safety).

### Example: 24 V valve on OUT1

| From | To |
|---|---|
| pin 5 `VM` | valve `+` |
| valve `−` | pin 1 `OUT1` |

## PWM / servo and analog inputs

6-pin terminal `PWM / AIN`, 3.81 mm.

| Pin | Signal | What it is for |
|---|---|---|
| 1, 2 | `PWM1`, `PWM2` | 5 V PWM: RC servo, laser, ESC, dimmer, spindle speed |
| 3, 4 | `AIN1`, `AIN2` | analog inputs 0–10 V, or a potentiometer |
| 5 | `+5V` | 5 V out, about 0.2 A for all `+5V` pins together |
| 6 | `GND` | ground |

- An RC servo draws more current than the `+5V` pins give. Power servos from their own 5–6 V supply and join its minus to `GND`.
- A potentiometer of 1–10 kΩ: ends to `+5V` and `GND`, wiper to `AIN`.

## RS485

3-pin terminal `RS485 A B GND`, 3.81 mm, for Modbus: a spindle inverter, industrial sensors, and MKS SERVO42D/57D motors as axes 5 and up (independent axes, not coordinated with axes 1–4).

- Connect `A` to `A`, `B` to `B` and `GND` to the ground of every device, with a twisted pair.
- If UPAN Core is at one end of the bus, fit the supplied jumper on `TERM 120R`.

## Qwiic

A JST SH 4-pin socket (Qwiic / STEMMA QT, 3.3 V, 200 mA resettable fuse) for ready-made I2C sensor boards: weight, temperature, distance (ToF), motion (IMU), pH. Daisy-chain several boards with Qwiic cables.

## Display

4-pin terminal `DISPLAY +5V TX RX GND` for the UPAN Display touch panel (coming later). `+5V` has a 500 mA resettable fuse.

## UPAN Axis socket

A 2 × 7 pin IDC socket for the ribbon cable to an UPAN Axis module next to the Core on the DIN rail. It carries the steps of axes 3 and 4, the shared disable line, the limit inputs of axes 3–4 and 3.3 V logic power. The Core makes the steps for all four axes, so they move together.

The ribbon cable carries no motor power. Wire the module to the power supply on its own wires. Plug and unplug the ribbon cable only with the power off.

## USB-C

- On a PC the controller shows up as a serial port (for `upan-cli` and `upan-mcp`) and as a USB drive: drop a package file on it to install the package.
- USB powers the logic for setup on a desk. Drivers in the sockets cannot move a motor from USB alone.
- USB and the power supply can be connected at the same time.

## Antenna

Screw the supplied antenna onto the SMA socket. In a metal cabinet, Wi-Fi does not get out: mount the antenna outside the cabinet with an SMA extension cable.

## Button and status light

One button with an RGB light pipe on the front.

| Action | Result |
|---|---|
| Short press (under 2 s) | opens a 30 s presence window for changing machine limits over USB |
| Hold 5 s | Wi-Fi setup mode, access point `UPAN-xxxx` |
| Hold 10 s while powering on | factory reset of network settings and working limits (machine limits are kept) |

| Light | State |
|---|---|
| short white flash | starting |
| blue, steady | ready |
| white, steady | moving |
| turquoise, breathing slowly | Wi-Fi setup |
| violet, breathing | firmware or package update |
| red, steady | error |
| red, flashing fast | e-stop active |

The firmware for the button and the light is in development; the behaviour above is the target, not final yet.
