Tuesday, December 6, 2011

042_use.less.thermostat

Almost done...

Need to implement a kickdown for the weekly timer event (requires a way to interpolate 7 day cycle out of monthly calendar data. Probably implement a counter to log everytime "day" changes and when it hits 7 execute kickdown and reset timer.

Other stuff ("learning") would just be calling appropriate values from our huge array and averaging them. Also implementing the finalized serial communication (Xbee?) between processing and arduino.

also: pachube

also: graph of pachube












import processing.serial.*;// import the serial library
Serial port;

PFont f = createFont("Knockout-HTF91-UltmtMiddlewt", 96, true);
PFont g = createFont("Knockout-HTF91-UltmtMiddlewt", 48, true);
int cels = 19;
int temp = 5;
int cal_x = 1000;
int cal_y = 600;
int multi = 25;

//COUNTER
int counter = 0;
int minutetracker = 0;
int hourtracker = 0;

//BIG ARRAY!!!
  int years = 2;
  int weeks = 52;
  int days = 7;
  int hours = 24;
  float[][][][] userTempArray = new float[years][weeks][days][hours];

//HOURLY ARRAY
  int[] hourlog = new int[59];


//KEYBOARD
//up/down arrows set user temp
void keyPressed() {            
  if (key == CODED) {   
    switch(keyCode) {
      case (LEFT):
      cels -= 1;
      break;
      case (RIGHT):
      cels += 1;
      break;
    }
  }
}



void setup() {
  size(1920, 1080);
  println(Serial.list());   // prints out the serial ports available
  port = new Serial(this, Serial.list()[0], 9600);// change to correct com port(1) which is displayed by the previous line
  background(0);        // color of the backround      
  frameRate(10);         
  for (int i = 0; i < years; i++) {
    for (int j = 0; j < weeks; j++) {
      for (int k = 0; k < days; k++) {
        for (int l = 0; l < hours; l++) {       
          //  for (int m = 0; j < halfhours; m++) {       
          userTempArray[i][j][k][l] = 0;
          // }
        }
      }
    }
  }
  


}

void draw() {
  background(#000000);  //Make the background black
  textFont(g);  //Set the font
  fill(#ffffff);  // Set the forground color white
  text("user input:", 820, 540);
  text("(c)", 1265, 540);
  text("temperature:", 747, 740);
  text("(c)", 1265, 740);
  textFont(f);  //Set the font
  fill((255+((cels-temp)*multi)), (255-((cels-temp)*multi)), (255-((cels-temp)*multi))); 
  text(cels, 1120, 540);
  fill((255-((cels-temp)*multi)), (255+((cels-temp)*multi)), (255+((cels-temp)*multi)));
  text(temp, 1120, 740);

  //time
  fill(255);
  String g = str(year())+"/"+str(month())+"/"+str(day())+"_"+str(hour())+":"+str(minute())+":"+str(second());
  text (g, 150, 250);

  //TIMING
  //take time all at once to avoid timing errors
  int secondtracker = second();
  int minutetracker = minute();
  int hourtracker = hour();
  
  //TEMPERATURE
  //UI simulating temperature change
  //********COMMENT OUT for final************
  if (frameCount%30==0)                      //take frame count, divide by 30 (3 seconds), when remainder == 0, execute
  {
    if (cels > temp){
      temp++;
    }
    if (cels < temp){
      temp--;
    }
    if (frameCount%60==0){
      if (cels == temp)
      {
        if (temp < 20)
        {
          temp--;
        }
        if (temp > 20)
        {
          temp++;
        }
     }
   }
  }
   
//LOG
//every 58 seconds, take current usertemp
  if (frameCount%580==0)
  {
    hourlog[minutetracker] = cels;
    int minutestemp = hourlog[minutetracker];
    println(hour()+":"+minute()+"'s user temp is *"+minutestemp+"* degrees celsius");
  }
  
//HOURLY
//at XX:59:56, average data in hourly log, dump to userTempArray, clear hourly log
  if (minute() == 59 && second() == 56)                                       //at XX:59:56
  {
    float average = 0;                                                        //set average to 0 (clear)
    for ( int i = 0; i < hourlog.length; ++i )                                //add all values in hourlog[]
      {
      average += hourlog[i]; 
      } 
    average /= (float)(hourlog.length);                                       //set average to above sum divided by length of hourlog[]
    userTempArray[0][0][0][hourtracker] = average;                            //assign average to userTempArray for it's respective hour
    println( hour()+"'s average user temp "+average );
    delay(1001);                                                              //delay 1s so XX:59:56 cannot reoccur until next hour
    for ( int i = 0; i < hourlog.length; ++i )                                //clear hourlog[
      {
      hourlog[i] = 0; 
      } 
  }

//DAILY
//at 23:59:58 take 
  if (hour() == 23 && minute() == 59 && second() == 58)
  {
    for (int i = 6; i > 0; i--)
    {
      for (int j = 23; j >= 0; j--)
      {
        userTempArray[0][0][i][j] = userTempArray[0][0][i-1][j-1];
      }
    }
    for (int i = 0; i < 24; i++)
    {
      userTempArray[0][0][0][i] = 0;
    }
    delay(1001);
  }
      
  //END
}

Sunday, November 6, 2011

036_arduino+grasshopper

3 tutorials selected for their relevance to our project:
1. Light sensor controlling LED (replace light sensor with temp sensor, LED with relay(heater)
2. Temp sensor (making sense of the analog signal input to the arduino)
3. Relay: good first step for our beefier 30A 120V relays



Lastly a small bonus, firefly/grasshopper(rhino) talking to Arduino!



CIRC-09





CIRC-10





CIRC-11





Grasshopper/Firefly: potientiometer controlling servo

Tuesday, November 1, 2011

034_fucknut_politburo_thisyear'sharvest

We have been rechristened.

Data taken from here.

Week 9

Total time spent.................46:43
Time spent in meetings.........15:58
% in meetings...................34.22%
Avg time/person...................7:47

..........................Hours worked.........Hours in group meetings...........Group meeting/individual work
Ted.........................7:00..............................0:00..................................................0%
Payton.....................4:20..............................4:20.................................................100%
Micaela....................4:10..............................3:25..................................................82%
Maria.......................5:30.............................5:30.................................................100%
Jingyao....................13:15.............................2:00.................................................15%
Alexander.................12:28.............................0:43..................................................6%




Monday 8PM


Monday 11PM


Tusday 11AM


Next year's harvest will be even more impressive than last, comrades!

Saturday, October 29, 2011

033_idealhouse_sineroof


  • Start with two ellipses, adjust their major/minor axes
  • Divide both ellipses into N1 points
    • Decompose points into X, Y and Z coordinates
    • Take the domain of the curves and run it through a sine function
    • Create new points that take the old X, Y, and add (a potentially negative number) the result of the sine function into the Z coordinate.
  • Draw lines between the points that belong to the inside and outside ellipses
  • Count the number of lines
    • Create a list of booleans which is number of lines - N2, TRUE and N2 False
    • Shift list of booleans by N3, wrapping on
    • Cull the list of lines by booleans
  • Decompose remaining lines into start(P1) and end(P2) points
    • Compare start and end points Z coordinate
      • If Z1 > Z2 then draw SDL (start, direction, length) line of N4 length along vector P1->P2
      • Else draw SDL line of N4 Length along vector P2->P1
    • Decompose P2 into XYZ coordinates, make new point using P2 XY and P1 Z
      • Create unit vector between P1 and P2b
      • rotate vector .5pi radians
      • set amplitude to N5
  • Extrude SDL lines by respective vectors