Solar Tracking Using Arduino and Modified DisEqC Rotor
by anil8tor in Workshop > Energy
10477 Views, 150 Favorites, 0 Comments
Solar Tracking Using Arduino and Modified DisEqC Rotor
Searching for a reliable method to keep my solar Garage Heater pointed at the sun, ;
https://www.instructables.com/id/Solar-Heater-for-M...
After receiving some great advice from fellow Instructableites, and some good leads on tracking projects, (Thanks German_MX) ,I was able to modify my DisEqC rotor for control and tracking.
Modify the DisEqC Rotor
I tried various ways to connect to the existing logic board in the rotor without success. I then removed all the electronic components, except the potentiometer. I then soldered power leads on the motor and connected a couple wires to the Pot outputs.
Adding a Pair of Photo-resistors
Next I soldered a couple Photo-Resistors to some perf board, added a 10K resistor to ground and the Vcc to the +5 volt terminal on the Arduino. A signal wire runs from the photo-cell side of the 10K resistor on each cell to an analog input. The two photo-cell/resistors were then mounted in holes drilled in a water-prof aluminum project box, looking out through the holes. I used silicone adhesive to mount the small boards to the inside of the box, and also to mount a piece of plexiglass covering both holes on the outside. A 1/4 inch grommet surrounds the 3.5 ft section of Cat5 cable I used to connect to the rotor box.
Testing...Testing...1,2,3....
I connected the motor control board to the motor and the Arduino. Connected the Pot from the rotor to an analog input on the Arduino and the +5 output on the motor control board. Then I temporarily taped the box lid with the photo-cells to the output shaft on the rotor. And made sure everything worked electronically, and mechanically. Then I moved on to the code.
Writing Code to Make It All Work.
I then set about looking at examples of solar tracking code for the Arduino. I found several, but none that worked exactly the way I needed. So I decided I would have to take what I had learned and write it myself. So I then found myself enthusiastically staring at the flashing cursor in a blank sketch. I tried many of the thing I had learned, and many more... time passes...the seasons change...Okay, really after a few days I had a functional program to control the rotor based on the amount of light each sensor was "seeing".
This Is a Bit Sketch-y
I plan to mount the whole business this weekend, but by all indications it should work fine. Here is what I came up with for the Arduino code :
/*
This code is written to use a L298 bridge IC based motor control board connected to and Arduino and a modified DisEqC rotor to trac the sun for a solar heater. Code snippets were pulled from several sorces in the public domaine, and some original written by myself. Please feel free to use modify and disrubute freely. By David Jackson 10/27/2016 *
/ connect motor controller pins to Arduino digital pins // motor one const int pwm = 10 ; //initializing pin 10 as pwm const int in1 = 9 ; const int in2 = 8 ;
int potpin = 3; // analog pin used to connect the potentiometer int pos; // variable to read the value from the analog pin
void setup() { // set all the motor control pins to outputs pinMode(pwm, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pos = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) pos= map(pos, 0, 1023, 0, 180); } //int pos = 0; // Variable to store the motor position. int inputPhotoLeft = 1; // Photo resistor left to analog pin 1 on arduino int inputPhotoRight = 0;// Photo resistor right to analog pin 0 on arduino
int Left = 0; // Store readings from the photoresistors. int Right = 1; // Store readings from the photoresistors.
void loop() { Serial.begin(9600);
// Reads the values from the photoresistors to the Left and Right variables. Left = analogRead(inputPhotoLeft); Right = analogRead(inputPhotoRight); Serial.println(Left); Serial.println(Right);
// Checks if left is greater than right, if so move to left. if (Left > (Right +20)) // +20 is the deadzone, so it wont hunt back and forth. { if (pos < 179) pos++; digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(pwm,255) ; //sets speed of motor at max (0-255) }
// Checks if right is greater than left, if so move to right. if (Right > (Left +20)) // +20 is the deadzone, so it wont hunt back and forth. { if (pos > 1) pos -= 1; digitalWrite(in1, LOW); digitalWrite(in2, HIGH); analogWrite(pwm,255) ; //sets speed of motor at max (0-255) }
// Added some delay, Change for your needs delay(10); digitalWrite(in1, LOW); digitalWrite(in2, LOW); // Turns the motor off when all is = }