hthang1988 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Arduino version 18 Stepper Library Problem #266

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. When using the "stepMotor" function with a pincount of 4 and with the 
following hardware setup:
when driving a ULN2003 directly from an Arduino, and using the ULN2003 to 
commutate a 4-phase unipolar motor (Parallax.com catalog #27964 7.5 degree 
stepper motor), by pulling the stepper motor coils to ground, the 
stepMotor function doesn't commutate properly.

What is the expected output? What do you see instead?
The expexted output is that the stepper motor will rotate in a certain 
direction when commanded to do so. What I see instead is that the motor 
toggles back and forth one step.

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
The version Arduino I am using is Arduino 0018. I am running the Arduino 
development environment on Windows Vista. I am using an Arduino mega (as 
opposed to an Arduino Duemilanove.

Please provide any additional information below.
To get the motor to commutate in full-step mode properly, I had to make 
the following change to the stepMotor function in the library:
 if (this->pin_count == 4) {
   switch (thisStep) {
     case 0:    //1100
     digitalWrite(motor_pin_1, HIGH);
     digitalWrite(motor_pin_2, HIGH);
     digitalWrite(motor_pin_3, LOW);
     digitalWrite(motor_pin_4, LOW);
     break;
     case 1:    // 0110
     digitalWrite(motor_pin_1, LOW);
     digitalWrite(motor_pin_2, HIGH);
     digitalWrite(motor_pin_3, HIGH);
     digitalWrite(motor_pin_4, LOW);
     break;
     case 2:    //0011
     digitalWrite(motor_pin_1, LOW);
     digitalWrite(motor_pin_2, LOW);
     digitalWrite(motor_pin_3, HIGH);
     digitalWrite(motor_pin_4, HIGH);
     break;
     case 3:    //1001
     digitalWrite(motor_pin_1, HIGH);
     digitalWrite(motor_pin_2, LOW);
     digitalWrite(motor_pin_3, LOW);
     digitalWrite(motor_pin_4, HIGH);
     break;
   } 
* JR 

Original issue reported on code.google.com by jrine31...@aol.com on 26 May 2010 at 6:53