Bipolar Stepping Motor and Arduino (without H-Bridge)?

Hi everybody,

I'm totally new to this community and I'm also pretty new to electronics, so please don't lynch me if i'm doing stupid beginner mistakes or explain myself a little weird.

However, let's get to my questions.

My first Arduino project was building a intervalometer to capture timelapse videos and it turned out pretty well. Now I wanna take this project a little further and want to make the camera move during the timeplapse. After some research I figured out that the best way doing this, is to use a stepper motor.

So I started to read about steppers and it's different types.

However, to gain some practical knowledge about steppers I decided to disassemble an old printer/scanner and see what I get.

I found a MITSUMI Stepping Motor M35SP-7T B. It has 4 wires, so it seems like it's a bipolar stepper. And measuring the resistance between the 4 outcoming wires made sure it is a bipolar stepper.

The only datasheet i could find was this: http://vinvin.dyndns.org/projects/M35SP-7T.pdf but it seems like a datasheet of the M35SP-7T unipolar version.

I decided to give it a try with my Arduino and no external power supply.

All tutorials I found on how to control a bipolar stepper with an Arduino microcontroller were implemented by using an H-Bridge. But i couldn't find any explanation why the H-Bridge is necessary. There is probably a easy explanation, but like I said, I'm quite new to electronics.

So I implemented the circuit like shown below, without H-Bridge, connecting the 4 wires of the stepping motor direct to the Arduino.

And it works fine with the following code:

// set pin numbers:
const int a1 = 1;     
const int a2 =  2;
const int b1 =  3;
const int b2 =  4;

void setup() {
  // initialize pins
  pinMode(a1, OUTPUT);
  pinMode(a2, OUTPUT);
  pinMode(b1, OUTPUT);
  pinMode(b2, OUTPUT);
  
  digitalWrite(a1, LOW);
  digitalWrite(a2, LOW); 
  digitalWrite(b1, LOW); 
  digitalWrite(b2, LOW); 
      
}

void loop(){

  step1();
  delay(10);
  step2();
  delay(10);
  step3();
  delay(10);
  step4();
  delay(10);
  
}

void step1 (){

  digitalWrite(a1, HIGH);
  digitalWrite(a2, LOW); 
  digitalWrite(b1, LOW); 
  digitalWrite(b2, LOW); 

}

void step2 (){

  digitalWrite(a1, LOW);
  digitalWrite(a2, LOW); 
  digitalWrite(b1, HIGH); 
  digitalWrite(b2, LOW); 

}

void step3 (){

  digitalWrite(a1, LOW);
  digitalWrite(a2, HIGH); 
  digitalWrite(b1, LOW); 
  digitalWrite(b2, LOW); 

}

void step4 (){

  digitalWrite(a1, LOW);
  digitalWrite(a2, LOW); 
  digitalWrite(b1, LOW); 
  digitalWrite(b2, HIGH); 

}

Like I said before, it works totally fine. The motor is turning fine, also in the other direction if i change the order of the steps. Or slower if I change the delay time. But I'm quite sure there must be some problems :).

So my questions are now: Why it is necessary to use a H-Bridge? Is it just used to be able to use a external power supply? Does my current implementation harm the arduino or the motor?

Thanks a lot for this great community

BTW: I know that this stepping motor I found in the scanner is way to weak to pull any kind of camera. I made this "project" just to get more familiar with stepping motors.

1 Like

An arduino pin can only supply a MAXIMUM of 40ma. It might provide more, but at your own risk of permanent damage. 20ma is more realistic for longevity of your arduino. I don't know of any stepper that takes such little current. The datasheet that you linked to says the motor will use 807ma. An H-bridge will allow a lot more current and make your arduino last longer.

Secondly, a motor will cause some nasty voltage spikes when you switch it. Without the proper protection, these dangerous spikes will be fed directly into the arduino... again causing damage. Some H-bridges have this safety measure built in. On others, it's easy to add.

