Skip to main content

Week 28 (Apr. 24, 2019): Final motor selection – Mini-Stepper Motor


Since last week, we have been trying to run the new brushless DC motor; however, it is still difficult to control, let alone its speed.

Therefore, we had to pursue our alternative motor, the mini-stepper motor that runs at 5V. Found in Arduino starter kits, this mini-stepper motor is accompanied by its dedicated motor driver board, the ULN2003, which is a chip containing a series of Darlington pair transistors. An image of the stepper motor and the ULN2003 board is shown below:


 Sources:

We were able to successfully run the new mini-stepper motor with the sample code included with the Arduino starter kit. One benefit to using the sample code is that it utilizes the Stepper library’s functions. One use function is the setSpeed( ) function, which allows the user to set the RPM speed of the stepper motor. We found that the maximum speed the motor could go without twitching, or vibrating erratically, was 30 RPM. It then calls the step( ) function to actually drive the motor.

A screenshot of the sample code is displayed below: 



The drawback to the sample code is that the step( ) function drives the stepper in regular wave drive mode, which involves energizing one coil at a time. This is the basic way of driving a stepper motor, and it does not present any advantages: it does not entail stepping the motor with hi-torque nor does it step the motor in half-steps nor micro-steps for finer movement. Running a stepper with hi-torque involves energizing 2 adjacent coils at a time. Running a stepper motor in half-steps involves alternating between energizing 1 coil, then 2 coils, etc. And running a stepper motor in micro-steps involves energizing one coil with a decreasing pulse-width-modulated (PWM) signal and energizing the next coil with an increasing PWM signal.

We ultimately decided to run the motor with hi-torque, as we did not need the motor to move in finer steps, but rather we wanted the motor to be able to overcome bumps in the track.

Our code is provided below:


/**********************************************************************   SUCCESS
 *
 * ME 106 Lab 8 Question 8 (Hi Torque / Full Step Drive)
 *
 **********************************************************************/
/* 
 *  This is Lab 8: Stepper Motor, Exercise 4, Question 8:
 *  High-Torque Mode
 *  Using the coil sequence from Exercise 1, the program will:
 * 
 *  Contain a function called steps_hitorque() that implements
 *  high-torque mode, which works on the principle of energizing
 *  two coils at the same time (Figure 5) instead of one. Once
 *  again, a negative value indicates that the motor should be
 *  driven in the opposite direction (CCW direction).
 */


/* (I) Include libraries */



/* (II) Variables */
// define the connections to motor driver inputs
#define IN_1 10
#define IN_2 11
#define IN_3 12
#define IN_4 13

int CW_coilA [4] = {IN_4, IN_3, IN_2, IN_1};
int CW_coilB [4] = {IN_3, IN_2, IN_1, IN_4};

int CCW_coilB [4] = {IN_1, IN_2, IN_3, IN_4};
int CCW_coilA [4] = {IN_4, IN_1, IN_2, IN_3};

/* Delay of 6000 microseconds = 0.006 sec */
const int minDelay = 1600;


/* (III) Function Prototypes */
void steps_hitorque(int mySteps);


/* (IV) setup */
void setup()
{
  // setup the pins to motor driver as outputs
  pinMode(IN_1, OUTPUT);
  pinMode(IN_2, OUTPUT);
  pinMode(IN_3, OUTPUT);
  pinMode(IN_4, OUTPUT);
}


/* (V) loop */
void loop()
{
  /* Call the steps_hitorque function once. Rotate 2048 steps (1 revolution) CW. */
//  steps_hitorque(2048);
  /* Call the steps_hitorque function once. Rotate 2048 steps (1 revolution) CCW. */
  steps_hitorque(-2048);
}


/* (VI) Function Definitions */
void steps_hitorque(int stepsToMake)
{
  /* Current step number (used as a counter) */
  int mySteps = 0;

  /* If user inputted a pos number, turn the stepper CW */
  // int CW_coilA [4] = {IN_1, IN_2, IN_2, IN_1};
  // int CW_coilB [4] = {IN_3, IN_3, IN_4, IN_4};
  if(stepsToMake > 0)
  {
    while(mySteps <= stepsToMake)
    {
      for(int i = 0; i < 4; i++)
      {
        digitalWrite(CW_coilA[i], HIGH);
        digitalWrite(CW_coilB[i], HIGH);
        delayMicroseconds(minDelay);
        digitalWrite(CW_coilA[i], LOW);
        digitalWrite(CW_coilB[i], LOW);
        mySteps++;
      }
    }
  }

  /* If user inputted a neg number, turn the stepper CCW */
  // int CCW_coilA [4] = {IN_1, IN_2, IN_2, IN_1};
  // int CCW_coilB [4] = {IN_4, IN_4, IN_3, IN_3};
  if(stepsToMake < 0)
  {
    while(mySteps >= stepsToMake)
    {
      for(int j = 0; j < 4; j++)
      {
        digitalWrite(CCW_coilB[j], HIGH);
        digitalWrite(CCW_coilA[j], HIGH);
        delayMicroseconds(minDelay);
        digitalWrite(CCW_coilA[j], LOW);
        digitalWrite(CCW_coilB[j], LOW);
        mySteps--;
      } 
    }
  }
 
}

Comments

Popular posts from this blog

Week 30 (May 8, 2019): Prototype Evaluation Day, Final Circuit, Incorporating 3D printed parts, Final Presentation, Posters, & Maker Faire

Today, we held Prototype Evaluation Day. Like the rest of the senior project classes, the advisor walks around the classroom, evaluating the senior project apparatuses, asking the student teams to demonstrate their devices, and explain their design, though processes, and results. Dr. Furman and Ron examined and inspected the Full-Scale model, then the Half-Scale model, and lastly, us, the Small-Scale Team. We had completed our circuit to power one pod car and one of the two induction charging stations prior to Evaluation Day, so we were able to successfully demonstrate the pod car driving around the track as well as the induction charging. While we were still troubleshooting issues with the tablet’s Raspberry Pi communicating with the Arduino, the Arduino is still capable of operating on its own, so we could at least demonstrate the motor driving the pod car around the track and through the offline stations. Depicted below is our final circuit that powers the pod car: Dep...

Week 27 (Apr. 17, 2019): ME 195B - Presentation #2 (Prototyping Stage Continuation) Reflection

Today, we completed Presentation 2, which is our 5 th  presentation overall, throughout the entire length of senior project, since last semester. Please refer to our Presentation #2 slides, embedded below. Covering the continuation of our prototyping efforts, we discussed progress on hardware acquisition, integration of components into a working circuit, and programming. Regarding programming, we were still working on the communication between the Raspberry Pi and the Arduino. And while the circuit is also coming together, there was one piece that gave us problems yesterday: the gimbal motor broke and so we had to order another motor that is not a gimbal but is still a brushless DC motor. An image of the new motor is found in our presentation slides below. While this was disheartening at first, we found that the gimbal is not intended for continuous rotation, but instead for precise movement, as they are used for cameras on drones. However, this was still a setback...