Solar Tracker Controller


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2010
    Location
    Albuquerque
    Posts
    19

    Default Solar Tracker Controller

    I am working on a single axis solar tracker but I am having trouble adding hysteresis to my project. I am using a PIC16F688.

    Code:
    ' * James Richards *
    ' * Solar Tracker  *
    ' * 5/21/10        *
    
    '----------Configuration----------
    INTCON = $80
    ANSEL  = %00010100
    ADCON1 = %00010000
    '----------Variables--------------
    ADCVAL1 var word
    ADCVAL2 var word
    RANGE   VAR WORD
    '----------Program---------------- 
    MAIN:
         
         ADCON0 = %10001001
         
         ADCON0.1 = 1
         NOTDONE1:
         pauseus 25
         if ADCON0.1 = 1 then notdone1
         
         ADCVAL1.highbyte = ADRESH
         ADCVAL1.lowbyte  = ADRESL
         
             ADCON0 = %10010001
             
             ADCON0.1 = 1
             NOTDONE2:
             pauseus 25
             if ADCON0.1 = 1 then notdone2
             
             ADCVAL2.highbyte = ADRESH
             ADCVAL2.lowbyte  = ADRESL
    '---------------------------------
    GREATER:
    range = ADCVAL2 - adcval1
    if (RANGE > 10) then cw 
    
    LESSER:
    range = ADCVAL1 - adcval2
    if (RANGE > 10) then ccw
    
    goto stay 
    
    CCW:
    high PORTC.2
    low PORTC.3
    pause 100
    goto main
    
    CW:
    low PORTC.2
    high PORTC.3
    pause 100
    goto main
    
    STAY:
    low PORTC.2
    low PORTC.3
    goto main
         
    
         
    end

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You might try pulling a few samples then average them before acting. It will make up for the stray cloud.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Another way to add hysteresis is to require a return direction change to be greater than an advance direction. So, if your last move was to the left caused by a "1x" reading, and a cloud causes a desire to move right, require the reading to be "1.1x", so it's 10% more than the last.

  4. #4
    Join Date
    Feb 2010
    Location
    Albuquerque
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Reply

    I would also like to add a small adjustable potentiometer to adjust the hysteresis but I will add that in later. I want the tracker to adjust its position every minute but I do not want to use any extra energy overadjusting. I need it to move to a certain position but when it gets there I want it to stay within certain limits instead of doing small oscillations trying to find an exact spot.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You could think telescope.
    Every minute so many steps on an encoder.
    The sun is pretty predictable
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Also, perhaps a larger than usual capacitor on the ADC pin would make it slower to react to minor, quick fluctuations.

    Regards,

    Anand

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,810


    Did you find this post helpful? Yes | No

    Default

    I sure would place a large capacitor in this case but also an averaging routine.

    Melanie had a suggestion on an older post about having 16 samples, sort them, ged rid off the 8 values (4 top, 4 bottom) and average the rest 8. Maybe for this project this is overkill, but i.m.h.o. the best solution.

    A noise can always sneak in.

    Ioannis

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts