Using the MSP430 LaunchpPad and Energia to control a stepper motor.
For this project a former Arduino’s project was used.
First thing was to make the stepper and driving board as a single assembly, this make it easier to experiment with it in the future.
Some wiring to connect the Launchpad (3.6 Volts) was done.
The stepper motor can be powered from the USB Voltage (5 volts at TP1) or
an external power supply. In this case I used both for testing purposes, the USB power and a Power adapter.
The connections are shown as an image to make it easier for all.
And now the code:
/*------------------------------------------------------ StepperPot_11 Arduining.com 13 APRIL 2013 A stepper motor follows a potentiometer on analog input 5. A software low-pass filter is used to reduce the noise in the analog reading. After 3 seconds of inactivity the motor coils are turned OFF to save energy. The RED_LED is used to signal when the stepper is powered. Hardware: LaunchPad with MSP430G2553. Driver: ULN2003A Stepper Motor: 28BYJ48, 5VDC, step pangle 5.625 ° Gear reduction 64:1 No-load starting frequency:> = 500PPS (4 rpm) Coil resistance 60 Ohms. -----------------------------------------------------*/ #include <Stepper.h> // change this to the number of steps on your motor #define STEPSREV 4096 // 64(fullsteps) * 64 (reduction ratio) #define COIL1 14 #define COIL2 12 #define COIL3 13 #define COIL4 11 #define POT A5 #define ENER RED_LED #define TIMEOUT 3000 //Turns off after 3 secs of inactivity. // create an instance of the stepper class, specifying // the number of steps per revolution and pins atached to motor coils. Stepper myStepper(STEPSREV, COIL1, COIL2, COIL3, COIL4); int PotVal; int LastPotVal= 0 ; // To implement a software Low-Pass-Filter int pos = 0; // stepper position(0-4096)->(0-360°) unsigned long stamp = 0; // last move time stamped. void setup() { myStepper.setSpeed(4); // set the motor speed to 4 RPM pinMode(ENER, OUTPUT); // status led (coils energized). // Serial.begin(9600); //for debuging. } void loop(){ PotVal = analogRead(POT); // Potentiometer value range 0-1023 PotVal= map(PotVal,0,1023,0,2047); // Map pot range in the stepper range. PotVal= PotVal * 0.1 + LastPotVal * 0.9 ; // Filtering to reduce noise. LastPotVal= PotVal; // Serial.print(Val); // For debuging. // Serial.print(" "); // " // Serial.println(pos); // " // delay(500); // " if(abs(PotVal - pos)> 4){ //if diference is greater than 4 steps. if((PotVal - pos)> 0){ digitalWrite(ENER, HIGH); //Motor energized. myStepper.step(1); // move one step to the right. pos++; } if((PotVal - pos)< 0){ digitalWrite(ENER, HIGH); //Motor energized. myStepper.step(-1); // move one step to the left. pos--; } stamp = millis(); // stamp actual time. } else { if((millis() - stamp) > TIMEOUT){ //Turn Off coils after TIMEOUT. digitalWrite(COIL1, LOW); digitalWrite(COIL2, LOW); digitalWrite(COIL3, LOW); digitalWrite(COIL4, LOW); digitalWrite(ENER, LOW); //Motor de-energized. } } }
See in YouTube this experiment:
Thanks for posting this, it is good to find a project with such detail and clarity. I have not yet been able to make it run yet. I am pretty sure that I am doing everything correctly. I have selected the correct board in Energia but no luck yet. Any suggestions? Thanks again for a good project.
than you for posting this , it is very useful for me. but can you please provide me the schematic for unl2003. and i have to use CCS for programming so can you suggest any thing cos i am totally new to embedded systems
.
Dear Friends. Thank for shring.
Is it possible to creare such project but with reaction stepper motor like servo?
What parts are needed?
Thank you!
How do I, tiva c series mux 74HC595 60 out relay.
U have the same code using arduino ? Ty dude
That is really good!
I would like to do too this project. Can you send me the CCS project file?
Thank you very much!
Sorry, Energia (Arduino-like environment) was used instead of CCS.
Thank you for your answer! It was too big support for me.
How would i do this with an arduino uno?
I need this kit ….where it will available can u provide me the address..
motor is rotating only in one direction after rotating potentiometer.
Hallo, what I have to change in this code to use it with arduino uno ?
Hallo, What I have to change in this code to use it with Arduino ? Thank You very much in advance !!
Dear sir.
assume you set a point and lost the power. after that when power On what happens to the set point.
OK. find it.
Set to zero.
int pos = 0; // stepper position(0-4096)->(0-360°)
Thanks.