Wiki

Reso-nance numérique | Arts et cultures libres

Outils du site


projets:temps:accueil

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
projets:temps:accueil [2018/01/15 16:19]
shaodan Créé depuis le formulaire projets:esadmm-creer
projets:temps:accueil [2018/02/20 16:18] (Version actuelle)
resonance [Code Arduino]
Ligne 13: Ligne 13:
  
 {{projets:temps:accueil:wechatimg70.jpeg?800|temps}} {{projets:temps:accueil:wechatimg70.jpeg?800|temps}}
 +
 +{{:projets:temps:montre.jpg?800|}}
  
 ===== Notes techniques ===== ===== Notes techniques =====
 Guide pas à pas et conseil pour la réalisation du projet. 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 ====
 +
 +<code cpp>
 +// 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     
 +#define Z_STP     
 +#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);
 +}
 +
 +</code>
 +
 +
 +=== Test vitesse ===
 +
 +++++ Code test vitesse |
 +<code cpp>
 +// 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         
 +#define Z         
 +#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); 
 +  }
 +}
 +</code>
 +++++
  
 ===== Matériaux et outils ===== ===== Matériaux et outils =====
Ligne 21: Ligne 204:
  
 ===== Photos ===== ===== Photos =====
-Code pour afficher les images du projet : +{{gallery>?&crop&lightbox}}
-<code>{{gallery>?&crop&lightbox}}</code>+
  
  
  
/home/resonancg/www/wiki/data/attic/projets/temps/accueil.1516029579.txt.gz · Dernière modification: 2018/01/15 16:19 de shaodan