bipolar stepper motor

Hello... I'm new here and I would really like your help!

I want to connect a bipolar stepper motor with 4 wires(step angle 7,5degrees and DC 24v) to Duemilanove arduino. What do I need to use? A h-bridge or a darlington array?

I would appreciate it if you could provide me with a simple but detailed diagram about how to connect those.

Please excuse me but I do not have significant knowledge about these... :-[

http://www.tigoe.net/pcomp/code/category/arduinowiring/51

first of all, thank u! It worked yesterday…

However, today although i have done the exact same circuit it don’t work…

there are these errors:

avrdude: stk500_paged_load(): (a) protocol error, expect=0x14, resp=0x1e
avrdude: stk500_cmd(): protocol error

After uploading the following code, it goes two steps forward and one step backward!!!

#include <Stepper.h>

#define motorSteps 48 // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 1
#define motorPin2 2
#define motorPin3 3
#define motorPin4 4
#define ledPin 13

// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);

void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(1);

// Initialize the Serial port:
Serial.begin(9600);

// set up the LED pin:
pinMode(ledPin, OUTPUT);
// blink the LED:
blink(3);
}

void loop() {
// Step forward 100 steps:
Serial.println(“Forward”);
myStepper.step(1);
delay(1250);

// Step backward 100 steps:
//Serial.println(“Backward”);
//myStepper.step(-100);
//delay(6500);

}

// Blink the reset LED:
void blink(int howManyTimes) {
int i;
for (i=0; i< howManyTimes; i++) {
digitalWrite(ledPin, HIGH);
delay(10);
digitalWrite(ledPin, LOW);
delay(10);
}
}

What is wrong??

However, today although i have done the exact same circuit it don't work...

there are these errors:

avrdude: stk500_paged_load(): (a) protocol error, expect=0x14, resp=0x1e avrdude: stk500_cmd(): protocol error

After uploading the following code, it goes two steps forward and one step backward!!!

So were you, or were you not, able to upload a new sketch?

However, today although i have done the exact same circuit it don't work...

Which circuit would that be?

#define motorPin1 1

Not really a good idea using pin 1. Pins 0 and 1 are the TX/RX pins, used in upload sketches, and serial communications.

  1. Actually, no. I wasn't able to upload a new sketch

  2. The circuit including L293. (I don't have any photos to attach at the moment)

  3. So I'll try it using 8-11 pins, although yesterday it worked just fine for the pins 1-4.

I'll post my news as soon as I try the thing you proposed ::)

(I don't have any photos to attach at the moment

It's not so much a photograph but a schematic that we need to see. Photographs are of limited use and at best only serve to show if you have made a mistake in realising a schematic.

although yesterday it worked just fine for the pins 1-4

It will do until you come to load another sketch. Then you have to disconnect pin 1 from your external circuit before you can upload.

My circuit is based on this schematic

It finally worked! I used 8-11 pins instead of 1-4 after your suggestions. Moreover, it appears to me that the problem was the voltage supply to the motor. Because it works properly when I connect a 9 or 12 V on V2 of the Hbridge directly. Before that I had connected Vin of arduino to V2 of bridge and had plugged in arduino a 12V supply; however it didn't seem to work

grrr… now I need help with my code… :-[

I use this one:

#include <Stepper.h>

#define motorSteps 48   

#define motorPin1 8
#define motorPin2 9
#define motorPin3 10
#define motorPin4 11
#define ledPin 13

// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);

void setup() {

  myStepper.setSpeed(30);

  // Initialize the Serial port:
  Serial.begin(9600);

  // set up the LED pin:
  pinMode(ledPin, OUTPUT);
  // blink the LED:
  //blink(3);
}

void loop() {
  
  Serial.println("Forward");
  myStepper.step(12);
  delay(30000);
}

I want it to turn 30 degrees every 30 sec. What do I do wrong (for one more time)??

plz guys… help me…

I want it to... OK, you explained that. I wrote some code... Good, you even showed it to use.

What do I do wrong?

You didn't tell us what happens when you run that code. Does the motor move? Does it move the wrong way? Does it move the wrong amount? Does it speak in a foreign language?

I’m having my own pains, I feel like I’m super close to having this working… But still, not quite.

I’ve wired up my bipolar motor as per the instructions in this diagram:
(as it won’t let me post images in my first post, I’ll dump the image in the following post)

As it stands, my stepper seems to step several (about 15 degrees) steps forward, and then the same number of steps (or very close) backward.

I’ve tried various little things from all possible coil wirings to various variants of the example code from the Arduino dev environment (see below for the default code). None of this seems to actually stop this factor. I have seen the motor make as much of a full half rotation on occasion when starting execution of the code, but nevertheless, I can’t get it to actually step in a regular circle.

PLEASE help!!! I’ve been trying to get this going for weeks (granted when I’ve had time)!

Sample Code:

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);

// the previous reading from the analog input
int previous = 0;

void setup()
{
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(30);
}

void loop()
{
  // get the sensor value
  int val = analogRead(0);

  // move a number of steps equal to the change in the
  // sensor reading
  stepper.step(val - previous);

  // remember the previous value of the sensor
  previous = val;
}

And for the above post I just made, here’s the diagram of how I’ve wired up my bipolar stepper…

What do have connected to analog pin 0?

Add a call to Serial.begin() in the setup function. Add Serial.print and/or Serial.println statements to loop, to print out the values in val and previous.

The output might provide a clue.

I actually figured it out, the diagram was wrong (at least in my case) in terms of where to connect the coils to the H-Bridge. I'll post more details later (I'm away from my project right now).

Thats for chiming in.