# DF unction Blocks George W

Document Sample

```					ME4447/6405

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Section Objectives:
Before the invention of the Programmable Logic Controller
(PLC), most industrial control was done using relay control
panels.
Switches and relays can be arranged in circuits to make
logical decisions. Output from these circuits can be used to
drive “loads” such as motors, heaters, or electromagnetic
coils. A relay control panel is comprised of a single to
thousands of these circuits.
In this Section, relay control panels will be presented.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Control Panel Components : Switch

2                                      2
1                                     1

3                                      3

Off: contacts 1 and 2 connected         On: contacts 1 and 3 connected

Pins 1 and 2 are “normally closed” since they are connected when the
switch is off. T Pins 1 and 2 are not connected when the switch is on.

Pins 1 and 3 are “normally open” since they are not connected when the
switch is off. Pins 1 and 3 are connected when the switch is on.

(Note: Although this is a toggle switch, this switch can symbolize any type
of input source such as push button switches, sensors, power supplies,
etc. in this lecture.)

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Control Panel Components : Coil

Coil off                                Coil on

(Note: Although this is really an electromagnetic coil, this can symbolize
any “load” such as a pump, dc motor, heating element, light, etc. for this
lecture.)

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Control Panel Components : Relay
1
1

3        2
3         2
Off: Coil off, contacts                      ON: Coil on, contacts
1 and 2 connected                            1 and 3 connected

A relay is a combination of coil and switch.

With coil off, the switch goes to its normal position off.

With coil on, the switch is pulled by electromagnetic force to its on
position.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : NOT (Inverter)
Using one switch, a logical “NOT” operation can
be constructed. An example is given below:

“NOT” Switch 1 = Coil

V+             Switch 1                          Coil
2
1

3

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Relay Logic : NOT (Continued)
“NOT” Switch 1 off = Coil on     Switch 1   Coil
0       1
V+             Switch 1                            Coil
2
1

3

“NOT” Switch 1 on = Coil off     Switch 1   Coil
1       0
V+             Switch 1                            Coil
2
1

3

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : AND
Using two switches, a logical “AND” operation can
be constructed. An example is given below:

Switch 1 “AND” Switch 2 = Coil

V+             Switch 1              Switch 2          Coil
2
2
1
1
3
3

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : AND (continued)
Switch 1 off “AND” Switch 2 off = Coil off
V+              Switch 1               Switch 2         Coil
2
2
1
1
3
3

Switch 1   Switch 2   Coil
0          0          0

Switch 1 on “AND” Switch 2 off = Coil off
V+              Switch 1               Switch 2        Coil
2
2
1
1
3
3
Switch 1   Switch 2   Coil
1        0        0
George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : AND (continued)
Switch 1 off “AND” Switch 2 on = Coil off
V+              Switch 1               Switch 2         Coil
2
2
1
1
3
3

Switch 1   Switch 2   Coil
0          1          0

Switch 1 on “AND” Switch 2 on = Coil on
V+              Switch 1               Switch 2        Coil
2
2
1
1
3
3
Switch 1   Switch 2   Coil
1        1         1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : OR
• Using two switches, a logical “OR” operation can be constructed.
• Parallel structure because when either is on, current will flow through
output coil
• Example is given below:
•Switch 1 “OR” Switch 2 = Coil

V+              Switch 1
2                               Coil
1

3

Switch 2
2
1

3

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : OR
Switch 1 off “OR” Switch 2 off = Coil off

V+             Switch 1
2                               Coil
1

3

Switch 2
2
1

3             Switch 1   Switch 2      Coil
0        0           0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : OR
Switch 1 on “OR” Switch 2 off = Coil on

V+             Switch 1
2                               Coil
1

3

Switch 2
2
1

3             Switch 1   Switch 2      Coil
1          0           1

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : OR
Switch 1 off “OR” Switch 2 on = Coil on

V+             Switch 1
2                               Coil
1

3

Switch 2
2
1

3             Switch 1   Switch 2      Coil
0          1           1

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : OR
Switch 1 on “OR” Switch 2 on = Coil on

V+             Switch 1
2                               Coil
1

3

Switch 2
2
1

3             Switch 1   Switch 2      Coil
1          1           1

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : XOR
Using two switches and four relays, a logical “XOR” operation can be
constructed. An example is given below:

Switch 1 “XOR” Switch 2 = Coil

V+                      V+
V+        Switch 1
1                       1
2
1                                                                       Coil
3
3        2              3        2

Switch 2
1                       1
2
1

3
3        2              3        2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : XOR (continued)
Switch 1   Switch 2   Coil
Switch 1 off “XOR” Switch 2 off = Coil off
0          0        0

V+                       V+
V+        Switch 1
1                        1
2
1                                                                             Coil
3
3        2              3          2

Switch 2
1                        1
2
1

3
3        2              3          2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : XOR (continued)
Switch 1   Switch 2   Coil
Switch 1 on “XOR” Switch 2 off = Coil on
1          0        1

V+                       V+
V+        Switch 1
1                        1
2
1                                                                             Coil
3
3        2              3          2

Switch 2
1                        1
2
1

3
3        2              3          2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : XOR (continued)
Switch 1   Switch 2   Coil
Switch 1 off “XOR” Switch 2 on = Coil on
0          1        1

V+                       V+
V+        Switch 1
1                        1
2
1                                                                             Coil
3
3        2              3          2

Switch 2
1                        1
2
1

3
3        2              3          2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Relay Logic : XOR (continued)
Switch 1   Switch 2   Coil
Switch 1 on “XOR” Switch 2 on = Coil off
1          1        0

V+                       V+
V+        Switch 1
1                        1
2
1                                                                             Coil
3
3        2              3          2

Switch 2
1                        1
2
1

3
3        2              3          2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Problems with relay control panels:
Mechanical Relays and switches failed regularly (coil failure, contact
wear and contamination, etc.)
Difficult to diagnose problems and replace relays and switches
Difficult to change hardwired logic (example: changing an “OR” circuit
to “XOR”)
Consumed a lot of power

To address these problems, Richard E. Morley of Bedford
Associates invented the first PLC as a consulting project for
General Electric in 1968. Bedford Associates is currently named
Modicon and is a supplier of PLCs.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Section Objectives:
Basic PLC Components needed to replace relay control
panels will be presented. These include:
Isolated Power Supply           Digital Input and Output pins ( DI/0)
Micro-controller                Memory
(Note: Advanced features such as Timers, Interrupts, Counters, etc.
will not be discussed in this lecture)

For this lecture, Siemens A&D S7
314C-2 PtP PLC installed in the
Mechatronics Laboratory will be used
as an example.
Siemens 314C-2 PtP

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Basic PLC: Isolated Power Supply
Every PLC has an external or internal Isolated Power Supply.
Isolated Power Supplies can have more than one isolated
outputs.
One isolated output is reserved for the PLC micro-controller. The
rest are reserved for other components such as DI/O.
Normally Power supplies are high voltage. Typically 24 Volts for
industrial PLCs.

The S7 314C-2 PtP PLC uses the
Siemens A&D PS307 5A power supply.
The PS307 5A can source 5 amps of
current at 24 volts. The PS307 5A has 3
isolated outputs.
Siemens PS307 5A

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Basic PLC: Micro-controller

Every PLC has at least one micro-controller

The S7 314C-2 PtP PLC uses a custom micro-controller.
Designed by Siemens A&D and manufactured by Infineon
Part Number:
Infineon
Siemens A&D
IBC 16
SXA1020A-E
S7 Controller
Specifications not given in documentation

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Basic PLC: Digital Inputs and Outputs (DI/Os)

DI/Os are electrically isolated from the micro-controller
modules.

Example:
The S7 314C-2 PtP PLC has 16 digital
outputs and 24 digital inputs. Can be
expanded up to 1024 DI/Os by adding

SM232 DI/O module

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Basic PLC: Memory

Memory on a PLC is separated into 3 main areas:
•    Can be RAM (dynamic) or EEPROM (retentive)
•    Used to store user programs
•    For S7 314C-2 PtP PLC : LOAD Memory located on memory card
WORK Memory
•    Memory is RAM
•    When PLC starts, Program is copied from LOAD memory to
WORK memory. The program is then executed from Work memory.
•    For S7 314C-2 PtP PLC: 48K bytes of WORK memory

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Basic PLC: Memory ( Continued)
SYSTEM Memory
    Memory is RAM
    Is used by micro-controller to implement counters, timers, interrupt
stacks, etc..
    Contains a bit for each D I/0
    Contains “Marker Memory”. Marker memory is a free area of RAM
that can be used by the programmer. (In S7 314C-2 PtP, 258
bytes are available as Marker Memory)
    Contains “Process Input and Output Images.” Periodically the PLC
will store the states of the inputs to the Process Input Image and
Process Output Image to the output. (In S7 314C-2 PtP, this is
limited to the first 128 bytes of input information and 128 bytes of
output information.)

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Section Objectives:
Initially PLCs were used to directly replace relay control
panels. To directly replace relay control panels based on
mechanical relays with PLCs based on a micro-controller
presented challenges. These challenges and solutions will
be discussed.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Transition:A Simplified Programmer’s Model
In the simplified programmer’s model of relay logic, all inputs I1, I2, .., Im
go into each relay logic section. Each relay logic section then produces an
output Q.

I1,I2, … ,Im         Relay Logic Section 1              Q1

I1,I2, … ,Im         Relay Logic Section 2              Q2

.
.
.

I1,I2, … ,Im         Relay Logic Section n              Qn

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Transition: Relay control panel execution of Model
A relay control panel will execute all relay logic sections in parallel since
each switch is capable of powering many coils at a time. If any input
changes at time t0 then all the relay logic sections will update the outputs
at time t1.

I1,I2, … ,Im changes at t0          Relay Logic Section 1           Q1 changes at t1

I1,I2, … ,Im changes at t0          Relay Logic Section 2           Q2 changes at t1

.
.
.

I1,I2, … ,Im changes at t0          Relay Logic Section n           Qn changes at t1

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Transition: PLC execution of Model
A PLC will execute all relay logic sections in series since a micro-
controller can execute only one instruction at a time. If any input changes
at time t0 then relay logic section 1 will update Q1 at t1, relay logic section
2 will update Q2 at t2, …. , and relay logic section n will update Qn at tn.

I1,I2, … ,Im changes at t0           Relay Logic Section 1           Q1 changes at t1

I1,I2, … ,Im changes at t0           Relay Logic Section 2           Q2 changes at t2

.
.
.

I1,I2, … ,Im changes at t0           Relay Logic Section n           Qn changes at tn

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Transition: Differences in Relay Control Panel vs.
PLC execution of Model
Difference 1:
Relay Control Panel – The maximum time any change in input is reflected in any output is t1.
PLC – The maximum time any change in input is reflected in any output is t1+t2+…+tN.

Difference 2:
Relay Control Panel – Since this is made from analogue components. It is possible to replace
a logic section without stopping execution of other logic sections if wired correctly.
PLC – This is made with a digital micro-controller. The micro-controller must be halted to
replace a logic section. All other logic sections will stop operation.

Difference 3:
Relay Control Panel – Since parallel execution of logic sections, all outputs are a function of
one set of inputs.
PLC – Since serial execution of logic sections, all outputs may not be a function of one set of
inputs. (example: input I2 may change as the micro-controller is processing Logic section 2.
George W. Q2 are based on of Mechanical
Therefore Q1 and Woodruff Schooldifferent inputs) Engineering, Georgia Tech
ME4447/6405

Transition: PLC Operation
To minimize the effects of differences between the Relay Control Panel and PLC
execution of the programming model, the PLC operates in the following manner:
Steps:
•   PLC Restarts (Warm Restart - contents of RAM
Warm Restart                                      are maintained)

Update Process Input Image
•   Executes User Program Once

•   Writes Process Output Image to Outputs
scan cycle

User Program

•   Take care of system processes ( such as
communications with other PLCs, updating user
Update Process Output Image
program, checking for STOP condition, etc..)

PLC System Processes
•   Loop Back to step 2

Steps 2 through 5 is called a scan cycle. (Note:
some people may refer to a PLC as a
STOP
Programmable “Loop” Controller because of the
scan cycle loop.)
George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Transition: PLC Operation
To Minimize Difference 1:
Time to complete a scan cycle can be set by user. If PLC violates the scan cycle, an interrupt
routine can be run or the PLC will halt execution. (For S7 314C-2 PtP, maximum scan
cycle allowed is 6 sec)
(All outputs of PLC must be updated at the fixed time set by the user)
To Minimize Difference 2:
If a part of the user program is replaced, the new part is written first to LOAD memory. During
step 5, PLC System Processes, the new part is copied into WORK memory from LOAD
Memory. During the next scan cycle, the new part of the user program will be executed.

To Minimize Difference 3:
If the programmer uses the inputs stored in the Process Input Image, the user program will
have access to the same inputs per scan cycle. Also if the programmer, writes outputs to
the Process Output Image, all the outputs will be updated simultaneously during step 4
(Update Process Output Image)
George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Section Objectives:
The biggest transition from relay control panels to PLCs
was the transition from the hard wired relay logic to logic
defined by user program. In order to allow established relay
logic users to program the PLC, a visual programming
language that looks like a relay control panel was created.
This visual programming language is called “Ladder Logic”.
In this section, basic Ladder Logic will be presented.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

To address a bit of memory

___ ___ . ___

Memory Area         Byte Address      Bit Number
Notation

To address a byte, word, or double word
___ ___ ___

Notation             Memory Notation

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Memory Area Notations:
Notation             Memory Area
I         Process Input Image

Q         Process Output Image

M         Marker Memory

PI        Peripheral Input ( Actual Input Pins)

PQ        Peripheral Output ( Actual Output Pins)

T         Timer Storage Area

C         Counter Storage Area

L         Local Memory of current Data Block

DB        Data Block Memory

(Note: Advanced features such as Timers, Counters, Data
Blocks Woodruff discussed in this lecture)
George W.will not beSchool of Mechanical Engineering, Georgia Tech
ME4447/6405

B       Byte (8 bits)

W       Word (16 bits)

D       Double Word (32 bits)

Each Memory Area is addressed in one byte increments
starting at byte 0.

Bit Number:
MSBit is 7 and LSBit is 0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Examples:

Marker Area

Byte 0           MB0
M1.3
(Note: only bit 3 of                 Byte 1
Marker Area byte 1)                                   MW1
Byte 2

Byte 3

Byte 4
MD3
Byte 5

Byte 6           MD4

Byte 7

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Examples:

Peripheral Input
Area
Byte 0

Byte 1         PIB1
PI2.5
(Note: only bit 5 of                  Byte 2
Peripherial Input Area byte 2)
Byte 3

Byte 4

Byte 5
PID4
Byte 6

Byte 7

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

are the power rail on the left and ground rail on the right. The rungs of the
ladder consists of Virtual Relay Components. (Note: Rungs are called
“Networks” in Step 7) (Currents always flow from power to ground)

Virtual Relay Components
Power Rail

Ground Rail
Virtual Relay Components

Virtual Relay Components

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Virtual Relay Components:

Mechanical Relay               Normally Open Switch ( equivalent to pins 1
and 3 of Mechanical Relay. If this switch is
1                closed for a virtual digital output relay, the
digital output pin is high. If this switch is open
for a virtual digital output relay, the digital output
pin is low )
3          2

Normally Closed Switch ( equivalent to pins 1
and 2 of Mechanical Relay)

Coil ( equivalent to coil of Mechanical Relay.
Used only as output to control state of output bit.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Ladder Logic : Virtual Relays (continued)
Any Marker or Function Block memory bit can be used to turn coils on/off in
order to control switches in one or more virtual relays.
If memory bit is 0, the coils of virtual relays associated with the bit are off.
If memory bit is 1, the coils of virtual relays associated with the bit are on.
Examples:
I0.0 bit controls both normally open and normally close switches in two
virtual relays
I0.1 bit controls both normally open and normally close switches in two
virtual relays

I0.0                  I0.1                  Q0.0

I0.0                  I0.1

Any D I/O memory bit ( Peripheral or Process Image) is a virtual relay for a
digital input or output pin of the PLC.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405    Logic: Rules for converting (transforming)
Each external signal source (e.g. Sensors, switches, push buttons
etc.) must be connected to an input pin of a PLC.
Each external load (e.g. Motors, solenoids, etc.) must be connected to
an output pin of a PLC.
Relay logic must be recreated by using virtual input and output relays
associated with input and output pins. (Virtual relay components at least
consist of virtual relays associated with all input and output pins)

Example: Ladder Logic : NOT (an inverter)
I0.0                                         Q0.0

Virtual Relay Components

Virtual Relay                                Virtual Relay
associated with input pin I0.0             associated with output pin Q0.0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Ladder Logic: Rules for converting Relay Logic
Construct Ladder Logic based on each possible virtual path inside
PLC from power to ground depending on connections between virtual
relays (using Virtual Relay Components to replace switches and coils
along the possible virtual paths):
1

Use           to replace normal closed switch
3       2

1
Use           to replace normal open switch

1             3       2
Use           to replace coil

3       2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Converting Relay Logic to Ladder Logic :NOT (an inverter)
“NOT” Switch 1 = Coil

From Relay Logic:

V+               Switch 1 (off state)           Coil (on state)
2
1

3

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Converting Relay Logic to Ladder Logic :NOT(continued)

• Separate external input and output :(make sure the circuits are connected to the
terminal 3 of the switch)
• Recreate circuit using relay without changing functionality of original circuit

Switch 1            NOT Operator (using 1 Relay)
V+        (off state)
2
V+
1                                        1
Coil
3
External input
3        2

External output

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic :NOT(continued)
Recreate Relay Logic to include Virtual Input and Output Relays associated with
each input and output pins(1 input + 1 output = 2 Virtual Relays) :

NOT Operator using 2 virtual Relays
inside PLC
V+       Switch 1
2
V+                  V+
Coil
1                                 1                   1

3
External input
(Note: Wired to PLC
3         2         3        2
Input Pin Associated
with I0.0)                                                            External output
Virtual Relay                               (Note: Wired to PLC
Virtual Relay         Output Pin Associated
associated with
associated with        with Q0.0)
input pin I0.0
output pin Q0.0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic :NOT(continued)
Construct Ladder Logic using Virtual Relay Components to replace switches
and coils along the possible virtual path inside PLC from power to ground :
NOT Operator using 2 virtual Relays inside PLC
V+       Switch 1
V+                       V+
2
Coil
1                                    1                        1

3

3        2               3        2

I0.0                                              Q0.0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Converting Relay Logic to Ladder Logic :NOT(continued)

Switch 1 (push buttons, sensors, etc.) is wired to PLC input pin
associated with I0.0
Coil (loads, motors, lights, etc.) is wired to PLC output pin associated
with Q0.0

I0.0                                     Q0.0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic : AND

Switch 1 “AND” Switch 2 = Coil

From Relay Logic:

V+             Switch 1              Switch 2          Coil
2
2
1
1
3
3

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic : AND(continued)
Separate external switches and coil and recreate circuit using relays:

AND Operator using 2 Relays
V+       Switch 1
V+
2
1                                   1
Coil
3

V+       Switch 2                            2
3
2
1                                  1

3

3         2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Converting
ME4447/6405           Relay Logic to Ladder Logic : AND(continued)
Recreate Relay Logic to include Virtual Input and Output Relays associated with
each input and output pins (2 inputs + 1 output= 3 Virtual Relays) :

AND Operator using 3 virtual Relays
V+       Switch 1
2
V+ inside PLC
1                                    1

3
(Note: Wired to PLC                                                  V+
Input Pin Associated                                                                         Coil
3         2
with I0.0)                                                            1
Virtual Relay
associated with
input pin I0.0

V+       Switch 2                                                3           2

2                                                              (Note: Wired to PLC
Output Pin Associated
1                                    1
Virtual Relay          with Q0.0)
3                                      associated with
(Note: Wired to PLC                                        output pin Q0.0
Input Pin Associated
3 2
with I0.1)            Virtual Relay
associated with
George W. Woodruff School
input pin I0.1
of Mechanical Engineering, Georgia Tech
Converting
ME4447/6405          Relay Logic to Ladder Logic : AND(continued)
Construct Ladder Logic using Virtual Relay Components to replace switches and
coils along the possible virtual path inside PLC from power to ground :
V+       Switch 1
2
V+
1                                   1
3
V+
3          2
1
Coil
Virtual Relay
associated with
V+                      input pin I0.0                 3        2
Switch 2
2
1                                   1        Virtual Relay
3                               associated with
output pin Q0.0
2
Virtual Relay3
associated with
input pin I0.1
I0.0              I0.1                     Q0.0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic : AND(continued)

Switch 1 is wired to PLC input pin associated with I0.0
Switch 2 is wired to PLC input pin associated with I0.1
Coil is wired to PLC output pin associated with Q0.0

I0.0          I0.1                       Q0.0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic : OR

Switch 1 “OR” Switch 2 = Coil
From Relay Logic:

V+             Switch 1
2                              Coil
1

3

Switch 2
2
1

3

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic : OR(continued)
Separate external switches and coil and recreate circuit using relays:

OR Operator using 2 Relays
V+       Switch 1
2
V+
1                                      1

3

3         2                           Coil

V+       Switch 2                           V+
2

1                                       1

3

3        2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Converting
ME4447/6405           Relay Logic to Ladder Logic : OR(continued)
Recreate Relay Logic to include Virtual Input and Output Relays associated with
each input and output pins(2 inputs +1 output =3 Virtual Relays) :
OR Operator using 3 virtual Relays
V+       Switch 1
2
V+ inside PLC
1                                    1

3
(Note: Wired to PLC                                         V+
Input Pin Associated                                                              Coil
3         2
with I0.0)                                                   1
Virtual Relay
associated with
input pin I0.0

V+       Switch 2                                       3           2
V+
2                                                   (Note: Wired to PLC
Output Pin Associated
1                                    1
Virtual Relay        with Q0.0)
associated with
(Note: Wired to PLC                               output pin Q0.0
Input Pin Associated
3          2
with I0.1)               Virtual Relay
associated with
input pin I0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
Converting
ME4447/6405            Relay Logic to Ladder Logic : OR(continued)
Construct Ladder Logic using Virtual Relay Components to replace switches and
coils along each possible virtual path inside PLC from power to ground :
V+     Switch 1
2             V+
1                                1

3
V+
3         2                              Coil
Virtual Relay                        1
associated with
V+       Switch 2    input pin I0.0 V+
2
3          2
1                                1

Virtual Relay
associated with
2   output pin Q0.0
3
Virtual Relay
associated with
input pin I0.1

I0.0                                        Q0.0

I0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic : OR(continued)

Switch 1 is wired to PLC input pin associated with I0.0
Switch 2 is wired to PLC input pin associated with I0.1
Coil is wired to PLC output pin associated with Q0.0

I0.0                                      Q0.0

I0.1

 Parallel structure because when either switch is on, current will flow
through output coil

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic : XOR
Switch 1 “XOR” Switch 2 = Coil
From Relay Logic:

V+                      V+
V+        Switch 1
1                       1
2
1                                                                   Coil
3
3        2              3        2

Switch 2
1                       1
2
1

3
3        2              3        2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Converting
ME4447/6405        Relay Logic to Ladder Logic : XOR(continued)
Recreate Relay Logic to include Virtual Input and Output Relays associated with
each input and output pins (2 inputs with each one controlling 2 Virtual Relays+ 1
output =5 Virtual Relays) :
XOR Operator using 5 virtual Relays
Virtual Relay associated
inside PLC
V+       Switch 1          with input pin I0.0
Virtual Relay associated
2             V+                     V+ with input pin I0.0
1                             1                      1

3                                                  Virtual Output
(Note: Wired to PLC                                                    Relay at Q0.0               Coil
Input Pin Associated                                                             V+
3        2             3        2
with I0.0)
1

V+       Switch 2
2

1                             1                                         3          2
1                                 (Note: Wired to
PLC Output Pin
Associated with
(Note: Wired to PLC                                                                         Q0.0)
Input Pin Associated
3        2             3        2
with I0.1)
Virtual Relay associated       Virtual Relay associated
with input School
George W. Woodruffpin I0.1 of              with Engineering,
Mechanicalinput pin I0.1 Georgia Tech
Converting
ME4447/6405          Relay Logic to Ladder Logic : XOR (continued)
Construct Ladder Logic using Virtual Relay Components to replace switches and
coils along each possible virtual path inside PLC from power to ground :
Virtual Relay associated
V+                                                     Virtual Relay associated
Switch 1        with input pin I0.0
with input pin I0.0
2               V+                    V+
1                            1                     1
3
Virtual Relay          Coil
Associated with V+
3        2            3        2
output pin Q0.0 1
V+       Switch 2
2
1                            1                     1
3                                                       3        2

3        2            3        2

Virtual Relay associated     Virtual Relay associated
with input pin I0.1          with input pin I0.1

I0.0                      I0.1                      Q0.0

I0.0               I0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Converting Relay Logic to Ladder Logic : XOR (continued)

Switch 1 is wired to PLC input pin associated with I0.0
Switch 2 is wired to PLC input pin associated with I0.1
Coil is wired to PLC output pin associated with Q0.0

I0.0                I0.1                Q0.0

I0.0                I0.1

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Section Objectives:
A micro-controller can be used for more than relay logic
with virtual relays. Ladder logic has components that take
advantage of the micro-controller. These components can
be categorized as follows: bit logic,comparator, converter,
counter, data base calls, jumps, integer functions, floating
point functions, move, program control, shift/rotate, status
bits, timers, and word logic.
It is impossible to cover all of the components in one
lecture. This lecture will first explain formatting of constants.
Then, only a few categories and examples of components
will be shown.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Constants

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Constants

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Constants

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Constants

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Bit Logic

Available Bit logic components:

Normally Closed Switch                 Positive Edge Detection
Normally Open Switch                   Negative Edge Detection
Output Coil                            Address Positive Edge Detection
Midline Output                         Address Negative Edge Detection
Set Coil                               Set-Reset Flip Flop
Reset Coil                             Reset-Set Flip Flop
Save RLO into BR Memory                Immediate Write
Bit Exclusive OR

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Bit Logic example: Set Coil and Reset Coil

Description:
Set Coil is executed only if power flows to the coil. When executed, the specified
<address> of the element is set to "1". It will remain set even if power is removed
from the coil.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Bit Logic example: Set Coil and Reset Coil

Description:
Reset Coil is executed only if power flows to the coil. When executed, the
specified <address> of the element is reset to "0". No power flow to the coil has
no effect and the state of the element's specified address remains unchanged.
(Note: can be used to reset timers and counters)

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Bit Logic example: Set Coil and Reset Coil

Example:
Switch 1 connected to Input 0.0
Switch 2 connected to Input 0.1
Coil connected to Output 0.0

If Switch 1 is turned on then turn on Coil and keep it on even if Switch 1 is
released. If Switch 2 turns on then turn off the Coil.

I0.0                                     Q0.0

S

I0.1                                     Q0.0

R

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Comparator

Available Comparator components (Note: Integer is Word, Double Integer is
Double Word)
Integer: Equal to                     Double Integer: Greater than or Equal to
Integer: Greater than                 Double Integer: Less than or Equal to
Integer: Less than                    Real: Equal to
Integer: Greater than or Equal to     Real: Greater than
Integer: Less than or Equal to        Real: Less than
Double Integer: Equal to              Real: Greater than or Equal to
Double Integer: Greater than          Real: Less than or Equal to
Double Integer: Less than

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Comparator example: Integer Compares

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Comparator example: Integer Compares

Example:
Coil (any load) connected to Output 0.0

If MW0 and MW2 are equal then turn on coil.

Q0.0
CMP
== I
MW0       IN1

MW2       IN2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Jumps

Available Jump components (Note: called Logic control in Step 7 Help)

Label
Unconditional Jump
Conditional Jump
Not conditional Jump

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Jump example: Conditional Jump

Description Conditional Jump:
The micro-controller will goto the specified Label if power flows into the JUMP.
(Note: a label can be assigned to any Network)

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Jump example: Label and conditional Jump
Example:
Switch 1 connected to Input 0.0

I0.0                                     “END”
JMP

Components

Components

END

I0.1                                      Q0.0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Integer Math

Available Integer Math components:
(Note: Integer is Word, Double Integer is Double Word)

Integer: Subtract                  Double Integer: Multiply
Integer: Multiply                  Double Integer: Divide
Integer: Divide                    Double Integer: Modulus

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Description:
IN1 and IN2 are added and the result is stored in OUT when power is
applied to EN . Power (current) flows out of EN0 when the addition is
George W. Woodruff School of addition results in an overflow.
completed unless the result of the Mechanical Engineering, Georgia Tech
ME4447/6405

Example:
Add 5 and integer stored at MW0. Store the result in MW2.

EN     EN0

5         IN1

MW0       IN2   OUT      MW2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Move

Available Move components:

Move

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Move example:

Description:
When power is applied to EN, IN is moved to the variable connected to Out
and power flows out of EN0
George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Move example:
Example:
Move 5 to MW2.

MOVE

EN     EN0

5         IN1   OUT        MW2

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Timer

Available Timer components:

Pulse S5 Timer                         Pulse Timer Coil
Extended Pulse S5 Timer                Extended Pusle Timer Coil
On-Delay S5 Timer                      On-Delay Timer Coil
Retentive On-Delay S5 Timer            Retentive On-Delay Timer Coil
Off-Delay S5 Timer                     Off-Delay Timer Coil

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Timer example:
ME4447/6405           Extended Pulse S5 Timer

Description:
A power transition from OFF to ON on S will restart the timer. Power flows
from Q while timer is running. The timer will run for a preset time TV. (Note:
George W. Woodruff School of PLC. This gives the PLC the Tech
256 timers allowed in S7 314C-PtP Mechanical Engineering, Georgia capability to
control up to 256 different coils (loads, devices, etc.))
ME4447/6405

Timer example:
Example:
Switch 1 connected to Input 0.0
Coil is connected to Output 0.0

Turn on coil for 10 seconds if Switch 1 is turned on.

T0
I0.0                                        Q0.0
S_EXt
S           Q
S5T#10s      TV          BI
R     BCD

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Word Logic

Available Word Logic components:

“AND” Word                          “AND” Double Word
“OR” Word                           “OR” Double Word
“XOR” Word                          “XOR” Double Word

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Word Logic example: “AND” Word

Description:
When power is applied to EN, IN1 and IN2 are “ANDed”, and the result is
stored in the variable connected to OUT. Power always flows out of EN0

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example:
“AND” MW0 and MW2. Store the result in MW4.

WAND W

EN     EN0

MW0       IN1

MW2       IN2   OUT      MW4

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Section Objectives:
In this section two example ladder logic programs will be
given.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 1 :

Switch 1 connected to Input pin 0.0
Load connected to Output pin 0.0

If Switch 1 is on then turn on and off a load at 2 second intervals
(Note: 2 second interval means a period of 4 seconds and 50% Duty
cycle).

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Example
ME4447/6405 1 (Continued)
Time: Scan cycle just before t = 0s
User Action : None
Initial state: M0.0 = 0 (off); I0.0 = 0; Q0.0 = 0
Note: I0.0 is address for Input pin 0.0; Q0.0 is address for Output pin 0.0
• Content of address I0.0 can be 0 or 1 depending on state of switch
• Content of address Q0.0 can be 0 or 1 depending on whether current flows
through virtual coil,          ,associated with it
T0
I0.0      M0.0                                       Q0.0
S_EXt
S        Q
S5T#2s        TV       BI
R    BCD

T1
I0.0      Q0.0                                       M0.0
S_EXt
S        Q
S5T#2s        TV       BI
R    BCD

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405

Time:Scan cycle just before t = 0
User Action: None
Status of 1st Rung:
Content of I0.0 is 0. Current cannot flow through the virtual switch
associated with it.
Content of M0.0 is 0 because on second rung the virtual coil associated
with M0.0 is not energized. The virtual switch associated with M0.0 is
closed. However, no current flows through it.
Timer 0 is not started. No current flows out of Q.
Virtual coil associated with Q0.0 is not energized. The content of Q0.0 is 0.
Status of 2nd Rung:
Content of I0.0 is 0. Current cannot flow through the virtual switch
associated with it.
Content of Q0.0 is 0. The virtual switch associated with Q0.0 is closed.
However, no current flows through it.
Timer 1 is not started. No current flows out of Q.
Virtual coil associated with M0.0 is not energized. The content of M0.0 is 0.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Example
ME4447/6405   1 : Continued
Time:Scan cycle at t = 0
User Action: User turns Switch 1 on
Virtual switches and coils associated with M0.0 and Q0.0 prevent current from flowing
through two networks (rungs) at same time

T0
I0.0      M0.0                                            Q0.0
S_EXt
S         Q
S5T#2s         TV        BI   (Note:
R    BCD       Time left: 2 s)

T1
I0.0     Q0.0                                            M0.0
S_EXt
S         Q
S5T#2s         TV        BI
R    BCD

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405
Time: Scan cycle at t = 0
User Action: User turns Switch 1 on
Status of 1st Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of M0.0 is 0 because on second rung the virtual coil associated
with M0.0 is not energized. The virtual switch associated with M0.0 is
closed. Current flows through it.
Timer 0 is started. It will run for 2 seconds. Current flows out of Q when
timer is running.
The virtual coil associated with Q0.0 is energized. The content of Q0.0 is 1.
Status of 2nd Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of Q0.0 is 1. The virtual switch associated with it is open. No
current flows through it.
Timer 1 is not started. No current flows out of Q.
Virtual coil associated with M0.0 is not energized. Content of M0.0 is 0.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 1 : Continued
Time: Scan cycle just before t = 2s
User Action: Keeps pressing switch 1

T0
I0.0     M0.0                                          Q0.0
S_EXt
S        Q
S5T#2s      TV       BI   (Note:
R    BCD       Time left: ~0)

T1
I0.0    Q0.0                                        M0.0
S_EXt
S        Q
S5T#2s      TV       BI
R    BCD

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405
Time: Scan cycle just before t = 2 s
User Action: keep pressing Switch 1
Status of 1st Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of M0.0 is 0 because on second rung the virtual coil associated
with M0.0 is not energized. The virtual switch associated with M0.0 is
closed. Current flows through it.
Timer 0 is running. Current flows out of Q. BI is close to 0.
The virtual coil associated with Q0.0 is energized. The content of Q0.0 is 1.
Status of 2nd Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of Q0.0 is 1. The virtual switch associated with it is open. No
current flows through it.
Timer 1 is not started. No current flows out of Q.
Virtual coil associated with M0.0 is not energized. Content of M0.0 is 0.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Example 1 : Continued
Time: Scan cycle at t = 2 s
User Action: Keeps pressing switch 1
Note: M0.0 in first network is 0 but changes state to 1 in second network

T0
I0.0      M0.0                                               Q0.0
S_EXt
S        Q
S5T#2s         TV       BI   (Note:
Time left 0 s)
R    BCD

T1
I0.0     Q0.0                                            M0.0
S_EXt
S        Q
S5T#2s         TV       BI   (Note:
R    BCD       Time left: 2 s)

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405
Time: Scan cycle at t = 2 s
User Action: keep pressing Switch 1
Status of 1st Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of M0.0 is 0 because on second rung the virtual coil associated
with M0.0 is not energized yet. The virtual switch associated with M0.0 is
closed. Current flows through it.
Timer 0 is stopped. No current flows out of Q.
No current flows through the virtual coil associated with Q0.0. The content
of Q0.0 changes from 1 to 0.
Status of 2nd Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of Q0.0 is 0. The virtual switch associated with it is closed. Current
flows through it.
Timer 1 is started. Current flows out of Q.
Virtual coil associated with M0.0 is energized. Content of M0.0 changes
from 0 to 1.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 1 : Continued
Time: Scan cycle just after t = 2 s
User Action: Keeps pressing switch 1
M0.0 contains 1, therefore, changes normally closed switch to open
Current can not flow anymore through first network
T0
I0.0     M0.0                                            Q0.0
S_EXt
S        Q
S5T#2s         TV       BI
R    BCD

T1
I0.0     Q0.0                                            M0.0
S_EXt
S        Q
S5T#2s         TV       BI   (Note:
R    BCD       Time left: 2 s – 1
scan cycle time)
George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405
Time: Scan cycle just after t = 2 s
User Action: keep pressing Switch 1
Status of 1st Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of M0.0 is 1 because on second rung the virtual coil associated
with M0.0 is energized. The virtual switch associated with M0.0 is open.
Current cannot flow through it.
Timer 0 is stopped. No current flows out of Q.
No current flows through the virtual coil associated with Q0.0. The content
of Q0.0 remains 0.
Status of 2nd Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of Q0.0 is 0. The virtual switch associated with it is closed. Current
flows through it.
Timer 1 is running. Current flows out of Q.
Virtual coil associated with M0.0 is energized. Content of M0.0 remains 1.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 1 : Continued
Time: Scan cycle just before t = 4 s
User Action: Keeps pressing switch 1

T0
I0.0     M0.0                                         Q0.0
S_EXt
S        Q
S5T#2s     TV       BI
R    BCD

T1
I0.0     Q0.0                                      M0.0
S_EXt
S        Q
S5T#2s     TV       BI   (Note:
R    BCD       Time left: ~0 s)

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405
Time: Scan cycle just before t = 4s
User Action: keep pressing Switch 1
Status of 1st Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of M0.0 is 1. The virtual switch associated with M0.0 is open. No
current can flow through it.
Timer 0 is stopped. No current flows out of Q.
The virtual coil associated with Q0.0 is not energized. The content of Q0.0
is 0.
Status of 2nd Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of Q0.0 is 0. The virtual switch associated with it is closed. Current
flows through it.
Timer 1 is running. Current flows out of Q. BI is close to 0.
Virtual coil associated with M0.0 is energized. Content of M0.0 is 1.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 1 : Continued
Time: Scan cycle at t = 4 s
User Action: Keeps pressing switch 1

T0
I0.0     M0.0                                       Q0.0
S_EXt
S        Q
S5T#2s     TV       BI
R    BCD

T1
I0.0     Q0.0                                       M0.0
S_EXt
S        Q
S5T#2s     TV       BI   (Note:
R    BCD       Time left: 0 s)

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405
Time: Scan cycle at t = 4s
User Action: keep pressing Switch 1
Status of 1st Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of M0.0 is 1. The virtual switch associated with M0.0 is open. No
current can flow through it.
Timer 0 is not started yet. No current flows out of Q.
The virtual coil associated with Q0.0 is not energized. The content of Q0.0
is 0.
Status of 2nd Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of Q0.0 is 0. The virtual switch associated with it is closed. Current
flows through it.
Timer 1 is stopped. No current flows out of Q. BI is equal to 0.
Virtual coil associated with M0.0 is not energized any more. Content of
M0.0 changes from 1 to 0.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
(Note: A once scan cycle error has been
ME4447/6405                              introduced in the timing. The reason is that
the coil of M0.0 on the second rung was
Example 1 : Continued                   turned off during the scan cycle at t = 4s. The
normally closed switch of M0.0 is not
Time: Scan cycle just after t = 4 s    evaluated again until the scan cycle after the
User Action: Keeps pressing switch 1   scan cycle at t = 4 s. Therefore, Timer T0
starts one scan cycle after t = 4. This error will
propagate and similar errors will accumulate. )
T0
I0.0     M0.0                                          Q0.0
S_EXt
S         Q
S5T#2s        TV        BI   (Note:
R    BCD       Time left: 2 s)

T1
I0.0     Q0.0                                           M0.0
S_EXt
S         Q
S5T#2s        TV        BI
R    BCD

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405
Time: Scan cycle just after t = 4s
User Action: keep pressing Switch 1
Status of 1st Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of M0.0 is 0. The virtual switch associated with M0.0 is closed.
Current flows through it.
Timer 0 is started. Current flows out of Q.
The virtual coil associated with Q0.0 is energized. The content of Q0.0
changes from 0 to 1.
Status of 2nd Rung:
Content of I0.0 is 1. Current flows through the virtual switch associated with
it.
Content of Q0.0 is 1. The virtual switch associated with it is open. Current
cannot flow through it.
Timer 1 is stopped. No current flows out of Q.
Virtual coil associated with M0.0 is not energized. Content of M0.0 remains
0.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 1 : Continued
Time: Some time later
User Action: User turns Switch 1 off

T0
I0.0      M0.0                                   Q0.0
S_EXt
S        Q
S5T#2s    TV       BI
R    BCD

T1
I0.0     Q0.0                                   M0.0
S_EXt
S        Q
S5T#2s    TV       BI
R    BCD

George W. Woodruff School of Mechanical Engineering, Georgia Tech
Explanations for the previous slide
ME4447/6405
Time: Some time later
User Action: turn off Switch 1
Status of 1st Rung:
Content of I0.0 is 0. Current cannot flow through the virtual switch
associated with it.
Timer 0 is stopped. No current flows out of Q.
The virtual coil associated with Q0.0 is not energized. The content of Q0.0
changes is 0.
Status of 2nd Rung:
Content of I0.0 is 0. Current cannot flow through the virtual switch
associated with it.
Timer 1 is stopped. No current flows out of Q.
Virtual coil associated with M0.0 is not energized. Content of M0.0 is 0.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 1 :

As this example illustrates, consistent timing is difficult to achieve with a
PLC due to the scan cycle. This is the reason why PLC’s are not used to
control systems with very fast time constants such as CNC machines,
chemical mixers, etc….

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 :

Switch 1 connected to Input pin 0.0
A Hall effect sensor (switch) is connected to Input pin 0.1
(Note: a Hall effect sensor will turn on when a magnetic object comes
in close proximity)
The motor for a conveyer belt is connected to Output pin 0.0
(Note: As previously mentioned, a coil can be any “load” such as a
motor during these lectures.)

If Switch 1 is turned on, the conveyer belt will transport 1000 magnetic rods
to Georgia Tech Students. Switch 1 must be turned off then on to send
another 1000 magnetic rods. The hall effect switch is positioned right under
the conveyer belt and can be used to count the rods as they pass by. Once
the hall effect sensor has counted 1000 rods, it turns the conveyor motor
off.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Example 2 (Continued)
Time: Scan cycle just before t = 0s
Actions : no rod near hall effect sensor (switch)
Review of normally closed and open virtual switches is present in next slide
Switch 1                Conveyor Belt                                Conveyor Belt
I0.0         M0.0     Q0.0                 Move                     Q0.0
EN    EN0                   S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                 M0.0
R
Conveyor Belt
CMP                                    Q0.0
== I
R
1001   IN1
Hall Effect Switch
MW1    IN2
EN   EN0               S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                                M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Review of normally open and closed virtual switches
When switch 1 is not turned on, or equivalently, I0.0 contains 0:

Switch 1              Conveyor Belt                         Conveyor Belt
I0.0       M0.0     Q0.0                Move               Q0.0
EN   EN0                 S
0   IN1 OUT    MW1
M0.0
S
Switch 1
I0.0                                                        M0.0
R

Conveyor Belt                   Conveyor Belt
V+
M0.0 Q0.0          Move               Q0.0
1
EN   EN0                 S
Switch 1                                           0   IN1 OUT    MW1
M0.0
3        2
S

M0.0
George W. Woodruff School of Mechanical Engineering, Georgia Tech   R
ME4447/6405
Explanations for the previous slide

Time: scan cycle before t = 0s
Actions : No rod near hall effect switch
Status of 2nd and 5th Rungs:
• M0.1 reset coil and M0.0 reset coil are turned
on by the normally closed switch I0.0 and I0.1
respectively. Therefore, the corresponding
normally closed switch M0.1 and M0.0 keep
their initial state.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405
Example 2 (Continued)
Time: Scan cycle at t = 0s
Actions : Switch 1 is turned on,
no rod near hall effect switch
Switch 1                Conveyor Belt                                Conveyor Belt
I0.0     M0.0        Q0.0                 Move                     Q0.0
EN    EN0                   S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                 M0.0
R
Conveyor Belt
CMP                                     Q0.0
== I
R
1001    IN1
Hall Effect Switch
MW1     IN2
EN   EN0               S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                                M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide

Scan cycle at t = 0s
Actions : No rod near hall effect switch
Status of 1st Rung:
• When switch 1 is turned on, the current flow from power
to ground in the first rung, as shown in red.
• MW1 is initialized as 0 by Move.
• Set coils Q0.0 and M0.0 are turned on (shown in red).
• The conveyor belt starts to move because the set coil
Q0.0 is turned on.
Status of 2nd Rung:
• Normally closed switches I0.0, is turned on to prevent
the M0.0 reset coil to be turned on.
George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 (Continued)
Time: Scan cycle just after t = 0s
Actions : no rod near hall effect switch

Switch 1                Conveyor Belt                                   Conveyor Belt
I0.0         M0.0     Q0.0                    Move                     Q0.0
EN    EN0                   S
0      IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                    M0.0
R
Conveyor Belt
CMP                                     Q0.0
== I
R
1001     IN1
Hall Effect Switch
MW1      IN2
EN   EN0               S
1     IN1
Hall Effect Switch
MW1      IN2 OUT        MW1
I0.1                                                                  M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide

Time: scan cycle just after t = 0s
Actions : No rod near hall effect switch
Status of 1st Rung:
• Since set coils Q0.0 and M0.0 are turned on, the
corresponding normally closed switches Q0.0 and M0.0
change their states to open (from red to black).
• The conveyor belt continues to move because of the
set coil Q0.0 to be turned on.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 (Continued)
Time: t = t1
Actions : Rod approaches hall effect switch, 1 is added to MW1
Switch 1                Conveyor Belt                                Conveyor Belt
I0.0         M0.0     Q0.0                 Move                     Q0.0
EN    EN0                   S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                 M0.0
R
Conveyor Belt
CMP                                    Q0.0
== I
R
1001   IN1
Hall Effect Switch
MW1    IN2
EN   EN0               S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                                M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide

Time: : t = t1
Actions : Rod approaches hall effect switch
Status of 4th Rung:
• Normally open switch I0.1 is turned on because od
approaches hall effect switch.
• Now current can flow on the 4th rung, and 1 is added to
• Set coil M0.1 is turned on, as shown in red.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 (Continued)
Time: t = t1 + 1 scan cycle
Actions : Rod passes over hall effect switch
Switch 1                Conveyor Belt                                 Conveyor Belt
I0.0         M0.0     Q0.0                   Move                    Q0.0
EN    EN0                   S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                  M0.0
R
Conveyor Belt
CMP                                    Q0.0
== I
R
1001    IN1
Hall Effect Switch
MW1     IN2
EN   EN0               S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                                 M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide

Time: : t = t1 + 1 scan cycle
Actions : Rod passes over hall effect switch.
Status of 5th Rung:
• Since set coil M0.1 is turned on, the corresponding
normally closed switches M0.1 is turned on (as shown
from red to black). Now the current cannot flow through
this rung.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 (Continued)
Time: t = t1 + 2 scan cycle
Actions : no rod near hall effect switch
Switch 1                Conveyor Belt                                    Conveyor Belt
I0.0         M0.0     Q0.0                     Move                     Q0.0
EN    EN0                   S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                    M0.0
R
Conveyor Belt
CMP                                      Q0.0
== I
R
1001     IN1
Hall Effect Switch
MW1      IN2
EN   EN0               S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                                    M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide

Time: : t = t1 + 2 scan cycle
Actions : Rod passes far away from hall effect
switch
Status of 4th Rung:
• Rod passes far away from hall effect switch, content in address
I0.1 changes from 1 to 0.
• The corresponding normally open switches I0.1 is turned off (from
red to black).
Status of 5th Rung:
• The corresponding normally closed switches I0.1 is turned off
(from black to red).
• Now current can flow on the last rung, and reset coil M0.1 is turned
on.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 (Continued)
Time: t = t1 + 3 scan cycle
Actions : no rod near hall effect switch
Switch 1                Conveyor Belt                                    Conveyor Belt
I0.0         M0.0     Q0.0                     Move                     Q0.0
EN    EN0                   S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                    M0.0
R
Conveyor Belt
CMP                                      Q0.0
== I
R
1001     IN1
Hall Effect Switch
MW1      IN2
EN   EN0               S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                                    M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide

Time: : t = t1 + 3 scan cycle
Actions : No rod near hall effect switch
Status of 5th Rung:
Since reset coil M0.1 is turned on, the corresponding
normally closed switches M0.1 in the 4th rung resets to
its initial state. Now the network is waiting for the next
rod.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 (Continued)
Time: t = t2
Actions : the 1001st rod approaches hall effect switch (so 1000 have been delivered)
Switch 1                Conveyor Belt                                Conveyor Belt
I0.0         M0.0     Q0.0                 Move                     Q0.0
EN    EN0                   S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                 M0.0
R
Conveyor Belt
CMP                                    Q0.0
== I
R
1001   IN1
Hall Effect Switch
MW1    IN2
EN   EN0               S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                                M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide

Time: t = t2+ 1 scan cycle
Actions : the 1001st rod approaches hall
effect switch
Status of 4th Rung:
• When the 1001st rod approaches hall effect
switch, MW1 is added by 1. Now MW1 equals to
1001. So far, 1000 shafts have been delivered.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 (Continued)
Time: t = t2+ 1 scan cycle
Actions : the conveyer is stopped with 1001th rod over the Hall effect switch
Switch 1                Conveyor Belt                                 Conveyor Belt
I0.0         M0.0     Q0.0                  Move                     Q0.0
EN    EN0                   S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                                 M0.0
R
Conveyor Belt
CMP                                    Q0.0
== I
R
1001    IN1
Hall Effect Switch
MW1     IN2
EN   EN0               S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                                 M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide

Time: t = t2+ 1 scan cycle
Actions : The conveyer is stopped with
1001th rod over the Hall effect switch
Status of 3rd Rung:
• Since MW1 equals to 1001, now power can
flow out from the Comparator (Equal to), which
turns on the reset coil Q0.0, (shown in red).
Because reset coil Q0.0 is turned on, conveyer
is stopped.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 (Continued)
Time: t = t2+ 1 scan cycle
Actions : the conveyer is stopped. Switch 1 must be turned off and on to deliver 1000 more
Switch 1               Conveyor Belt                             Conveyor Belt
I0.0      M0.0       Q0.0               Move                    Q0.0
EN    EN0                 S
0     IN1 OUT         MW1
M0.0
S
Switch 1
I0.0                                                             M0.0
R
Conveyor Belt
CMP                                 Q0.0
== I
R
1001   IN1
Hall Effect Switch
MW1    IN2
EN   EN0             S
1       IN1
Hall Effect Switch
MW1     IN2 OUT        MW1
I0.1                                                            M0.1
George W. Woodruff School of Mechanical Engineering, Georgia Tech
R
ME4447/6405
Explanations for the previous slide
Time: t = t2+ 1 scan cycle
Actions : Conveyer is stopped. Switch 1 must be turned off
and on to deliver 1000 more
Status of 1st Rung:
• Because reset coil Q0.0 is turned on, set coil Q0.0 on 1st Rung is turned off,
as shown in black.
• Since set coil M0.0 is still on, the corresponding normally closed M0.0 is
also on, which prevents current flowing into the 1st rung. Thus, set coil
Q0.0 cannot be turned on, and conveyer cannot move.
How to deliver another 1000 rods
• If we turn off switch 1, the current can flow into 2nd rung, then reset coil
M0.0 is turned on, which leads the corresponding normally closed M0.0 is
turned off. Everything returns to their initial states.
• Now if we turn on switch 1, a new cycle begins, and another 1000 rods
will be delivered.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

Example 2 :

This and the previous example illustrates that the serial nature of the PLC
micro-controller can still affect program execution.

Also, this program can be simplified using an positive edge detection coil.
This was not done because the positive edge detection coil was not an
example in Section 5.

George W. Woodruff School of Mechanical Engineering, Georgia Tech
ME4447/6405

So far we have looked at topics applicable to all PLC’s. Further Study Should focus
on:

Topics applicable to some but not all PLC’s:
Interrupts                 A/D
Counters                   Function Blocks

Communication Protocol:
Profibus
How to use communications to communicate with other PLC’s,
smart actuators and sensors, etc…

George W. Woodruff School of Mechanical Engineering, Georgia Tech

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 4 posted: 6/26/2012 language: pages: 141
How are you planning on using Docstoc?