PDA

View Full Version : Solar tracker with bs2 & ds1302 & linear actuator



adobejoe
02-06-2010, 12:38 PM
I am trying to construct a solar tracker that will rotate panels based upon time of day. Basically activate in 8 forward steps and retract at midnight. Have edited the demo program by Chris Savage, but it needs some work. I think I am on the right track, but it needs a do loop or two? This is my first attempt in a long time from programming. Like BASIC and FORTRAN in the 1980's Andy

sam_sam_sam
02-07-2010, 08:06 AM
adobejoe

Welcome to the Parallax·Forum

You have a few problem with what you have

When you use the DS1302 Time Chip you·have to· [WrBurst·or ·RdBurst]
with all of the all of the ·registers· [secs, mins, hrs, date, month, day, year]

·SHIFTOUT DataIO, Clock, LSBFIRST, [WrBurst]
· SHIFTOUT DataIO, Clock, LSBFIRST, [secs, mins, hrs,

Or

·SHIFTOUT DataIO, Clock, LSBFIRST, [RdBurst]
· SHIFTIN DataIO, Clock, LSBPRE, [secs, mins, hrs, date, month, day, year]



Set_Time: ' DS1302 Burst Write
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [WrBurst]
SHIFTOUT DataIO, Clock, LSBFIRST, [secs, mins, hrs,
date, month, day, year, 0]
LOW CS1302 ' Deselect DS1302
RETURN

Get_Time: ' DS1302 Burst Read
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [RdBurst]
SHIFTIN DataIO, Clock, LSBPRE, [secs, mins, hrs, date, month, day, year]
LOW CS1302 ' Deselect DS1302
RETURN

·Now if you just want read one or two··registers· then you have to write it this way

·SHIFTOUT DataIO, Clock, LSBFIRST, [WrSecs, Wrmins Wrhrs]
·SHIFTOUT DataIO, Clock, LSBFIRST, [secs ,mins, hrs]

Or

SHIFTOUT DataIO, Clock, LSBFIRST, [RdSecs, Rdmins, Rdhrs]
· SHIFTOUT DataIO, Clock, LSBFIRST, [secs, min, hrs]



Set_Secs: ' DS1302 Write Seconds
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [WrSecs]
SHIFTOUT DataIO, Clock, LSBFIRST, [secs]
LOW CS1302 ' Deselect DS1302
RETURN

Set_mins: ' DS1302 Write mintues
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [Wrmins]
SHIFTOUT DataIO, Clock, LSBFIRST, [mins]
LOW CS1302 ' Deselect DS1302
RETURN

Set_Hrs: ' DS1302 Write Hours
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [WrHrs]
SHIFTOUT DataIO, Clock, LSBFIRST, [Hrs]
LOW CS1302 ' Deselect DS1302
RETURN


Get_secs: ' DS1302 Read Seconds
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [RdSecs]
SHIFTIN DataIO, Clock, LSBPRE, [secs]
LOW CS1302 ' Deselect DS1302
RETURN

Get_mins: ' DS1302 Read Minutes
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [Rdmins]
SHIFTIN DataIO, Clock, LSBPRE, [mins]
LOW CS1302 ' Deselect DS1302
RETURN

Get_Hrs: ' DS1302 Read Hours
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [RdHrs]
SHIFTIN DataIO, Clock, LSBPRE, [Hrs]
LOW CS1302 ' Deselect DS1302
RETURN



·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·http://forums.parallax.com/images/smilies/idea.gif·that you may have and all of your time finding them http://forums.parallax.com/images/smilies/smile.gif

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 2/7/2010 12:29:10 AM GMT

upand_at_them
02-07-2010, 08:16 AM
It would help to do more than just post the code for somebody to go through. You don't say what is wrong, what it does, what it doesn't do.

adobejoe
02-07-2010, 11:30 AM
SAM SAM SAM, Thank you for reply, that is exactly one of the questions I was pondering was whether I need to read/write to ALL the registers even though, in theory, all I need is hours and minutes. So I will revise and kind of go from there. I know I have other questions like how to wire and construct the H bridge, but will study some more. Thanks! Andy

adobejoe
02-09-2010, 11:48 AM
Sam,

·Revised somewhat. In your attached file DS1302-Demo.bs2 I show diferrent pin assignments for Data I/O =pin 6 and Clock =pin 7 from what I find on the Maxim pin configuration chart? I am trying to place my subroutines in the order they will be executed. 1)RTC_OUT (initializatino routine) 2)Set_Time (But I think there should be a DEBUG...something here to allow keyboard input?), 3)Get_Time (the first thing executed in the DO loop), then the comparators to time to If..THEN operate my solenoid).

