5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0035)

Various stepper / DC motors and servo's
Post Reply
admin
Site Admin
Posts: 726
Joined: Sun Aug 05, 2012 4:02 pm

Re: 5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0

Post by admin » Wed Feb 06, 2013 12:33 am

Image

Image

4 phase DC stepper motor with included driver interface board. Stepper motor has 1:64 ratio gear box. Can be driven in both forward and reverse directions. Works with standard Arduino stepper motor library.

Please note: The +/- power connector is marked with a 5-12V input. This is because the same driver board can be used with the 12V version of the stepper motor. You should not apply more than 5V to the supply input as you will damage the stepper motor.


Motor Features:

Diameter: 28mm
Voltage: 5V
Step angle: 5.625 x 1/64
Reduction ratio: 1/64


ULN2003 Driver Board:

A, B, C, D LED indication for four-phase stepper motor status
Size: 31x35mm


PINOUT:

MCU interface
IN1.....Input drive to motor coil A (HIGH/5V = Coil energised)
IN2.....Input drive to motor coil B (HIGH/5V = Coil energised)
IN3.....Input drive to motor coil C (HIGH/5V = Coil energised)
IN4.....Input drive to motor coil D (HIGH/5V = Coil energised)
IN5.....N/A
IN6.....N/A
IN7.....N/A

Power
1 (-)......0V/GND
2 (+).....5V
3...........Connect to 4 with jumper
4...........Connect to 3 with jumper

Motor
1..........Coil A
2..........Coil B
3..........Coil C
4..........Coil D
5..........5V power (via Power connector pin 4)



Image

Code: Select all

/* FILE:    ARD_Stepper_Motor_HCARDU0035_Example.pde
   DATE:    02/09/12
   VERSION: 0.1

This is an example of how to use the HobbyComponents Arduino compatable stepper
motor with driver interface (HCARDU0035) . When run this program will
continually
rotate the motor one full revolution the the forward direction
followed by one full
revolution in the reverse direction. Although this stepper motow will
work with the
standard Arduino stepper motor library functions, this priogram
demonstates how easy
it is to directly control.

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute
this code.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO
WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK
OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
DAMAGES FOR ANY
REASON WHATSOEVER.

*/




/* Defines the vales passed to the function vStepMotor()
   to specify which direction you would like the motor to
   turn in. */

#define FORWARD true
#define REVERSE false

/* Defines the digital IO pins used to control each of
   the stepper motors coils. */

#define MOTOR_COIL_1_DIO 8
#define MOTOR_COIL_2_DIO 9
#define MOTOR_COIL_3_DIO 10
#define MOTOR_COIL_4_DIO 11

/* The number of steps for 1 revolution of this stepper
   motor is 360 degrees devided by the motor step angle
   of 5.625 multiplied by the gear ratio 1/64 multiplied
   by the number of coils 4 devided by two.
   Therefore: 360 / (5.625 * (1 / 64)) = 512 */

#define STEPSPER1REV 512


/* Set the 4 DIO pins used to drive the stepper motor to outputs */
void setup()
{
  pinMode(MOTOR_COIL_1_DIO, OUTPUT);
  pinMode(MOTOR_COIL_2_DIO, OUTPUT);
  pinMode(MOTOR_COIL_3_DIO, OUTPUT);
  pinMode(MOTOR_COIL_4_DIO, OUTPUT);
}

/* MAIN PROGRAM */
void loop()
{
  /* Used for counting the number of steps the motor has made */
  word u16StepCounter;

  /* Rotate the stepper motor one full forward revolution */
  for (u16StepCounter = 0; u16StepCounter < STEPSPER1REV; u16StepCounter++)
  {
    vStepMotor(FORWARD, 3);
  }

  /* Rotate the stepper motor one full reverse revolution */
  for (u16StepCounter = 0; u16StepCounter < STEPSPER1REV; u16StepCounter++)
  {
    vStepMotor(REVERSE, 3);
  }
}

/* Function will pulse all four coils of the sterrper motor in either
the forward
   or reverse directions. The function accepts to inputs, a true or a
false denoting
   the direction the motor should turn in (true = forward, false =
reverse), and a setp
   delay time in milliseconds between each step. */

