You are on page 1of 12

Module 14

DFB
October 2008

Overview
DFB is a user logic encapsulated in a
reusable block
To structure the application, simplify the
program creation, improve readability, make
debugging easier and protect your know-how

The designer programs and debugs the DFB


function block model called DFB Type
DFB can be protected and exported / imported
between designer and users
DFB is local to an application or global in
library

The end user creates an image of this block


called DFB Instance" and use it on the
application
DFB code is loaded only once in the CPU

Schneider Electric

- Training M RUIZ June 2008

DFB Structure
DFB type
Inputs

Outputs

Inputs/outputs
Public / private variables

Code sections

Name : 32 characters max


Inputs / outputs parameters

Public or private internal


variables
One or several sections of
program
Comment : 1024
characters max

Schneider Electric

- Training M RUIZ June 2008

I/O Parameters and Internal Variables


Inputs : 32 max
In read only by the DFB
To transfer values from application to DFB

Outputs : 32 max
In write only by the DFB
To transfer values from DFB to application

Inputs / outputs : 32 max


In read / write by the DFB
To transfer values to DFB, modify and return them to application

Private variables : unlimited


Only used by DFB (i.e. : intermediate variable)

Public variables : unlimited


Used by DFB and application or user in adjust mode
Values modified (program / adjustment) can be saved as initial values by setting %S94
Schneider Electric

- Training M RUIZ June 2008

Section of Program
DFB structured in program sections
IEC compliant : only one section
Not IEC compliant : several sections

Section
Symbolic name
Written in LD, IL, ST, FBD
Validation condition
Protection (no, write, read / write)
Comment : 256 characters max

Use only parameters and variables defined for


function block or system bits and words

Schneider Electric

- Training M RUIZ June 2008

DFB Properties
General attributes
Name
Comment : 1024 characters max
Protection : None, read only, no read & write
(independent of application protection)
Diag : to define a user diagnostic DFB

Descriptive form
To edit descriptive file

Schneider Electric

- Training M RUIZ June 2008

Use a DFB Instance


DFB instance
Used in all application tasks except
event tasks and SFC transitions
Connect inputs / outputs to
application variables of same type

DFB instance used as


A standard block in LD and FBD
languages
An elementary function in ST or IL
languages

Schneider Electric

- Training M RUIZ June 2008

Store DFB in Library

User types are saved into


Custom Lib family
Possibility to create sub-families

Copy into library DFB


type to store
Schneider Electric

- Training M RUIZ June 2008

Diagnostic DFB
A DFB can be used for application diagnostics at source (directly at the PLC
level)
Defaults are registered in the Diag buffer with a datation made by the PLC
The clients (viewers) can display and acknowledge these defaults
Detecting
Diag DFB

Memorizing
Diag BUFFER

Viewing VIEWER

PLC
Message

Application
Diag
Buffer

Viewer 1

Acknowledge

Registration
Acknowledge

Viewer 2
Message

Date

Schneider Electric

- Training M RUIZ June 2008

Principle
Detecting
Diag DFB

Memorizing
Diag BUFFER

Viewing VIEWER

PLC
Message

Application
Diag
Buffer

Viewer 1

Acknowledge

Registration
Acknowledge

Viewer 2
Message

Date

Schneider Electric

- Training M RUIZ June 2008

10

Registration / Deregistration
REGDFB function is used to write a time stamped record inside the Diag
buffer when an error occurs (up to 4 registrations inside a same DFB)
DEREG function updates inside the Diag buffer the date and time of the error
disappearance. The message is delete inside the buffer only when ALL clients
have acknowledged the default (for errors that require acknowledgement)
REGDFB and DEREG functions are only available inside a diagnostic DFB
Syntaxes are as follows
REGDFB(AREA, 16#0062, SLEN, CTRL, PIN, VALPIN, ESTS, ERID, STAT)
OUT := DEREG(ERID)

Schneider Electric

- Training M RUIZ June 2008

11

Create a Diagnostic DFB


Activate the Application diagnostics option for
your project (Tools / Project settings)
Access to the DFB properties (through the
DFB Types tab of the Data Editor)
Activate Diag option of DFB type
Activate Diag option of each monitored inputs
Create the program to manage the monitored
inputs and register the defaults (use REGDFB
and DEREG functions)
Instanciate the DFB and customize the default
messages according to your project
Schneider Electric

- Training M RUIZ June 2008

12