Stepper Motor Interfacing with MSP-EXP430G2 TI Launchpad

Overview of Stepper Motor

Stepper Motor
Stepper Motor

 

The Stepper motor is a brushless DC motor that divides the full rotation angle of 360° into a number of equal steps.

The motor is rotated by applying a certain sequence of control signals. The speed of rotation can be changed by changing the rate at which the control signals are applied.

For more information about Stepper Motor and how to use it, refer to the topic Stepper Motor in the sensors and modules section.

 

Connection Diagram of Stepper Motor with MSP-EXP430G2 TI Launchpad

Interfacing Stepper Motor With MSP-EXP430G2 TI Launchpad
Interfacing Stepper Motor With MSP-EXP430G2 TI Launchpad

 

Rotate Stepper Motor in clockwise and counter-clockwise directions alternately MSP-EXP430G2 TI Launchpad

Here, we are using a six-wire unipolar stepper motor. Only four wires are required to control this stepper motor. The two center-tap wires of the stepper motor are connected to 5V supply.

ULN2003 driver is used to driving the stepper motor.

Note: To find winding coils and their center tap leads, measure resistance in between the leads. From center leads we will get half the resistance value as compared to the resistance between winding ends.

 

Tread Carefully: MSP-EXP430G2 TI Launchpad board has a RAM of 512 bytes which is easily filled, especially while using different libraries. There are times when you need the Serial buffer to be large enough to contain the data you want and you will have to modify the buffer size for the Serial library. While doing such things, we must ensure that the code does not utilize more than 70% RAM. This could lead to the code working in an erratic manner, working well at times, and failing miserably at others. 

There are times when the RAM usage may exceed 70% and the codes will work absolutely fine, and times when the code will not work even when the RAM usage is 65%. 

In such cases, a bit of trial and error with the buffer size and/or variables may be necessary.

 

Stepper Motor Code for with MSP-EXP430G2 TI Launchpad

void setup() {
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(14, OUTPUT);
}

void loop() {
	/* Rotation in one direction */
  for(int i = 0; i<12; i++)
  {
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(14, LOW);
    delay(100);
    digitalWrite(11, HIGH);
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
    digitalWrite(14, LOW);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
    digitalWrite(14, LOW);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(13, HIGH);
    digitalWrite(14, LOW);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
    digitalWrite(14, LOW);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
    digitalWrite(14, HIGH);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(14, HIGH);
    delay(100);
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(14, HIGH);
    delay(100);
  }
  digitalWrite(11, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);
  digitalWrite(14, LOW);
  delay(100);
  
	/* Rotation in opposite direction */
  for(int j = 0; j<12; j++)
  {
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(14, HIGH);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
    digitalWrite(14, HIGH);
    delay(100);
    
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
    digitalWrite(14, LOW);
    delay(100);
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(13, HIGH);
    digitalWrite(14, LOW);
    delay(100);
    
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
    digitalWrite(14, LOW);
    delay(100);
    digitalWrite(11, HIGH);
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
    digitalWrite(14, LOW);
    delay(100);
    
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(14, LOW);
    delay(100);
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    digitalWrite(14, HIGH);
    delay(100);
  }
  digitalWrite(11, LOW);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);
  digitalWrite(14, HIGH);
  delay(100);
}

 

Video of Stepper Motor Control Using with MSP-EXP430G2 TI Launchpad


Components Used

TI Launchpad MSP-EXP430G2
TI Launchpad MSP-EXP430G2
1
ULN2003 Motor Driver
ULN2003A is a high-voltage, high-current Darlington transistor array.
1

Downloads

Stepper_Motor_Interfacing_With_TI_Launchpad_INO Download
Ad