Module 3.D DFB&Diagnostic DFBs
Module 3.D DFB&Diagnostic DFBs
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 1
Derived Function Block
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 2
Principles
DFBs include :
input/output parameters
public or private internal variables (declared)
one or more sections written in LD, IL, ST, FBD
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 3
Structure
Creation of a DFB type under Unity Pro M L & XL
DFB Code
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 4
Creating - principles
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 5
Properties
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 6
I/O interface
Inputs : 32 max
DFB Type Name in read-only by the DFB
to transfer the value from application to
DFB
Inputs Outputs type and name (32 characters max)
Outputs : 32 max
in write-only by the DFB
to transfer the value from DBF to
application
I/O type and name (32 characters max)
Inputs/Ouputs : 32 max
Public Variables in read/write by the DFB
Private Variables transfer the value to DFB, modify it and
return it to application
DFB Code type and name (32 characters max)
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 7
Variables
Private : unlimited
DFB Type Name
internal variable of DFB
only used for programming the DFB (eg :
Copy of intermediate calculation)
Inputs Variables Outputs
name (8 characters max)
Public : unlimited
internal variable of DFB
can be accessed by application or user in
adjust mode outside the block (read or
I/O
write rights)
Public Variables name (8 characters max)
Private Variables
The values of public variables, modified by
program or by adjustment, can be saved in
DFB Code place of the initial values, by setting %S94(to 1)
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 8
Code
Structured in sections :
DFB Type Name
IEC compliant, one single section
Not IEC compliant, several sections
Copy of
Inputs Outputs
Variables
Section
written in instruction list,structured text,
ladder language, functional block diagram
a symbolic name (32 characters max)
a validation condition
I/O
protection attribute (no protection, write-
protected, read/write-protected)
Public Variables
comment (maximum of 256 characters)
Private Variables
DFB Code
Use only the parameters defined for the
function block or the system words and bits
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 9
Example : create
Name : Parts_counter
Inputs :
Rst : reset the counter
Preset : counter preset value
Count : counter input
Output :
Done : preset value reached output
Public variable :
Cur_val : current value increment by the
count input
Code
Descriptive form
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 10
Use - principles
Project browser
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 11
Use - example
DFB instantiation :
DFB instances used under Unity Pro, L or XL
in all application tasks except event tasks and
SFC transitions
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 12
Overview
Embedded diagnostic
to make a diagnostic at source (directly at the PLC level)
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 13
Principle
Detecting Memorizing
Viewing VIEWER
Diag DFB Diag BUFFER
PLC Viewer 1
Application Message
Diag Acknowledge
Buffer
Registration
Acknowledge
Viewer 2
Message
Date
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 14
Registration
Alarm Registration
The error registration instruction REGDFB ( ) write a time
stamped record inside the Diag buffer when an error occurs.
Many registrations can be managed inside a same DFB (up to 4
registrations)
Use only inside Diagnostic DFBs
Syntax
REGDFB (AREA, 16#0062, SLEN, CTRL, PIN, VALPIN,
ESTS, ERID, STAT
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 15
De-registration
Alarm De-registration
The ‘de-registration’ instruction DEREG ( ) updates inside the
buffer the date and time attached to the error disappearance
The Message will be deleted inside the buffer only when ALL the
Viewers have got the acknowledgment information
Use only inside Diagnostic DFBs
Syntax
OUT := DEREG(ERID);
Note: the alarm remains saved in the diagnostics buffer until the
error is acknowledged (for errors that require acknowledgement)
and read by all Viewers.
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 16
Creation
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 17
Creation (cont)
Unity traininc course V2.0 - Module 3.D : DFB & Diagnostic DFB 18