FLX 3402 Relay Output

I would like to read a variable tag from plc and based on the value set one of the relay outputs on the 3402 high. Its to read water level from the plc and if the water level goes above a setpoint (alarm) then an output relay should go high. It also has to have an activation delay. How do I set this up?

Thansk,
W

I believe you should be able to do this in the BASIC IDE with some code like this:

Onchange “Digital_Input_tag”, “@Set_Digital_Output()”

Function Set_Digital_Output()

if Digital_Input_tag@ = 0 Then
Digital_Output_Tag@ = (0 or 1 depending on what you want it to do)
Endif

if Digital_Input_tag@ > 0 Then
Digital_Output_Tag@ = (0 or 1 depending on what you want it to do)
Endif

Endfn

I modified it a bit and it works well. Now I need to add a delay, eg level has to be continouosly >80 for x seconds to set R1Test high. How would you add a timer?

Onchange “Level”,"@R1Test"
Function R1Test
If Level@ > 80 Then
R1Test@ = (1)
Endif
If Level@ < 80 Then
R1Test@ = (0)
Endif
Endfn

I have an idea for this, can you create an additional tag called Counter, we’ll use that as a way to cause the delay. I haven’t tested this yet but something like this should work

You should be able to do something like this:

Onchange “Level”,"@R1Test"
Ontimer 1, “@Output_Delay

Function R1Test
If Level@ > 80 Then
tset 1,1 // turns on timer one that will increment every 1 second
Endif
If Level@ < 80 Then
tset 1,0 // turns off timer
counter@ = 0 // resets the counter
R1Test@ = (0) // Turns off output
Endif

Endfn

Function Output_delay
counter@ = counter@ + 1
if counter@ = 80 then //condition only applies if counter = 80
R1Test@ = (1) // turns on output after 80 seconds
endif
Endfn

Hello Bill
Here is a suggestion
When the level is high initiate a timer. Use the ONTIMER event to set the output and reset the timer. see new and modified code in italicized text
DISCLAIMER - I have not run this code

Create a new script for the timer event in this case “LvlAlm” is the new script
Add an ONTIMER event to the init section

ONTIMER 1, “goto LvlAlm”

Modify R1Test as shown below

Function R1Test
If Level@ > 80 Then
REM set timer 1 for 10 minute delay (600 seconds)
TSET 1,600
Endif

If Level@ < 80 Then
R1Test@ = (0)
*REM Clear the timer *
TSET 1, 0
Endif
Endfn

Function R1Test
If Level@ > 80 Then
REM set timer 1 for 10 minute delay (600 seconds)
TSET 1,600
Endif

If Level@ < 80 Then
*REM Clear the timer *
TSET 1, 0
R1Test@ = (0)
Endif
Endfn

This is the new function to set the output using the ONTIMER event
function LvlAlm
REM TIMER 1 has expired initiate alarm
R1Test@ = (1)
REM Clear the timer
TSET 1, 0
Endfn

What if I configure an alarm condition for Level, for which I can set a delay? Then set R1Test on FLB 3205 high when alarm is active? Any suggestions for a script?

ONALARM “Level”,“GOTO Action”
END
Action:
IF ALSTAT"Level" = 2 Then
r1test@ = 1
Endif
IF ALSTAT"Level" = 4 Then
r1test@ = 0
Endif
End

Hi Bill,

Are you trying to run the script based off of the ALSTAT level for an individual tag? I think you should be able to do something like the code below:

Onalarm “level”, “Goto Action”

Action:

SETSYS TAG, “LOAD”, “Level”
Current_Alarm_Val% = GETSYS TAG, “alstat”

IF Current_Alarm_Val% = 2 Then
r1test@ = 1
Endif
IF Current_Alarm_Val% = 4 Then
r1test@ = 0
Endif

End

-Tim

I am not sure where the “LOAD” comes in, but my script as shown below works good. Do you see any problems with it?

ONALARM “Level”,“GOTO Action”
END
Action:
IF ALSTAT"Level" = 2 Then
r1test@ = 1
Endif
IF ALSTAT"Level" = 4 Then
r1test@ = 0
Endif
End

Thank you

I had thought it required a setsys load of the tag before being able to grab the ALSTAT data but if that’s working right now then I’d say you’re all set

I am having issues at one ewon with the following script, not on another. What could be wrong? It reboots a few minutes after PDCTemp goes into alarm. PDCTemp alarm delay is set for 20 sec. After reboot my script is no longer running. The relay outputs also go back to 0.

ONALARM “PDCTemp”,“GOTO Action”
END
Action:
IF ALSTAT"PDCTemp" = 2 Then
r1test@ = 1
r2test@ = 1
Endif
IF ALSTAT"PDCTemp" = 4 Then
r1test@ = 0
r2test@ = 0
Endif
End

Log shows:
0/07/2020 11:05:12 1073762140 Reboot reason: Unknown (power loss,…) wd

10/07/2020 10:49:11 1073762140 Reboot reason: Unknown (power loss,…) wd

10/07/2020 10:36:54 1073762140 Reboot reason: Unknown (power loss,…) wd

10/07/2020 10:27:16 1073762140 Reboot reason: Unknown (power loss,…) wd

However, power was not lost

I also noticed that everytime I restarted the script the pause and play button on the top right started flashing randomly.

W

Hi Bill,

Can you send me a backup.tar file of this device so we can try and take a closer look at it?

-Tim

Here you go!

It looks like you have your code in the cyclic section, can you move it to the init section and see if that fixes the issue?