void vStepMotor(boolean bDirection, word u16StepDelay)
{
  /* Holds which DIO pin is currently asciated with which motor coil */
  byte bMotorCoil_1;
  byte bMotorCoil_2;
  byte bMotorCoil_3;
  byte bMotorCoil_4;

  /* Set the order of the DIO pins depending on the direction the
     motor is requires to turn in. */
  if (bDirection == true)
  {
    bMotorCoil_1 = MOTOR_COIL_1_DIO;
    bMotorCoil_2 = MOTOR_COIL_2_DIO;
    bMotorCoil_3 = MOTOR_COIL_3_DIO;
    bMotorCoil_4 = MOTOR_COIL_4_DIO;
  }else
  {
    bMotorCoil_1 = MOTOR_COIL_4_DIO;
    bMotorCoil_2 = MOTOR_COIL_3_DIO;
    bMotorCoil_3 = MOTOR_COIL_2_DIO;
    bMotorCoil_4 = MOTOR_COIL_1_DIO;
  }


  /* Pulse each of the stepper motors coils in a sequencial order */
  digitalWrite(bMotorCoil_1, HIGH);
  digitalWrite(bMotorCoil_2, LOW);
  digitalWrite(bMotorCoil_3, LOW);
  digitalWrite(bMotorCoil_4, LOW);

  delay(u16StepDelay);

  digitalWrite(bMotorCoil_1, LOW);
  digitalWrite(bMotorCoil_2, HIGH);
  digitalWrite(bMotorCoil_3, LOW);
  digitalWrite(bMotorCoil_4, LOW);

  delay(u16StepDelay);

  digitalWrite(bMotorCoil_1, LOW);
  digitalWrite(bMotorCoil_2, LOW);
  digitalWrite(bMotorCoil_3, HIGH);
  digitalWrite(bMotorCoil_4, LOW);

  delay(u16StepDelay);

  digitalWrite(bMotorCoil_1, LOW);
  digitalWrite(bMotorCoil_2, LOW);
  digitalWrite(bMotorCoil_3, LOW);
  digitalWrite(bMotorCoil_4, HIGH);

  delay(u16StepDelay);

  digitalWrite(bMotorCoil_1, LOW);
  digitalWrite(bMotorCoil_2, LOW);
  digitalWrite(bMotorCoil_3, LOW);
  digitalWrite(bMotorCoil_4, LOW);
}

Gareth

5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0035)

Post by Gareth » Wed Feb 20, 2013 8:49 pm

Just a quick note in case anyone else has this issue. Using the standard Arduino Stepper library 'as is' will only result in the stepper motor driving in one direction.

See here for solution:

http://arduino.cc/forum/index.php?PHPSE ... msg1097797

Essentially have to reorder pins to 8,10,9,11 in code

Speeds/rpm are also not compatible so try 2048 for step to complete 1 revolution and 5 where it says 60rpm to make it go at 1rpm approx

Hope this helps others :)

admin
Site Admin
Posts: 726
Joined: Sun Aug 05, 2012 4:02 pm

Re: 5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0

Post by admin » Thu Jun 06, 2013 8:39 pm

Hi,

Thanks for the information. In our experiments we found it better not to even bother with the library and just pulse the pins directly. Here is an example of how to do this:

Code: Select all

/* FILE:    ARD_Stepper_Motor_HCARDU0035_Example.pde
   DATE:    02/09/12
   VERSION: 0.1

This is an example of how to use the HobbyComponents Arduino compatable stepper
motor with driver interface (HCARDU0035) . When run this program will
continually
rotate the motor one full revolution the the forward direction
followed by one full
revolution in the reverse direction. Although this stepper motow will
work with the
standard Arduino stepper motor library functions, this priogram
demonstates how easy
it is to directly control.

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute
this code.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO
WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK
OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
DAMAGES FOR ANY
REASON WHATSOEVER.

*/




/* Defines the vales passed to the function vStepMotor()
   to specify which direction you would like the motor to
   turn in. */

#define FORWARD true
#define REVERSE false

/* Defines the digital IO pins used to control each of
   the stepper motors coils. */

#define MOTOR_COIL_1_DIO 8
#define MOTOR_COIL_2_DIO 9
#define MOTOR_COIL_3_DIO 10
#define MOTOR_COIL_4_DIO 11

/* The number of steps for 1 revolution of this stepper
   motor is 360 degrees devided by the motor step angle
   of 5.625 multiplied by the gear ratio 1/64 multiplied
   by the number of coils 4 devided by two.
   Therefore: 360 / (5.625 * (1 / 64)) = 512 */

#define STEPSPER1REV 512


/* Set the 4 DIO pins used to drive the stepper motor to outputs */
void setup()
{
  pinMode(MOTOR_COIL_1_DIO, OUTPUT);
  pinMode(MOTOR_COIL_2_DIO, OUTPUT);
  pinMode(MOTOR_COIL_3_DIO, OUTPUT);
  pinMode(MOTOR_COIL_4_DIO, OUTPUT);
}

/* MAIN PROGRAM */
void loop()
{
  /* Used for counting the number of steps the motor has made */
  word u16StepCounter;

  /* Rotate the stepper motor one full forward revolution */
  for (u16StepCounter = 0; u16StepCounter < STEPSPER1REV; u16StepCounter++)
  {
    vStepMotor(FORWARD, 3);
  }

  /* Rotate the stepper motor one full reverse revolution */
  for (u16StepCounter = 0; u16StepCounter < STEPSPER1REV; u16StepCounter++)
  {
    vStepMotor(REVERSE, 3);
  }
}

/* Function will pulse all four coils of the sterrper motor in either
the forward
   or reverse directions. The function accepts to inputs, a true or a
false denoting
   the direction the motor should turn in (true = forward, false =
reverse), and a setp
   delay time in milliseconds between each step. */

