Điều khiển động cơ bước 5V

robotchomoinguoi

Thành viên
Tham gia
10/10/2017
Bài viết
2
Điều khiển động cơ bước 5V- Giới thiệu
Bài viết nguồn xem tại: laptrinhdieukhien.com
Điều khiển động cơ bước 5V là bài học thứ 8 trong chuỗi bài tự học arduino. Ở bài học này, chúng ta sẽ cùng làm quen với loại động cơ bước đơn giản 28BYJ-48 và module ULN2003.

5V-Stepper-Motor-28BYJ-48-With-Drive-Test-Module-Board-ULN2003.jpg


Loại động cơ bước được sử dụng trong bài học này là loại động cơ bước 4 pha (2 pha được chia đôi ở mỗi pha ngay tại vị trí giữa) (gồm 5 dây). Một bước động cơ xoay 5.625 độ, để quay hết một vòng là 64 bước

3064_882450-1471690895-0-ttl-phong-dm2.png


Thông số kỹ thuật

Điện thế: 5V

Số pha: 4

Tỉ lệ bánh răng: *64

Một bước tương đương 5.625 độ

Tần số: 100Hz

Điện trở trong 50 Ω±7%(25℃)

Linh kiện chuẩn bị
Arduino Uno R3

Dây bus đực cái

Động cơ bước 5V và module ULN2003


Hướng dẫn chi tiết

Để điều khiển động cơ bước 5V, ở video hướng dẫn sau đây chúng ta sẽ sử dụng thư viện Stepper.h được tích hợp sẵn trong arduino IDE để điều khiển. Các bạn chú ý theo dõi các bước thực hiện nhé

upload_2018-4-3_21-58-3.gif


Code mẫu arduino
Các bạn có thể sử dụng code mẫu này để nạp cho arduino nhé.

/*

Stepper Motor Control – one revolution

This program drives a unipolar or bipolar stepper motor.

The motor is attached to digital pins 8 – 11 of the Arduino.

The motor should revolve one revolution in one direction, then

one revolution in the other direction.

Created 11 Mar. 2007

Modified 30 Nov. 2009

by Tom Igoe

*/

#include

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution

// for your motor

// initialize the stepper library on pins 8 through 11:

Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {

// set the speed at 60 rpm:

myStepper.setSpeed(60);

// initialize the serial port:

Serial.begin(9600);

}

void loop() {

// step one revolution in one direction:

Serial.println(“clockwise”);

myStepper.step(stepsPerRevolution);

delay(500);

// step one revolution in the other direction:

Serial.println(“counterclockwise”);

myStepper.step(-stepsPerRevolution);

delay(500);

}
 
×
Quay lại
Top