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.
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.
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
Thank you Robin... good news: I tried the A4988 on a breadboard without the CNC V3 shield and it works correctly!!!
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??
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.
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.
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?
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.
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"?
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"?
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.
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.
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.