AccelStepper and Pololu A4988

4,340 views
Skip to first unread message

onurolce

unread,
Feb 19, 2012, 4:07:54 AM2/19/12
to accelstepper
Hi,

I've a question to you. I was using my stepper(1.8/200 step) with
L293D IC. and I could use AccelStepper library too.

But I bought Pololu A4988 driver for microstep such as 1/16. But I
could not see anyway to driver it by AccelStepper.

I need your help ( sample code and connections ) about that.

Thanks

Onur

Mike McCauley

unread,
Feb 19, 2012, 4:23:09 AM2/19/12
to accels...@googlegroups.com
Hello,

Sorry, I dont have one of those.

Cheers.

>
> Thanks
>
> Onur
--
Mike McCauley mi...@open.com.au
Open System Consultants Pty. Ltd
9 Bulbul Place Currumbin Waters QLD 4223 Australia http://www.open.com.au
Phone +61 7 5598-7474 Fax +61 7 5598-7070

Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS, NetWare etc.

Orlando Andico

unread,
Feb 19, 2012, 4:26:35 AM2/19/12
to accels...@googlegroups.com
Use the 1 pin driver, connect dir and step. Youll have to use some other pins to control the ms9-ms2.
--
Orlando Andico
+65.6436.1577 | +65.8139.0251

onur olce

unread,
Feb 19, 2012, 8:30:16 AM2/19/12
to accels...@googlegroups.com
can you explain a little more please ?

Brian Schmalz

unread,
Feb 19, 2012, 9:43:09 AM2/19/12
to accels...@googlegroups.com

You may want to try looking at this page I wrote: http://schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html

 

The last couple examples show code that works with Step and Direction driver chips (which the A4988 is) and AccelStepper. Note that while I illustrate an EasyDriver as the driver board, you could just as well replace that with a Big Easy Driver board (based on the A4988) or Polou’s A4988 driver board, or your own A4988 circuit.

 

The trick is in the initial stepper object creation, to use the 1 pin driver mode, and specify the step and direction pins in the object creation.

 

Let us know if this doesn’t make sense-

 

*Brian

lanthan l

unread,
Feb 19, 2012, 4:02:58 PM2/19/12
to accels...@googlegroups.com
Hi,

Another example here:

https://github.com/lanthan/polargraph4dirstep

that is Euphy's polargraph soft adapted to use step/dir control with the accelstepper library
The changes needed were very small and straightforward.

Mike McCauley

unread,
Feb 20, 2012, 4:44:31 PM2/20/12
to accels...@googlegroups.com
Hello,

What Orlando means is that you need to set up AccelStepper in the 'stepper
driver' mode. This means it will control 2 output pins, one for direction and
one for step.

You will need to construct your AccelStepper something like this:

AccelStepper stepper(1, 10, 11);

the 1 means 'stepper driver' mode
10 is the pin to be used to step
101 is the pin to be used to direction

If you need to controil some other pins of the stepper driver, you will have
to do that yourself.

Cheers.

onurolce

unread,
Feb 23, 2012, 7:42:58 AM2/23/12
to accelstepper
Hi Brian,
I could not find Easy Driver in Turkey markets. So therefore I bought
Pololu A4988 stepper driver. But I think they use same chip.
I worked on your recommendations about Accel Stepper but I see that
thsi library for many rounds which I don't need for my new project.
Now I have another problem, it's about step missing/losing. Let me try
to explain:
I will have 180 degree total turn by 45 degree steps. so total step
will be 180 / 45 = 4 times. in every 1 time steppers should wait 2
seconds. But my source will be battery so energy saving is important
for me. When I DISABLE to driver and then ENABLE again, I lose some
steps. this is very bad thing. I researched in forums for solution :
they recommend to keep last position of motor and disable and before
then enable put those values back to motor position. it's good idea
but how can I do it with A4988 driver ? or have another solution for
this problem ?
Wish to get answer soon.
Thanks
Onur


