Advertisement
icstation

28BYJ-48 Stepper Motor Control System with Arduino

Nov 27th, 2014
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. 28BYJ-48 Stepper Motor Control System Based On Arduino With ULN2003 Chip(http://www.instructables.com/id/28BYJ-48-Stepper-Motor-Control-System-Based-On-Ard/)
  2. ICStation Team introduce you this stepper motor control system based on ICStation UNO compatible with Arduino. It uses ULN2003 chip to drive. The working voltage is DC5V. It is widely used on ATM machine, inkjet printer,cutting plotter, fax machine,spraying equipment, medical instruments and equipments, PC peripheral, and USB Mass Storage ,precise instrument,industrial control system,office automation,robot areas,etc.
  3.  
  4. Functions
  5.  
  6. 1.When start up, the stepper motor will rotate in the clockwise direction, at the same time the1602 LCD will display the stepping rate and rotating direction.
  7. 2.When you press the key1, the stepper motor will rotate in the counter-clockwise direction.
  8. 3.When you turn the potentiometer to the left or to the right, you can adjust the stepping rate of the stepper motor. At the same tine the 1602 LCD will display the current speed.
  9.  
  10. Step 1: Components List
  11. 1.ICStation ATMEGA328 UNO V3.0 R3 Board Compatible Arduino
  12. http://www.icstation.com/product_info.php?products_id=3516
  13. 2.1602A HD44780 Character LCD Display Module
  14. http://www.icstation.com/product_info.php?products_id=1419
  15. 3.5V 4 Phase 5 Line 28BYJ-48 5VDC Stepper Motor
  16. http://www.icstation.com/product_info.php?products_id=2204
  17. 4.50K Ohm B50K Knurled Shaft Linear Rotary Taper Potentiometer
  18. 5.ULN2003AN DIP-16 TI Darlington Transistor Array
  19. 6.Trim Pot Resistor Potentiometer
  20. 7.830 Point Solderless PCB Bread Board MB-102 Test DIY
  21. 8.12X12X5mm Tact Switches 4 Legs
  22. 9.Bread Board Jump Line Jumper Wire
  23. 10. Dupont 20cm Color Cable Line
  24. 11.+5V DC power supply
  25.  
  26. Working Principle:
  27. To change the rotating speed of the stepper motor by changing the input frequency of pulse signal. And to realize the motor rotating in the clockeise direction and counter-clockwise direction by controlling the transform sequence of the pulse signal.
  28.  
  29.  
  30. Code for your reference:
  31.   #include <Stepper.h>
  32.   #include <LiquidCrystal.h>
  33.   int Iint1=0;
  34.   int Iint2=1;
  35.   int anjian1=2;
  36.   int anjian2=3;
  37.   int motorSpeed;
  38.   LiquidCrystal lcd(9,8,7,6,5,4);
  39.   const int stepsPerRevolution =200;
  40.   // Here set the stepper motor rotation step how much is a circle
  41.   int dim=stepsPerRevolution;
  42.   // Set the step motor number and pin
  43.   Stepper myStepper(stepsPerRevolution, 10,11,12,13);
  44.   void setup()
  45.   {
  46.    lcd.begin(16, 2);
  47.    lcd.print("speed:");
  48.   
  49.    lcd.setCursor(10,0);
  50.    lcd.print("n/min");
  51.   
  52.    lcd.setCursor(0, 1);
  53.    lcd.print("Direction:");
  54.    // Set the motor speed of 60 steps per minute
  55.   
  56.    myStepper.setSpeed(60);
  57.   pinMode(anjian1,INPUT_PULLUP);
  58.    pinMode(anjian2,INPUT_PULLUP);
  59.    attachInterrupt(Iint1,counterclockwise,FALLING);
  60.    attachInterrupt(Iint2,clockwise,FALLING);
  61.    Serial.begin(9600);
  62.   }
  63.   
  64.   void loop()
  65.    {
  66.   
  67.    myStepper.step(dim);
  68.    void Direction();
  69.    // Read the sensor values:
  70.    int sensorReading = analogRead(A0);
  71.    // Map it to a range of 0-150:
  72.    int motorSpeed = map(sensorReading, 0, 1023, 0, 150);
  73.    // Set the motor speed:
  74.    if (motorSpeed > 0)
  75.    {
  76.    myStepper.setSpeed(motorSpeed);
  77.    lcd.setCursor(6,0);
  78.    lcd.print(float(float(motorSpeed)/float(200)));
  79.    }
  80.    }
  81.   
  82.    void clockwise()
  83.    {
  84.    // clockwise rotation
  85.    dim=stepsPerRevolution;
  86.    lcd.setCursor(10, 1);
  87.    lcd.print(">>>>>>");
  88.    }
  89.   
  90.   
  91.    void counterclockwise()
  92.    {
  93.    // anti-clockwise
  94.    dim=-stepsPerRevolution;
  95.    lcd.setCursor(10, 1);
  96.    lcd.print("<<<<<<");
  97.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement