Prevent Power Up Email

MobileMe

Active Member
I'm currently working on a board that mainly does email notifications on relay events.  The problem I'm having is when the board is first powered up, it will send out emails for normal state conditions.  Is there a way to prevent that from happening? It seems possible, but I just can't see it.  Here is what I have so far...
 
START

LOOP:
    CALLSUB RESETS
    TSTEQ IP1 1
    CALLSUB ACOFF
    TSTEQ IP1 0
    CALLSUB ACON
    GOTO LOOP
END

RESETS:
    TSTEQ IP1 0
    CALLSUB RESET1
    TSTEQ IP1 0
    CALLSUB RESET2
    TSTEQ IP1 1
    CALLSUB RESET3
    TSTEQ IP1 1
    CALLSUB RESET4
    RET
RESET1:
    ANDB RAM1 1
    BNZ SET1ZERO
    RET
SET1ZERO:
    XORB RAM1 1 RAM1
    RET
RESET2:
    ANDB RAM1 2
    BNZ SET2ZERO
    RET
SET2ZERO:
    XORB RAM1 2 RAM1
    RET
RESET3:
    ANDB RAM1 4
    BNZ SET4ZERO
    RET
SET4ZERO:
    XORB RAM1 4 RAM1
    RET
RESET4:
    ANDB RAM1 8
    BNZ SET8ZERO
    RET
SET8ZERO:
    XORB RAM1 8 RAM1
    RET

ACOFF:
    ANDB RAM1 1 RAM2
    TSTEQ 0 RAM2
    ADD VAR1 1 VAR1
    TSTEQ 0 RAM2
    SET RAM3 CTS
    ORB RAM1 1 RAM1
    SUB RAM3 CTS RAM4
    TSTGT RAM4 3
    GOTO ACFAIL
    RET
ACFAIL:
    ANDB RAM1 2 RAM2
    TSTEQ 0 RAM2
    EMAIL EM1
    ORB RAM1 2 RAM2
    RET

ACON:
    ANDB RAM1 4 RAM2
    TSTEQ 0 RAM2
    SET RAM3 CTS
    ORB RAM1 4 RAM1
    SUB RAM3 CTS RAM4
    TSTGT RAM4 3
    GOTO ACRESTORE
    RET
ACRESTORE:
    ANDB RAM1 8 RAM2
    TSTEQ 0 RAM2
    EMAIL EM2
    ORB RAM1 8 RAM1
    RET
 
You can add delay at the beginging of your PLC code. Like
START
initialization here
DELAY 3000
normal:
your logic goes here
goto normal
END
 
CAI_Support said:
You can add delay at the beginging of your PLC code. Like
START
initialization here
DELAY 3000
normal:
your logic goes here
goto normal
END
The delay didn't help.  It only prolongs the email. 
 
In my applications, I usually sit in a tight loop until the clock has achieved sync from the NTP source. This assures that the board is connected, got network connection and DHCP etc is all going, and seems to give the temp sensors long enough time to have populated the WCs internal tables.
 

Code:
START   
        delay 5000      # Let things settle
        set var2 90     # initialize variables
        set var4 0
        set var5 0
        set ram5 2
TSYNC:
        tstge CYEAR 2012
        goto midnight
        set op8 1   # flash LED rapidly to indicate no sync yet
        delay 100
        set op8 0
        delay 100
        goto TSYNC

...
 
Why not some sort of hardware approach?  For instance, could you trigger a timer delay relay off of the main board's power so it would provide a contact closure xx amount of seconds after the board is powered on?  Then have a digital input status that relay's contacts and use that as a conditional flag before sending out any emails?
 
I ended up just setting the email variables to normal operation on startup so I don't get any emails when the board is powered on for the first time.  I tested it and It seems to be working great.  I'm trying to avoid false notifications so when the power flickers, I don't get ten emails saying the power went out and back on again. 
 
I do like the time sync loop idea. 
 
Back
Top