Stepper motor

I have a sketch I am trying to get working properly. Basically I have a mega with a LCD Keypad shield a L298 motor control shield with a 28BYJ-48 stepper motor.

This setup is to rotate a variable capacitor from 0 - 180 degrees which it does without many problems and comes to a stop at 0 and 180 and will only rotate in the opposite direction e.g if rotated to 180 it will only rotate to 0.

However, when the arduino is turned on it goes through initialisation and then rotates approx 22 degrees which then messes up the position of the capacitor ( it makes the arduino think that the 22 degree position is now 0) So if I reset multiple times the capacitor eventually goes to 180 but the arduino thinks it’s 0. What I need to happen on startup is nothing and the stepper motor does not rotate until I tell it to AND importantly that the position of the stepper is remembered and displayed on the LCD. Or the motor will go to either 180 or 0 on startup

Is this possible or should I look at other means?

Adrian

capacitor_control.ino (4.85 KB)

AFAIK you need a ULN2003 driver for a 28byj motor.

I am not familiar with those motors myself.

...R

Robin2: AFAIK you need a ULN2003 driver for a 28byj motor.

I am not familiar with those motors myself.

...R

Robin2: AFAIK you need a ULN2003 driver for a 28byj motor.

I am not familiar with those motors myself.

...R

Have tried with that driver but the same problem. I have ordered another stepper motor but I live along way from supplier

Adrian

Perhaps if you edit your Original Post and change the title to something like "Problem with 28BYJ-48 stepper motor" you will attract the attention of someone with more knowledge about them.

And there must be hundreds of existing Forum Threads about them. Have you searched?

...R

  {
    while (digitalRead (A2) == HIGH);
      myStepper.step(1);
  }

What are the useless curly braces for? Oh, gee, did I actually say that they were useless?

A2 is a dumb name for the pin. We have no idea what is connected to the pin, how that thing is wired, or why you want to wait for it to go LOW to take one step.

  for (int i = 0; i <= 200; i++)
  {
    myStepper.step(-1);
  }

As opposed to

   myStepper.step(-200);

? Why?

GET RID OF THOSE STUPID GOTO STATEMENTS!

Hi,

Have tried with that driver but the same problem. I have ordered another stepper motor but I live along way from supplier

Have you got a circuit diagram of how you connected the ULN2003 driver?

Have you got a simple stepper driving code just to test the stepper.

Did you develop this code in stages, getting each stage working before going to the next, or write it all at once?

I doubt if your stepper is bad, but you need to work with the driver to get the correct order of connections to make the stepper move back and forth.

Tom..... :)

TomGeorge: Hi, Have you got a circuit diagram of how you connected the ULN2003 driver?

Have you got a simple stepper driving code just to test the stepper.

Did you develop this code in stages, getting each stage working before going to the next, or write it all at once?

I doubt if your stepper is bad, but you need to work with the driver to get the correct order of connections to make the stepper move back and forth.

Tom..... :)

Stepper works in both directions. The problem is (as in the original post) that the motor turns approx 22 degrees when the arduino is turned on putting the 0 to 180 degree calibration out. I will post a diagram tomorrow Thanks for all the other help

Adrian

That is a unipolar step motor. It can be wired in a bipolar configuration (using only 4 of the 6 wires) making an L298 suitable.

homepage.divms.uiowa.edu/~jones/step/types.html

--Michael

Hi, Have you got a simple bit of code, even code from the library example to check your stepper performance?

Did you write your code in stages?

Thanks.. Tom.... :)

TomGeorge: Hi, Have you got a simple bit of code, even code from the library example to check your stepper performance?

Did you write your code in stages?

Thanks.. Tom.... :)

Have checked the stepper with other code all is working.

Adrian

TomGeorge: Hi, Have you got a simple bit of code, even code from the library example to check your stepper performance?

Did you write your code in stages?

Thanks.. Tom.... :)

Have to come clean and say I didnt write this sketch it was given to me to get working it had multiple compile errors and the formatting left a lot to be desired.

Adrian