Okay -

2 reasons to use the H-Bridge -

#1 - What current does that motor draw? You might be OK, but you also might be pulling to much current through the Arduino which will damage it. The H-Bridge handles the current so your Arduino doesn't have to.

#2 - Motors have coils and coils are called Inductors. When you turn off the power to a winding there is an effect just like the spark coil in your car. The Arduino is not designed to deal with that inductive "kick" and will probably fail over time.

If you use a Stepper motor Driver you can also free up pins for other uses, or for more stepper motors. Most drivers have 2 inputs, Step and Direction. Stepp pulses for every step, and direction goes high or low to select the direction to rotate.

As another aside - since Arduino pins 0 & 1 are used for the serial port, it is generally better not to use them for other I/O because it sometimes makes it hard to get the Arduino back in program mode. If you are using the 328 in a dedicated application this is not a problem, but to make it easier for you it really is best to leave those pins free for serial communication on an Arduino.

try easydriver or Big Easy Driver from sparkfun

Thanks a lot for the explanations and the advice. I think I'll try to implement it with an H-Bridge as soon as I get one.

Get an IC named L293DNE. It's an H-bridge and work fine with bipolars and Arduino.
If you've got 6 wire unipolar stepper, get ULN2003A or ULN2004A.

The datasheet quoted lists two different versions, one with 8ohm windings and one with 50ohm windings - which have you got? You'll need a power supply don't forget, and it needs to be compatible with the motor's ratings. Note that the L293 chips loses a few volts so your supply may have to be a little higher in voltage than you might think.

one with 8ohm windings and one with 50ohm windings - which have you got

Even if he had the 50R one that takes 100mA at 5V which is over twice the maximum current.
Also with no back EMF diodes that arrangement is going to damage the arduino with over voltage as well as over current.

Hello again, after over a year I finally had time to get back to this project. First of all I want to say sorry that the thread subject is not really what I'm asking for now, but I didn't want to open a new thread. The second thing is that instead of an Arduino I'm using a Teensy now. Hope that's not a problem.

I connected everything as follows (with help of the Arduino Cookbook) and it is working:

However in the Arduino Cookbook, the "Teensy supply voltage/L298 logic supply voltage" is separated from the "stepper supply voltage" like in the following schematic:

My question is now, is this "voltage supply separation" just because the stepper often needs another voltage then the microcontroller or is there another reason? In my case the stepper runs quite ok with 5V (I still couldn't figure out what the optimum voltage for this stepper is), so i use the same power supply for the Teensy and the stepper. Is this ok or will I damage my Teensy?

Sorry for this noob question :blush: and thanks for the answer(s)

Motors often run at 12V, 24V or 48V, rarely 5V

And also yes, you do want to separate motor power from logic power if poss - motors put all sorts of spikes and
noise on the supply which are a recipe for malfunctioning logic devices, and worst of all a stalled motor
might bring the supply rail down to a couple of volts. However steppers are a little different and don't
have stall-current as such - but noise and spikes are still an issue.

Furthermore if a motor is over-spun mechanically it will raise its supply voltage higher than normal - this
could blow all the 5V logic devices if sharing supplies..

Hi Mark,

Thanks for the quick answer. My power supply outputs 5VDC max. 2A. And when i haven't connected the circuit to it I can also measure these 5V. When I connect the circuit it drops to 4.6V. I guess/hope that's normal and it should be fine for the Teensy as it can operate down to 2.4V. The current I measured from the power supply to the circuit is 0.65A. How can this be? If the stepper alone should already drain a current of 1.2A (I=V/R I=4.6V/4.1ohm)? There is probably an easy explanation, so maybe you can point me in some direction where I can read about it :).

Is there a possibility to separate the power supply somehow or can I build some microcontroller protection with some additional components? All I found was the suggestion to put a 5.1 V zener diode pointing from GND to +5V :~. Would this be enough?

Thanks again

