Society of Robots - Robot Forum

Software => Software => Topic started by: extreme.aly on March 29, 2013, 12:33:47 PM

Title: Unipolar Stepper Motor
Post by: extreme.aly on March 29, 2013, 12:33:47 PM
Hello,

I recently bought a Unipolar Stepper Motor. It makes 7.5 degree of rotation per step (48 steps/rev).

I tried it on Arduino using ULN2003 with the Arduino's built-in Stepper.h library. It worked perfectly.

But the problem is, I don't want to use the built-in library. I want to make it work without the library. The reason for doing this is, I'll be using the same stepper motor on PIC and I think we don't have a library on PIC for this.

So I tested the following sequence:
1110
1101
1011
0111
And tested it with different delays after updating the new values. But the stepper motor did nothing but to vibrate about its original position. The bigger the delay, more jerky motion it produced.

Please help me make my own set of functions to control this stepper motor!

Here is the code I'm testing:
Code: [Select]
int motorPin1 = 7;
int motorPin2 = 8;
int motorPin3 = 9;
int motorPin4 = 10;
int delayTime = 100;

void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
}

void loop() {
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delayTime);
}
Title: Re: Unipolar Stepper Motor
Post by: extreme.aly on March 29, 2013, 12:51:31 PM
Opps, fixed the code in the next minute of posting the thread! :P

Switched motorPin2 and motorPin3!

But still I have a question. I don't get the same torque with this code as with the Library code. Why?

I tried another sequence:
0011
0010
0110
0100
1100
1000
1001
0001
This has even lesser torque =/

What's the best sequence? I need as much torque as possible!
Title: Re: Unipolar Stepper Motor
Post by: waltr on March 29, 2013, 04:41:01 PM
Microchip has some App Notes on using stepper motors. These do discussion the switching sequence and driver circuits. Look them up and read.
Title: Re: Unipolar Stepper Motor
Post by: Webbot on March 30, 2013, 01:16:48 PM
This may help http://www.societyofrobots.com/member_tutorials/node/128 (http://www.societyofrobots.com/member_tutorials/node/128)