Shop OBEX P1 Docs P2 Docs Learn Events
Solar tracker with bs2 & ds1302 & linear actuator — Parallax Forums

Solar tracker with bs2 & ds1302 & linear actuator

adobejoeadobejoe Posts: 17
edited 2012-01-28 11:24 in BASIC Stamp
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

Comments

  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-02-07 00:06
    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· [noparse]/noparse][color=red]WrBurst[/color][color=white]·[/color]or [color=white]·[/color][color=red]RdBurst[/color
    with all of the all of the ·registers· [noparse]/noparse][color=red]secs, mins, hrs, date, month, day, year[/color

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


    Or

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

     Set_Time:                                                                    ' DS1302 Burst Write
      HIGH CS1302                                                                 ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]WrBurst]
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]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, [noparse][[/noparse]RdBurst]
      SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]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, [noparse][[/noparse]WrSecs, Wrmins Wrhrs]
    ·SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]secs ,mins, hrs]


    Or

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

    Set_Secs:                                             ' DS1302 Write Seconds
      HIGH CS1302                                         ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]WrSecs]
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]secs]
      LOW CS1302                                          ' Deselect DS1302
      RETURN
     
    Set_mins:                                             ' DS1302 Write mintues
      HIGH CS1302                                         ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]Wrmins]
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]mins]
      LOW CS1302                                          ' Deselect DS1302
      RETURN
     
    Set_Hrs:                                             ' DS1302 Write Hours
      HIGH CS1302                                        ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]WrHrs]
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]Hrs]
      LOW CS1302                                         ' Deselect DS1302
      RETURN
     
    
    Get_secs:                                           ' DS1302 Read Seconds
      HIGH CS1302                                       ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdSecs]
      SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]secs]
      LOW CS1302                                        ' Deselect DS1302
      RETURN
     
    Get_mins:                                           ' DS1302 Read Minutes
      HIGH CS1302                                       ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]Rdmins]
      SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]mins]
      LOW CS1302                                        ' Deselect DS1302
      RETURN
     
    Get_Hrs:                                           ' DS1302 Read Hours
      HIGH CS1302                                      ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdHrs]
      SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]Hrs]
      LOW CS1302                                       ' Deselect DS1302
      RETURN
    



    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 2/7/2010 12:29:10 AM GMT
  • upand_at_themupand_at_them Posts: 61
    edited 2010-02-07 00:16
    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.
  • adobejoeadobejoe Posts: 17
    edited 2010-02-07 03:30
    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
  • adobejoeadobejoe Posts: 17
    edited 2010-02-09 03:48
    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
  • Rob7Rob7 Posts: 275
    edited 2010-02-13 05:17
    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_samsam_sam_sam Posts: 2,286
    edited 2010-02-13 16:01
    ·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, [noparse][[/noparse]WrBurst]
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]secs, mins, hrs,
        date, month, day, year, 0]
      LOW CS1302                            ' Deselect DS1302
      RETURN
    



    I hope this helps

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 2/13/2010 4:18:37 PM GMT
  • adobejoeadobejoe Posts: 17
    edited 2010-02-16 03:17
    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
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-02-28 04:48
    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?
  • KievlaninKievlanin Posts: 55
    edited 2012-01-28 11:24
    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.
Sign In or Register to comment.