Anda di halaman 1dari 80

2011 Automation Summit

Orlando, FL
Navigating the world of automation

Navigating the world of automation

Top Ten Programming Mistakes Made by People New to S7


2011 Automation Summit
Title: Top Ten Programming Mistakes Made by
People New to S7
Track:#56
Topic: Learn about some of the common
problems experienced by people learning S7.
Presenter: Tim Jager
Company: DMC

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 2

Top Ten Programming Mistakes Made by People New to S7

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 3

Company Profile

Based In
Based In
Chicago
Chicago
but work
but work
Globally
Globally
DMC has the highest number of
DMC has the highest number of
S7 certified engineers
S7 certified engineers

Since 1996
30 Employees
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Our customers

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Areas of Expertise

Custom
Test
Manufacturing
and
Software
Measurement
and
Engineering
Automation
& Embedded
Intelligence
Microsoft
SharePoint
Consulting
ServicesSystems

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Relevant Siemens Projects

Dulles Airport Transit Tunnel Ventilation System


WinCC Redundancy
S7 400H Redundant PLC
4000 I/O Points

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Relevant Siemens Projects

Batch Mixing Systems for Confectionary Company

S7-300
Standardized code base
Deployment at multiple facilities
Mixing/batching control
Recipe management
Web-based reporting system

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Relevant Siemens Projects

Automotive Assembly Lines for Tier 1 Supplier

S7 400 PLCs
WinCC Flex HMIs
Standardized code base
User Configurable
JIT - Lean Manufacturing
Deployment at multiple facilities

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Relevant Siemens Projects

US Navy LCS-1
Littoral Combat Ship
S7 400H Redundant PLC
Mission Critical Logic

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Presenter Info

Tim Jager
Project Director at DMC
Mechanical Engineer (University of Illinois)
Licensed Professional Engineer in Illinois
With DMC since 1999
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Top 10 S7 Mistakes

#1

Simple Hardware mistakes

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 12

Common Hardware Mistakes

My PLC Doesnt Work???

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 13

Common Hardware Mistakes

My PLC Doesnt Work???

It needs a memory card

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 14

Common Hardware Mistakes

My PLC Doesnt Work???

It needs a memory card

Its in STOP Mode

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 15

Common Hardware Mistakes

I wonder whats on the MMC Card?

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 16

Common Hardware Mistakes

I wonder whats on the MMC Card?

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 17

Common Hardware Mistakes

I wonder whats on the MMC Card?

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 18

Common Hardware Mistakes

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 19

Common Hardware Mistakes

This is not an RS232 Serial Port!!!


Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 20

Top 10 S7 Mistakes

#2

Using Absolute
Address Priority
instead of Symbolic

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 21

Set your Address Priority to Symbolic


You Just took the Red pill. You are on your way down the rabbit hole that leads
down the path of true object oriented PLC Programming.

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 22

A Typical Data Block

DB1 dbGlobals

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 23

A Typical Data Block

DB1 dbGlobals

Address:

Symbol Name:

DB1.DBX0.0

dbGlobals.bStart
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 24

A Typical Rung Of Ladder

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 25

A Typical Rung Of Ladder

Address Logic
Symbolic Logic

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 26

A Typical Rung Of Ladder

Address Logic
Symbolic Logic

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 27

What happens if we change the Data Block?

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 28

Absolute vs. Symbolic Priority

In Symbolic Mode the intended logic is maintained

The address
address logic
logic has
has
The
changed from
from 0.1
0.1 to
to 0.2
0.2
changed
The symbolic
symbolic logic
logic is
is
The
maintained
maintained

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 29

Absolute vs. Symbolic Priority

In Absolute Mode the intended logic is NOT maintained!

The Address
Address logic
logic is
is
The
maintained
maintained

But the
the Symbolic
Symbolic logic
logic is
is
But
totally wrong!
wrong!
totally

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 30

Absolute vs. Symbolic Priority


You dont have to know where the server lives or its IP address. You just need the
symbolic name to send an email.
So start forgetting about addresses and start thinking about symbolic names.

