IEC Function Blocks

N

Thread Starter

Nitin

Hello

How is the "enable" functionality for timers and counters defined in the IEC standard 1131? It seems very vague. I believe AB an other vendors are defining these blocks differently. Can anyone share the knowledge on this issue? My big question is, what happens when the enable goes away, in case of a timer? Is it still executed (timers incrementing) but the output will not be turned on or what?
Thanks
 
F

Friedrich Haase

Indeed, vendors define these function block differently. I don't know how AB timers will work. But IMHO the IEC timers (and counters) are NOT vague. Below you find the complete IEC definition.

You mentioned an "enable" functionality. Neither timers nor counters have an "EN" input. Timers do have an IN input, which not the same. And counters
have edge sensitive CU and/or CD inputs. The edge sensitivity is not shown in the ST snippets. Function blocks don't need to handle edge sensitivity. It should be done when parameters are supplied or by automatical inclusion of R_TRIG function blocks or whatever.

Your "enable" functionality could mean the additional input "EN" which you might see in ladder diagrams. They are not part of the function blocks but a ladder feature. When "EN" is 0 (FALSE) the function block will not be
executed. So it cannot recognise any changing inputs and will not set it's outputs accordingly - i.e. they should remain at the last value. Whether or not the (internal) time within the timer function blocks will still pass by depends on the implementation. IMHO it will and it should.

Regards
Friedrich Haase


<snip from IEC 61131-3, 2nd. edition>

3 kinds of timers - TP, TON, TOF.

+-------+
| *** |
BOOL---|IN Q|---BOOL
TIME---|PT ET|---TIME
+-------+

TP / Pulse (TP) timing
----------------------

+--------+ ++ ++ +--------+
IN | | || || | |
--+ +-----++-++---+ +---------
t0 t1 t2 t3 t4 t5
+----+ +----+ +----+
Q | | | | | |
--+ +---------+ +--+ +-------------
t0 t0+PT t2 t2+PT t4 t4+PT
PT +---+ + +---+
: / | /| / |
ET : / | / | / |
: / | / | / |
: / | / | / |
0-+ +-----+ +--+ +---------


TON / On-delay (TON) timing
---------------------------

+--------+ +---+ +--------+
IN | | | | | |
--+ +--------+ +---+ +-------------
t0 t1 t2 t3 t4 t5
+---+ +---+
Q | | | |
-------+ +---------------------+ +-------------
t0+PT t1 t4+PT t5
PT +---+ +---+
: / | + / |
ET : / | /| / |
: / | / | / |
: / | / | / |
0-+ +--------+ +---+ +-------------
t0 t1 t2 t3 t4 t5


TOF / Off-delay (TOF) timing
----------------------------

+--------+ +---+ +--------+
IN | | | | | |
---+ +--------+ +---+ +-----------
t0 t1 t2 t3 t4 t5
+-------------+ +---------------------+
Q | | | |
---+ +---+ +------
t0 t1+PT t2 t5+PT
PT +---+ +------
: / | + /
ET : / | /| /
: / | / | /
: / | / | /
0------------+ +---+ +--------+
t1 t3 t5

The effect of a change in the value of the PT input during the timing
operation is an implementation-dependent parameter.


3 types of counters - CTU, CTD, CTUD.

CTU / up-counter
----------------

+-----+
| CTU |
BOOL--->CU Q|---BOOL
BOOL---|R |
INT---|PV CV|---INT
+-----+

IF R THEN CV := 0 ;
ELSIF CU AND (CV < PVmax)
THEN CV := CV+1;
END_IF ;
Q := (CV >= PV) ;


CTD / down-counter
------------------

+-----+
| CTD |
BOOL--->CD Q|---BOOL
BOOL---|LD |
INT---|PV CV|---INT
+-----+

IF LD THEN CV := PV ;
ELSIF CD AND (CV > PVmin)
THEN CV := CV-1;
END_IF ;
Q := (CV <= 0) ;


CTUD / up-down counter
----------------------

+------+
| CTUD |
BOOL--->CU QU|---BOOL
BOOL--->CD QD|---BOOL
BOOL---|R |
BOOL---|LD |
INT---|PV CV|---INT
+------+

IF R THEN CV := 0 ;
ELSIF LD THEN CV := PV ;
ELSE
IF NOT (CU AND CD) THEN
IF CU AND (CV < PVmax)
THEN CV := CV+1;
ELSIF CD AND (CV > PVmin)
THEN CV := CV-1;
END_IF;
END_IF;
END_IF ;
QU := (CV >= PV) ;
QD := (CV <= 0) ;

The numerical values of the limit variables PVmin and PVmax are implementation-dependent.
<snip>

Note:
If pictures and timing diagrams look funny, try to view them with a fixed pitch font - like Courier. Depending on your mail viewer you possibly have to copy the text into another editor.
 
R

Robert Trask

Hmmm, good question. I could find no information in the 'standard' about the enabling/disabling of FB's. So I contacted a friend at Beckhoff (TwinCAT creator) and here was his response...


if you remove the enable in twincat it is in an effect a jump...which has the adverse effect of leaving all outputs in their current state...but the block does stop functioning...ie if a timer.q is on it will stay on..according to the lead guy here...but the timer will stop timing. the input or enable in AB speak should stop the block from functioning as well as turn the outputs off....this is the unfortunate byproduct of the
instruction list vs ladder war that we all live in... in IL removing the enable effects a jump command...where the code is not processed where as in ladder the enable being removed effects a false rung or statement so the outputs are set off and the rung is processed but bypassed...


Basically, by my understanding, it appears that IEC does not officially deal with EN on individual Function Blocks. Like many things it seems to be a functionality left to an individual vendor of control software. To combat confusion in RLL it would seem wise to avoid. I personally have never found the need to enable/disable a specific function.

Robert Trask, PE
Mind Span eSciences
Wilmington, NC
USA
 
Top