Just wanted to ask if any of the veterans on here could help with simple program writing help.
Concept: Controlling a shut off valve (on/off) based on a pressure signal condition (4-20mA).
Input - Pressure Transmitter 4-20mA, 0-100 psi IN1
Output - Valve open/close (on/off) OUT1
If pressure goes below low setting minus 2 psi (or corresponding 4-20mA value) for longer than 1 minute valve close initiation shall commence. Send alarm email (if possible)
If pressure goes above high setting plus 2 psi (or corresponding 4-20mA value) for longer than 1 minute valve close initiation shall commence. Send alarm email (if possible)
Otherwise valve to remain open
I will will add details on this pressure sensor range setup shortly, but start off by building up a custom analog table, theres some good examples on this forum. Then we do a program for your sequence, I like to use flags for evaluating conditions with a lot of logic behind it, that way you can see what the flag is doing and put trend logs on it. First up are a couple of flags which flip on and off according to the pressure reading high and low conditions. Each of these flags also has a timer associated with it.
05 REM USE A FLAG AND ASSOCIATED TIMER FOR THE LOW PRESSURE CONDITION ****.
10 IF PRESS < LOWSET THEN START VAR1
20 IF PRESS > LOWSET + .1 THEN STOP VAR1
30 VAR2 = TIME-ON( VAR1 )
40 REM ***** AND DO THE SAME FOR THE HIGH PRESSURE CONDTION *****
50 IF PRESS > HISET THEN START VAR3
60 IF PRESS < HISET + .1 THEN STOP VAR3
70 VAR4 = TIME-ON( VAR3 )
Now we need another flag that becomes true when the low and high flags have been on more than a minute
80 IF VAR2 > 0:01:00 THEN START VAR5 ELSE STOP VAR5
90 IF VAR4 > 0:01:00 THEN START VAR6 ELSE STOP VAR6
And now the program for the valve.
100 IF NOT VAR1 AND NOT VAR3 THEN START VALVE
110 IF VAR1 OR VAR3 THEN STOP VALVE
And finally the alarms. Var5 and 6 are the flags which tell us the condition has been met for a minute already so we dont need to use much of a delay in these ‘Delayed Alarms’ or dalarm statements, I have arbitrarily thrown in a 1 second delay.
120 DALARM VAR5 , 1 , LOW PRESSURE ALARM
130 DALARM VAR6 , 1 , HIGH PRESSURE ALARM
We’re still working on the emailed alarms, I am embarrassed it has taken us as long as it has. The delay is mainly with wanting to do it right with SSL encrpytion but its time for us to get something done without at least encryption for now. Should have something we can show in a week or two at most. Promise.
Thank you very much for this. No worries on the email - just wanted to see if it was an option.
Thank you for your time.