VS.
Absolute Address

Symbolic Address

2222N. Elston Ave

tim.jager@dmcinfo.com

Chicago, IL 60614
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 31

Top 10 S7 Mistakes

#3

I/O Mapping

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 32

Input / Output Mapping

I'M GONNA PROGRAM LIKE IT'S 1999

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 33

Traditional Input / Output Mapping


1. At the beginning of the scan,
Each physical input gets mapped
to an internal variable

Physical Input
Internal Variable

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 34

Traditional Input / Output Mapping


1. At the beginning of the scan,
Each physical input gets mapped
to an internal variable

2. Now run all of the logic (which


references only internal bits)

Internal Variable
Internal Variable
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 35

Traditional Input / Output Mapping


1. At the beginning of the scan,
Each physical input gets mapped
to an internal variable

2. Now run all of the logic (which


references only internal bits)
3. At the end of the scan,
internal output bits get mapped
to physical outputs
Internal Variable
Physical Output
Page 36

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

S7 I/O Mapping Just use the Symbol Table

Make sure you are in


Symbolic Priority Mode

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 37

Top 10 S7 Mistakes

#4

Improper Use of Bit Memory


AKA: Mbits

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 38

MBits

M0.0 M0.7

M1.0 M1.7

M2.0 M2.7

M2.0 M2.7
Page 39

M0.0
M0.1
M0.2
M0.3
M0.4
M0.5
M0.6
M0.7
M1.0
M1.1
M1.2
M1.3
M1.4
M1.5
M1.6
M1.7
M2.0
M2.1
M2.2
M2.3
M2.4
M2.5
M2.6
M2.7
M3.0
M3.1
M3.2
M3.3
M3.4
M3.5
M3.6
M3.7

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

MBits

M0.0 M0.7

M1.0 M1.7

M2.0 M2.7

M2.0 M2.7
Page 40

MBytes
M0.0
M0.1
M0.2
M0.3
M0.4
M0.5
M0.6
M0.7
M1.0
M1.1
M1.2
M1.3
M1.4
M1.5
M1.6
M1.7
M2.0
M2.1
M2.2
M2.3
M2.4
M2.5
M2.6
M2.7
M3.0
M3.1
M3.2
M3.3
M3.4
M3.5
M3.6
M3.7

MB0

MB1

MB2

MB3
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

MBits

M0.0 M0.7

M1.0 M1.7

M2.0 M2.7

M2.0 M2.7
Page 41

MBytes
M0.0
M0.1
M0.2
M0.3
M0.4
M0.5
M0.6
M0.7
M1.0
M1.1
M1.2
M1.3
M1.4
M1.5
M1.6
M1.7
M2.0
M2.1
M2.2
M2.3
M2.4
M2.5
M2.6
M2.7
M3.0
M3.1
M3.2
M3.3
M3.4
M3.5
M3.6
M3.7

MWords

MB0
MW0
MB1

MB2
MW1
MB3
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

MBits

M0.0 M0.7

M1.0 M1.7

M2.0 M2.7

M2.0 M2.7
Page 42

MBytes
M0.0
M0.1
M0.2
M0.3
M0.4
M0.5
M0.6
M0.7
M1.0
M1.1
M1.2
M1.3
M1.4
M1.5
M1.6
M1.7
M2.0
M2.1
M2.2
M2.3
M2.4
M2.5
M2.6
M2.7
M3.0
M3.1
M3.2
M3.3
M3.4
M3.5
M3.6
M3.7

MWords

MDoubleWords

MB0
MW0
MB1
MD0
MB2
MW1
MB3
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

When is it OK to use M Bits?

Debugging
Quick prototyping / demonstrations
When you absolutely have to!

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 43

When is it OK to use M Bits?

Critical / Time-sensitive field fixes*

M-Bits
* As long as you promise to put in a permanent fix when the heat is off.
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 44

When is it OK to use M Bits?

If you use
MBits, make
sure they are
NOT IN USE
already.

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 45

When is it OK to use M Bits?

