206 208

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Programming Examples

B.4

Example: Counter and Comparison Instructions

Storage Area with Counter and Comparator


The following figure shows a system with two conveyor belts and a temporary storage area in between them. Conveyor belt 1 delivers packages to the storage area. A photoelectric barrier at the end of conveyor belt 1 near the storage area determines how many packages are delivered to the storage area. Conveyor belt 2 transports packages from the temporary storage area to a loading dock where trucks take the packages away for delivery to customers. A photoelectric barrier at the end of conveyor belt 2 near the storage area determines how many packages leave the storage area to go to the loading dock. A display panel with five lamps indicates the fill level of the temporary storage area.
Display Panel

Storage area empty (Q 12.0)

Storage area not empty (Q 12.1)

Storage area 50% full (Q 15.2)

Storage area 90% full (Q 15.3)

Storage area Filled to capacity (Q 15.4)

Packages in

I 12.0

Temporary storage area for 100 packages

I 12.1

Packages out

Conveyor belt 1 Photoelectric barrier 1

Conveyor belt 2 Photoelectric barrier 2

B-10

Ladder Logic (LAD) for S7-300 and S7-400 Programming A5E00261407-01

Programming Examples

Ladder Logic Program that Activates the Indicator Lamps on the Display Panel
Network 1: Counter C1 counts up at each signal change from 0 to 1 at input CU and counts down at each signal change from 0 to 1 at input CD. With a signal change from 0 to 1 at input S, the counter value is set to the value PV. A signal change from 0 to 1 at input R resets the counter value to 0. MW200 contains the current counter value of C1. Q12.1 indicates storage area not empty.
C1 S_CUD CU I 12.1 CD I 12.2 S C#10 I 12.3 R CV_BCD MW200 PV CV MW210 Q

I 12.0

Q 12.1

Network 2: Q12.0 indicates storage area empty.

Q 12.1

Q 12.1

Network 3: If 50 is less than or equal to the counter value (in other words if the current counter value is greater than or equal to 50), the indicator lamp for storage area 50% full is lit.
CMP <= I 50 MW210 IN1 IN2

Q 15.2

Network 4: Network 4: If the counter value is greater than or equal to 90, the indicator lamp for storage area 90% full is lit.
CMP >= I MW210 90 IN1 IN2

Q 15.3

Ladder Logic (LAD) for S7-300 and S7-400 Programming A5E00261407-01

B-11

Programming Examples

Network 5: If the counter value is greater than or equal to 100, the indicator lamp for storage area full is lit.
CMP >= I MW210 100 IN1 IN2

Q 15.4

B.5

Example: Integer Math Instructions

Solving a Math Problem


The sample program shows you how to use three integer math instructions to produce the same result as the following equation: MW4 = ((IW0 + DBW3) x 15) / MW0

Ladder Logic Program


Network 1: Open Data Block DB1.

DB1 OPN

Network 2: Input word IW0 is added to shared data word DBW3 (data block must be defined and opened) and the sum is loaded into memory word MW100. MW100 is then multiplied by 15 and the answer stored in memory word MW102. MW102 is divided by MW0 with the result stored in MW4.

ADD_I EN IW0 DBW3 IN1 IN2 OUT ENO MW100 MW100 15

MUL_I EN IN1 IN2 OUT ENO MW102 MW102 MW0

DIV_I EN IN1 IN2 OUT MW4 ENO

B-12

Ladder Logic (LAD) for S7-300 and S7-400 Programming A5E00261407-01

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy