Ooops yes. You are right.
On the other hand, 100ms isn't too litlte for a motor to start and move the panel?
Ioannis
Ooops yes. You are right.
On the other hand, 100ms isn't too litlte for a motor to start and move the panel?
Ioannis
Ioannis, Yes I do beleive 100 milliseconds is to short of a period to operate the motor BUT, I didn't write the code... I only regergitated it from some old records I had for Muzakyo...
Dave Purola,
N8NTA
"The line begining with "Start", the first thing the program goes is disable the motor outputs....."
i think that can be apply to my proramming.... the function is just like the proramming ioannis write....
greater: 'greater routine
b2 = b0 - b1 'find the difference
if b2 > 10 then cw 'is it within the range? if not go to clockwise/ solar panel facing west
low PORTB.0 'pin portb.0 low /stopping the solar panel for moving
low PORTB.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
b2 = b1 - b0 'find the difference
if b2 > 10 then ccw 'is it within the range? if not got counter clockwise/solar panel facing east
low PORTB.0 'pin portb.0 low /stopping the solar panel for moving
low PORTB.1 'pin portb.1 low / stopping the solar panel for moving
goto start 'if it is in the range, do it again
so what the suitable timing for the pause...?
i not try it yet to the motor....
i am currently doing the circuit.... and now try to assemble the circuit with the lcd....
i need to add command for lcd in the proramming ....
i think i will follow Ioannis idea about the programming of the motor....
also such as dave said...... stop only there are indifference in Cds value.....
this is the proramming for the LCD
TRISA = 1 'Set all PORTA pins as inputs (Cds)
TRISc = 0 'Set all PORTc pins as outputs (motor)
TRISD = 0 'Set all PORTD pins as outputs (LCD)
TRISB = 1 'Set all PORTD pins as outputs (limit switch)
start:
pot porta.0,255,v1 'Read 1st CdS Sensor (east)
pot porta.1,255,v2 'Read 2nd CdS Sensor (west)
'LCD display
Serout 1,4,[254, 1] 'Clear Screen
Pause 25
Serout portd.1,1,["Cds 1 = "] 'display Cds 1 =
Serout portd.1,1,[#v1] 'display value Cds 1
Serout 1,1,[254,192] 'Move cursor to first position on second line
Pause 5
Serout portd.2,1,["Cds 2 = "] 'display Cds 2 =
Serout portd.2,1,[#v2] 'display value Cds 1
Pause 100 'display the Cds value for a little time
my problems is there are 4 output for the lcd so i dont know where to put this programming that only have two output.....?
detail lcd
16 x 2 characters LCD display
With yellow backlight
Built in controller (HD44780 or equivalent)
http://www.cytron.com.my/usr_attachm..._Schematic.pdf
Last edited by muzakyo; - 4th March 2011 at 17:19.
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....?
Maybe you have not noticed but you CAPs lock seems to be stuck on.
The waring message means exactly what it says.
Move you project directory closer to the root of the drive so there are less than 62 characters between "C" and the end of your file name.
C:\myProject\xxx.bas
Dave
Always wear safety glasses while programming.
Bookmarks