Catégories
Liens
Guide pas à pas et conseil pour la réalisation du projet.
// 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_STP 2 #define Y_STP 3 #define Z_STP 4 #define EN 8 // Variables const boolean DEBUG = true; int start_time = 200; // 1000 const int step_delay = 200; // 500 ! microseconds const int step_sec = 53; // 200*16 > 3200 steps / 60 = 53,3333 steps const int step_min = 53; // 200*16 > 3200 steps / 60 = 53,3333 steps const int step_hour = 133; // 200*16 > 3200 steps / 24 = 133,3333 steps int current_sec = 1; int current_min = 1; int current_hour = 1; int delay_time; // Move functions void moveSecond() { for (int i = 0; i < step_sec; i++) { digitalWrite(X_STP, HIGH); delayMicroseconds(step_delay); digitalWrite(X_STP, LOW); delayMicroseconds(step_delay); } } void moveMinute(){ for (int i = 0; i < step_min; i++) { digitalWrite(Y_STP, HIGH); delayMicroseconds(step_delay); digitalWrite(Y_STP, LOW); delayMicroseconds(step_delay); } } void moveHour(){ for (int i = 0; i < step_hour; i++) { digitalWrite(Z_STP, HIGH); delayMicroseconds(step_delay); digitalWrite(Z_STP, LOW); delayMicroseconds(step_delay); } } 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); // Directions digitalWrite(X_DIR, HIGH); digitalWrite(Y_DIR, HIGH); digitalWrite(Z_DIR, HIGH); // Enable pinMode(EN, OUTPUT); digitalWrite(EN, LOW); // Debug console if (DEBUG) Serial.begin(19200); } void loop(){ // Seconds moveSecond(); current_sec = (current_sec + 1) % 10; // !! 60 delay_time = start_time - (step_sec * step_delay / 1000); // Minutes if (current_sec == 0) { moveMinute(); current_min = (current_min + 1) % 10; // !! 60 delay_time = delay_time - (step_min * step_delay / 1000) ; } // Hours if (current_sec == 0 && current_min == 0) { moveHour(); current_hour = (current_hour + 1) % 24; delay_time = delay_time - (step_hour * step_delay / 1000) ; } // Debug serial monitor if (DEBUG) { Serial.print(current_hour); Serial.print(":"); Serial.print(current_min); Serial.print(":"); Serial.print(current_sec); Serial.print(" - delay : "); Serial.println(delay_time); } // Delay time delay(delay_time); }
// 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); } }
Liste de matériel et outils nécessaires.