need help with project
ryan4385
Posts: 17
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
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
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.
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
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.
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.
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:
LOOPS:
Better way (i dont try this maybe some errors inside, this is only for explanation, this replace all STANDBYs)
little rework for better read
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
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.
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)
Ryan
add time and temp·to·standby
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.
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!
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··that you may have and all of your time finding them
·
·
·
·
Sam
·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··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 3/16/2010 11:35:23 PM GMT