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 9 (Oct. 24, 2018): Presentation #2 (Primary & Alternative Design Concepts) Reflection & Eliminating GPS as a Possibility

Earlier this week, to prepare for our presentation on October 24, I looked into different GPS modules. Unfortunately, I concluded that it was not possible to implement one. Recently, I learned in my ME 190 class (Mechatronics System Design) that GPS is not very accurate, as it does not have a fine resolution. Within a 10-meter radius, the satellite cannot distinguish whether the object is at the 1-meter mark or if it’s at the 9-meter mark; in other words, the object that the GPS is attached to will just be a big dot on the map. To illustrate my point, a map is shown below. The top image depicts the position of the GPS user represented by a large dot. That dot covers 10-meters, as the bottom image shows smallest measurement that that can be achieved by zooming in is 10-meters. After travelling nine-meters in one direction, the GPS has not updated the location of the dot. Additionally, the object would have to be travelling faster than 1 m/s; we aimed to have the podcar travel at around