Tuesday, October 19, 2010

Week 5

After the critique of our week 4 solar tracker we decided to focus more on the 2-axis tracker itself and not its application. This resulted in a redesign of the solar tracking mechanism with inspiration coming from the eye. As light enters the eye, it is concentrated to a point where it comes into contact with the retina. The biomimicry aspect of our device comes from how the solar tracker receives the signal to move. Similar to an eye, the light comes through a pinhole and contacts the sensor array (similar to rods and cones in a eye). The light is then read as a number and the device responds by moving towards it. 


 The device consists of a sphere (the eye) fixed at two points to a turntable so it can rotate freely. An arc of pegs (the mohawk) is attached to the bottom of the sphere and meshes with a gear (powered by a servo) that rotates the eye. The image below shows the preliminary sketches for the movement mechanism of our solar tracker.The gear/mohawk mechanism is then attached to another servo that allows the whole eye to rotate on the xy plane by moving  the turntable. The second image is a photograph of one of the joints connecting the turntable and the xy plane servo. The slit in the bar allows the system to adjust in height small amounts to prevent the servo from lifting the lid off the device. 

Below is a video of the partially constructed device that allows you to see the movement on both the xy and yz planes. 


This is an image of our fully functional two-axis solar tracking device. When the pin hole has oriented with a light source, the green led indicator light comes on  and is visible through the front of the acrylic case. 


This is the code used for operating the servos to track a light source. It is very similar to the one used last week but with the light values mapped to 1050 to account for one of the photoresistors being a different type and reading a much higher value.



#include <Servo.h>

Servo zyplane; //servo attached to the base servo rotates on the zy plane (around x axis)
Servo xyplane;
int pos = 90;
int pos2 = 90;

//PhotoResistors (these are all analog pins)
int photo1 = 0; 
int photo2 = 1;
int photo3 = 2;
int photo4 = 3;
int photo5 = 4;

//alignment indicator LED (this is a digital PWM pin)
int ledPin = 5;  

void setup()
{
  pinMode(ledPin, OUTPUT); //sets the led pin to output
  pinMode(photo1, INPUT);
  pinMode(photo2, INPUT);
  pinMode(photo3, INPUT);
  pinMode(photo4, INPUT);
  pinMode(photo5, INPUT);

  zyplane.attach(10);// attach the pin 10 servo to servo object
  xyplane.attach(9);
  Serial.begin(9600); // use the serial port
}

void loop()
{
 //--------------------gives a value for each photoresistor------------------------------
 int light1 = analogRead(photo1); //Read the lightlevel
 light1 = map(light1, 0, 900, 0, 1050); //adjust the value 0 to 900 to span 0 to 1050
 light1 = constrain(light1, 0, 1050);//make sure the value is between 0 and 1050
  
 int light2 = analogRead(photo2); //Read the lightlevel
 light2 = map(light2, 0, 900, 0, 1050); //adjust the value 0 to 900 to span 0 to 1050
 light2 = constrain(light2, 0, 1050);//make sure the value is between 0 and 1050


 int light3 = analogRead(photo3); //Read the lightlevel

 Serial.println(light3);

 int light4 = analogRead(photo4); //Read the lightlevel
 light4 = map(light4, 0, 900, 0, 1050); //adjust the value 0 to 900 to span 0 to 1050
 light4 = constrain(light4, 0, 1050);//make sure the value is between 0 and 255


 int light5 = analogRead(photo5); //Read the lightlevel
 light5 = map(light5, 0, 900, 0, 1050); //adjust the value 0 to 900 to span 0 to 1050
 light5 = constrain(light5, 0, 1050);//make sure the value is between 0 and 1050



//----------------------------------operates xyplane servo---------------------------------//

  if (light1>light3 && light1>light5  && light1>light4  && light1>light2 && pos!=180 ){
      xyplane.write(pos);
  delay(100);
  pos ++;
  }
    
  if (light3>light1 && light3>light5  && light3>light4  && light3>light2 && pos!= 0  ){
      xyplane.write(pos);
  delay(100);
  pos --;
}
//-------------------------------operates zyplane servo----------------------------------------
   //zyplane.attach(10);// attach the pin 10 servo to servo object
  
  if (light2>light4 && light2>light5  && light2>light3  && light2>light1 && pos2!=180 ){ 
  zyplane.write(pos2);
  delay(100);
  pos2 --;
  }
  
  if(light4>light2 && light4>light5  && light4>light1  && light4>light3 && pos2 != 0){
  zyplane.write(pos2); //goes to the position
  delay(100); //this gives the servo time to move
  pos2 ++;
}



//---------------------------operates LED alignment indicator--------------------------------------

 if (light5>light1 && light5>light2 && light5>light3 && light5>light4){

  digitalWrite(ledPin, HIGH);
 }
  else{ 
    digitalWrite(ledPin, LOW);
    
  }





No comments:

Post a Comment