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

Lecture 18

This document provides information about stepper motors, including: - Stepper motors move in discrete steps with multiple coils organized in phases, and rotating one step at a time by energizing each phase in sequence allows for precise positioning. - Stepper motors are well-suited for precision motion control applications due to their ability to achieve precise positioning and speed control with computer controlled stepping. - The document also provides code examples for controlling and setting the speed of stepper motors using an Arduino library.

Uploaded by

Azam Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Lecture 18

This document provides information about stepper motors, including: - Stepper motors move in discrete steps with multiple coils organized in phases, and rotating one step at a time by energizing each phase in sequence allows for precise positioning. - Stepper motors are well-suited for precision motion control applications due to their ability to achieve precise positioning and speed control with computer controlled stepping. - The document also provides code examples for controlling and setting the speed of stepper motors using an Arduino library.

Uploaded by

Azam Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Stepper Motors

Servo Motors
• Stepper motors are DC motors that move in discrete steps. They have multiple coils that are
organized in groups called "phases". By energizing each phase in sequence, the motor will rotate,
one step at a time.

• With a computer controlled stepping you can achieve very precise positioning and/or speed
control. For this reason, stepper motors are the motor of choice for many precision motion control
applications.

• 1 step = 1.8 degrees and 200 steps = 360 degrees

2
Stepper Motor Types

3
Syntax
• #include <Stepper.h>

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

Stepper Data Variable Number of


type Pins
Revolutions

• myStepper.setSpeed(5);

• myStepper.step(stepsPerRevolution);

4
Code
/* Stepper Motor Control */

#include <Stepper.h>
const int stepsPerRevolution = 90;
// 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(5);
// 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);
5 }
Speed Control
#include <Stepper.h>
  
// Number of steps per output rotation
const int STEPS_PER_REV = 200;
const int SPEED_CONTROL = A0;
 
// Create Instance of Stepper Class
// Specify Pins used for motor coils
// The pins used are 8,9,10,11
// Connected to L298N Motor Driver In1, In2, In3, In4
// Pins entered in sequence 1-2-3-4 for proper step sequencing
 
Stepper stepper_NEMA17(STEPS_PER_REV, 8, 9, 10, 11);
 
void setup() {
  // nothing to do inside the setup
}
 
void loop() {
  // read the sensor value:
  int sensorReading = analogRead(SPEED_CONTROL);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
  if (motorSpeed > 0) {
    stepper_NEMA17.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    stepper_NEMA17.step(STEPS_PER_REV / 100);
  }
6 }
4

You might also like