====== A4988 ======
{{:materiel:a4988:dsc_0059.jpg?400|}}
Voir projet [[projets:temps:accueil|TEMPS]] qui utilise 3 drivers avec une UNO et Shield.
// http://aconcaguasci.blogspot.fr/2016/11/arduino-cnc-shield-control-stepper.html
// current limit settings
/* 70
* Current Limit = 0.7 * VRef * 2 = 1.4 * vref
* nema 1.7 A
* Vref = 1.7/ 1.4 = 1.2V
* Test avec 9v . 06.01.2018
*/
#define EN 8
//Direction pin
#define X_DIR 5
#define Y_DIR 6
#define Z_DIR 7
//Step pin
#define X_STP 2
#define Y_STP 3
#define Z_STP 4
// a9488 settings
int delayTime=500; //Delay between each pause (uS)
void step(byte stepperPin, int steps)
{
for (int i = 0; i < steps; i++) {
digitalWrite(stepperPin, HIGH);
delayMicroseconds(delayTime); // bloquant
digitalWrite(stepperPin, LOW);
delayMicroseconds(delayTime);
}
}
void setup(){
pinMode(X_STP, OUTPUT);
pinMode(Y_STP, OUTPUT);
pinMode(Z_STP, OUTPUT);
pinMode(X_DIR, OUTPUT);
pinMode(Y_DIR, OUTPUT);
pinMode(Z_DIR, OUTPUT);
digitalWrite(X_DIR, HIGH);
digitalWrite(Y_DIR, HIGH);
digitalWrite(Z_DIR, HIGH);
pinMode(EN, OUTPUT);
digitalWrite(EN, LOW);
}
void loop(){
step(X_STP, 53); //X, Clockwise
delay(1000);
}
Test vitesse
// Arduino UNO / CNC shield / 3 * A4988 drivers (microstep (1/16)) / 3 Steppers nema 17 HS???
// pins
#define X_DIR 5
#define Y_DIR 6
#define Z_DIR 7
#define X 2
#define Y 3
#define Z 4
#define EN 8
// Variables
int count=0;
int vitesse = 500; // vitesse 500 OK
int count_hour = 60; // normalement ~3200 pas pour changer d'heure (= tour)
void setup(){
// Pins
pinMode(X, OUTPUT);
pinMode(Y, OUTPUT);
pinMode(Z, OUTPUT);
pinMode(X_DIR, OUTPUT);
pinMode(Y_DIR, OUTPUT);
pinMode(Z_DIR, OUTPUT);
// Directions
digitalWrite(X_DIR, HIGH);
digitalWrite(Y_DIR, HIGH);
digitalWrite(Z_DIR, HIGH);
// Enable
pinMode(EN, OUTPUT);
digitalWrite(EN, LOW);
}
void loop(){
count++;
moveMotor(X,60,vitesse);
moveMotor(Y,1,vitesse);
if ((count % count_hour) == 0) {
moveMotor(Z,1,vitesse);
}
}
void moveMotor(int _pin, int _nb, int _delay){
for (int i = 0; i < _nb; i++) {
digitalWrite(_pin, HIGH);
delayMicroseconds(_delay);
digitalWrite(_pin, LOW);
delayMicroseconds(_delay);
}
}