Académique Documents
Professionnel Documents
Culture Documents
Note
V1.0
2006/08/01
2/14
Table of Contents
Table of Contents ......................................................................................................... 3
Description ................................................................................................... 4
Objectives .................................................................................................... 4
Summary of the Sample Program................................................................ 4
1
1.1
1.2
1.3
2
2.1
2.2
2.3
V1.0
2006/08/01
3/14
Using Data Blocks (DB) for storage of data used and generated by the
FB task.
Two views of DB1: one containing the gasoline engine initial parameter
values and one containing the gasoline engine initial and actual
parameter values
Table 1-2 displays the Symbol Table containing all of the global symbols
used in the program.
V1.0
2006/08/01
4/14
OB1, Network 1
FB1 (Engine), Network 1
OB1, Network 2
The outputs of the Gasoline Engine instance of FB1 are set as follows:
#Engine_On output is set to 1.
#Preset_Speed_Reached is set to 1 when the following parameters are set as specified:
"Automatic Mode" is set to 0.
#Switch_On is set to 1.
#Switch_Off is set to 0.
#Failure is set to 1.
#Actual_Speed is set to a value greater than the #Preset_Speed.
DB1 (Gasoline) - Gasoline Engine Initial Values
V1.0
2006/08/01
5/14
OB1, Network 4
FC1, Network 1
The #Fan_On output of the Gasoline Engine Fan FC1 is set to 1 when the following
parameters are set as specified:
#Engine_On is set to 1.
#Timer_Function is set to 1.
When #Engine_On is set to 0, the #Fan_On output of the Gasoline Engine Fan FC1 is set to
0 after 4 seconds have elapsed.
Table 1-2: FB_FC_DB Program Symbol Table
V1.0
2006/08/01
6/14
Global symbols appear in quotation marks ("name") and are valid in the
entire program. "Block-specific" symbols are represented with a hash
symbol before the name (#name) and are only valid within the FB or FC.
Note
V1.0
2006/08/01
7/14
1.1
OB1
This is the call for the function block FB1 ("Engine") with the data for a
gasoline engine (data block "Gasoline" DB1).
V1.0
2006/08/01
8/14
This is the call for the function block FB1 ("Engine") with the data for a
diesel engine (data block "Diesel" DB2).
Network 4: Controlling the Fan for the Gasoline Engine
Figure 1-4: OB1 - Network 4
This is the call for the function FC1 to control the gasoline engine fan.
When the gasoline engine is turned off, FC1 causes a 4-second time delay
before the gasoline engine fan is turned off.
V1.0
2006/08/01
9/14
This is the call for the function FC1 to control the diesel engine fan. When
the diesel engine is turned off, FC1 causes a 4-second time delay before
the diesel engine fan is turned off.
1.2
FB1
This function block contains a memory function for controlling the engine
and a comparator for monitoring the speed.
We want to use the same function block to control two different engines.
We therefore want to assign all the "engine-specific" signals as function
block parameters. The signals that are scanned are the inputs of the
function block ("in" declaration); the signals that are modified are the
outputs ("out" declaration). One of the local variables, #Preset_Speed, is
engine-specific, but because it is a fixed value, it can be stored as static
data in the engine data ("stat" declaration). This is known as a "static local
variable".
Figure 1-6: Function Block Variable Detail View
When the function block is processed (block call) in the organization block
OB1, we will assign the function block parameters the specific signals for
each engine.
V1.0
2006/08/01
10/14
Note
#Failure is a "zero-active" signal, which usually has the signal state "1" (if
there is no error) and signal state "0" when an error occurs. The required
function is obtained if we program a normally closed contact for the signal
#Failure.
If both the set and reset signal states are "0", nothing is changed. If both
signal states change to "1" at exactly the same time, the reset instruction
dominates because of the order; #Engine_On is reset (signal state is 0).
V1.0
2006/08/01
11/14
1.3
FC1
You can program a function (FC) when the algorithm (the control function)
does not have to store any of its own data. In contrast to a function block
(FB), a function has no instance data block.
This example shows a simple function: a fan starts when the engine is
switched on. When the engine is switched off again, the fan continues to
run for another 4 seconds and then stops.
The box "S_OFFDT" is taken from the Program Elements catalog and
labeled #Timer_Function. The variable #Timer_Function is started with the
input parameter #Engine_On. This variable #Timer_Function with the data
type TIMER stands for a timer function which is assigned a timer address
(for example, T1) later on when it is called in OB1.
The timer function provides a switch-off delay, with a timer delay of 4
seconds. You can also assign the time delay as an input parameter with the
data type S5TIME so that a different follow-on time can be configured for
the fan in each engine.
V1.0
2006/08/01
12/14
Reference Information
2.1
Application
An FB contains a program that is always executed when the FB is called by
a different logic block. Function blocks make it much easier to program
frequently occurring, complex functions.
Function Blocks and Instance Data Blocks
An instance data block is assigned to every function block call that transfers
parameters.
2.2
Application
An FC contains a program section that is always executed when the FC is
called by a different logic block. You can use functions for the following
purposes:
V1.0
2006/08/01
13/14
2.3
If a logic block (FC, FB, or OB) is called, it can occupy space in the local
data area (L stack) temporarily. In addition to this local data area, a logic
block can open a memory area in the form of a DB. In contrast to the data
in the local data area, the data in a DB are not deleted when the DB is
closed (in other words, after the corresponding logic block has been
executed).
Each FB, FC, or OB can read the data from a shared DB or write data to a
shared DB. This data remains in the DB after the DB is exited.
An FB can open and use a shared DB and an instance DB at the same
time. Figure 2-1 shows the different methods of access to data blocks.
Figure 2-1 Shared and Instance DBs
V1.0
2006/08/01
14/14