about sending 1 email a time

var you can see on system status for testing but only have 8, rams you can't see but get more to use
 
BTCAD said:
tell me please what is the difference between ram and var?
 
Pittom beat me to it. Sorry for being vague. Webcontrol has 8 VAR and 8 RAM locations for storing varables. The advantage of using VAR is the current value is reported in web status. I should have used VAR in my example but was lazy and just copied a piece of working code.
 
/tom
 
THANK YOU GUYS!
 
 
One more question:
 
What should I do if I want to set OP8 for 10 sec if IP1 is triggered. I mean, set OP8 10 sec and wait for a new event,,,
 
 
This is my current working code.
 
 
 
START   
 SET RAM1 0 
 SET OP3 1 
LOOP:
 TSTEQ IP1[2000] 1 
 CALLSUB IN1_ON  
 TSTEQ IP1[5000] 0 
 CALLSUB IN1_OFF  
 CALLSUB RESET  
 TSTEQ OP8 1 
 CALLSUB EMAIL  
 GOTO LOOP  
 END   
IN1_ON:
 SET OP8 1 
 SET OP1 1 
 DELAY 250  
 SET OP1 0 
 DELAY 250  
 RET   
IN1_OFF:
 SET OP8 0 
 SET OP2 1 
 DELAY 1000  
 SET OP2 0 
 DELAY 3000  
 RET   
RESET:
 TSTEQ OP8 0 
 SET RAM1 0 
 RET   
EMAIL:
 TSTEQ RAM1 0 
 EMAIL EM1  
 DELAY 100  
 SET RAM1 1 
 RET   
 
is this what you mean
 
tsteq ip1 1
set op8 1
delay 5000  ;adjust for as long as you want
set op8 0
 
how does the non-blocking delay work
 
set op1[5000]1      
 
op1 will be set to 1 after 5000 but program will keep going on?
 
This is the working code I wrote :
 
START  
        SET RAM3 0
        SET RAM2 0
        SET RAM1 0  
 SET OP1 0
        SET OP2 0
        SET OP3 1 
LOOP:
 TSTEQ IP1 1 
 CALLSUB IN1_ON
 
        TSTEQ IP1[2000] 1 
 CALLSUB ALM
 
        TSTEQ OP8 1
        CALLSUB ALMOFF
        TSTEQ IP1 0
        CALLSUB IN1_OFF
         
 CALLSUB RESET  
 TSTEQ RAM3 1 
 CALLSUB EMAIL
 GOTO LOOP  
 END   
ALM:
        TSTEQ RAM2 0
        SET OP8 1
        DELAY 1000
        SET RAM2 1 
 RET   
ALMOFF:
       
        TSTEQ OP8 1
        SET OP8 0
       
        RET
IN1_ON: 
        SET RAM3 1
 SET OP1 1 
 DELAY 250  
 SET OP1 0 
 DELAY 50 
 RET   

IN1_OFF:
 SET OP8 0 
 SET OP2 1 
 DELAY 3000  
 SET OP2 0 
 DELAY 2000
        SET RAM2 0
        SET RAM3 0
 RET   

RESET:
 TSTEQ RAM3 0 
 SET RAM1 0 
 RET   

EMAIL:
 TSTEQ RAM1 0 
 EMAIL EM1  
 DELAY 100  
 SET RAM1 1 
 RET   
 
This code isn't going to work very well.  You have lots of delay operators in there and then you are also testing inputs which are apparently time sensitive (since you are using non-blocking delay function on them).  
 
You code may very well not even test those inputs but once every 5 seconds or more.  When a "delay" is hit, the whole program just stops.
 
The delay function is not generally a very good function since it stops the entire code dead in its tracks.  It is only a quick and dirty way to do stuff when your code has pretty much only a single simple job. 
 
Back
Top