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

need help with project

ryan4385ryan4385 Posts: 17
edited 2010-03-16 23:27 in BASIC Stamp
I am designing an automatic garage closer using the bs2 and want it to do many things
1st after 10minutes of the garage door opening and stay open it will close by it self
2nd it will output the temperature on an lcd screen
3rd it will keep track of the time and if the the time is 11pm then it will automatically goto the buffer within the program and then close the door after 1o minutes
4th there will be a switch that will disable all of the program except the temp and the switch will be overiden by the time part of the program
5TH also there will a pir sensor mounted and hook up to the stamp and if it sense movement it will tigger an output to turn on the lights

when i goto run the program i get an error message and dont what it means or how to fix it

Thank you for any help

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-10 15:59
    What's the error message?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-10 16:07
    A word of advice ...
    Your program is long and not simple. You really need to debug this a piece at a time, then combine the pieces. You've got a clock and a temperature sensor, an LCD screen, plus a PIR sensor. Start with just the clock and the door motor and get that part working. Add the LCD screen and get that working, then add the temperature sensor and its display code. Last part would be to add some switches and the PIR sensor. At each step along the way, make sure the whole thing works before moving on to the next piece.
  • ryan4385ryan4385 Posts: 17
    edited 2010-03-10 17:23
    the error message i get is data occupies same location as program
    i had the temp, lcd and motor part working it all part with the program when i add the clock part of the program
    if anyone can help me make it more simplied

    thank you
    ryan
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-10 18:12
    The message means that your program is too big for the Stamp's memory. You get this specific message because you're using DATA statements which store the data starting at location zero in the EEPROM. Your compiled program is stored backwards in memory starting at the end of memory (2K) and working towards lower addresses. If these overlap, you get the error message you've seen.

    You shorten programs by cutting back on the length of messages in I/O statements and by replacing multiple blocks of nearly identical code with one block and making that a subroutine.
  • MoskogMoskog Posts: 554
    edited 2010-03-10 18:23
    Your program also contains a lot of Pauses that could be hidden in FOR NEXT loops instead. Another thing with the Pauses, they keep your Stamp busy doing nothing instead of being busy do all the things you want it do do. If you cant make your program smaller you maybe have to get a multislot Stamp intead.
  • ryan4385ryan4385 Posts: 17
    edited 2010-03-10 21:03
    can anyone maybe open the program and modified the program so i see what you guys are talking about? as far as what i did was just took the for the operation of a sensor and just copy and paste into my mine.
  • C-BobC-Bob Posts: 19
    edited 2010-03-10 21:34
    Your program contains more 870 characters in DEBUG commands
    Stamp2 have 2048 bytes of memory
    - Remove DEBUGs
    - For setting clock use defined pattern YYYY.MM.DD/HH.MM and DEBUGIN
    - For delay use loops

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    C-Bob

    Every problem·have at least one·nice, simply and·wrong solution.
  • ryan4385ryan4385 Posts: 17
    edited 2010-03-11 00:02
    C-bob is there another program to use to for the ds1302 because i have yet to come up with a way for when the time 11pm to automatically override the disable switch command and close the door and what do you mean with delay use loop
  • C-BobC-Bob Posts: 19
    edited 2010-03-11 17:24
    i try explain i think structure:

    main loop
    - read time
    - check inputs
    - branch by inputs
    go to main

    inputs state 1
    - compare time
    - do st.
    return

    input state 2
    - compare time
    - do st.
    return

    LOOPS:

    your code:
    STANDBY5: 
        SEROUT 8,$4054,[noparse][[/noparse]254,133,"STANDBY MODE"] 
        DEBUG "STANDBY MODE", CR 
        PAUSE G                                 'st.
        PAUSE G                                 'st. 
        PAUSE G                                 '.
        PAUSE G                                 '.
        PAUSE G                                 '.
        PAUSE G                                 '.
        PAUSE G                                 '.
        PAUSE G                                 '.
        PAUSE G                                 'St. 10 times
    GOTO CHECK
    


    LOOPS:

    STANDBY5: 
        SEROUT 8,$4054,[noparse][[/noparse]254,133,"STANDBY MODE"] 
        DEBUG "STANDBY MODE", CR 
        for n = 1 to 10 do                        'Begin loop
            PAUSE G                               'do st. n times
        next                                      'End loop 
    GOTO CHECK
    

    Better way (i dont try this maybe some errors inside, this is only for explanation, this replace all STANDBYs)

    Standby: 
        SEROUT 8,$4054,[noparse][[/noparse]254,133,"STANDBY MODE"] 
        DEBUG "STANDBY MODE", CR 
        timer = 0                                 'variable for check time in standby 
        do 'LOOP                                  'Begin loop
            PAUSE G                               'do st.
            timer = timer + 1                     'every turn increment timer var 
        loop while (IN11 = 1) or (timer<60)       'end LOOP if switch or timer override 
    GOTO CHECK
    

    little rework for better read yeah.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    C-Bob

    Every problem·have at least one·nice, simply and·wrong solution.

    Post Edited (C-Bob) : 3/14/2010 8:50:55 AM GMT
  • MoskogMoskog Posts: 554
    edited 2010-03-11 17:39
    ryan4385
    I think you should forget about the DS1302 and the whole memory-eating clock part until the rest of the program is done and de-bugged.·Or do what Mike mention and start with the clock-part·and make no·additional code before that one is working. One thing at a time. And it is not that easy that you can just copy and paste·program code from somewhere else into yours without knowing what you really do.
    You said...
    what do you mean with delay use loop
    C-bob·mean that you put your delays (PAUSE G) into loops, either DO.. LOOP or FOR.. NEXT,
    so 10 PAUSE G statements could be replaced with
    (times var nib)
    FOR times = 1 TO 10
    PAUSE G
    NEXT
    
    
  • ryan4385ryan4385 Posts: 17
    edited 2010-03-16 05:01
    I updated the code for my project but the next problem is that i dont know to get the clock to work with my program. It doesnt have to show seconds but i would it to update the screen every minute.

    Ryan
  • C-BobC-Bob Posts: 19
    edited 2010-03-16 16:45
    Maybe helpful:
    add time and temp·to·standby
    STANDBY:
        SEROUT 8,$4054,[noparse][[/noparse]254,133,"STANDBY MODE"]
        DEBUG "STANDBY MODE", CR
        timer = 0                                 'variable for check time in standby
        DO                                        'Begin loop
          PAUSE G                                 'do st,
          GOSUB TEMP                                                                                    ADD this
          GOSUB TIME                                                                                    ADD this
          timer = timer + 1                       'every turn increment timer var
        LOOP WHILE (IN11 = 1) OR (timer<60)       'end LOOP if switch or timer override
    GOTO CHECK
    

    I dont find routine for display time -·add this to·TIME subroutine.
    If you need second you must rework all program - tip: do everything on time base and dont use delays for time measurement.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    C-Bob

    Every problem·have at least one·nice, simply and·wrong solution.
  • MoskogMoskog Posts: 554
    edited 2010-03-16 17:10
    ryan4385
    I dont know how much experience you have with programming but you I think you should print your code on a sheet of paper and then go through the whole thing with a pencil. Start with the beginning and draw arrows from your GOSUBs and GOTOs and to the subroutines and back again from the RETURNS or next GOTOs and so on. Try to understand what really happends.
    If you want to show the time on the DEBUG screen once in a minute you should concentrate on that now and forget all about temperature or things that shall happend at 23.00. I still think you start in the wrong end here with a too big project, better to start small and add more once you understand what you really do!

    If you really get stuck then ppl here will help you!
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-03-16 23:01
    What is the· most important routine that you want to do
    then what is the second most important routine
    then what is third most important routine
    an·so .......>>>>>>>>>>>>

    Please list them in the order that you want them to be

    One problem is that you do not have a DO LOOP
    and your code is very hard to follow

    In the most important routine is where you have a DO LOOP that keep check what need to be look at all the time
    whether it is looking at·TEMP or·TIME all other routine are what you want to have ·done with what you are looking at

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

    ·
    ·
    ·
    ·
    Sam
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-03-16 23:27
    You could use these routine for this

    ·3rd it will keep track of the time and if the the time is 11pm then it will automatically goto the buffer within the program and then close the door after 1o minutes

    DO

    GOSUB Get_Time
    ·DEBUG HOME, HEX2 HRS, ":", HEX2 mins, ":"
    · IF hrs = $23 AND mins = $00 AND secs = $00 THEN


    GOSUB Ten_MINS_Timer

    ENDIF

    LOOP

    1st····· after 10 minutes of the garage door opening and stay open it will close by it self

    Ten_MINS_Timer:

    DO
    GOSUB Get_Time
    DEBUG HOME, HEX2 HRS, ":", HEX2 mins, ":"··· ·' (OR) DEBUG· HOME ? Minutes

    IF oldmins <>·mins THEN····· ' This Routine Compars the oldmins to mins
    ·· oldmins =·mins··············· ' This Routine is so that Counter Update once a minutes

    ···Minutes = Minutes + 1···· ' This is your Minutes Counter
    ELSE····
    · IF Minutes = 10 THEN
    · GOSUB RELAY

    ENDIF
    ENDIF

    LOOP

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

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 3/16/2010 11:35:23 PM GMT
Sign In or Register to comment.