temps

  • Porteur du projet : shaodan li shaodan
  • Date : 15/01/2018/ - …
  • Licence : CC-by-sa-3.0
  • Description : le temps fait des dessins
  • Fichiers sources : mettre un lien
  • Lien : mettre un lien

Note d'intention

le temps fait des dessins

temps

Notes techniques

Guide pas à pas et conseil pour la réalisation du projet.

Electronique

  • CNC shield
  • 3 x A4988 drivers (microstep (1/16))
  • 3 Steppers nema 17 HS

Code Arduino

// 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);
}

Test vitesse

Code test vitesse

Matériaux et outils

Liste de matériel et outils nécessaires.

Photos