trying to get my motors to work

Im working on a project for wings i bought 2 17hd48002h,a arduino uno board with a motor shield already someone told me to try this but its for a cnc shield

#define EN 8

#define X_DIR 5

#define Y_DIR 6

#define Z_DIR 7

#define X_STP 2

#define Y_STP 3

#define Z_STP 4

void step(boolean dir, byte dirPin, byte stepperPin, int steps)

{

digitalWrite(dirPin, dir);

delay(50);

for (int i = 0; i < steps; i++) {

digitalWrite(stepperPin, HIGH);

delayMicroseconds(20);

digitalWrite(stepperPin, LOW);

delayMicroseconds(800);

}

}

void setup(){

pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);

pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);

pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);

pinMode(EN, OUTPUT);

digitalWrite(EN, LOW);

}

void loop(){

step(false, X_DIR, X_STP, 200);

step(false, Y_DIR, Y_STP, 200);

step(true, Z_DIR, Z_STP, 200);

delay(1000);

}

so it would not work for my motor shield all i need is for one motor to spin clockwise and the other to spin counter clockwise thanks for the help in advance :slight_smile: :slight_smile: :slight_smile:

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum. Also use the AutoFormat feature to indent your code properly. All of that will make it much easier to help you.

Post a link to the datasheet for your stepper motors.
What stepper motor drivers are you using?
What power supply have you got for the motors (volts and amps)?

...R
Stepper Motor Basics
Simple Stepper Code

Robin2:
Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum. Also use the AutoFormat feature to indent your code properly. All of that will make it much easier to help you.

Post a link to the datasheet for your stepper motors.
What stepper motor drivers are you using?
What power supply have you got for the motors (volts and amps)?

...R
Stepper Motor Basics
Simple Stepper Code

i hope this is what your looking for as far as drivers i have a Motor Drive Shield L293D and then for power i had bought the adruino for beginners kit and it came with a 6 aa power pack not sure if that would work with it

I'm not sure exactly which motor on that sheet is yours. There is one labeled STP-MTR-17048(D) which has a rated current of 2 amps and a resistance of 1.4 ohms

An L293D is not suitable for that motor. It needs a specialized stepper motor driver. However the common hobby driver Pololu DRV8825 will not be able to supply 2 amps so you probably need a more expensive driver that can handle maybe 3 or 4 amps to give some spare capacity. I think there are some driver boards using TB6560 chips that may be suitable. Otherwise you are looking at much more expensive drivers.

Batteries are quite unsuitable for a high current stepper motor. Stepper motors are very inefficient and need a mains power supply. You should also be powering the motor with 12v or 24v.

...R

Post a link to product page or datasheet to each piece of hardware you mention so we know what
you are actually talking about exactly. In particular motors usually come with a variety of winding
options and the main part number doesn't tell you that.

I suspect you have low impedance steppers which require current drive, not voltage drive (most
modern steppers are like this and not compatible with any DC motor shield which are only voltage
drive).

Upto about 1.5A you can use a DRV8825 stepper driver module, plentiful, available and cheap.

6 AA cells? No, you need something like 12, 18 or 24V supply of about 15W output rating.
For battery power think bulky 12V SLA, not AA cells. Higher supply voltage will permit faster
running of the motors.

https://cdn-learn.adafruit.com/assets/assets/000/001/854/medium800/adafruit_products_DC_Motor_Ports.gif?1447864310 this is the motor sheild i have

with two of these motors http://www.zyltech.com/uploads/1/0/1/0/101081916/s136714152818872222_p129_i1_w1600.jpeg

with this https://cdn-reichelt.de/bilder/web/xxl_ws/B300/ARDUINO_UNO_A06.png

ok so i got both of them to spin but not sure how to get them to run constant there just spinning once and thats it what i want is to be able to have one spin clockwise the other spin counter clockwise and be able to adjust the speed and how many steps