..and make sure to add symbol


names in the symbol table.

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 46

When is it OK to use M Bits?

Or suffer the consequences

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 47

When is it OK to use M Bits?

Clock Byte

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 48

Top 10 S7 Mistakes

#5

Not using or
Improperly using the
Clock Byte

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 49

What is the Clock Byte?

Each bit of the clock memory byte is assigned a frequency.


Bit of the Clock Memory Byte 7
Period Duration (s)
2.0
Frequency (Hz)
0.5

6
5
1.6 1.0
0.625 1

4
3
0.8 0.5
1.25 2

2
0.4
2.5

1
0.2
5

0
0.1
10

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 50

Symbol Table Entry For Clock Byte

Reserve these so nobody uses Memory overlapping the Clock Byte


Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 51

Clock Byte

The bits within the Clock byte can change at


any time during the scan.

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 52

Clock Byte Synchronous Global

UDT1 udtClockByte

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 53

Clock Byte Synchronous Global

DB1 dbGlobals

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 54

Clock Byte Synchronous Global

DB1 dbGlobals

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 55

Clock Byte Synchronous Global


DB1 dbGlobals

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 56

Clock Byte Synchronous Global

MB0

dbGlobals.ClockByte
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 57

What Happens If
Always_False
Mapped to M0.0

M0.0
M0.1

Always_True

M0.2

Mapped to M0.1

M0.3
M0.4
M0.5
M0.6
M0.7
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 58

What Happens If
Always_False
Mapped to M0.0

M0.0
M0.1

Always_True

M0.2

Mapped to M0.1

M0.3

Clock Byte

M0.4

Mapped to MB0

M0.5
M0.6
M0.7
Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 59

Overlapping Mbits are BAD!

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 60

Top 10 S7 Mistakes

#6

Using Uninitialized
Temp Memory

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 61

What is Temp Memory?

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 62

Improper Use of Temp Memory

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 63

Improper Use of Temp Memory

Dont read from a TEMP


unless you have written to it
first!

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 64

Top 10 S7 Mistakes

#7

Not Using Timed


Interrupts.

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 65

OB1 vs. OB30..38

OB1

OB30OB38

Runs as fast as it can.

Run at specific time intervals.

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 66

Timed Interrupts OB30..OB38

PID Control

Data Sampling

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 67

Top 10 S7 Mistakes

#8

Not using reusable


function blocks

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 68

What is a Function Block

A Function Block is a piece of reusable code that consists of:

Code is encapsulated in a Highly reusable form


Increases Programming efficiency and reduces errors

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Timer

One of the simplest and most


commonly used function block is a
Timer.
TON

T#200ms

IN

PT

ET

178

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Creation of Function Block


Isolate Common/Duplicate Code

If the same code is used many times in your program, consider


Navigating the world of automation
creating function blocks.
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Creation of Function Block


Isolate Common/Duplicate Code

Step 1. locate common code.


Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Creation of Function Block


Isolate Common/Duplicate Code

Step 1. locate common code.


Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Creation of Function Block


Isolate Common/Duplicate Code

Step 2. Replace duplicated code with function blocks.


Navigating the world of automation
Copyright Siemens Industry, Inc. 2011. All rights reserved.

Custom FB Examples
Motor
Motor
FB
FB

Cylinder
Cylinder
FB
FB

Pump
Pump
FB
FB

Valve
Valve
FB
FB

Barcode
Barcode
Scanner
Scanner
FB
FB

Robot
Robot
Interface
Interface
FB
FB

Label
Label
Printer
Printer
FB
FB

Machine
Machine
Vision
Vision
FB
FB

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Top 10 S7 Mistakes

#9

Inconsistent Blocks

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 76

Check Block Consistency

Dont forget to download the Data Block!!

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 77

Top 10 S7 Mistakes

And last but not least..

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 78

Top 10 S7 Mistakes

#10

Going it Alone

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 79

Thank You!

Navigating the world of automation


Copyright Siemens Industry, Inc. 2011. All rights reserved.

Page 80

Anda mungkin juga menyukai