Hallo,
der unten angefügte, leicht abgewandelte Versuchssketch funktioniert so weit, die Stepper laufen auch ziemlich ruhig.
Allerdings macht erst einer der beiden Motoren eine Drehung in Drehrichtung, stoppt dann, dann macht der zweite Motor
die gleiche Drehung, stoppt, danach der erste Motor die Drehung in die Gegenrichtung, stoppt, danach dann erst der zweite Motor in die Gegenrichtung.
Ich möchte gern, dass beide Motoren gleichzeitig laufen jeweils entgegengesetzt laufen.
Habt Ihr Vorschläge?
Danke im voraus
Frank
/*
Stepper Motor Control - one revolution
This is the examply by Tom Igoe delivered with th Arduino IDE.
Adapted by Stefan Thesen for 28BYJ-48 stepper motor
https://blog.thesen.eu
*/
//leicht abgewandelt durch sunsailor
#include <Stepper.h>
// Get steps per turn and RPM out of datasheet:
// ============================================
// 5.625/64 deg per step --> 4096 steps for 360 deg
// step relates to half-step sequencing, which means 8 steps
// We use 4 full steps ==> 2048 steps per turn
//
// recommended frequency range 600-1000Hz for 8 half-steps
// 1000Hz/4096 half-steps --> approx 4sec per turn is max speed
// ==> 15rpm
// Note: actually we will use ~500Hz using the 4 step approach
// but motor will not be able to turn faster.
// Get stepping sequence out of datasheet:
// =======================================
// Stepping sequence as given in datasheet
// this is an 8-step half-step approach
// Steps
// Wire 1 2 3 4 5 6 7 8
// 1 x x x
// 2 x x x
// 3 x x x
// 4 x x x
//
// We use only even / full steps thus:
// Steps
// Wire 2 4 6 8
// 1 x x
// 2 x x
// 3 x x
// 4 x x
//
// Code of Arduino Stepper Lib has implemented:
// Steps
// Wire 1 2 3 4
// 1 x x
// 2 x x
// 3 x x
// 4 x x
//
// ==> Simple Solution: exchange wire 2&3
const int stepsPerRevolution = 2048; // here go the 2048 steps
// for your motor
// initialize the stepper library on pins 8 through 11 -> IN1, IN2, IN3, IN4
// as shown above, we need to exchange wire 2&3, which we do in the constructor
Stepper myStepper1(stepsPerRevolution, 8, 10, 9, 11);
Stepper myStepper2(stepsPerRevolution, 4, 6, 5, 7);
void setup()
{
// set the speed at 8 rpm:
myStepper1.setSpeed(8);
myStepper2.setSpeed(8);
// initialize the serial port:
Serial.begin(9600);
}
void loop()
{
// step one revolution in one direction:
Serial.println("clockwise");
myStepper1.step(stepsPerRevolution);
myStepper2.step(stepsPerRevolution);
delay(500);
// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper1.step(-stepsPerRevolution);
myStepper2.step(-stepsPerRevolution);
delay(500);
}