Shop OBEX P1 Docs P2 Docs Learn Events
help with project — Parallax Forums

help with project

ryan4385ryan4385 Posts: 17
edited 2010-02-28 03:47 in BASIC Stamp
i am designing a program that will close the garage door after 10 minutes. I have that part of the program done but would like to modify it so that if a switch is close that is disable the program but will not override the alarm clock part of the program using ds1302 and can show parts of the program on the lcd screen. Also if is possiable to always display the temperature not require

thank you for any help

Ryan

Post Edited (ryan4385) : 2/25/2010 4:45:42 AM GMT

Comments

  • JDJD Posts: 570
    edited 2010-02-25 01:11
    Ryan,

    A few questions; what is or is not working in the program that you have attached with the RTC program you want to merge.·Can you upload the entire program you want to use? The reason I ask, is that it's easier to offer suggestions when we have all the pieces.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • ryan4385ryan4385 Posts: 17
    edited 2010-02-27 21:50
    anyone got any suggestion?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-27 22:05
    You've already gotten help from Joshua. My suggestion is to do what he asked.
  • FranklinFranklin Posts: 4,747
    edited 2010-02-28 03:27
    Write code to do this:
    IF switch = open
    DoThis
    endif
    rest of your code

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-02-28 03:47
    See If you can get this to work· this ·should help you do what you want to

    ·
    ' =========================================================================
    '
    '   File...... DS1302_Counter_Demo.bs2
    '   Purpose... Demonstrate The DS1302 Clock & RAM Functions
    '   Author.... Chris Savage -- Parallax, Inc.
    '   E-mail.... [url=mailto:csavage@parallax.com]csavage@parallax.com[/url]
    '   Started...
    '   Updated... 10-09-2005
    '
    '   {$STAMP BS2}
    '   {$PBASIC 2.5}
    '
    ' =========================================================================
    
     
    '
    ' Pin Assignments
    ' 0   DS1302 DataIO
    ' 1   DS1302 Clock
    ' 2   DS1302 Chip Select
    
    ' -----[noparse][[/noparse] Revision History ]------------------------------------------------
     
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
    DataIO          PIN     4               ' DS1302.6
    Clock           PIN     3               ' DS1302.7
    CS1302          PIN     5               ' DS1302.5
    
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
    WrSecs          CON     $80             ' Write Seconds
    RdSecs          CON     $81             ' Read Seconds
    WrMins          CON     $82             ' Write Minutes
    RdMins          CON     $83             ' Read Minutes
    WrHrs           CON     $84             ' Write Hours
    RdHrs           CON     $85             ' Read Hours
    CWPr            CON     $8E             ' Write Protect Register
    WPr1            CON     $80             ' Set Write Protect
    WPr0            CON     $00             ' Clear Write Protect
    WrBurst         CON     $BE             ' Write Burst Of Data
    RdBurst         CON     $BF             ' Read Burst Of Data
    WrRam           CON     $C0             ' Write RAM Data
    RdRam           CON     $C1             ' Read RAM Data
    
    ' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
    index           VAR     Byte            ' Loop Counter
    reg             VAR     Byte            ' Read/Write Address
    ioByte          VAR     Byte            ' Data To/From DS1302
    secs            VAR     Byte            ' Seconds
    secs01          VAR     secs.LOWNIB
    secs10          VAR     secs.HIGHNIB
    mins            VAR     Byte            ' Minutes
    mins01          VAR     mins.LOWNIB
    mins10          VAR     mins.HIGHNIB
    hrs             VAR     Byte            ' Hours
    hrs01           VAR     hrs.LOWNIB
    hrs10           VAR     hrs.HIGHNIB
    date            VAR     Byte
    month           VAR     Byte
    day             VAR     Nib             ' Day
    year            VAR     Byte            ' Year
     
    work            VAR     Byte            ' Work Data
    
    ' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
    Init:
      reg = CWPr                            ' Initialize DS1302
      ioByte = WPr0                         ' Clear Write Protect
      GOSUB RTC_Out                         ' Send Command
    
    ' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
    Start:
    mins = $00
    secs = $00
    GOSUB Set_Time
    DO
      GOSUB Get_Time
     DEBUG HOME, HEX2 mins, ":", HEX2 secs
      IF mins = $03 AND secs = $15 THEN EXIT
    LOOP
    DEBUG CR, CR, "3:15 Elapsed"
    STOP                     '   [color=red]<<<<<<<<<<[/color]
     
    ' [color=red]The STOP line is not need when you put own code bellow [/color]
     
    RETURN 
         ' [b][color=red]one note you may or may not this line this depends on how you write you code [/color][/b]
    [b] [/b]
                            [color=red]' remove the stop and put what you want it to do[/color]
    [color=#ff0000]                           ' and do not for get the RETURN line at the bottom[/color]
                               ' [color=red]of this routine[/color] 
    ' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
    
    RTC_Out:
      HIGH CS1302                           ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg, ioByte]
      LOW CS1302                            ' Deselect DS1302
      RETURN
    RTC_In:
      HIGH CS1302                           ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg]
      SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]ioByte]
      LOW CS1302                            ' Deselect DS1302
      RETURN
    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
    

    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/28/2010 4:07:18 AM GMT
Sign In or Register to comment.