-
solar tracker controller
hello to all in the forum!
I'm new here in the forum and starter in this picbasic programming. please anyone could help me to rewrite this code.
I just added this two lines to the original code and it won't work.
the portb.0 and portb.1 connected to the H bridge.
Code:
if PORTA.1 = 0 then face_east 'limit switch1
if PORTA.2 = 0 then hold 'limit switch2
****************************************************
@ DEVICE PIC16F84,WDT_ON,PWRT_ON,PROTECT_OFF
INCLUDE "bs1defs.bas"
start:
low PORTB.0 'pin portb.0 low
low PORTB.1 'pin portb.1 low
Pot PORTB.2,255,b0 'read first cds sensor
pot PORTB.3,255,b1 'read second cds sensor
if b0 = b1 then start 'if equal do nothing
if b0 > b1 then greater 'if greater, check how much greater
if b0 < b1 then lesser 'if lesser, check how much lesser
if PORTA.1 = 0 then face_east 'limit switch1
if PORTA.2 = 0 then hold 'limit switch2
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
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
goto start 'if it is in the range, do it again
cw: 'turn the motor shaft clockwise / solar panel facing west
high PORTB.0 'pin portb.0 high / facing west
pause 100 'let it turn for the moment
goto start 'check again
ccw: 'turn the motor shaft counter clockwise/ solar panel facing east
high PORTB.1 'pin portb.1 high/ solar panel facing east
pause 100 'let it turn for the moment
goto start 'check again
face_east: '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
sleep 14400 'wait for 4 hours
high PORTB.1 'pin portb.1 high /solar panel back facing east ready for next day sun shine
sound PORTB.4,[124,12000] 'tone
pause 1000 'wait for 1 sec
goto start 'check again
hold: '
low PORTB.0 'pin portb,0 low / stopping the solar panel for moving
low PORTB.1 'pin portb.1 low / ----- do ----
sleep 3600 'wait for 1 hour
goto start 'check again
end
'Copied from pic microcontroller project book by John Iovine
-
For starters CIRE what is the code not doing? Next, what are the settings for PORTA? Input or Output?
Dave Purola,
-
solar tracker controller
hello Dave!
The PortA.1 and PortA.2 is the input which is connect to a limit
switch. Pulled up by 10 Kilo ohms, when PortA.2 is in 0/ground, it should be stop. After 4 hrs. it will turn back to original position(panel facing east). PortA.1 is also a limit switch,on reverse function. The original title of this code is Light tracker and it's working well, when I added the line . won't work anymore.
" if PORTA.1 = 0 then face_east 'limit switch1"
" if PORTA.2 = 0 then hold 'limit switch2 "
Yes, the code compiled in Picbasic Pro 2.44
-
Gday CIRE
One possible problem and one definite.
...................
Pot PORTB.2,255,b0 'read first cds sensor
pot PORTB.3,255,b1 'read second cds sensor
if b0 = b1 then start 'if equal do nothing
if b0 > b1 then greater 'if greater, check how much greater
if b0 < b1 then lesser 'if lesser, check how much lesser
if PORTA.1 = 0 then face_east 'limit switch1
if PORTA.2 = 0 then hold 'limit switch2
.......................
1) possible
in yr above code, if bo=b1 you will loop endlessly. Try getting an LCD to output the actual bo and b1 values, to see what you are actually getting
2) definite
The three "if B0.. " lines cover all options, and result in branches to other labels in the program
as such the two lines you added can never be reached and therefore will never be executed. Hence have no effect on basic program you started with.
Andrew
-
1 Attachment(s)
solar tracker controller
Hello there Andrew!
Thank you for your response and I am tried to get the idea.Well
I have 1 week to go for the coming 2m & 70cm DXing contest. Enclosed the schematic diagram. Surely when I turn to 60yrs. I'm
expert in this like the others and you,hi hi hi.
-
Gday Cire
60? whats that.
Looking at yr diag, i assume the limit switches are used to set the amount of travel for the tracker.
So operation would be
start pointing east
track sun during day
when hit west limit switch stop tracking and wait for sun to go down
quickly slew back to east until hit east limit switch
wait until light again
repeat process
if this is the case i would do this
move the new call to stop tracking so it is checked before anything else
delete the other call to "hold" routine
................
start:
low PORTB.0 'pin portb.0 low
low PORTB.1 'pin portb.1 low
if PORTA.1 = 0 then face_east 'limit switch1 <- move to here
Pot PORTB.2,255,b0 'read first cds sensor
pot PORTB.3,255,b1 'read second cds sensor
................
modify new routines
face_east: '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
sleep 14400 'wait for 4 hours
high PORTB.1 'pin portb.1 high /solar panel back facing east ready for next day sun shine
'Add this next bit to wait until east limit switch closes
' dont go back to start, do all here
hitsw:
if PORTA.2 = 1 then hitsw 'loop until you have hit the switch
'note, now use = 1, ie while sw is open, just keep slewing until it closes
low PORTB.0 'pin portb,0 low / stopping the solar panel for moving
low PORTB.1 'pin portb.1 low / ----- do ----
sound PORTB.4,[124,12000] 'tone
sleep 3600 'wait for 1 hour
goto start 'check again
end
Andrew
-
Solar tracker controller
Hello Andrew!
60yrs? Hmmm.. When I reach 60 years old, might be an expert on this field like the others and you!
You got the idea on two limit switch'coz the Solar Panel frame I've made is limit to 45 degrees east and 45 degrees west.
Disregarding the
"if b0 = b1 then start 'if equal do nothing
if b0 > b1 then greater 'if greater, check how much greater
if b0 < b1 then lesser 'if lesser, check how much lesser
and other supporting lines will turn the motor on high speed
back and fort direction. The idea of like "SUN Flower" makes no sense at all. What do you think? (pardon my bad english)
-
Hi all,
I m a new member... and i m now doing a same project too... named "PIC microcontroller solar tracker"... Does anyone has the circuit or schemetic of the solar tracker?? and some explanation of the circuit?? i need that badly... Thx... :D
Regards,
Ultimate Killing Machine
-
Re: solar tracker controller
hello
can anyone check my proramming
i am doing the same project.....
solar tracker
pic 16f877
2cds with dc motor
Code:
v1 var byte 'variable v1
v2 var byte 'variable v2
v3 var byte 'variable v3
TRISA = 1 'Set all PORTA pins as inputs
TRISc = 0 'Set all PORTc pins as outputs
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
greater: 'Greater routine
v3 = v1 - v2 'Find the difference
if v3 > 10 then cw 'Is it within range? If not, go to cw
goto start 'In range do again
lesser: 'Lesser routine
v3 = v2 - v1 'Find the difference
if v3 > 10 then ccw 'Is it within range? If not, go to ccw
goto start 'Do again
slp:
low portc.0 'stopping the solar tracker for moving
low portc.1 'stopping the solar tracker for moving
goto start
cw: 'Turn the sensor array clockwise
high portc.o '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
end
-
Re: solar tracker controller
Muzakyo, I don't see where the motor is commanded to stop.. Must operate like a windshield wiper unless it's asleep?
Dave Purola,
N8NTA
-
Re: solar tracker controller
i am a newbie in pic......
but from the proramming the motor will run for a certain time (100 miliseconds) and then it will get back in the start loop....
for the motor i am not sure.... but when i compile it there are no problems.
did i need to do like the slp: programming..?
for this program i refer to the pic microcontroller project book by John Iovine and pic robotic : a beginner's guide to robotic by john iovine... (first post)
-
Re: solar tracker controller
muzakyo, I don't see anywhere in your code that you are stopping the motor if your system is "on target". You need to place some kind of DEAD BAND limits that are within the ON TARGET criteria. I mean +- so many counts... You should have at least 4 states, 1 for sleep (waiting for next morning), 1 for going east, 1 for going west and 1 for stop during the day when system is on target.
Dave Purola,
N8NTA
-
Re: solar tracker controller
sorry my lack of knowledge....
for the system when the system are on the target is
skp:
if v1 = v2 then start 'If equal, do nothing
it will go back to the start..... then it will never give output to the motor (so motor will not rotate anywhere) until one of the cds value higher than other.
so to stop the motor when it run
cw: 'Turn the sensor array clockwise
high portc.0 'Turn on h-bridge
pause 100 'Let it turn for a moment
low portc.0 'turn off the h-bridge
goto start 'Check again
what do u think....
can u give idea how to improve this proramming
-
Re: solar tracker controller
muzakyo, Yes that is more resonable.... Just don't forget to do the same for the other direction as well...
Dave Purola,
N8NTA
-
1 Attachment(s)
Re: solar tracker controller
muzakyo, I found this .txt file I saved from a couple of years ago. I thought you might be interested because it looks like the same code you are trying to use but has been modified since your version.... Enjoy...
-
Re: solar tracker controller
Hmm, I took a look at the code, but see no check to stop the motors when in a balance of the sensors (if they were moving).
Maybe this will help:
Code:
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
This is an idea, not tested.
Ioannis
-
Re: solar tracker controller
Ioannis , The line begining with "Start", the first thing the program goes is disable the motor outputs.....
Dave Purola,
N8NTA
-
Re: solar tracker controller
Ooops yes. You are right.
On the other hand, 100ms isn't too litlte for a motor to start and move the panel?
Ioannis
-
Re: solar tracker controller
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
-
Re: solar tracker controller
"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 ....
-
Re: solar tracker controller
Quote:
Originally Posted by
muzakyo
"so what the suitable timing for the pause...?
Well, I personally leave the motor on untill the sensors are indicating that there is no more indifference. I also start a timer each time the motors are started and check it for a timeout condition.
-
Re: solar tracker controller
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
-
Re: solar tracker controller
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....?
-
Re: solar tracker controller
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
-
Re: solar tracker controller
Quote:
Originally Posted by
Dave
muzakyo, I found this .txt file I saved from a couple of years ago. I thought you might be interested because it looks like the same code you are trying to use but has been modified since your version.... Enjoy...
what programme did you use ?! micopaskal ?! or what ?! thanks !
-
Re: solar tracker controller
I hope you realize that your motors will only be powered by 4.3V or so, even though your source is 12V. The PIC will put out a maximum of 5V from its output pins, and those drive the bases of the two 'top' transistors in the bridge. The emitters will go no higher than a diode drop below the bases. If you really are using the circuit you show, your 'top' transistors are going to dissipate a lot of power, and your motor won't have much power.
-
Re: solar tracker controller
PiRaTuS, From the looks of it, it was written for a Basic Stamp.... Just my observation....
-
Re: solar tracker controller
thanks a lot , can i convert from basic stamp to mikro pascal ?!
-
Re: solar tracker controller
Quote:
Originally Posted by
Dave
muzakyo, I found this .txt file I saved from a couple of years ago. I thought you might be interested because it looks like the same code you are trying to use but has been modified since your version.... Enjoy...
im sorry , but can you hel me with this , do you have electric schematic and PCB
-
Re: solar tracker controller
My comment was referring to the schematic posted by CIRE.
-
Re: solar tracker controller
This dual axis solar dish tracker is way more than you need, but you find something useful, like a motor controller. http://www.harbornet.com/sunflower/sunrun.pbp Best, Doug
-
Re: solar tracker controller
hello can anyone uplode the programme for single axis solar controller pl...................
-
Re: solar tracker controller
-
Re: solar tracker controller
post the entire reports.....including circuit desgin and value of resistors and all plz..............(solar tracker)
-
Re: solar tracker controller
Quote:
Originally Posted by
manjunath000
post the entire reports.....including circuit desgin and value of resistors and all plz..............(solar tracker)
He does post the schematic. The resistors look to just be pull ups. Pick a good pullup value, and you should be good. Most people don't post their board drawings, but I suppose it doesn't hurt to ask :)
-
Re: solar tracker controller
Quote:
Originally Posted by
manjunath000
post the entire reports.....including circuit desgin and value of resistors and all plz..............(solar tracker)
If you read the schematic, you will see in the bottom right hand corner that all resistors are specified as 10K, 1/4 watt
-
Re: solar tracker controller
Quote:
Originally Posted by
CIRE
Hello there Andrew!
Thank you for your response and I am tried to get the idea.Well
I have 1 week to go for the coming 2m & 70cm DXing contest. Enclosed the schematic diagram. Surely when I turn to 60yrs. I'm
expert in this like the others and you,hi hi hi.
hello friend,
pls send me the code for solar panel tracking system, this is my mail id ([email protected])
-
Re: solar tracker controller
-
Re: solar tracker controller
please send the programmming codes
circuit pdf link is http://www.journalagent.com/z4/downl...un=PAJES-58538
two axis automatic solar sun tracking using pic ic and stepper motors,pleasesend program c codes
-
Re: solar tracker controller
One more and you are off the board...
Ioannis