Information about the 28BYJ-48 stepper motor and ULN2003 driver board. The 28BYJ-48 is one of the cheapest stepper motors you can find.Although it is not super accurate or powerful, it is a great motor to use for smaller projects or if you just want to learn about stepper motors. We will connect the stepper motor to the ULN driver, which we'll connect to Croduino. License code free. The picture shows the parts of the ULN2003 module. For more info, check out the datasheet. Stepper motor, ULN2003 breakout boar and Croduino we will connect as shown below. Techincally the ULN2003 is a not a stepper driver, it is a generic high current driver that can be used to drive lots of things. If you search for stepper drover chips, the ULN2003 is unlikely to be a result. The stepper motor drivers offer feature that are not included on the ULN2003. Motor Driver ULN2003 BreakOut Connected To Arduino From IN1 - IN4 To D8 - D11 Respectively To Power you Motor, Recommanded to use external Power Supply with 5V-500mA at least, Don't power it directly from arduino Board 5V. ULN2003A can also be used to drive different motors (e.g. DC Motors or Stepper Motors) with Microcontrollers (like Arduino, PIC Microcontroller or 8051 Microcontroller etc.). Some of the other applications of ULN2003 include logic buffers, lamp drivers, line drivers, LED display, motor driver circuits etc. Introduction to ULN2003.
The simplest way of interfacing a unipolar stepper to Arduino is to use a breakout for ULN2003A transistor array chip. The ULN2003A contains seven darlington transistor drivers and is somewhat like having seven TIP120 transistors all in one package. The ULN2003A can pass up to 500 mA per channel and has an internal voltage drop of about 1V when on.
The header file: __________________________________________________________________ #ifndef Stepper_h #define Stepper_h class StepperMotor { public: StepperMotor(int In1, int In2, int In3, int In4); // Constructor that will set the inputs void setStepDuration(int duration); // Function used to set the step duration in ms void step(int noOfSteps); // Step a certain number of steps. + for one way and - for the other int duration; // Step duration in ms int inputPins[4]; // The input pin numbers }; #endif ___________________________________________________________________ The cpp file: ___________________________________________________________________ #include <Arduino.h> #include <StepperMotor.h> StepperMotor::StepperMotor(int In1, int In2, int In3, int In4){ ![]() // Record pin numbers in the inputPins array this->inputPins[0] = In1; this->inputPins[1] = In2; this->inputPins[2] = In3; this->inputPins[3] = In4; // Iterate through the inputPins array, setting each one to output mode for(int inputCount = 0; inputCount < 4; inputCount++){ pinMode(this->inputPins[inputCount], OUTPUT); } duration = 50; } void StepperMotor::setStepDuration(int duration){ this->duration = duration; } void StepperMotor::step(int noOfSteps){ /* The following 2D array represents the sequence that must be used to acheive rotation. The rows correspond to each step, and the columns correspond to each input. L */ bool sequence[][4] = {{LOW, LOW, LOW, HIGH }, {LOW, LOW, HIGH, HIGH}, {LOW, LOW, HIGH, LOW }, {LOW, HIGH, HIGH, LOW}, {LOW, HIGH, LOW, LOW }, {HIGH, HIGH, LOW, LOW}, {HIGH, LOW, LOW, LOW }, {HIGH, LOW, LOW, HIGH}}; int factor = abs(noOfSteps) / noOfSteps; // If noOfSteps is +, factor = 1. If noOfSteps is -, factor = -1 noOfSteps = abs(noOfSteps); // If noOfSteps was in fact negative, make positive for future operations /* The following algorithm runs through the sequence the specified number of times */ for(int sequenceNum = 0; sequenceNum <= noOfSteps/8; sequenceNum++){ for(int position = 0; ( position < 8 ) && ( position < ( noOfSteps - sequenceNum*8 )); position++){ delay(duration); for(int inputCount = 0; inputCount < 4; inputCount++){ digitalWrite(this->inputPins[inputCount], sequence[(int)(3.5 - (3.5*factor) + (factor*position))][inputCount]); } } } Uln2003 Stepper Motor Driver Arduino}_______________________________________________________________________ An implementation: _______________________________________________________________________ #include <StepperMotor.h> StepperMotor motor(8,9,10,11); void setup(){ Serial.begin(9600); motor.setStepDuration(1); } void loop(){ motor.step(1000); Uln2003 Arduinodelay(2000); motor.step(-1000); Uln2003 Motor Driver Arduinodelay(2000);Arduino Driver Stepper Uln2003}Uln2003 Arduino TutorialUln2003 Stepper Motor Driver Arduino Code_________________________________________________________________________Wiring diagram: Uln2003 Dc Motor Driver ArduinoComments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |