Difference between revisions of "Msc1G2:Student4"

From ex25
Jump to: navigation, search
(Arduino code & Setup)
Line 9: Line 9:
 
div#links a:hover  {color: #ff4da6; text-decoration: none; opacity: 1;}
 
div#links a:hover  {color: #ff4da6; text-decoration: none; opacity: 1;}
 
</style>
 
</style>
 
 
 
  
  
Line 19: Line 16:
  
 
== '''Prototype''' ==
 
== '''Prototype''' ==
 +
<p>Listatua publikatuko, Erantzun bat da, baina ez eiusmod tempor eta bizitasuna , eskulana eta obesitatea , beraz . Urteak pasa ahala , egingo dut , nork beteko ditu , eskola auzoan nostrud aliquip abantaila bertatik , baina, lan egiteko. Duis izan nahia mina plazerra kritikatu Irure inork ihes egin cillum dolore eu resultant no ekoizten izateko. Excepteur cupidatat beltzen Ez zara zorionez effeminate eta bere espiritu batera utzi duzu , hau da, sunt culpa qui zerbitzuak pintxoak ere .</p>
  
 
<html>
 
<html>
 
<iframe width="850" height="531" src="http://raumgewand.de/Hyperbody/Concept/concept.html" frameBorder="0" seamless="seamless" scrolling="no" allowfullscreen></iframe>
 
<iframe width="850" height="531" src="http://raumgewand.de/Hyperbody/Concept/concept.html" frameBorder="0" seamless="seamless" scrolling="no" allowfullscreen></iframe>
 
</html>
 
</html>
 +
 +
 +
 +
 +
 +
<i align="center">Video of prototype here?</i>
 +
 +
 +
 +
  
 
[[File: Group2_151215_2ndprototype.jpg | 850px]]
 
[[File: Group2_151215_2ndprototype.jpg | 850px]]
Line 29: Line 37:
 
[[File: Group2_151215_3rdprototype.jpg | 850px]]
 
[[File: Group2_151215_3rdprototype.jpg | 850px]]
 
<i>2nd silicone prototype for pneumatic actuators</i>
 
<i>2nd silicone prototype for pneumatic actuators</i>
 
<html>
 
<iframe width="850" height="450" src="https://www.youtube.com/embed/HcOF2Yo120c" frameborder="0" allowfullscreen></iframe>
 
</html>
 
<i>pneumatic idea</i>
 
 
[[File: Group2_151209_arduinomega-setup-pumps+valves.png | 850px]]
 
<i>arduino + electromagnetic valves + airpumps</i>
 
  
 
== '''Simulation''' ==
 
== '''Simulation''' ==
Line 52: Line 52:
 
[[File: Group2_151203_origami_folding.jpg | 850px]]
 
[[File: Group2_151203_origami_folding.jpg | 850px]]
 
<i>Origami folding</i>
 
<i>Origami folding</i>
 
<html>
 
<iframe width="850" height="450" src="https://www.youtube.com/embed/9lQlAmPbXNs" frameborder="0" allowfullscreen></iframe></html>
 
 
== '''Structure''' ==
 
 
<html>
 
<iframe src="//giphy.com/embed/l41lFJ1UoFnp7AayI" width="850" height="478" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p></p>
 
</html>
 
<i>Possible modul arrangement on curve created by the system</i>
 
<br>
 
 
<html>
 
<iframe width="850" height="450" src="https://www.youtube.com/embed/L94M3FBiqEY" frameborder="0" allowfullscreen></iframe>
 
</html>
 
<i>First attempt to calculate the folding of the arms (iterartion with a feedback loop)</i>
 
<br>
 
 
<html>
 
<iframe width="850" height="450" src="https://www.youtube.com/embed/gxl-uKEnwqc" frameborder="0" allowfullscreen></iframe>
 
</html>
 
<i>Dynamic reaction to random attractor points (kangaroo physics)</i>
 
<br>
 
 
<html>
 
<iframe width="850" height="450" src="https://www.youtube.com/embed/vMOSf5iADjc" frameborder="0" allowfullscreen></iframe>
 
</html>
 
<i>Modul arrangement + attractor points</i>
 
