Control a Stepper Motor Using an Arduino
Stepper Motor Speed Control using Arduino
Today, I am going to tell you that how to make a simple algorithm for Stepper Motor Speed Control using Arduino. I have already ... Download Arduino Code
Stepper Motor Speed Control using Arduino
In the tutorial Stepper Motor Direction Control using Arduino, I will explain you about making an algorithm to run the stepper motor at different speed. If the stepper motor is already running at its maximum speed and you want want to accelerate it further then nothing will happen to the speed of the stepper motor. If the stepper motor is rotating slowly and you enhance its speed, then the speed of the motor will increase in proportion to the number of accelerating command sent through the serial port.
Flow Chart
Block Diagram
Arduino Code Description
In this section of the tutorial Stepper Motor Speed Control using Arduino, I am going to elaborate you about the Arduino source.
void Accelerate_Motor() { count=count+10; //Speed will increase continuously as we continue to press H if (count>120) //Speed must not be greater than 120 { count=120; } Serial.println("Accelerating"); //printing on the serial port Serial.println("");//prints blank line on the serial port myStepper.step(stepsPerRevolution);//counter clockwise rotation myStepper.setSpeed(count); //Updating the speed of the motor lcd.setCursor(3,0);//setting LCD cursor lcd.print("Acelerating"); //printing on LCD }
void Deaccelerate() { count=count-10; //reducing the speed of the motor if (count<20) //speed of the motor must not be less than 20 { count=20; } Serial.println("Deaccelerating"); // prints on the serial port Serial.println(""); //prints blank line on the serial port myStepper.step(stepsPerRevolution); myStepper.setSpeed(count); //Updating the speed of the motor lcd.setCursor(3,0); //setting cursor on LCD lcd.print("Deaccelerating"); //prints the command on LCD }
#include <LiquidCrystal.h>//Library for LCD #include <Stepper.h> //Library for Stepper motor const int stepsPerRevolution = 255; // initialize the stepper library on pins Stepper myStepper(stepsPerRevolution, 4, 5, 6, 7); char data; int count = 120; //LCD pins assigning LiquidCrystal lcd(8, 9, 10, 11, 12, 13); void setup() { // set the speed at 60 rpm myStepper.setSpeed(60); // initialize the serial port: Serial.begin(9600);// rate at which the arduino communicates lcd.begin(20, 4);//LCD type lcd.setCursor(3,0);//setting LCD cursor and printing on it lcd.print("Stepper Motor"); lcd.setCursor(6,1); lcd.print("Speed"); lcd.setCursor(5,2); lcd.print("Control"); lcd.setCursor(2,3); lcd.print("via Arduino UNO"); delay(3000); lcd.clear ();//Clearing the LCD screen lcd.setCursor(0,2); lcd.print("www.TheEngineering"); lcd.setCursor(4,3); lcd.print("Projects.com"); } void loop() { if(Serial.available()) { data = Serial.read(); //Reading the data from serial port } if(data == 'C'){Clockwise();} //Clockwise rotation if(data == 'A'){AntiClockwise();} //Anti-clockwise rotation if(data == 'S') //stopping the stepper motor { data = 0; lcd.setCursor(3,0); lcd.print("No rotation"); Serial.println("No rotation");//print on the serial } if(data == 'H'){Accelerate_Motor();} if(data == 'L'){Deaccelerate();} }
Complete Hardware Setup
Source: https://www.theengineeringprojects.com/2017/04/stepper-motor-speed-control-using-arduino.html
0 Response to "Control a Stepper Motor Using an Arduino"
Post a Comment