Codey OnlineArduino- & ESP32-Komponentenbibliothek › NEMA17 Stepper Motor
NEMA17 Stepper Motor
Aktoren

NEMA17 Stepper Motor

Ein NEMA17-Schrittmotor wandelt Schrittimpulse über zwei elektromagnetische Spulen in eine präzise Winkelbewegung um. Er wird typischerweise über einen Schrittmotortreiber mit den vier Spulenanschlüssen des Motors angesteuert (meist als A+/A− und B+/B− gekennzeichnet), während die übrigen gekennzeichneten Anschlüsse am Stecker dieselben Spulenverbindungen in einer anderen Pinbelegung darstellen. Verwende die passende Verdrahtung des Schrittmotortreibers, um die A- und B-Spulen nacheinander zu bestromen.

Breite: 53.6 mm

Pinbelegung — NEMA17 Stepper Motor

Pin Signal Beschreibung
1A power Stepper coil 1 terminal A — connect to one output of motor driver phase A
1B power Stepper coil 1 terminal B — connect to the other output of motor driver phase A
2A power Stepper coil 2 terminal A — connect to one output of motor driver phase B
2B power Stepper coil 2 terminal B — connect to the other output of motor driver phase B

Beispielschaltplan — NEMA17 Stepper Motor

Von Nach Kabel
board:5V x2:VDD red
board:GND x2:GND black
board:D2 x2:STEP green
board:D3 x2:DIR blue
board:D4 x2:EN yellow
board:5V x3:CW red
board:GND x3:CCW black
board:A0 x3:WIPER purple
x2:1A x1:1A cyan
x2:1B x1:1B magenta
x2:2A x1:2A brown
x2:2B x1:2B pink

Arduino-Beispielcode — NEMA17 Stepper Motor

Dieses Beispiel wurde für das arduino-uno geschrieben und kompiliergeprüft. Codey Online passt es für jedes andere unterstützte Board an.

// Canonical NEMA17 stepper motor example using an A4988-style driver.
// Wiring:
// Arduino D2 -> STEP
// Arduino D3 -> DIR
// Arduino D4 -> EN (active LOW)
// Arduino 5V -> VDD
// Arduino GND -> GND
// Potentiometer CW -> 5V, CCW -> GND, WIPER -> A0
// Motor coils -> driver outputs 1A/1B and 2A/2B

const int STEP_PIN = 2;
const int DIR_PIN  = 3;
const int EN_PIN   = 4;
const int POT_PIN  = A0;

void stepMotor(long steps, bool direction, unsigned int stepDelayMicros) {
  digitalWrite(DIR_PIN, direction ? HIGH : LOW);

  for (long i = 0; i < steps; i++) {
    digitalWrite(STEP_PIN, HIGH);
    delayMicroseconds(stepDelayMicros);
    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(stepDelayMicros);
  }
}

void setup() {
  pinMode(STEP_PIN, OUTPUT);
  pinMode(DIR_PIN, OUTPUT);
  pinMode(EN_PIN, OUTPUT);

  digitalWrite(STEP_PIN, LOW);
  digitalWrite(DIR_PIN, LOW);
  digitalWrite(EN_PIN, HIGH); // disable driver at start

  Serial.begin(9600);
  while (!Serial) { }

  Serial.println("NEMA17 stepper motor demo with A4988 driver");
  Serial.println("Turn the potentiometer to change speed.");
  Serial.println("The motor alternates direction after each full rotation.");
}

void loop() {
  int pot = analogRead(POT_PIN);
  unsigned int stepDelayMicros = map(pot, 0, 1023, 2000, 300);
  const int stepsPerRevolution = 200; // typical 1.8 degree NEMA17 motor

  digitalWrite(EN_PIN, LOW); // enable driver

  Serial.print("Speed control pot=");
  Serial.print(pot);
  Serial.print("  step delay(us)=");
  Serial.println(stepDelayMicros);

  Serial.println("Rotating clockwise...");
  stepMotor(stepsPerRevolution, true, stepDelayMicros);
  delay(500);

  Serial.println("Rotating counterclockwise...");
  stepMotor(stepsPerRevolution, false, stepDelayMicros);
  delay(500);
}

Ähnliche Komponenten

A4988 Stepper Driver

A4988 Stepper Driver

DRV8825 Driver Board

DRV8825 Driver Board

L298N Motor Driver Board

L298N Motor Driver Board

Left DC Motor

Left DC Motor

Bau dein Arduino- oder ESP32-Projekt mit AI

Beschreib einfach, was du bauen willst. Codey Online schreibt den Code, zeichnet den Schaltplan, kompiliert alles und flasht dein Board direkt aus dem Browser.

Kostenlos starten