On Feb 19, 4:43 pm, Brian Schmalz <brian.schm...@logicpd.com> wrote:
> You may want to try looking at this page I wrote:http://schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html
>
> The last couple examples show code that works with Step and Direction driver chips (which the A4988 is) and AccelStepper. Note that while I illustrate an EasyDriver as the driver board, you could just as well replace that with a Big Easy Driver board (based on the A4988) or Polou's A4988 driver board, or your own A4988 circuit.
>
> The trick is in the initial stepper object creation, to use the 1 pin driver mode, and specify the step and direction pins in the object creation.
>
> Let us know if this doesn't make sense-
>
> *Brian
>
> From: accels...@googlegroups.com [mailto:accels...@googlegroups.com] On Behalf Of onur olce
> Sent: Sunday, February 19, 2012 7:30 AM
> To: accels...@googlegroups.com
> Subject: Re: AccelStepper and Pololu A4988
>
> can you explain a little more please ?
> On Sun, Feb 19, 2012 at 11:26 AM, Orlando Andico <orly.and...@gmail.com<mailto:orly.and...@gmail.com>> wrote:
> Use the 1 pin driver, connect dir and step. Youll have to use some other pins to control the ms9-ms2.
>
>
>
>
>
>
>
>
>
> On Sunday, February 19, 2012, Mike McCauley <mi...@open.com.au<mailto:mi...@open.com.au>> wrote:
> > Hello,
>
> > On Sunday, February 19, 2012 01:07:54 AM onurolce wrote:
> >> Hi,
>
> >> I've a question to you. I was using my stepper(1.8/200 step) with
> >> L293D IC. and I could use AccelStepper  library too.
>
> >> But I bought Pololu A4988 driver for microstep such as 1/16. But I
> >> could not see anyway to driver it by AccelStepper.
>
> >> I need your help ( sample code and connections ) about that.
>
> > Sorry, I dont have one of those.
>
> > Cheers.
>
> >> Thanks
>
> >> Onur
> > --
> > Mike McCauley                               mi...@open.com.au<mailto:mi...@open.com.au>
> > Open System Consultants Pty. Ltd
> > 9 Bulbul Place Currumbin Waters QLD 4223 Australia  http://www.open.com.au
> > Phone +61 7 5598-7474<tel:%2B61%207%205598-7474>                       Fax   +61 7 5598-7070<tel:%2B61%207%205598-7070>
>
> > Radiator: the most portable, flexible and configurable RADIUS server
> > anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
> > Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
> > TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
> > DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS, NetWare etc.
>
> --
> Orlando Andico
> +65.6436.1577<tel:%2B65.6436.1577> | +65.8139.0251<tel:%2B65.8139.0251>

onur olce

unread,
Feb 23, 2012, 7:51:45 AM2/23/12
to accels...@googlegroups.com
Hi,

I worked on your recommendations about Accel Stepper but I see that thsi library for many rounds which I don't need for my new project.
Now I have another problem, it's about step missing/losing. Let me try to explain:
I will have 180 degree total turn by 45 degree steps. so total step will be 180 / 45 = 4 times. in every 1 time steppers should wait 2 seconds. But my source will be battery so energy saving is important for me. When I DISABLE to driver and then ENABLE again, I lose some steps. this is very bad thing. I researched in forums for solution : they recommend to keep last position of motor and disable and before then enable put those values back to motor position. it's good idea but how can I do it with A4988 driver ? or have another solution for this problem ?
Wish to get answer soon.
Thanks
Onur

Brian Schmalz

unread,
Feb 23, 2012, 9:03:32 AM2/23/12
to accels...@googlegroups.com

Onur,

 

I’m sorry that you can’t get the Easy Driver or Big Easy Driver in Turkey! The Pololu 4988 is _very_ similar to the Big Easy Driver – better in some ways, worse in others, but basically the same.

 

So for your missing step problem – are you finding that the shaft of the stepper motor is moving on its own when you disable the driver?

 

Stepper motors do NOT hold their position if you turn off the drivers. When you use ENABLE or SLEEP, it disables the drivers. So the motor will ‘freewheel’ and not hold its position anymore.

 

One solution to this is to add enough mechanical friction in your system so that even if the stepper motor is free to spin, your output won’t move on its own. Using a worm gear is one way to do this quite well.

 

The other thing that could be happening is that the microstep state machine is losing its state when you disable the driver. What happens when you use ENABLE to disable the driver is that, when you start back up again, the driver chip will always return to “full” step. In other words, if you were on microstep 7 of 16 when you disabled, when you re-enable, it will snap to either microstep 1 or microstep 16 (no way to tell which one) which are the ‘full’ step positions.

 

The only way to avoid this is to make sure that you only stop on ‘full’ step positions. So only move in multiple of 16 steps (if you’re using 16 microstep mode). That way you’ll always start and end on ‘full’ step positions and won’t lose microsteps when you re-enable the driver.

 

*Brian

 

From: accels...@googlegroups.com [mailto:accels...@googlegroups.com] On Behalf Of onur olce
Sent: Thursday, February 23, 2012 6:52 AM
To: accels...@googlegroups.com
Subject: Re: AccelStepper and Pololu A4988

 

Hi,

Reply all
Reply to author
Forward
0 new messages