Andy

Rob7
02-13-2010, 01:17 PM
Sounds like a great project adobejoe.
Can you post some pic's and a schematic of your project when you get a chance ?

Rob7

sam_sam_sam
02-14-2010, 12:01 AM
·I think this is what you are looking for· try this


Start:
DO ' DEBUG Menu
DEBUG CLS ' Clear The DEBUG Screen
DEBUG CRSRXY, 0, 0, "Press 1 to Set Date/Time.", CR
DEBUG CRSRXY, 6, 1, "2 to Display Date/Time.", CR
DEBUG CRSRXY, 6, 3, "RESET Stamp to return to menu.", CR
DEBUGIN DEC1 work ' Get 1 Number
IF work = 1 THEN
GOSUB Set_Mode
GOSUB Set_Time
ELSEIF work = 2 THEN
DEBUG CLS ' Clear The DEBUG Screen
DO
GOSUB Get_Time ' Get The Current Date/Time
GOSUB Show_Time ' Display It
LOOP
ENDIF
LOOP



Set_Mode:
DEBUG CLS ' Clear The DEBUG Screen
DEBUG CRSRXY, 0, 0, "Enter 2 digit year, i.e. 05 = 2005:", CR
DEBUGIN HEX2 year ' Set Year
DEBUG CRSRXY, 0, 1, "Enter 2 digit month, i.e. 03 = March:", CR
DEBUGIN HEX2 month ' Set Month
DEBUG CRSRXY, 0, 2, "Enter 2 digit date, i.e. 02 = 2nd:", CR
DEBUGIN HEX2 date ' Set Date
DEBUG CRSRXY, 0, 3, "Enter day of the week as a number 1-7", CR
DEBUG CRSRXY, 0, 4, "1=SUN, 2=MON, 3=TUE, 4=WED, 5=THU, 6=FRI, 7=SAT", CR
DEBUGIN HEX1 day ' Set Day
DEBUG CRSRXY, 0, 5, "Enter 1 for 12 Hour Mode or 0 for 24 Hour Mode:", CR
DEBUGIN HEX1 modeFlag
IF modeFlag = 0 THEN
DEBUG CRSRXY, 0, 6, "Enter 2 digit hour, 00-23:", CR
DEBUGIN HEX2 hrs ' Set Hours (24 Hour Mode)
ELSE
DEBUG CRSRXY, 0, 6, "Enter 2 digit hour, 01-12:", CR
DEBUGIN HEX2 hrs ' Set Hours (12 Hour Mode)
DEBUG CRSRXY, 0, 7, "Enter 0 for AM, 1 for PM:", CR
DEBUGIN HEX1 ampmFlag ' Set AM/PM Flag
ENDIF
DEBUG CRSRXY, 0, 8, "Enter 2 digit minutes, 00-59:", CR
DEBUGIN HEX2 mins ' Set Minutes


Set_Time: ' DS1302 Burst Write
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [WrBurst]
SHIFTOUT DataIO, Clock, LSBFIRST, [secs, mins, hrs,
date, month, day, year, 0]
LOW CS1302 ' Deselect DS1302
RETURN


I hope this helps

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·http://forums.parallax.com/images/smilies/idea.gif·that you may have and all of your time finding them http://forums.parallax.com/images/smilies/smile.gif

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 2/13/2010 4:18:37 PM GMT

adobejoe
02-16-2010, 11:17 AM
Sam,

Okay I modified my code, but when I try to run this the very first I/O line is highlighted and I get " Expected ':' or end-of-line." So, from my manual, it mentions colons are placed after labels. I know this is probably a very simple error, and I feel my intelligence is pretty narrow. The logic I can understand in programming; the syntax is killing me. Anyway, attached is a photo of what I am trying to accomplish. Anyone familiar with tracking solar (PV) will appreciate the advantages, particularly in a windy are, like Wyoming.

Any input appreciated.

Andy

NWCCTV
02-28-2010, 12:48 PM
Just a thought, as I am new to the forum and am emjoying all the great posts. Rather than having the actuator rotate by time of day, why not put in a light array detector instead? This would enable you to progtam it amd not have to mess with it during DST and would capture the sun from the brightest location. Does this make sense?

Kievlanin
01-28-2012, 07:24 PM
It does.
However, If you have clouds, you will have falth signals.

Best to rotate by calculating sun location (for this is quite complex math involved and programming must be at high level of knowledge)

I like "adobejoe" idea. And I came to this idea also, and reviewing it as I am building mechanics for my Solar Tracker.