#include <AccelStepper.h>
#include <AFMotor.h>
AF_Stepper motor1(200, 2);
AF_Stepper motor2(200, 1);
void forwardstep1() { 
  motor1.onestep(FORWARD, SINGLE);
}
void backwardstep1() { 
  motor1.onestep(BACKWARD, SINGLE);
}
void forwardstep2() { 
  motor2.onestep(FORWARD, SINGLE);
}
void backwardstep2() { 
  motor2.onestep(BACKWARD, SINGLE);
}
AccelStepper stepper1(forwardstep1, backwardstep1);
AccelStepper stepper2(backwardstep2, forwardstep2);
void setup()
{
  Serial.begin(9600);
 
  int revs1, revs2, RPM1, RPM2;
//input revoultions(for motor1 and motor2) and RPMs below:
//for negative rotation enter a negative revolution
  revs1 = -10;
  revs2 = 10;
  RPM1 = 100;
  RPM2 = 100;
 
  stepper1.setMaxSpeed(1000);
  stepper2.setMaxSpeed(1000);
  stepper1.moveTo((revs1*200)-3);
  stepper1.setSpeed(RPM1 * 3.75);
  stepper2.moveTo((revs2*200)+3);
  stepper2.setSpeed(RPM2 * 3.75);
}
void loop()
{
  if ((stepper1.distanceToGo()) != 0)
  {
    stepper1.runSpeedToPosition();
  } 
  else{
    motor1.release();
  }
  if ((stepper2.distanceToGo()) != 0)
  {
    stepper2.runSpeedToPosition();
  } 
  else{
    motor2.release();
  }
}

Two of these are what you need: https://www.pololu.com/product/2133

Let me repeat loudly:

The Adafruit motor driver is +COMPLETELY UNSUITABLE+ for those motors and will overheat, burnout, overheat
the motors, fail suddenly, maybe all of the above.

DRV8825 stepper drivers should be appropriately configured for the motor current (note they will need
good cooling at those high currents - perhaps run them a little lower than 1.7A)

AccelStepper with DRIVER mode is the way to talk to DRV8825s

Note that the supply voltage for the DRV8825 can be 12V, 18V, 24V, more volts gives better top speeds.

Ok i will buy that is there anything else that i need its for wings that i want to make the wings widith is 18in and lenth is 25in not sure about the weight but im using cardboard and feathers but im trying to make the wings move no need for them to move really fast :confused: :confused: :confused: a

mikey111203:
Ok i will buy that is there anything else that i need its for wings that i want to make the wings widith is 18in and lenth is 25in not sure about the weight but im using cardboard and feathers but im trying to make the wings move no need for them to move really fast :confused: :confused: :confused: a

Post a diagram of the thing you are planning to make.

If you just want a flapping movement for wings I suspect a simple DC motor would be sufficient.

...R

Heres a picture of the wings i have in mind it will be smaller but similar and its for my 10 year old daughter
https://goo.gl/images/f2kTy3

I've completely forgotten what this Thread is about :slight_smile:

...R

You did not respond to my other comment in Reply #8. But maybe you were also distracted by your picture.

And can you post a diagram showing the mechanical part of the wings - what moves, and how the motor will be connected etc. In other words a lower temperature diagram :slight_smile:

...R

Yeah i just want the wings to flap but without the gear i will attach one wing to one motor and the other wing to the other motor reason being didnt want it to get to complicated this is my first project :slight_smile: :slight_smile:

mikey111203:
Yeah i just want the wings to flap but without the gear i will attach one wing to one motor and the other wing to the other motor reason being didnt want it to get to complicated this is my first project :slight_smile: :slight_smile:

A diagram, please.

To be honest, I suspect two motors will be more complicated than one motor.

...R

Project - YouTube hey i made a video i kinda rigged everything up this is what i had in mind i am a neeb this is my first project so if u think you know a better way shoot it to me

Thanks for the little video.

IMHO it would be very much easier to do what you want with a pair of servos. They are easier to work with mechanically, electrically and program-wise. Something like this

flappingWing.png

...R

He i looked for sevos but didnt find any the size i need that were in expensive if you where i can find the size i would need and that will work with the adafruit v1 and my uno board will be greatly appreciated thanks again in advance

What about a Hobby King standard servo for £2.76

If that sort of servo, or the next bigger size is not sufficient then you need to tell us how much torque you need.

...R

PS. I have no connection with Hobby King other than as a customer.