Wiki

Reso-nance numérique | Arts et cultures libres

Outils du site


Panneau latéral

projets:hyperstatic:accueil

Ceci est une ancienne révision du document !


hyperstatic

  • Porteur du projet : Moritz Führer moritzfuehrer
  • Date : 09/06/2017/ - …
  • Licence : CC-by-sa-3.0
  • Description : camera turning around a shiny reflecting metal ball in a evenly lightened white sphere to create a projection with a static image of the metal ball, its reflection that never changes even if the speed of the camera varies
  • Fichiers sources : mettre un lien
  • Lien : mettre un lien

Note d'intention

camera turning around a shiny reflecting metal ball in a evenly lightened white sphere to create a projection with a static image of the metal ball, its reflection that never changes even if the speed of the camera varies

hyperstatic

Notes techniques

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

Matériaux et outils

Liste de matériel et outils nécessaires.

Codes

Arduino

// A COMMENTER ! 
// .......
// page wiki + photos : http://reso-nance.org/wiki/projets/creer
// organiser son dossier . dessins, electronic (connexions), programme, ...
 
// source .  https://github.com/sparkfun/Monster_Moto_Shield/blob/master/Firmware/MonsterMoto_Shield_Example_Sketch/MonsterMoto_Shield_Example_Sketch.ino
 
#define DURATION_SAMPLING 5 // temps entre chaque valeur du capteur et changement de vitesse
 
// Seauence de vitesses pour le moteur
const int NB_SEQUENCE = 8; // nombre de sequence
int speedSequence [][2] = { // tableau de couples de valeurs (pwm entre 0 et 255, ms)
  {50, 1000}, // speed = 50, ms = 1000
  {200, 5000},
  {100, 2000},
  {100, 10000},
  {255, 3000},
  {255, 4000},
  {50, 5000},
  {50, 10000}, // finir avec la meme vitesse
}; 
 
float currentSpeed = 0;
 
// Effect Hall sensor
const int hallPin = 10;    // the pin that the pushhall is attached to
int hallPushCounter = 0;   // counter for the number of hall presses
int hallState = 0;         // current state of the hall
int lasthallState = 0;     // previous state of the hall
 
void setup()
{
  // Communication
  Serial.begin(9600);
 
  // Sensor setup
  pinMode(hallPin, INPUT);
 
  // Motor Setup
  pinMode(6, OUTPUT); // motor 2 PWM
  pinMode(4, OUTPUT); // motor 2 INA: Clockwise input
  pinMode(9, OUTPUT); // motor 2 INB: Counter-clockwise input
  digitalWrite(4, LOW); 
  digitalWrite(9, LOW);
 
  // Motor direction
  digitalWrite(9, HIGH); // 4 or 9
 
  delay(2000);
}
 
void loop()
{  
  // Launch seauence of speed variations
  readMotorSequence();  
}
 
// Speed variations
void readMotorSequence(){
  int destSpeed = 0; 
  int destDuration = 0;
  float deltaSpeed;
 
  // boucle sur la seauence globale
  for (int i = 0; i < NB_SEQUENCE; i++) // nombre de seauence = 5
  {
    destSpeed = speedSequence[i][0]; // recupere les valeurs du tableau de seauence
    destDuration = speedSequence[i][1];
    deltaSpeed = (destSpeed - currentSpeed ) / (destDuration / DURATION_SAMPLING) ; // calcul du delta de la vitesse
 
    /*
    // DEBUG
    Serial.println("*******************"); 
    Serial.print(destSpeed); 
    Serial.print(" " );
    Serial.println(destDuration);   
    Serial.print(" " );
    Serial.println(deltaSpeed);
    */
 
    // interpolation de la vitesse vers la vitesse de destination destSpeed
    for (int t = 0 ; t < destDuration ; t = t + DURATION_SAMPLING) {  
      //Serial.print("Speed: ");
      //Serial.println(currentSpeed);
 
      // Motor speed      
      analogWrite(6, (int) currentSpeed); 
 
      currentSpeed = currentSpeed + deltaSpeed;
 
      // Get and send sensor value at the same time
      getHallSensor();
 
      delay(DURATION_SAMPLING);
    }
  }
}
 
// Get value of hall sensor and send it through Serial communication
void getHallSensor() {
  hallState = digitalRead(hallPin);
  if (hallState != lasthallState) {
    if (hallState == HIGH) {
      Serial.write(hallPushCounter); // better than Serial.println(hallPushCounter);
      hallPushCounter++;
    }
  }
  lasthallState = hallState;
}

Processing

// A COMMENTER !
// .......
 
// Libs
import processing.video.*;
import processing.serial.*;
 
Capture videocam;
Serial myserial;       
 
// Setup
int W = 1280; //1920x1080 ou 1280x720 ou 1024x768
int H = 720;
int R = 30; // 15 ou 30
String CAM_NAME = "/dev/video2"; // a changer
String ARDUINO_NAME = "/dev/ttyUSB0"; // a changer
boolean DEBUG = false; // afficher la liste des ports série et résolutions de caméra
 
// Other variables
int sensorValue;
int lastSensorValue = 0;
int sensorTime;
int lastSensorTime =0;
PFont f;
String val;
float rpm;
 
void setup () {
 
  fullScreen(); // ou alors size (1280, 720, P2D);
  background(0);
 
  // Affichage des résolutions et des ports séries disponibles 
  if (DEBUG) {
    printArray(Serial.list());
    printArray(Capture.list());
  }
 
  // Arduino
  myserial = new Serial(this, ARDUINO_NAME, 9600);
 
  // Webcam
  videocam = new Capture(this, W, H, CAM_NAME, R);
  videocam.start();
 
  // Font
  f = createFont("SourceCodePro-Regular.ttf", 100);
  textFont(f);
  textAlign(CENTER, CENTER);
}
 
void draw () {  
  // Read Webcam
  if (videocam.available ()) {
    videocam.read ();
  }
 
  // Choose : "image (videocam, 0, 0)" ou "set(0, 0, videocam)"; 
  set(0, 0, videocam);
 
  // Display text
  String t = str((int)rpm) + " T/m";
  text(t, W/2, H/2);
}
 
// Read serial value (from Serial.write() in the Arduino program)
void serialEvent (Serial myPort) {
  sensorValue = myPort.read();
 
  // Find the RPM
  if (sensorValue != lastSensorValue) {
    sensorTime = millis() - lastSensorTime ;
    rpm = 60000 / sensorTime;
  }
 
  lastSensorTime = millis();
  lastSensorValue = sensorValue;
}

Photos

Code pour afficher les images du projet :

{{gallery>?&crop&lightbox}}
/home/resonancg/www/wiki/data/attic/projets/hyperstatic/accueil.1497023361.txt.gz · Dernière modification: 2017/06/09 17:49 de resonance