Schrittmotor ruckelt beim starten (Nullpunkt an Lichtschranke)

chefin:
Ich denke mal, das deine Steppermotorinitialisierung falsch ist

Dem stimme ich nicht zu. Allerdings nimmt er die Bezeichnungen für DC-Motoren für die Ausgänge. Besser so:

const int pwmA = 3;  // Stepper: ENA 
const int pwmB = 11;  // Stepper: ENB
const int brakeA = 9;  // Stepper: unbenutzt
const int brakeB = 8;  // Stepper: unbenutzt
const int dirA = 12;  // Stepper: IN1 und IN2 als IN1#
const int dirB = 13;  // Stepper: IN3 und IN4 als IN3#

ENA und ENB sind enable=HIGH.

Die Anschlüsse brakeA und brakeB können hochohmig (je 10kOhm interner Pulldown), LOW oder die Lötbrücke getrennt sein.

Zu dirA und dirB ein Zitat aus der Bibliothek:

  • When wiring multiple stepper motors to a microcontroller, you quickly run
  • out of output pins, with each motor requiring 4 connections.
  • By making use of the fact that at any time two of the four motor coils are
  • the inverse of the other two, the number of control connections can be
  • reduced from 4 to 2 for the unipolar and bipolar motors.
  • A slightly modified circuit around a Darlington transistor array or an
  • L293 H-bridge connects to only 2 microcontroler pins, inverts the signals
  • received, and delivers the 4 (2 plus 2 inverted ones) output signals
  • required for driving a stepper motor. Similarly the Arduino motor shields
  • 2 direction pins may be used.

Dementsprechend ist die Initialisierung richtig:

Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2);