<br>
 
 
<html>
 
<iframe width="850" height="450" src="https://www.youtube.com/embed/uNCYn2iyQR4" frameborder="0" allowfullscreen></iframe>
 
</html>
 
<i>First approach to geometry</i>
 
  
 
== '''Setup and arduino code''' ==
 
== '''Setup and arduino code''' ==
Line 310: Line 276:
 
   return nextState;
 
   return nextState;
 
}</nowiki>
 
}</nowiki>
 +
 +
== '''Documentation''' ==
 +
 +
<gallery style="text-align:left" mode="packed-hover" heights="120px" >
 +
File: Group2_151209_arduinomega-setup-pumps+valves.png|Arduino setup prototype2
 +
File: Group2_151203_origami_folding.jpg|Origami folding patterns
 +
</gallery>
 +
 +
<html>
 +
<iframe width="400" height="255" src="https://www.youtube.com/embed/HcOF2Yo120c" frameborder="0" allowfullscreen></iframe>
 +
</html>

Revision as of 17:12, 26 January 2016

Prototype

Listatua publikatuko, Erantzun bat da, baina ez eiusmod tempor eta bizitasuna , eskulana eta obesitatea , beraz . Urteak pasa ahala , egingo dut , nork beteko ditu , eskola auzoan nostrud aliquip abantaila bertatik , baina, lan egiteko. Duis izan nahia mina plazerra kritikatu Irure inork ihes egin cillum dolore eu resultant no ekoizten izateko. Excepteur cupidatat beltzen Ez zara zorionez effeminate eta bere espiritu batera utzi duzu , hau da, sunt culpa qui zerbitzuak pintxoak ere .



Video of prototype here?



Group2 151215 2ndprototype.jpg 1st silicone prototype for pneumatic actuators

Group2 151215 3rdprototype.jpg 2nd silicone prototype for pneumatic actuators

Simulation

Shape

Group2 151203 origami folding.jpg Origami folding

Setup and arduino code

Group2 20160126 Prototype setup.jpg

//sensor.h defenition (used instead of void)
struct Sensor;

Sensor nextState(Sensor);
// Arduino code for Swarmscape prototype 2015-01-26
// Setup: FSR pressure sensors + array outputs linked to electronic valves

#include "sensor.h"
#include <TimerOne.h>

// Setting constants
int ledPin = 13;
int SENSOR_THRESHOLD = 40;
int SENSOR_TIMEOUT = 50;
int DEFLATE_TIMEOUT = 70;
int PRESSUREMAP_LOW = 0;
int PRESSUREMAP_HIGH = 750;
int MEASURE_TRESHOLD = 7;

// Building the structure
enum sensorState {
  set1,
  set2,
  idle,
  activated,
  measure,
  released,
  timed_out,
  deflate
};

struct Sensor {
  sensorState state;
  int pin;
  int time;
  int pressure;
  int out_pin;
  int defl_pin1;
  int defl_pin2;
};

Sensor sensor1 = {set1, A0, 0, 80, 12, 11, 14};
Sensor sensor2 = {set1, A1, 0, 80, 9, 7, 18};
Sensor sensor3 = {set1, A2, 0, 80, 5, 3, 22};


void setup() {
  Serial.begin(9600);
    
  pinMode(sensor1.pin, INPUT);
  pinMode(sensor2.pin, INPUT);
  pinMode(sensor3.pin, INPUT);
  
  pinMode(sensor1.out_pin, OUTPUT);
  pinMode(sensor2.out_pin, OUTPUT);
  pinMode(sensor3.out_pin, OUTPUT);
  
  pinMode(ledPin, OUTPUT);
  
  pinMode(sensor1.defl_pin1, OUTPUT);
  pinMode(sensor1.defl_pin2, OUTPUT);
  pinMode(sensor2.defl_pin1, OUTPUT);
  pinMode(sensor2.defl_pin2, OUTPUT);
  pinMode(sensor3.defl_pin1, OUTPUT);
  pinMode(sensor3.defl_pin2, OUTPUT);  
  
  Timer1.initialize(50000);         // initialize timer1, and set a 1/2 second period
  
  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
  
  Serial.println("Start: ");
  Serial.print("sensor1: ");
  Serial.print(sensor1.state); Serial.print(' ');
  Serial.print(sensor1.pin); Serial.print(' ');
  Serial.print(sensor1.time); Serial.print(' ');
  Serial.println(sensor1.out_pin);
  Serial.print("sensor2: ");
  Serial.print(sensor2.state); Serial.print(' ');
  Serial.print(sensor2.pin); Serial.print(' ');
  Serial.print(sensor2.time); Serial.print(' ');
  Serial.println(sensor2.out_pin);
  Serial.print("sensor3: ");
  Serial.print(sensor3.state); Serial.print(' ');
  Serial.print(sensor3.pin); 
}


