← Back to Lab Hub RP2040 MicroPython Actuator Lab

Stepper Motor Phase Excitation & Matrix Simulator

4-Phase Electromagnetic Coil Sequences, Full-Step / Wave Drive, and Step Angle Calculations

🧲 Stepper Motor Coil Excitation Physics
Electromagnetic Torque & Step Sequence: Unipolar and bipolar stepper motors rotate by sequentially energizing internal stator coils (Coil A1, A2, B1, B2). In Full-Step Drive, two adjacent coils are energized simultaneously to maximize holding torque (angle step = 1.8° for 200-step motors). In Wave Drive, only one coil is active at a time for minimal power consumption.

Step Angle Calculation: Step Angle = 360° / N_steps (e.g., 360° / 200 steps = 1.8° per step). Standard Angle: 1.8° / Step 4-Pin Control Matrix
Drive Excitation Mode: Full-Step (Dual Coil)
Full-Step (2-Coil)
Wave Drive (1-Coil)
Stepping Speed (RPM / Delay): Speed: 60 RPM (5 ms step delay)
Play / Pause
Step Forward ⏩
Step Reverse ⏪
📊 4-Phase GPIO Excitation Sequence Matrix
Step Index IN1 (Coil A1) IN2 (Coil A2) IN3 (Coil B1) IN4 (Coil B2)
🐍 MicroPython Stepper Matrix Control Code
from machine import Pin
import time

# 4 GPIO Output Pins for ULN2003 Driver
pins = [Pin(16, Pin.OUT), Pin(17, Pin.OUT), Pin(18, Pin.OUT), Pin(19, Pin.OUT)]

# Excitation Matrix
FULL_STEP = [
  [1, 1, 0, 0], [0, 1, 1, 0],
  [0, 0, 1, 1], [1, 0, 0, 1]
]

# Active Step State Pointer
step_idx = 0

while True:
  for i in range(len(pins)):
    pins[i].value(FULL_STEP[step_idx][i])
  time.sleep_ms(5)
  step_idx = (step_idx + 1) % len(FULL_STEP)
📝 Stepper Excitation Quiz
Why does Full-Step Drive (2 coils active simultaneously) provide higher holding torque compared to Wave Drive (1 coil active)?