arduino motor control - philadelphia.edu.jo
TRANSCRIPT
![Page 1: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/1.jpg)
Arduino Motor Control
Dr. Tarek A. Tutunji
Philadelphia University
![Page 2: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/2.jpg)
Outline• DC Motor
• Servo Motor
• Stepper Motor
![Page 3: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/3.jpg)
DC Motor
![Page 4: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/4.jpg)
DC Motor Control using PWM
![Page 5: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/5.jpg)
Example: DC Motor Speed Control
reference: www.circuitstoday.com
![Page 6: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/6.jpg)
Example: DC Motor Controlusing analogWrite
const int pwmPin = 10;
Const int Pot = A0;
void setup() {
pinMode(pwmPin, OUTPUT;
}
void loop() {
analogWrite(pwmPin, 99 );
}
Note:
Duty Cycle is 387/1000 = 0.387
Then, 0.387 x 255 = 98.685
![Page 7: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/7.jpg)
Servo Motor
![Page 8: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/8.jpg)
Servo Motors• Servo motors have built-in shaft encoder
• Data sheets provide the required pulses for specific speed and/or position
Motor EncoderMain
ControllerElectronics
![Page 9: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/9.jpg)
Servo Motor• An actuator with built-in feedback mechanism that responds to a
control signal by moving to and holding a position, or by moving at continuous speed.
![Page 10: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/10.jpg)
Servo motors
Reference: living with the lab
![Page 11: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/11.jpg)
Servo Motor
![Page 12: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/12.jpg)
Servo Motor
![Page 13: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/13.jpg)
Servo Motor
• File Examples Servo Knob
/* Controlling a servo position using a potentiometer (variable resistor) */
#include <Servo.h>
Servo myservo; // create servo object
int potpin = 0; // analog pin connect the potentiometer
int val; // variable to read the value from analog pin
void setup()
{ myservo.attach(9); // attaches the servo on pin 9 }
void loop()
{
val = analogRead(potpin); // reads potentiometer
val = map(val, 0, 1023, 0, 180); // scale the value
myservo.write(val); // sets the servo position
delay(15); // waits for the servo to get there
}
![Page 14: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/14.jpg)
Stepper Motor
![Page 15: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/15.jpg)
Stepper Motor
![Page 16: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/16.jpg)
Stepper Motor
![Page 17: Arduino Motor Control - philadelphia.edu.jo](https://reader034.vdocument.in/reader034/viewer/2022042702/6265639d30d2566acb199bb6/html5/thumbnails/17.jpg)
Stepper MotorFile Examples Stepper stepper_oneRevolution
/* 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 */
#include <Stepper.h>
const int stepsPerRevolution = 200;
// number of steps per revolution for your motor
// initialize stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup()
{ myStepper.setSpeed(60); } // Set the speed at 60 rpm
void loop() {
// step one revolution in one direction:
myStepper.step(stepsPerRevolution);
delay(500);
}