Arduino + CNC SHIELD V3 + A4988 + Nema 17

Hi everybody, I'm using an Arduino Mega with CNC V3 SHIELD and one A4988 Stepper Motor Driver Carrier (Pololu - A4988 Stepper Motor Driver Carrier), to control this Nema 17 motor (http://www.omc-stepperonline.com/nema-17-bipolar-stepper-12v-04a-40ncm567ozin-17hs150404s-p-14.html).
Power supply= 12VDC 1A

The problem is that I get no response from motor. I'm using the following simple code:

int stp = 3; //connect pin 3 to step
int dir = 6; // connect pin 6 to dir
int a = 0; // gen counter

void setup()
{
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
}

void loop()
{
if (a < 200) //sweep 200 step in dir 1
{
a++;
digitalWrite(stp, HIGH);
delay(10);
digitalWrite(stp, LOW);
delay(10);
}
else
{
digitalWrite(dir, HIGH);
a++;
digitalWrite(stp, HIGH);
delay(10);
digitalWrite(stp, LOW);
delay(10);

if (a>400) //sweep 200 in dir 2
{
a = 0;
digitalWrite(dir, LOW);
}
}
}

I set the Vref to 0,23V by following the Pololu instruction, then I checked with a tester the voltage on the A4988 chip and it seems to work all correctly: ENABLE=about 5V, MS1 MS2 and MS3 = 0V, RESET and SLEEP are in continuity, STEP = 2,4V (maybe it's the average voltage between 0 and 5V LOW/HIGH), DIR changes every 4 seconds from 5V to 0, VMOT=12V, VDD= 5V. The strange values are on 2B, 2A, 1A, 1B where I always get 12 V.

Help me please,
Giando

The Pololu A4988 web page has a good wiring diagram. There is no need to connect enable to anything, and I can't remember whether 5v stops it or makes it go.

I don't know what you mean by "STEP = 2,4v" - measuring the I/O pin voltage or the motor coil voltage with a multimeter when the motor is moving is meaningless, you need an oscilloscope.

Try a much slower step interval - perhaps 100 millisecs, although your 40 should work.

You may like to try this Simple Stepper Code

...R
Stepper Motor Basics

Thank you very much but it doesn't work :frowning:

giando:
Thank you very much but it doesn't work :frowning:

And that tells me absolutely nothing that I can use to help you.

What is "it" ?

if it is a program, post the code.
Tell us what it actually does and tell us what you want it to do.

...R

I tried a much slower step interval (100 millisecs) and I tried your "Simple Stepper Code", but nothing changed. I want my nema 17 motor to move, but it doesn't give any response.

--- By using a L293D chip and relative code, the motor with the same power supply works correctly... so the motor is good and the power supply also ---

Anyway I can use a tester, tell me what I have to check and I will do it. Thanks

Have you a link to the datasheet for the "CNC V3 SHIELD" - it sounds like something is mixed up in the connection between the Arduino and the A4988.

Please make a pencil drawing showing all the wiring connections and post a photo of the drawing.

When you tried my stepper code did you notice whether the motor was more difficult to turn by hand - that would indicate that the coils are energized.

Can you try the A4988 on a breadboard without the CNC V3 shield ?

...R

Thank you Robin... good news: I tried the A4988 on a breadboard without the CNC V3 shield and it works correctly!!! :smiley:

I confirm that the ENABLE pin must be 0 volt to enable the Motor Driver but when I put the a4988 on the CNC V3 shield the ENABLE pin measures about 5V and I don't know why!!! Arduino pin 8 is linked to the a4988 Enable pin but when the code is running and the a4988 is not on the shield it measures 0volt correctly. When the a4988 is on the shield the pin 8 measures about 5 volt. Why??

CNC v3 shield: Arduino CNC Shield – 100% GRBL Compatable | Protoneer.co.nz

From a quick look at the board schematic I think there is a 10k pullup resistor on the Enable pins which would suggest that your Arduino needs an output LOW to counteract that. But I may be wrong.

...R

You're a Genius :smiley: :smiley: :smiley: thank you Robin.. Now it works correctly, this is the simple code:

int stepPin = 2;
int dirPin = 5;
int enable = 8;

void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(enable,OUTPUT);

digitalWrite(enable,LOW);
}
void loop() {
digitalWrite(dirPin,HIGH); // rotazione oraria
digitalWrite(stepPin,HIGH);
delay(1);
digitalWrite(stepPin,LOW);
delay(1);
}