Elokuu:
Hi Mark,

Thanks for the quick answer. My power supply outputs 5VDC max. 2A. And when i haven't connected the circuit to it I can also measure these 5V. When I connect the circuit it drops to 4.6V. I guess/hope that's normal and it should be fine for the Teensy as it can operate down to 2.4V. The current I measured from the power supply to the circuit is 0.65A. How can this be? If the stepper alone should already drain a current of 1.2A (I=V/R I=4.6V/4.1ohm)? There is probably an easy explanation, so maybe you can point me in some direction where I can read about it :).

That voltage drop is rather large - are you measuring at the supply or at the load? If the latter it may be you are
using wire that's too thin for the current. Logic supplies are usually spec'd as 5.0V +/- 0.25V, though with CMOS this
isn't too crucial.

The current is lower than you expect because you are using a darlington H-bridge chip - which will drop 1.5 to 2.5V and
the motor will only see 3.5 to 3.5V across its windings, thus takes a lot less current. For low voltage motors the L298 and L293
are really inefficient.

The pin out in the strip-board diagram doesn't match the L298 which is not a DIP16 chip as far as I can tell. It doesn't
match the pinout of the L293D.

Is there a possibility to separate the power supply somehow or can I build some microcontroller protection with some additional components? All I found was the suggestion to put a 5.1 V zener diode pointing from GND to +5V :~. Would this be enough?

Thanks again

Protection from spikes would involve a filter in the supply rail - these can be LC or RC. There is no easy way to
protect from drop-outs due to motor stalls (but that won't apply to this case, only to DC motors).

A perhaps better approach is to have the motor at 12V, then you can use a regulator from this to generate a clean 5V
for the logic. But it all depends on your motor!

MarkT:
That voltage drop is rather large - are you measuring at the supply or at the load? If the latter it may be you are
using wire that's too thin for the current.

I measured at the supply and it's around 4.65V. I don't know why there is such a big drop. At the stepper it's just 2.5V. I don't think the wires are to thin, because the wires which are on the stepper (from the manufacturer) are actually even thinner than the one I'm using.

MarkT:
The current is lower than you expect because you are using a darlington H-bridge chip - which will drop 1.5 to 2.5V and
the motor will only see 3.5 to 3.5V across its windings, thus takes a lot less current.

Thanks for the explanation. It makes sense and also accords with my measuring at the stepper.

MarkT:
The pin out in the strip-board diagram doesn't match the L298 which is not a DIP16 chip as far as I can tell. It doesn't
match the pinout of the L293D.

Yes, you are totally right.The L298 is a Multiwatt15 as shown below:

But you can bend the "front row" of pins a little so it fits in the breadboard. So the left side are the even pins from 14 to 2, starting with 14 at the top, and the right side are the uneven pins from 15 till 1, starting with 15 at the top. But, yes I should have mentioned this while posting the "schematic".

MarkT:
Protection from spikes would involve a filter in the supply rail - these can be LC or RC. There is no easy way to
protect from drop-outs due to motor stalls (but that won't apply to this case, only to DC motors).

Ok, I will have a look at LC and/or RC filters then.

MarkT:
A perhaps better approach is to have the motor at 12V, then you can use a regulator from this to generate a clean 5V
for the logic. But it all depends on your motor!

My power supply actually also has a 12V output (it's a hard disc power adapter). But I'm afraid that I'll burn the l298, because (12V-2.5V)/4.1ohm = 2.3A. Even now with 0.6A the L298 gets pretty hot. Please correct me if I'm wrong.

Thanks

i want interface 4 dual staft stepper motor with a single arduino broad....
can it be possible or not ??

DO NOT double post.

And this is a very old Thread

I have already answered your question in your own Thread.

...R

Well apart form the above comments, if your motor gets stuck for whatever reason, there will be some back EMF and current fed into the arduino. Defnitely something you dont want. In most H bridge driver circuits, there will some diodes preventing current from flowing back.