PDA

View Full Version : Solar Tracker Controller



dirtbiker5627
- 1st June 2010, 22:13
I am working on a single axis solar tracker but I am having trouble adding hysteresis to my project. I am using a PIC16F688.


' * 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

mackrackit
- 1st June 2010, 22:22
You might try pulling a few samples then average them before acting. It will make up for the stray cloud.

tenaja
- 1st June 2010, 22:30
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.

dirtbiker5627
- 2nd June 2010, 03:43
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.

mackrackit
- 2nd June 2010, 04:09
You could think telescope.
Every minute so many steps on an encoder.
The sun is pretty predictable :)

ardhuru
- 2nd June 2010, 05:58
Also, perhaps a larger than usual capacitor on the ADC pin would make it slower to react to minor, quick fluctuations.

Regards,

Anand

Ioannis
- 2nd June 2010, 08:19
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