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
Bookmarks