Simple program to switch on relays

I thought an advantage of using DELAY is that the system will not accept any input trigger from the door contact within those 60s and send no extra email as well during 60s
 
That is true.  I prefer to set a flag that blocks multiple emails and then resets based on some event.
 
I hate using DELAY.  I prevents any other activity from happening and renders the code useless for that time.  
 
Dear Lou,
Could you explain me the intention of this in the loop section
 


TSTLT CTS RAM2              
 
[SIZE=12pt]ADD RAM2 60 RAM2             [/SIZE]
 
LOOP:
TSTLT CTS RAM2              
GOTO LOOP
ADD RAM2 60 RAM2  
CODE IN THIS SECTION ONLY RUNS ONCE EVERY 60 SECONDS
GOTO LOOP
    
If memory serves, we wanted the x10 subroutine to only run once per minute so you didn't get x10 codes flooding your power lines.
 
So this routine will be done evey 60 sec
LOOP:
TSTLT  CTS RAM2
GOTO LOOP
ADD RAM2 60 RAM2          
SET RAM1 0                      
TSTGE CH 21              
ORB RAM1 1 RAM1          
TSTLT CH 23               
ORB RAM1 2 RAM1           
ANDB RAM1 3                    
CZ RESET2                           
ANDB RAM1 3                     
CNZ RELAY2      
GOTO LOOP                 
 
Yes.
 
Techniques such is this is how you avoid using DELAY[x]
 
LOOP:
HERE IS WHERE YOU PUT OTHER CODE THAT YOU WANT TO KEEP RUNNING
TSTLT  CTS RAM2
GOTO LOOP
ADD RAM2 60 RAM2          
SET RAM1 0                      
TSTGE CH 21              
ORB RAM1 1 RAM1          
TSTLT CH 23               
ORB RAM1 2 RAM1           
ANDB RAM1 3                    
CZ RESET2                           
ANDB RAM1 3                     
CNZ RELAY2      
GOTO LOOP                 
 
Thanks
Ok I understand.
 
TSTGE CH 20
ORB RAM1 1 RAM1   results in RAM1 =1  if the current hour is greater or equal 20h
 
 
TSTLT CH 2
ORB RAM1 2 RAM1 results in RAM1 again =1 if the current hour is lower then 23h
 
 
ANDB RAM1 3 ?
How can this result in a 1
Isn’t it always 0
 
CZ RESET2  This is looking for a 0  to reset the X10 device
What I don’t understand because my two X10 devices keep on swapping the whole day
 
I believe it is as follows:
 
ORB RAM1 1 RAM1  sets bit0 of ram1 to 1 
ORB RAM1 2 RAM1  sets bit 1 of ram1 to 1
ANDB RAM1 3  is looking for bit0 and bit1 of ram1 to each be 1 = 3
 
But, I have been known to be wrong before!
 
TJF1960 said:
I believe it is as follows:
 
ORB RAM1 1 RAM1  sets bit0 of ram1 to 1 
ORB RAM1 2 RAM1  sets bit 1 of ram1 to 1
ANDB RAM1 3  is looking for bit0 and bit1 of ram1 to each be 1 = 3
 
But, I have been known to be wrong before!
 
That is correct, that is what I was doing when I wrote it.  
 
Thanks
I understand.
But for some reason ANDB RAM1 3  results always in a 1 because the X10 devices keep on swapping all the time.
I tried this
        TSTGE CH 21 
         CALLSUB RELAY2  
         TSTGE CH 23 
         CALLSUB RESET2  
         TSTLT CH 21 
         CALLSUB RESET2 
and it works  to switch the X10 devices between 21h and 23h    
But strange, sometimes one X10 device switches on for 1sec and stops again
 
         TSTGE CH 21 
         CALLSUB RELAY2  
         TSTGE CH 23 
         CALLSUB RESET2  
         TSTLT CH 21 
         CALLSUB RESET2
 
If the hour is 23 then that will turn the relay on then off
 
You should have picked my code.  :P
 
Dear,
I see.
At 23h and until 24h CH is greater then 21h so X10 is on, and greater then 23h so X10 has to stop.
This should work from 21h till 24h?
         TSTGE CH 21 
         CALLSUB RELAY2  
          
         TSTLT CH 21 
         CALLSUB RESET2  
 
I tried your code again but both the X10 devices keep ON all the time
 
This version should be working.

START    
    TSTLT CYEAR 2013  
    GOTO START   
    TSTLT CH 20  
    TSTLT CH 6  
    GOTO GETSCH   
    SET RAM1 0  
RESUME:
    CALLSUB XTEN   
    ANDB 1 RAM1 OP1
    DIV RAM1 2 RAM1
    ANDB 1 RAM1 OP2
    END   

GETSCH:
    DIV CM 15 RAM1
    ANDB RAM1 1 RAM1
    ADD 1 RAM1 RAM1
    GOTO RESUME   
XTEN:
    MOD CM 5 RAM2
    TSTEQ 0 RAM2
GOTO XTENTX  
    ANDB -9 VAR1 VAR1
    RET    

XTENTX:
    ANDB 1 VAR1  
    BNZ  DONE  
    ANDB RAM1 1 RAM2
    X10 2 0 RAM2
    ANDB RAM1 2 RAM2
    DIV RAM2 2 RAM2  
    X10 2 1 RAM2
    ORB VAR1 1 VAR1
DONE:
    RET    
 
 

 
 
Back
Top