void callback() {
  sensor1 = nextState(sensor1);
  sensor2 = nextState(sensor2);
  sensor3 = nextState(sensor3);
  
  Serial.print("State 1: ");
  Serial.print(sensor1.state);Serial.print(";");
  Serial.print(sensor1.time);
  
  Serial.print("State 2: ");
  Serial.print(sensor2.state);Serial.print(";");
  Serial.print(sensor2.time);
  
  Serial.print("State 3: ");
  Serial.print(sensor3.state);Serial.print(";");
  Serial.print(sensor3.time);
  Serial.print("\n");
  
}

void loop()
{
  // your program here...
}



Sensor nextState(Sensor sensor) {
  Sensor nextState = {sensor.state, sensor.pin, sensor.time, sensor.pressure, sensor.out_pin, 
sensor.defl_pin1, sensor.defl_pin2};
  boolean pressed = analogRead(sensor.pin) > SENSOR_THRESHOLD;  
  
  switch (sensor.state) {
// Setup state
    case set1:
      digitalWrite(sensor.out_pin, 1);
      nextState.state = set2;
      nextState.state = idle;
      break;
      
    case set2:
      nextState.time ++;  
      if (sensor.time > 50) {
      digitalWrite(sensor.defl_pin1, 0);
      digitalWrite(sensor.defl_pin2, 0);
      nextState.time = 0;
      nextState.state = idle;
      }
      else {
        nextState.state = set2;
      }
      break;
// Idle state
    case idle:
      nextState.time = 0;
      if (pressed) {
        nextState.state = measure;
      } else {
        nextState.state = idle;
      }
      break;
// Measurementstate
    case measure:
        nextState.time++;
        if(sensor.time > MEASURE_TRESHOLD);
          digitalWrite(sensor.out_pin, 0);
          sensor.pressure = analogRead(sensor.pin);
          nextState.time = 0;
          nextState.state = activated;
        }
        else {
          nextState.state = measure;
        }
      break;
// Activated state
    case activated:
      if (pressed) {
        nextState.time ++;
      } else {
        nextState.state = timed_out;
      }
      
      if (sensor.time > SENSOR_TIMEOUT) {
        nextState.state = timed_out;
      }
      
      break;
// Released state (stays up)
    case released:
      digitalWrite(sensor.out_pin, 1);
      nextState.time++;
      if(sensor.time > map(sensor.pressure, 0, 1024, PRESSUREMAP_LOW, PRESSUREMAP_HIGH)) {
        digitalWrite(ledPin, 0);
        nextState.time = 0;
        nextState.state = deflate;
      }
      else {
        digitalWrite(ledPin, 1);
        nextState.state = released;
      }
      break;
// Time-out state      
    case timed_out:    
      digitalWrite(sensor.out_pin, 1);
      if (pressed) {
        nextState.state = timed_out;
      } else {
        nextState.state = released;
      }
      break;
// Deflate state      
    case deflate:
      nextState.time++;
      digitalWrite(sensor.defl_pin1, 0);
      digitalWrite(sensor.defl_pin2, 0); 
      if (sensor.time > DEFLATE_TIMEOUT) {
        digitalWrite(sensor.defl_pin1, 1);
        digitalWrite(sensor.defl_pin2, 1); 
        nextState.state = idle;      
      }
      else {
        nextState.state = deflate;
      }
      break;
    default:
      break;
  }
  return nextState;
}

Documentation