Vous êtes sur la page 1sur 9

2 Axis Solar Tracker

Using a sensor array and DC motors driven by relays this project will allowsolar panels to follow the sun. This project was mainly developed using the example code that comes with the Arduino Software download.

I have been developing this project for about a month now and thought I would share and hopefully get some feedback. The idea is that it will track the sun and just wait for morning to realign again. No counting steps or any other absolute positioning required. Set it up, connect it to a battery, and walk away. I have built a mock on the breadboard and successfully driven the gear motors as intended with the schematic shown below. Was hoping to get some peer review/proofing of the schematic and code before finalizing the design and committing to the actual build. Still need to incorporate battery charging circuitry and probably some fuse/overload protection also.

The un-calibrated sensor readings feed a much larger, more precise, data set to the microcontroller (as was expected). By skipping the calibration process I can remove a large layer of complexity from the design solution. The down side to this is that it is way more precise than need be. To get the sensor array I built to work correctly it needs to be within about to an 1/8 of a degree perpendicular to the sun. This will cause a large number of motor steps to keep alignment throughout the day. Great tracking performance (if you want to shoot down missiles), but poor utilization of collected solar energy. Tradeoffs are needed. Using a solar cell and a volt meter I found I need to be within about plus or minus 5 degrees of perpendicularity for best collector efficiency. Instead of trying to tweak the design parameters with the software it will be easier to alter the array to give a bit more freedom to the perpendicularity tolerance. Of Interest I was reading Wikipedia after writing the above comments and it stated that a plus minus 5 degree angle will be greater than 99.6% efficient. It turns out the rod in my eye is a pretty accurate protractor. (grin)
Code:

/* Solar Tracker (Preliminary Example Code) Uses 3 photoresistors to track the suns movement. The microcontroller evaluates the photoresistor values and drives the appropriate positioning motor for correct alignment. created 28 Jul 2012 By David A Smith modified 28 Jul 2012 By David A Smith

This code is in the public domain. */ // These constants won't change: const int sensorPinA0 = A0; // pin that the Bottom/Left sensor is attached to const int sensorPinA1 = A1; // pin that the Right sensor is attached to const int sensorPinA2 = A2; // pin that the Top sensor is attached to //const //const //const //const int int int int pmotorPinA0 pmotorPinA1 tmotorPinA0 tmotorPinA2 = = = = 11; 10; 9; 8; // pin that the pan // pin that the pan // pin that the tilt // pin that the tilt motor motor motor motor relay relay relay relay is is is is attached attached attached attached to to to to

// variables: int sensorValueA0 = 0; int sensorValueA1 = 0; int sensorValueA2 = 0;

// Bottom/Left photoresistor // Right photoresistor // Top photoresistor

int panDelay = 1000; run int tiltDelay = 1000;

// The amount of time the pan and tilt motor will // this will vary depending on motor and drive train

void setup() { // Send debugging information via the Serial monitor Serial.begin(9600); //Assign and set motor driver pins to low pinMode(11, OUTPUT); digitalWrite(11, LOW); pinMode(10, OUTPUT); digitalWrite(10, LOW); pinMode(9, OUTPUT); digitalWrite(9, LOW); pinMode(8, OUTPUT); digitalWrite(8, LOW); } void loop() { // read the sensor: sensorValueA0 = analogRead(sensorPinA0); sensorValueA1 = analogRead(sensorPinA1); sensorValueA2 = analogRead(sensorPinA2);

// Compare sensor readings and drive pan motor left or right // If the sensor values are equal (what we want) it will skip adjusting the pan motor // Pan Right if (sensorValueA0 > sensorValueA1){ digitalWrite(11, HIGH); delay(panDelay); digitalWrite(11, LOW); } // Pan Left if (sensorValueA0 < sensorValueA1){ digitalWrite(10, HIGH); delay(panDelay); digitalWrite(10, LOW); } // Compare sensor readings and drive tilt motor up or down // If the sensor values are equal (what we want) it will skip adjusting the tilt motor // Tilt Down if (sensorValueA0 > sensorValueA2){ digitalWrite(9, HIGH);

delay(tiltDelay); digitalWrite(9, LOW); } // Tilt Up if (sensorValueA0 < sensorValueA2){ digitalWrite(8, HIGH); delay(tiltDelay); digitalWrite(8, LOW); }

//Print debugging information Serial.print("Left/Bottom reading = "); Serial.println(sensorValueA0); // the left/bottom sensor analog reading Serial.print("Right reading = "); Serial.println(sensorValueA1); // the right sensor analog reading Serial.print("Top reading = "); Serial.println(sensorValueA2); // the top sensor analog reading delay(1000); }