ST program calling FB with a TON inside it - TON not working help pls

matt_sd

Member
Join Date
Jan 2007
Location
Australia
Posts
96
This is a strange one, I have a simple alarm filter function block done in Structured Text (ST). I am calling it from a program. When this program is in Ladder it works OK but when the calling program is in Structured Text (ST), the TON timer inside the FB it calls doesn't time. Very strange. My code must have a bug in it but I have use FB calls like this elsewhere and worked ok.
This is programmed with Beckhoff Twincat but any IEC1131 should be the same.


This is alarm filter Function Block:-


FUNCTION_BLOCK alarm_filter_FB
VAR_INPUT
enable:BOOL; (*Enable this FB *)
Inhibit:BOOL; (*This is the inhibit input 1 = Inhibit Alarm*)
alm_in:BOOL; (*This is the Alarm in 1 = Alarm State*)
delay:TIME:=t#5s; (*This is the Delay in seconds (5 seconds is default)*)
END_VAR

VAR_OUTPUT
Alm_out:BOOL; (*This is the alarm output*)
END_VAR

VAR
TON: TON; (* Call TON standard block *)
END_VAR


(* If the inhibit is not set, when the alam input is set, after x time the alarm is generated *)
ton.PT:=delay;
IF NOT Inhibit AND alm_in AND enable THEN
ton.IN:=1;
ELSE
ton.IN:=0;
END_IF
Alm_out:=ton.Q;





THIS IS THE PROGRAM IN ST THAT CALLS THE FB:-



PROGRAM alarm_filter_instance
VAR
input: BOOL;
instance1: alarm_filter_FB;
output: BOOL;
END_VAR

(* Tank Level Low *)
instance1.Delay:=t#10s;
instance1.enable:=1;
instance1.Inhibit:=0;
instance1.Alm_in:= input;

output:=instance1.Alm_out;


If you look at the attached, this is the instance open, the timer is not timing and neither is the delay of 10s been moved into the PT?
Any help appreciated

Matt
 
I haven't done any Beckhoff programming for some time, but I can't see a call to the function block - your code just writes the input parameters and reads the output parameters.
 
You didn't call SFB TON, it should be called cyclically from your code for example:
ton(IN:= alm_in AND enable AND NOT inhibit,
PT:= delay);
Alm_out:= ton.Q;
 
Thank gregoryg & L D[AR2,P#0.0].

That seems like the problem. I have programmed ladder for 15 years but only programmed in ST in the last 6 months.

I thought that as TON was declared, it would be called (just like ladder)

ST is good in Beckhoff as there are not the modules created in ladder (unlike Control logix where all the modules exist in ladder)

Thanks again, you have saved me time :)

Regards

Matt
member.php?u=21496
 

Similar Topics

I have mapped data tags Vlt_1 and Amp_1 from a device_1 (with ip address) to a red lion programmable controller which is connected to it over...
Replies
1
Views
1,401
need to make a simple program in my class. I can use 1 input for my button 1 output for the light. The button needs to toggle the light. No single...
Replies
2
Views
43
Hi, I am new to ladder logic. I have completed a code in the Xinje PLC XC3-32RT-E for one of the machines I am developing. Currently the program...
Replies
10
Views
131
Hi everyone i have a customer, who wants to show an alarm on the machine, if the I/O forces are enabled and set, on at ControlLogix L81E with...
Replies
3
Views
138
I can't seem to get the Panel View Plus 7 standard edition to downgrade to V_11, when I check the AB downloads and compatibility websites for this...
Replies
1
Views
93
Back
Top Bottom