void vStepMotor(boolean bDirection, word u16StepDelay)
{
  /* Holds which DIO pin is currently asciated with which motor coil */
  byte bMotorCoil_1;
  byte bMotorCoil_2;
  byte bMotorCoil_3;
  byte bMotorCoil_4;

  /* Set the order of the DIO pins depending on the direction the
     motor is requires to turn in. */
  if (bDirection == true)
  {
    bMotorCoil_1 = MOTOR_COIL_1_DIO;
    bMotorCoil_2 = MOTOR_COIL_2_DIO;
    bMotorCoil_3 = MOTOR_COIL_3_DIO;
    bMotorCoil_4 = MOTOR_COIL_4_DIO;
  }else
  {
    bMotorCoil_1 = MOTOR_COIL_4_DIO;
    bMotorCoil_2 = MOTOR_COIL_3_DIO;
    bMotorCoil_3 = MOTOR_COIL_2_DIO;
    bMotorCoil_4 = MOTOR_COIL_1_DIO;
  }


  /* Pulse each of the stepper motors coils in a sequencial order */
  digitalWrite(bMotorCoil_1, HIGH);
  digitalWrite(bMotorCoil_2, LOW);
  digitalWrite(bMotorCoil_3, LOW);
  digitalWrite(bMotorCoil_4, LOW);

  delay(u16StepDelay);

  digitalWrite(bMotorCoil_1, LOW);
  digitalWrite(bMotorCoil_2, HIGH);
  digitalWrite(bMotorCoil_3, LOW);
  digitalWrite(bMotorCoil_4, LOW);

  delay(u16StepDelay);

  digitalWrite(bMotorCoil_1, LOW);
  digitalWrite(bMotorCoil_2, LOW);
  digitalWrite(bMotorCoil_3, HIGH);
  digitalWrite(bMotorCoil_4, LOW);

  delay(u16StepDelay);

  digitalWrite(bMotorCoil_1, LOW);
  digitalWrite(bMotorCoil_2, LOW);
  digitalWrite(bMotorCoil_3, LOW);
  digitalWrite(bMotorCoil_4, HIGH);

  delay(u16StepDelay);

  digitalWrite(bMotorCoil_1, LOW);
  digitalWrite(bMotorCoil_2, LOW);
  digitalWrite(bMotorCoil_3, LOW);
  digitalWrite(bMotorCoil_4, LOW);
}

pauldreed
Posts: 2
Joined: Sun Dec 01, 2013 4:46 pm

Re: 5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0

Post by pauldreed » Sun Dec 01, 2013 5:05 pm

I've never used a stepper motor before, so pls bear with me...
The formula to drive the motor through one revolution is 360 / (5.625 * (1 / 64)) = 512
... so if I wanted it to complete say 3 full revolutions, is it simply a case of amending the calculation to; 1080 / (5.625 * (1 / 64)) = 1536

Also, as anyone any idea of how powerful the motor is? I realize it's only small, but could this potentially drive a small pulley and lift a weight of 250 gms?

My project is building a device to lift a sliding cat flap at dawn and close it again at dusk (not very exciting, I know!)

Paul

andrew
Site Admin
Posts: 804
Joined: Sun Aug 05, 2012 4:15 pm

Re: 5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0

Post by andrew » Mon Dec 02, 2013 12:14 pm

o if I wanted it to complete say 3 full revolutions, is it simply a case of amending the calculation to; 1080 / (5.625 * (1 / 64)) = 1536
Yes thats correct
Also, as anyone any idea of how powerful the motor is? I realize it's only small, but could this potentially drive a small pulley and lift a weight of 250 gms?
The manufacturer rates it at 300 gf.cm. This is something we haven't tested ourselves but depending on your mechanism (i.e pulley leaver etc) for lifting the weight it may be just capable of doing it. It depends on how far away the weight is from the center of rotation and if there is any counter balance.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Rich
Posts: 2
Joined: Sat Jan 25, 2014 12:34 am

Re: 5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0

Post by Rich » Sat Jan 25, 2014 12:43 am

thanks for the code, can someone please advise how the circuit would look if I wanted to control the motor with a button?

I'm guessing rough code would be:

Code: Select all

buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) { 
//turn motor on 
//(add code here)
}

pauldreed
Posts: 2
Joined: Sun Dec 01, 2013 4:46 pm

Re: 5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0

Post by pauldreed » Sat Jan 25, 2014 8:46 pm

I would use;

int buttonpin = 2; //wire a switch from pin 2 to ground to energise motor
void setup() {
pinMode(buttonpin, INPUT_PULLUP);
}
void loop() {
while (digitalRead(buttonpin) == LOW) {
//run the motor
}
}


Paul

Rich
Posts: 2
Joined: Sat Jan 25, 2014 12:34 am

Re: 5v 4-phase DC gear Stepper Motor + Driver Board (HCARDU0

Post by Rich » Sun Feb 16, 2014 11:45 am

EDIT: I managed to find a wide variety of Stepper Motor Couplers on ebay, I opted for 5x8mm as this was the closest match I could find.


thanks for that.

Final question, does anyone know where I can get some kind of couplings for this so I can connect the shaft to other things? I'm very new to hardware and I basically want to be able to convert this manual handle to be driven by the motor.

Image

thanks

Post Reply