0% found this document useful (0 votes)
58 views

Tugas Program Stepper Motor Mata Kuliah Elektronika Kontrol Kelas A "Buat Program Untuk Menggerakkan Putaran Motor Stepper"

The document describes an Arduino program to control the rotation of a stepper motor. It defines the pin connections for the stepper motor and sets the number of steps needed to rotate the motor to angles of 30, 40, 60, 90, 135, 180, 270, 360, and 540 degrees. The program then uses for loops to rotate the motor to each of these angles by pulsing the step pin on and off the defined number of steps. It also describes modifying the program to rotate the motor continuously 360 degrees or a number of steps based on data received from a computer terminal.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Tugas Program Stepper Motor Mata Kuliah Elektronika Kontrol Kelas A "Buat Program Untuk Menggerakkan Putaran Motor Stepper"

The document describes an Arduino program to control the rotation of a stepper motor. It defines the pin connections for the stepper motor and sets the number of steps needed to rotate the motor to angles of 30, 40, 60, 90, 135, 180, 270, 360, and 540 degrees. The program then uses for loops to rotate the motor to each of these angles by pulsing the step pin on and off the defined number of steps. It also describes modifying the program to rotate the motor continuously 360 degrees or a number of steps based on data received from a computer terminal.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

TUGAS PROGRAM STEPPER MOTOR

MATA KULIAH ELEKTRONIKA KONTROL KELAS A

“BUAT PROGRAM UNTUK MENGGERAKKAN PUTARAN MOTOR STEPPER”

OLEH:

Raihan Adi Nugroho 175060307111003

PROGRAM STUDI S1 TEKNIK ELEKTRO

FAKULTAS TEKNIK

UNIVERSITAS BRAWIJAYA

MALANG

2019
Stepper berputar membentuk sudut 30, 40, 60, 90, 135, 180, 270, 360, 540

// Identifikasi Pin Stepper


const int stepPin = 5;
const int dirPin = 2;
const int enPin = 8;

float stepPerAngle = 1.8; // setiap step = 1.8

// Identifikasi Numstep
int numstep1;
int numstep2;
int numstep3;
int numstep4;
int numstep5;
int numstep6;
int numstep7;
int numstep8;
int numstep9;

void setup() {
Serial.begin(9600);
// Identifikasi 2 Pin Output Stepper
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(enPin,OUTPUT);
digitalWrite(enPin,LOW);
digitalWrite(dirPin,HIGH);

// Menentukan Perputaran Derajat


n1 = 30;
n2 = 40;
n3 = 60;
n4 = 90;
n5 = 135;
n6 = 180;
n7 = 270;
n8 = 360;
n9 = 540;

// Menentukan Step Yang Dibutuhkan


numstep1 = n1 / stepPerAngle;
numstep2 = n2 / stepPerAngle;
numstep3 = n3 / stepPerAngle;
numstep4 = n4 / stepPerAngle;
numstep5 = n5 / stepPerAngle;
numstep6 = n6 / stepPerAngle;
numstep7 = n7 / stepPerAngle;
numstep8 = n8 / stepPerAngle;
numstep9 = n9 / stepPerAngle;
}
void loop() {

digitalWrite(dirPin,HIGH);

//Looping Dimulai
for(int x = 0; x < numstep1; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}
for(int x = numstep1; x < numstep2; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

for(int x = numstep2; x < numstep3; x++) {


digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

for(int x = numstep3; x < numstep4; x++) {


digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

for(int x = numstep4; x < numstep5; x++) {


digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

for(int x = numstep5; x < numstep6; x++) {


digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

for(int x = numstep6; x < numstep7; x++) {


digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

for(int x = numstep7; x < numstep8; x++) {


digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

for(int x = numstep8; x < numstep9; x++) {


digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

}
Stepper berputar membentuk sudut sesuai data dikirim dari
komputer/terminal

// Identifikasi Pin Stepper


const int stepPin = 5;
const int dirPin = 2;
const int enPin = 8;

float stepPerAngle = 1.8; // setiap step = 1.8

// Identifikasi Numstep
int numstep1;

void setup() {
Serial.begin(9600);
// Identifikasi 2 Pin Output Stepper
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(enPin,OUTPUT);
digitalWrite(enPin,LOW);
digitalWrite(dirPin,HIGH);

// Menentukan Perputaran Derajat


n1 = 360;

// Menentukan Step Yang Dibutuhkan


numstep1 = n1 / stepPerAngle;

}
void loop() {
digitalWrite(dirPin,HIGH);

//Looping Dimulai
for(int x = 0; x < numstep1; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}

}
Stepper berputar sejumlah tertentu sesuai data dikirim dari
komputer/terminal

// Identifikasi Pin Stepper


const int stepPin = 5;
const int dirPin = 2;
const int enPin = 8;

void setup() {
Serial.begin(9600);
// Identifikasi 2 Pin Output Stepper
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(enPin,OUTPUT);
digitalWrite(enPin,LOW);
digitalWrite(dirPin,HIGH);

}
void loop() {

digitalWrite(dirPin,HIGH);

//Looping Dimulai
for(int x = 0; x < 5; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}
}

You might also like