v1 var byte 'variable v1
v2 var byte 'variable v2
v3 var byte 'variable v3
TRISA = 1 'Set all PORTA pins as inputs (Cds)
TRISB = 1 'Set all PORTB pins as outputs (limit switch)
TRISC = 0 'Set all PORTC pins as outputs (motor)
start:
pot porta.0,255,v1 'Read 1st CdS Sensor (east)
pot porta.1,255,v2 'Read 2nd CdS Sensor (west)
if v1 <= 230 then skp 'start program
if v2 > 230 then slp 'is it dark enough to sleep? (sleep mode)
skp:
if v1 = v2 then start 'If equal, do nothing
if v1 > v2 then greater 'If greater, check how much greater
if v1 < v2 then lesser 'If lesser, check how much lesser
if PORTB.1 = 0 then face_east 'limit switch1
if PORTB.2 = 0 then hold 'limit switch2
greater: 'greater routine
v3 = v1 - v2 'find the difference
if v3 > 10 then cw 'is it within the range? if not go to clockwise/ solar panel facing west
low PORTC.0 'pin portb.0 low /stopping the solar panel for moving
low PORTC.1 'pin portb.1 low / stopping the solar panel for moving
goto start 'if it is in the range,do it again
lesser: 'lesser routine
v3 = v2 - v1 'find the difference
if v3 > 10 then ccw 'is it within the range? if not got counter clockwise/solar panel facing east
low PORTC.0 'pin portb.0 low /stopping the solar panel for moving
low PORTC.1 'pin portb.1 low / stopping the solar panel for moving
goto start 'if it is in the range, do it again
slp:
low PORTC.0 'stopping the solar tracker for moving
low PORTC.1 'stopping the solar tracker for moving
sleep 1800 'sleep the system for half an hour
goto start
cw: 'Turn the sensor array clockwise
high PORTC.0 'Turn on h-bridge
pause 100 'Let it turn for a moment
goto start 'Check again
ccw: 'Turn the sensor array counter clockwise
high PORTC.1 'Turn on h-bridge
pause 100 'Let it turn a moment
goto start 'Check again
face_east: 'facing east
low PORTC.0 'pin portb.0 low /stopping the solar panel for moving
low PORTC.1 'pin portb.1 low / stopping the solar panel for moving
sleep 14400 'wait for 4 hours
high PORTC.1 'pin portb.1 high /solar panel back facing east ready for next day sun shine
pause 1000 'wait for 1 sec
goto start 'check again
hold:
low PORTC.0 'pin portb,0 low / stopping the parabolic for moving
low PORTC.1 'pin portb.1 low /
sleep 3600 'wait for 1 hour
goto start
end
WHY THIS PROGRAMMING CANNOT BE COMPILE....
WARNING - THE MICROCHIP ASSEMBLER (MPASM)ONLY ALLOW 62 CHARACTER TO BE USED FOR PATH AND FILE NAME. CURRENT LENGTH IS 68 CHARACTERS....
I DONT UNDERSTAND..... PLEASE ANYONE EXPLAIN TO ME....?
Bookmarks