در خیلی جاها به دلیل عدم سازگاری خروجی پردازنده ها با مشخصات موتور نمیشود مستقیما آن را به موتور متصل کرد و نیاز به درایور داریم.
این درایور به دلیل ویژگیهای خوب و قیمت پایینی که دارد بسیار مورد توجه قرار گرفته است و در بسیاری از پروژه ها حضور دارد.
اندازه و شکل آن با برد برد و شیلدهای مخصوص ماشینهای CNC و پرینترهای سه بعدی کاملا سازگار می باشد.
توان راه اندازی موتور های دو فاز با ولتاژ 8 تا 35 ولت با جریان 2 آمپر در هر فاز امکان استفاده از این ماژول را برای طیف وسیعی از موتورها فراهم می کند.
در اینجا به چگونگی استفاده از این درایور می پردازیم
پینهای ماژول به شرح زیر می باشد
تغذیه موتور VMO 8-35V
منفی موتور GND Motor ground
SLP و RST اگر 5 ولت باشد موتور فعال است و اگر صفر باشد موتور حرکت نمیکند. این پین بیشتر برای آنکه وقتی موتور حرکت ندارد مصرف انرژی کاهش یابد استفاده می شود
ولتاز تغذیه درایور VDD 5V
منفی درایور GND Logic ground
فرمان حرکت STP Pin 3
فرمان جهت حرکت DIR Pin 2
به فازهای موتور متصل می شوند. 1A, 1B, 2A, 2B Stepper motor
پینهای A1 و B1 به یک فاز و A2 و B2 به فاز دیگر متصل میشوند. اتصال فازها پلاریته ندارند.
اگر جهت چرخش موتور بر خلاف انتظار شما بود کافیست جای پینهای A1 و B1 را با هم عوض کنید.
پینهای MS1 تا MS3 برای تعیین وضعیت هر استپ می باشد.
MS1=Low , MS2=Low , MS3=Low - Full step
MS1=High , MS2=Low , MS3=Low - 1/2 step
MS1=Low , MS2=High , MS3=Low - 1/4 step
MS1=High , MS2=High , MS3=Low - 1/8 step
MS1=High , MS2=High , MS3=High - 1/16 step
حالا همانند شکل زیر اتصالات موتور را و درایور را انجام دهید و برنامه نمونه را بارگزاری کنید. این برنامه موتور را در دو جهت حرکن می دهد
// Define stepper motor connections and steps per revolution:
#define dirPin 2
#define stepPin 3
#define stepsPerRevolution 200
void setup() {
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}
void loop() {
// Set the spinning direction clockwise:
digitalWrite(dirPin, HIGH);
// Spin the stepper motor 1 revolution slowly:
for (int i = 0; i < stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(2000);
digitalWrite(stepPin, LOW);
delayMicroseconds(2000);
}
delay(1000);
// Set the spinning direction counterclockwise:
digitalWrite(dirPin, LOW);
// Spin the stepper motor 1 revolution quickly:
for (int i = 0; i < stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin, LOW);
delayMicroseconds(1000);
}
delay(1000);
// Set the spinning direction clockwise:
digitalWrite(dirPin, HIGH);
// Spin the stepper motor 5 revolutions fast:
for (int i = 0; i < 5 * stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin, LOW);
delayMicroseconds(500);
}
delay(1000);
// Set the spinning direction counterclockwise:
digitalWrite(dirPin, LOW);
//Spin the stepper motor 5 revolutions fast:
for (int i = 0; i < 5 * stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin, LOW);
delayMicroseconds(500);
}
delay(1000);
}