microcontroller based solar panel tracking system

Discussion in 'The Projects Forum' started by taiyos, May 21, 2011.

  1. taiyos

    taiyos Thread Starter New Member

    Joined:
    May 21, 2011
    Messages:
    5
    hi

    am working on micro controller based solar panel tracker and am using the pic 16F877A micro controller. am writing the program using HI TECH C compiler.i have a problem on how to program the micro controller to control the stepper motor.the micro controller should drive the motor clockwise and counter one step at a time according to the sensed value from the light sensors.
  2. beenthere

    beenthere Retired Moderator

    Joined:
    Apr 20, 2004
    Messages:
    15,815
    Location:
    Missouri, USA (GMT -6)
    Here is some good material to get you started - http://www.cs.uiowa.edu/~jones/step/

    Another thing you might want to consider is what sensors to use, how many of them, and how to interface them to your PIC.
  3. taiyos

    taiyos Thread Starter New Member

    Joined:
    May 21, 2011
    Messages:
    5
    i have selected the sensors n i have almost finished the hardware design part.what i have doubt is on the programming.the controller should be able to sleep during night and wake up in the morning by it self in order to save power. n driving the stepper motor one step at a time clockwise and counter.
  4. GetDeviceInfo

    GetDeviceInfo Senior Member

    Joined:
    Jun 7, 2009
    Messages:
    1,503
    Location:
    Canada
    there are a couple of approaches to this, but you should answer first, are you looking to obtain maximum power to charge a battery. A closed loop tracking system will consume power continously during seek times. An option is for you to calculate the steps/degrees of sweep, and wake the system up at timed intervals to do a step. That way you don't have to worry about the system hunting and using unnecessary energy.

    Your program would then be something simple;
    - at dusk, or a specific time (think RTC interrupt), sweep to home (sunrise), configure RTC for next interrupt, sleep.
    - on timed interrupt, step stepper, configure RTC for next interrupt, sleep.

    Often in such implementations, a chart based data set can be employed to accomodate non linear sweeps.
  5. THE_RB

    THE_RB AAC Fanatic!

    Joined:
    Feb 11, 2008
    Messages:
    5,435
    A stepper motor is a poor choice at it consumes huge amounts of power when stopped or going slow, compared to a DC motor that consumes nothing when stopped and very little when PWM'ed to go slow.

    You can get around hunting by using a forward-only algorithm, with 2 sensors when the sun is forward it will only turn forward a bit until the sensors match then go back into sleep mode.

    If you periodically exit sleep and check (say every 5 minutes) you get a known period so the sun must have moved a known amount, so the solar panel will always move the same amount each period but also will always be phase locked to the sun's position.

    Then at night you can turn the array back to east, at the speed that found to be most energy efficient with your motor and load.
    Last edited: May 25, 2011
  6. GetDeviceInfo

    GetDeviceInfo Senior Member

    Joined:
    Jun 7, 2009
    Messages:
    1,503
    Location:
    Canada
    I wouldn't agree with your assessment of stepper over non. Steppers can have much better holding torque when non powered, compared to a DC motor. But non the less, your mention of it brings some consideration. A panel in the breeze may need better holding torque than provided by either alone, suggesting a worm gear as a possible solution.
  7. blueroomelectronics

    blueroomelectronics Senior Member

    Joined:
    Jul 22, 2007
    Messages:
    1,704
    Location:
    Toronto, Canada
    Good suggestion.
    PS to OP, the Suns position can be determined mathematically based on time, date, long & lat... I believe it's called a Heliostat No need for sensors just an accurate RTCC with alarm (DS1307 is popular). Just a thought.
  8. radiohead

    radiohead Active Member

    Joined:
    May 28, 2009
    Messages:
    457
    Location:
    United States
  9. THE_RB

    THE_RB AAC Fanatic!

    Joined:
    Feb 11, 2008
    Messages:
    5,435
    Ah ok, thanks for that, I missed that idea entirely that the stepper motor might be turned completely off between moves. That is very unusual in most stepper operated systems but could work fine, it is likely to have heaps of gearing probably including a worm drive so backdriving should not be a problem with either type of motor.

    And I would still expect a PWM DC motor to be significantly more energy efficient when actually moving than a stepper.

    I think the key is to choose between a light sensor closed-loop system or a stepper (dc motor encoder?) open loop system that mathematically "knows" where the sun is.

    Two light sensor is simple, self correcting and allows a very low power intermittant DC motor system, I like that combination. If you use a microcontroller to cover it's flaws like possible hunting, and to do sensor dirt testing etc it's a good solution.
  10. strantor

    strantor Well-Known Member

    Joined:
    Oct 3, 2010
    Messages:
    3,647
    Location:
    Houston tx
    +1

    I was looking into making a solar panel sun tracking system with an arduino last year and found that the light sensor type approach is prone to all kinds of problems, like clouds moving, light reflections from other things, sensors becoming dirty, etc. . The best way to go about it is to calculate the Azimuth of the sun. I know that the program is out there already written for Arduino but I'm sure you could find it for PIC also. How it works is that the sun moves through the sky in a predictable pattern all year long, and with a little math your PIC can calclute exactly where the sun is, even if there's an eclipse. You just have to tell it where its (GPS coordinates, elevation), and what time it is. You can get snazzy and put a GPS unit on it, so that it will work automatically wherever you transplant it to, or if it will remain in a fixed loaction, you can just include the coordinates in your code. You will need a real time clock ic also. try googling azimuth and heliostat.
  11. taiyos

    taiyos Thread Starter New Member

    Joined:
    May 21, 2011
    Messages:
    5
    thank you all of you ,for your advices

    at this time i cannot change the design i mean the stepper or the sensors ....,cause i have to submit the final report soon.so if u can concentrate your advices on what i have to do on the existing design it would be much better.and can i make the micro sleep and wake up any time i want for a definite period?any body who know the hi tech c compiler syntax,would you give me the code....and i have some problems on the delay routine.

    thank you;
  12. THE_RB

    THE_RB AAC Fanatic!

    Joined:
    Feb 11, 2008
    Messages:
    5,435
    That's where the PIC can cover the flaws of a sensor system. It knows roughly how many degrees per hour the sun moves through, and can move to a "close enough" position after each 5 minute sleep cycle. Then feedback from the 2 sensors allows a small extra movement. It will phase lock to the sun with no problems, but in case of a bad sensor reading it will still be within a degree or so of the perfect location.

    The big benefit is that it does not need to know what time of day it is or what day of the year it is.

    Thta is a big drawback needing a real time clock that is always correct. Sure a GPS clock will solve that nicely, but at quite a cost and might be delicate in an external environment.

    You can probably leave the PIC running as it only uses a couple of mA. Then generate the timed period using a timer interrupt. That will make a very accurate 1 second period;

    Code:
      // C code for a 1 second period with a 1MHz timer (4MHz xtal); 
      // uses 1 variable; unsigned long bres
      // gets here every TMR0 int (every 256 ticks)
    
      bres += 256;// add 256 ticks to bresenham total
    
      if(bres >= 1000000)// if reached 1 second!
      {
        bres -= 1000000;// subtract 1 second, retain error
        do_1sec_event();// update clock, etc
      }
    
    You can use that code in your TMR0 interrupt that occurs every 256uS.

    Suggestion on solar tracking algorithm;
    (sun moves 360' per day or 15' per hour, that is about 1.25' every 5 minutes)
    1. every 5 minutes move 1.1 degrees (leaves 0.15 degrees error).
    2. check sensors, if west>east move another 0.3 degrees.

    The result is that every 5 minutes it will move either 1.1 degrees or 1.4 degrees, and the input from the sensors will keep it phase locked to the sun.

    Anyway, that is a starting point.
  13. taiyos

    taiyos Thread Starter New Member

    Joined:
    May 21, 2011
    Messages:
    5
    how can i wake up a pic micro from sleep?
    i mean when the sun rises in the morning.
  14. russpatterson

    russpatterson Member

    Joined:
    Feb 1, 2010
    Messages:
    351
    Location:
    Carlsbad, California
    Only put the PIC to sleep for five minutes at a time (or something like that). On wake-up, check if the Sun's shining. If not, go back to sleep for five minutes. Your PIC will only be running for a total of a few seconds per night and use very little power.
  15. GetDeviceInfo

    GetDeviceInfo Senior Member

    Joined:
    Jun 7, 2009
    Messages:
    1,503
    Location:
    Canada
    or, run your sensors through a window comparator which interrupts the micro when west angled sensor excedes east angled sensor, then step until comparator flips back.
  16. taiyos

    taiyos Thread Starter New Member

    Joined:
    May 21, 2011
    Messages:
    5
    i have tried the comparator method but i coudnt wake the micro up....,i don know may be the error is on the code.so do u have any suggestion. i was writing the code in ccs c language.
Similar Threads
Forum Title Date
The Projects Forum microcontroller based power factor controller Mar 24, 2013
The Projects Forum build a battery charger and microcontroller based battery level indicator Dec 5, 2012
The Projects Forum Microcontroller based power supplies Sep 8, 2012
The Projects Forum Microcontroller Based Smoke Detector May 26, 2012
The Projects Forum Microcontroller based PFC May 26, 2011

Related Site Pages

Section Title
Worksheet Stepper motors
Textbook Stepper motors : Ac Motors

Share This Page