Let's Make Robots!

A4988 and steppers My experience and mistakes

I've bought a few of the pololu stepper drivers A4988 to populate a ramps1.3 board used in printrbot. Before building the mechanics I soldered together the ramps board and plugged it all together with my arduino mega2560 and the drivers. Having tried to work out the best software combination with marlin version and either pronterface or replicator G I could not for the life of me get any action from the steppers in the control panel for either host software.
Anway I tried with only 1 driver plugged into ramps at a time just in case there were any shorts etc. After much persevering of trying many things and bleary eyed in the dim light at night I accidently misaligned the driver in the ramps slot and sparks and smoke ensued.
Realising I'd not only damaged the driver but my mega as well I immediately ordered replacements.
However it's at least a 2 week wait from China. So I thought I'll start back at the basics with my arduino duemilanove and the A4988 in a breadboard.

Having checked the circuit diagram for minimal wiring with the pololu information I wired it up found some arduino code and gave it a try.

Ok motor action, great. Hangon, no not great. It runs for a moment then stops and squeals like a bitch.
Disconnect, reconnect does the same thing, runs for a little then stops and squeals.
Ok so at this stage I have no idea what it can be. I read instructions in many places about the wiring of steppers thinking I may have it wrong.
I experimented with different current settings on the trimmer pot with no success. I have 2 different types of motor now because I thought perhaps I'd bought unsuitable steppers. Assisted by some nonsense I read somewhere that the pololu drivers don't work too well with the low voltage high current motors I'd bought.
Now I am big on reading datasheets maybe not always thoroughly at first but it is the thing you do. So I wondered at the start what kind of frequency you could use with the step pin. One pulse makes the stepper step once. So looking at the datasheet on page 6, I see logic timing.
There it says minimum step pulse 1us time on and 1us time off. Fine well thats as low a resolution as the arduino goes so I picked 2us on/off.
I even checked with my oscillosope at one stage to see how accurate it was and it was satisfactory.
However WRONG!!!
Update 21/10/12 - As Oddbot pointed out below this minimum refers only to the chip and not how fast your stepper
                                  can step. At 1us steps your stepper would have to be capable of 150,000 RPM

After much frustration and at the point of what the heck I'll try anything I changed the timing to 1 millisecond on/off. What do you know it works?
So I then set about finding what was the actual minimum on/off time for step frequency and it turned out to be 350us. Thats a bloody long way from 1us.
Now I just have to work out what needs changing in the pins.h and configuration.h to get it to work with my mega and ramps. 
Looking at pins.h for the mega2560 section the pins seem completely out. Like there is no pins 60 and 61 on a mega?
Only the z axis seems to have correct step and dir pin #defines.
Correction 21/10/12 - I have since learned the analog pins 6 & 7 are digital pins 60 &61

If anyone can explain why the pins.h file has these pin numbers for the mega2560 I would love to know. Also what else do I need to change in the marlin files to get it to work nicely?

One other thing do not forget the bridge from sleep to reset.  a floating value on the reset will cause you grief as well.

Now hurry up China Post I need to sort out Marlin and Ramps.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Dears

Can I Use stepper motor "1.65A _2.4V" by A4988 Driver?

please guide me...

Are you sure the pins.h file is incorrect? There are 70 digital pins from D0 to D69.  D54-D69 are your analog inputs.


This is the information I was looking for.  First time I've used a mega2560 and I wan't sure how the pins were named. I looked at the arduino site and googled. And only last night found a spreadsheet someone had made with the pin numbers and their names.
I have to wait now for my mega from China. If I'd bought one here they are like 60-70 dollars if I wait it's only costing me 21 dollars.
What I now think I did wrong originally is failed to uncomment the #define for Rampsv1.3 under arduino mega2560 in the pins.h file. Could be as simple as that why I couldn't get marlin and repG working.

I think you will find the 1uS specification is the limit of the CMOS circuitry.

Even with your pulses being 1uS ON and 1uS OFF that is a frequency of 500,000Hz. Assuming a 200 step/revolution motor that is still 150,000 RPM!!

Steppers are normally very slow motors and even with high voltage drivers cannot match the humble DC brushed motor. Once you divide that down by 350 you get 428.57 RPM which is about 7 revolutions per second assuming a 200 step/revolution motor. It will be faster if your motor has a lower resolution.

Wow, yeah I never thought of it that way Obbot, thanks. If I'd done the rpm calculation it would have made more sense.
I never thought of working the step frequency out that way. Which shows why you are building robots for a living and why I'm just a hobbyist. lol.
Certainly wouldn't want a cnc or 3d printer motor turning that fast.

First of all what motors are those,  any specs?

Second you say they start to move then stop and squeek, well I see some possile things here:

1. You might be trying to turn them too fast try lower speeds

2. Related to 1 you did not mention the voltage you are trying to run them at ... I assume 12  v. If the motors are high amp ones you will probably need higher voltage to run them fast

3. Is the driver gettig hot? It may switch on over current protection

That's all I got so far ...

Hey thanks Tinhead. You are absolutely right I was trying to step them too fast. This was really a blog about my problems and how I solved them rather than asking for help. Although I still have to get the motors working with ramps when I get my replacement mega2560. I have gotten as far as discovering the pins.h file has incorrect configuration for mega2560 and ramps1.3 board.
I can run either of the types of motors I have in a breadboard with the A4988 and I can get the full range of microsteps as well.
one is 12v .33amp 34 ohm coils 1.8 deg

other is
1.8 amp and 1.8 ohm coils and I guess around 3.2 volts 1.8 deg

It's more of a ramps/marlin issue I have to solve now. I appreciate your help.