Hi !
I recently wanted to make a little project that involves driving stepper motors , which requires drivers .
I wanted to use ULN2003 modules OR maybe the famous EasyDriver But I had a question about programming them :
Can I program both/any with Stepper library ? Or does it need some sort of special library ? Because I'm not a professional programmer so I want to do something simple .
And can I use Unipolars with EasyDriver ?
Thanks !!
Can I program both/any with Stepper library ?
You pick the library that goes with the driver.
And can I use Unipolars with EasyDriver ?
Does that look like a programming question?
Arman5592:
And can I use Unipolars with EasyDriver ?
No.
...R
I want to program this :
And I am wondering whether I can control this with stepper library or not ?
thanks
And I am wondering whether I can control this with stepper library or not ?
No. The Stepper library can not control that picture.
Have you taken the trouble to read the Reference material about the Stepper library. This, for instance?
Have you Googled arduino uln2003 ?
If you want to do anything complex the AccelStepper library is better.
...R
I have seen all of those and many other stuff for making a "CNC" but there were so many stuff I can't remember any .
As it turns out , I can
And thanks
Arman5592:
I have seen all of those and many other stuff for making a "CNC"
Things may be a little more complicated....
Neither the Stepper nor the AccelStepper libraries are designed to allow the closely coordinated control of 2 or more stepper motors that is necessary in a CNC machine - for example they can't ensure that one motor takes 179 steps in exactly the same time another motor takes 23 steps. If that sort of coordination is important you will have to write your own code or use something like GRBL - but I don't think it works with unipolar motors.
...R
Arman5592:
Hi !
I recently wanted to make a little project that involves driving stepper motors , which requires drivers .
I wanted to use ULN2003 modules OR maybe the famous EasyDriverBut I had a question about programming them :
Can I program both/any with Stepper library ? Or does it need some sort of special library ? Because I'm not a professional programmer so I want to do something simple .
And can I use Unipolars with EasyDriver ?
Thanks !!
If you are going to "bit bang" the stepper by individually driving each lead (with an H bridge or darlington array), you need to write your own sequencing code to turn the coils on and off in the proper order (and whether you are using a unipolar or bipolar motor).
BTW, I suggest using a bipolar motor.
If you use a stepper driver chip or stepper driver breakout board (HIGHLY recommended!), then all you do is send it a digital level for direction (CW or CCW) and one pulse per step. Super easy.
Here's a simple bit-banger that I wrote. It's probably not the best, but it works well - use it if it helps you.
// map arduino pins to motor driver leads
// don't forget to enable "enable" pins if necessary!
const uint8_t pins[] = {
_OUT1_PIN, _OUT3_PIN, _OUT2_PIN, _OUT4_PIN
};
const uint8_t bits[] = {
0b1000, //0b1100, // uncomment for half step
0b0100, //0b0110,
0b0010, //0b0011,
0b0001, //0b1001,
};
uint8_t sop = (sizeof (pins) / sizeof (*pins)); // size of pins
uint8_t sob = (sizeof (bits) / sizeof (*bits)); // size of bits
volatile uint8_t POS; // position (relative)
// steps can be negative or positive to control direction
// for a 200 ppr motor, "rotate (200)" turns 1 revolution
// "rotate (-200)" turns 1 revolution in the opposite direction
void rotate (long int steps)
{
uint8_t x;
int8_t dir = (steps < 0) ? -1 : 1;
long int y;
long int z;
z = abs (steps);
for (y = 0; y < z; y++) {
x = sop;
while (x--) {
digitalWrite (pins[x], bits[POS%sob] & (0x01 << x));
}
POS+=dir; // change to POS -= dir; to swap CW and CCW
_delay_ms (3); // adjust for desired step rate
// or use _delay_us () for finer control
}
}
(edit to add): If you use the code above and your motor only turns one step back and forth instead of rotating, change the ORDER of the motor pins. For example, instead of "_OUT1_PIN, _OUT3_PIN, _OUT2_PIN, _OUT4_PIN", you may need "_OUT1_PIN, _OUT2_PIN, _OUT3_PIN, _OUT4_PIN". The sequence will be obvious once you look at it.
PaulS:
And I am wondering whether I can control this with stepper library or not ?
No. The Stepper library can not control that picture.
Really?
Really?
Really. How are you going to make that picture step()?
PaulS:
Really?
Really. How are you going to make that picture step()?
With connecting a stepper motor to it xD
With connecting a stepper motor to it xD
You'll need to connect a picture of a stepper motor to it. Using cellophane tape or staples.
So . Can I control that board with a little stepper with an arduino uno ? I have both Stepper and AccelStepper libraries and the so-called "CustomStepper" library and I am willing to download any other library .
I just want to use some if and while statements to control them with a bunch of push buttons .
There IS a way of making AccelStepper controlling two (or more motors simultaneously) Here is howto.
- Setup AccelStepper with the callback option.
- Use Accelstepper as a master pulse for termining acceleration and speed, but not direction
- Your callback routine will be called once every time AccelStepper generates a pulse
- Write your callback routine that it generates pulses for the individual motors.
Lets say you want to move your axes at an angle with tan=5/3:
void stepperCallback(){
 xPulses++;
 if(xPulses == 3){
  digitalWrite(xPulsePin, 1);
  delayMicroseconds(1);
  digitalWrite(xPulsePin, 0);
  xPulses = 0;
 }//if(xPulses)
 yPulses++;
 if(yPulses == 5){
  digitalWrite(yPulsePin, 1);
  delayMicroseconds(1);
  digitalWrite(yPulsePin, 0);
  yPulses = 0;
 }//if(yPulses)
}//stepperCallback()
Just to show the general principle. Of course you should look at a bresenham algorithm or something similar for a real application but the general idea should be clear.
nilton61:
There IS a way of making AccelStepper controlling two (or more motors simultaneously) Here is howto.
[/quote]I don't think that will work with a ULN2003 where AccelStepper needs to produce the correct sequence of pulses on 4 pins to make the motor move.
Arman5592:
So . Can I control that board with a little stepper with an arduino unoI think you have already been told 2 or 3 times that you can.
...R
Ok thanks I just wanted to be sure about it .
And I currently don't need two steppers moving at once - This is just a little device that uses them , and it is manned . Although I am looking forward to learn more and finally make it autonomous and add more options , but because I'm not professional about it , I wouldn't like to start with a big project . Another thing that matters , I want to have minimum programming AND make it in less than 2 weeks (from zero) .
Just a general advice with stepper motors. Use a current controlled microstepping controller like the easy driver or similar with a high as possible unregulated supply voltage and a large reservoir cap. Also use AccelStepper to minimize the risk of loosing pulses
Another thing that matters , I want to have minimum programming AND make it in less than 2 weeks (from zero) .
Might as well admit defeat now. Save two whole weeks.
I use a commercially bought Ac to Dc converter so I don't know what's happening inside . I bet it's not regulated , it is one of those versions you could adjust the voltage (a very old one - maybe even 30 yrs old) .
I would also rather use EasyDriver but I suppose it's bipolar-only but I'm working with unipolars (unfortunately) so my choices of cheap drivers are limited to uln2003s and that's what I'm using .
And It's completely possible , I won't admit defeat : it only requires a bunch of if statements , which is the work of an afternoon .
Then making the project wouldn't take more than a week .