non blocking delay usage

tbalon

Member
WebControl rev 2.2.2, firmware SH 3.2.13
 
One of my TLL inputs is connected to a switch ( opto ) that detects when a backup sump pump is activated. The code I have works, but I originally had issues with multiple emails being sent. 
 
The switch, on IP1, is normally high (1) indicating the backup pump is OFF. When the float is activated, the pump comes on, and IP1 goes low for the duration of the time it takes for the backup pump to reduce the water level below the float. 
 
Here is the original code. What was happening was that the email was sent more than once while the pump was activated ( IP1 low ) 
 
START    
SET RAM1 0  
 
LOOP:
TSTEQ IP1 0   # is the pump running ? 
GOTO SEND     
SET RAM1 0    # reset the flag 
GOTO LOOP   
END    
 
SEND:
BNZ RAM1 LOOP  # if we have sent the email alredy goto loop
SET RAM1 1     # otherwise set flag indicating we are sending email
EMAIL EM1
GOTO LOOP  
 
I think what was happening is that I had some bounce issues with the float switch on IP1, so I added a small delay to the code after setting RAM1 to allow the switch to settle. 
 

START    
SET RAM1 0  
 
LOOP:
TSTEQ IP1 0   # is the pump running ? 
GOTO SEND     
SET RAM1 0    # reset the flag 
DELAY 250      # debounce 
GOTO LOOP   
END    
 
SEND:
BNZ RAM1 LOOP  # if we have sent the email alredy goto loop
SET RAM1 1     # otherwise set flag indicating we are sending email
EMAIL EM1
GOTO LOOP

 
This worked and I only get one email. However, I think this could be done more elegantly using the non-blocking delay on IP1 such as ...
 

START    
SET RAM1 0  
 
LOOP:
TSTEQ IP1[250] 0   # is the pump on more than 250 ms ? 
GOTO SEND     
SET RAM1 0    # reset the flag 
GOTO LOOP   
END    
 
SEND:
BNZ RAM1 LOOP  # if we have sent the email alredy goto loop
SET RAM1 1     # otherwise set flag indicating we are sending email
EMAIL EM1      # send mail 
GOTO LOOP
 
Two questions....
 
1 - Assuming this works, is the any known issues with using the non-blocking delay on TTL inputs with SH 3.02.13 firmware ? 
 
2 - How can I comment the code ? When I paste code into the PLC it complains about the # comments, is there any comment symbol ????? 
 

 
 
 
Hi,
 
Dr. Lou posted a non-blocking delay summary here:
http://cocoontech.com/forums/topic/22849-cai-webcontrol-non-blocking-delay-function/
Too bad, searching the forum does not return this post.
 
Currently there is no support for comment in the PLC code.  We are sorry for the inconvenience.
Non-blocking delay can be confusing sometimes. We don't think there is known issue with non-blocking delay.  If you found any, please do let us know.
 
Thanks!
 
Back
Top