Can some look at this routine (DO WHILE IN3 = 0 AND DO WHILE IN3 = 1 ) PROBLE
sam_sam_sam
Posts: 2,286
I going to use this to log Running Time·or·OFF Time depending which setting·I am using·.......... For A\C units and other·equipment as well
DO WHILE IN3 = 0············ ·' This is mode # 1
Power_ON:
·DO WHILE IN2 = 0············· ' This the routine for mode # 1
GOSUB Display_Time:
·LOOP
DO WHILE IN2 = 1
GOSUB Show_Time
GOSUB Show_State_Input
LOOP
GOSUB Halt_clock
GOSUB Restart_clock
GOSUB Power_Restarts
GOSUB Power_ON
LOOP
DO WHILE IN3 = 1························ ·' This mode # 2
Power_Off:
DO
·GOSUB Show_Time
·······························
·GOSUB Show_State_Input
·LOOP UNTIL IN2 = 1············ ' This is the routine for· mode # 2
·DO
GOSUB Halt_clock
LOOP UNTIL IN2 = 0
GOSUB Restart_clock
GOSUB Power_restarts:
GOSUB Power_Off
·
LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 7/18/2008 1:03:47 AM GMT
DO WHILE IN3 = 0············ ·' This is mode # 1
Power_ON:
·DO WHILE IN2 = 0············· ' This the routine for mode # 1
GOSUB Display_Time:
·LOOP
DO WHILE IN2 = 1
GOSUB Show_Time
GOSUB Show_State_Input
LOOP
GOSUB Halt_clock
GOSUB Restart_clock
GOSUB Power_Restarts
GOSUB Power_ON
LOOP
DO WHILE IN3 = 1························ ·' This mode # 2
Power_Off:
DO
·GOSUB Show_Time
·······························
·GOSUB Show_State_Input
·LOOP UNTIL IN2 = 1············ ' This is the routine for· mode # 2
·DO
GOSUB Halt_clock
LOOP UNTIL IN2 = 0
GOSUB Restart_clock
GOSUB Power_restarts:
GOSUB Power_Off
·
LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 7/18/2008 1:03:47 AM GMT
Comments
As to your question, if you don't add some form of debounce it will give you a problem.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
In the red code, just before LOOP of DO WHILE IN3=0, you GOSUB Power_ON,
which is already part of that DO WHILE, so this will lead to stack overflow.
In the blue code, just before LOOP of DO WHILE IN3=1, you GOTO Power_OFF,
which is already part of that DO WHILE, so you·never get back to the DO WHILE
to check IN3, and therefore the loop never exits.
regards peter
Thank you for your reply
Input 3 will be a switch which will be on one mode or the other
······ DO WHILE IN3=0 And· ·DO WHILE IN3=1,
There are·two··different mode and two··different· routines
······ Mode 1 (Power_ON)
One is for keep track of time·while·unit is running
Flow chart
1) check to see if there is power on input # 2
If·YES then·RUN Clock
If NO then STOP Clock
······· Mode 2 (Power_OFF)
Two is for keeping track of time while unit is OFF
Flow Chart
1) check to see if there is power on input 2
If NO then·RUN clock
If YES then STOP Clock
I·can only use·one mode at a time
It work the way·I want it to
I just was not sure if this was the right way to do it or not
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 7/17/2008 7:31:42 PM GMT
It sounds like you need logic more along the lines of…
You may not need both EXIT statements...One conditional may require you to stay in the loop...But I woldn't use multiple DO...LOOP conditionals...If you intend to stay in the loop excpet for one specific event then exit the loop as shown above but in the right conditional.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Post Edited (Chris Savage (Parallax)) : 7/17/2008 8:30:19 PM GMT
Thanks· that just what I need this works alot better
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 7/18/2008 12:54:53 AM GMT