Can you give me some advice to get the maximum performance (torque, speed) from my motor (http://www.omc-stepperonline.com/nema-17-bipolar-stepper-12v-04a-40ncm567ozin-17hs150404s-p-14.html)? What power supply (volt, amps) should I use? And what VREF I have to set in your opinion?

You need to set Vref to suit the current allowed in your motor. The Pololu A4988 web page describes how to do it.

You should use the highest voltage allowed by the A4988. As long as there is more than 0.8 amps available there should be no problem.

That is a high resistance coil and your motor will not run as fast, for a given supply voltage, as a motor with a lower resistance coil. However the motors with lower coil resistance usually need more amps and can exceed the capability of an A4988. Stepper drivers that can comfortably provide 2 amps and up are significantly more expensive.

...R

Thank you Robin, and about the code what is the minimum delay in microseconds in order to get the max rpm? By doing some attempt I noticed that below 650 microseconds the motor does not work. With 650 microseconds delay I get 240rpm (good).
Then must the following delay be identical?

digitalWrite(stepPin,HIGH);
delayMicroseconds(650);
digitalWrite(stepPin,LOW);
delayMicroseconds(650);

I suggest you change your code a little so it is like this

digitalWrite(stepPin,HIGH);
delayMicroseconds(10);
digitalWrite(stepPin,LOW);
delayMicroseconds(1290)

The actual pulse can be very short. By putting all the interval in one place you have only one variable to play with. I have similar stepper motors (not identical) and I get about 1000 steps per second with a 20v supply (IIRC).

Of course for a useful program you should not use delay() - but it is OK for testing.

...R

Perfect, I tried your suggested delays and they work fine, then I tried to decrease 1290us to 1200, 1100... but it doesn't works, so I have to leave this configuration.

Is (10us + 1290us) delay better than (650us + 650us) or is it the same?

Why do you say "for a useful program you should not use delay() - but it is OK for testing"?

And what do you think about this power supply for 4motors (12V, 0,4 amps/phase): http://www.omc-stepperonline.com/switching-power-supply-100w-24v-45a-for-cnc-router-kits-115v230v-s10024-p-154.html

Thank you Robin :wink:

giando:
Is (10us + 1290us) delay better than (650us + 650us) or is it the same?

It should give the same speed but I prefer only to have one number that I need to change the speed. In fact, because the digitalWrite() function is slow the 10µs delay is not needed at all.

Why do you say "for a useful program you should not use delay() - but it is OK for testing"?

An Arduino can do nothing else during a delay period. See Several Things at a Time

And what do you think about this power supply for 4motors

That should be fine. I was surprised at first because you said it has 45amps - but you just omitted the decimal point. A 45 amp supply would just be hard on your wallet.

...R

Thank you very much Robin, your advices are precious for me!!!

Now I'm looking for a DRV8825 Stepper Motor Driver Carrier (Pololu - DRV8825 Stepper Motor Driver Carrier, High Current), maybe it is better than A4988 and I will get more RPM and TORQUE from my motors.

giando:
Now I'm looking for a DRV8825 Stepper Motor Driver Carrier (Pololu - DRV8825 Stepper Motor Driver Carrier, High Current), maybe it is better than A4988 and I will get more RPM and TORQUE from my motors.

AFAIK the principal difference between them is that the DRV8825 can handle a little more current and a slightly higher voltage. If you don't make use of either of those I would not expect any difference in performance.

...R

From what I understand, for my motor (12V 0,4 Amps/Phase) I can give maximum 0,8 amps, while I can increase a lot the voltage for example 36V. Is it correct?
But I don't know exactly how much the voltage can influence the performance (rpm, torque) from 12V to 24V or 36V.

Anyway I'm using this motor because I need the maximum torque and rpm with the minimum weight of the motor and the only parameter that I was considering is the "holding torque". My motor weighs 280g and it has an holding torque of 40Ncm. I didn't find something better..

I don't know how you relate the 0.4 amps to 0.8 amps. Each coil has a max of 0.4 amps and that is how the limit in the A4988 or DRV8825 should be set.

I think you will need to experiment to see the effect of the higher voltage. The stepper driver will determine the maximum voltage. With a more expensive driver you could probably go to 80v. However I have no idea how much benefit that would provide.

Holding Torque is when the motor is stationary. Some motor manufacturers provide graphs showing torque at different speeds.

...R