You are on page 1of 74

EHA

Training center

LG PLC training course


Level I (beginner)

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
-2-

EHA
Training center
LG PLC training course
Level 1 (beginners level)
Pre-requisites
Duration
Description
Technology

Target audience

contents

:
:
:

None
6 days two hours per day
Basics of PLC Operation and programming
LG K7M/MK-120S
PC
KGL and other appropriate Software
All person that are required to deal with PLC
circuits and PLC programming.
Lesson 1:
Digital signal
Digital input device
Digital output device
PLC architecture "PLC inside view"
PLC circuit wiring and interface
Lesson 2:
Ladder logic
Memory map
KGL programming software
Lesson 3:
Timers
1. On delay timer
2. Off delay timer
3. Mono stable timer
Examples
using master controller tool
Lesson 4:
Counters
Examples
Lesson 5:
Step controller "sequence controller"
and its' applications
Lesson 6:
How to choose suitable PLC for your
application
General notes

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
-3-

Course Philosophy:
Training depends mainly on Practical applications. The
course contents are spread out over a 6-day period one lesson
per day every lesson is two hours, thus allowing absorption of
technical data through practical example. Training manuals are
supplied to the student for future reference. Included in the course
is a copy of the entire PLC and HMI reference manuals in soft
copy version.
Once a student has completed the LG PLC course level I,
he/she will be able to:
Create basic PLC programs.
Understand the internals of a PLC.
Have practical experience in choosing and
connection and programming of PLC.
Be ready to advance to the LG PLC course level II.

Looking forward to having you on the course!

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
-4-

Lesson1

introduction to PLC

Main points
Digital Signal
Digital input Devices
Digital output Devices
PLC in side view
Hardware wiring

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
-5-

Digital Signal
Definitions of Digital Signal

An electrical signal that varies in discrete steps ON ( 24V or 5V


TTL) And OFF (0V)

A digital signal is composed only of electrical pulses


representing either zero or one

Digital value is non-sequentially changing value


Written as the Number like 0,1,2,3. The signal of on or
Off is written as digital Value of 0 or 1

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
-6-

Digital input devices


Inputs come from sensors that translate physical phenomena into
electrical signals.
Typical examples of sensors are listed below in relative order of
popularity.
Inductive proximity - is a metal object nearby?
Capacitive proximity - is a dielectric object nearby?
Optical presence - is an object breaking a light beam or reflecting
light?
Mechanical contact - is an object touching a switch?
Inputs for a PLC come in a few basic varieties, the simplest are AC
and DC inputs.
Sourcing and sinking inputs are also popular. Instead, the device
only switches current on or off, like a simple switch.
Sensors allow a PLC to detect the state of a process. Logical
sensors can only detect a state that is either true or false.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
-7-

Inductive Sensors
Inductive sensors use currents induced by magnetic fields to detect
nearby metal objects. The inductive sensor uses a coil (an inductor)
to generate a high frequency magnetic field as shown in Figure.

If there is a metal object near the changing magnetic field, current


will flow in the object. This resulting current flow sets up a new
magnetic field that opposes the original magnetic field. The net
effect is that it changes the inductance of the coil in the inductive
sensor. By measuring the inductance the sensor can determine
when a metal have been brought nearby.
These sensors will detect any metals, when detecting multiple types
of metal multiple sensors are often used.
The sensors can detect objects a few centimeters away from the
end. But, the direction to the object can be arbitrary as shown in
Figure.
The magnetic field of the unshielded sensor covers a larger volume
around the head of the coil.
By adding a shield (A metal jacket around the sides of the coil) the
magnetic field becomes smaller, but also more directed. Shields will
often be available for inductive sensors to improve their
directionality and accuracy.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
-8-

Example (CYLINDRICAL TYPE WITH LEADS)


Part number: PR08DC
Form autonics PR Series

FEATURES:
Size: 8-12-18-30 mm diameter
2-wire DC, 3-wire DC or 2-wire AC models available
Normally open or normally closed
Shielded or non-shielded models
3-wire DC available NPN or PNP
Standard or long body versions
LED indication of output status
2 meter cable

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
-9-

Capacitive Sensors
Capacitive sensors are able to detect most materials at distances up
to a few centimeters. Recall the basic relationship for capacitance.

In the sensor the area of the plates and distance between them is
fixed. But, the dielectric constant of the space around them will
vary as different materials are brought near the sensor. An
illustration of a capacitive sensor is shown in Figure. an oscillating
field is used to determine the capacitance of the plates. When this
changes beyond a selected sensitivity the sensor output is
activated.

NOTE:
For this sensor the proximity of any material near the electrodes
will increase the capacitance. This will vary the magnitude of the
oscillating signal and the detector will decide when this is great
enough to determine proximity.
These sensors work well for insulators (such as plastics) that tend
to have high dielectric coefficients, thus increasing the capacitance.
But, they also work well for metals because the conductive
materials in the target appear as larger electrodes, thus increasing
the capacitance as shown in Figure. In total the capacitance
changes are normally in the order of pFard
Electro Hydraulic Automation (EHA)
(+202)4941760-499377
Fax.(+202)49192896
- 10 -

Dielectrics and Metals Increase the Capacitance

The sensors are normally made with rings (not plates) in the
configuration shown in Figure. In the figure the two inner metal
rings are the capacitor electrodes, but a third outer ring is added to
compensate for variations.
Without the compensator ring the sensor would be very sensitive to
dirt, oil and other contaminants that might stick to the sensor.
Example: (CYLINDRICAL TYPE WITH LEADS)
Part number: CR18-8DN
Form autonics CR Series

FEATURES:
Size: 18mm or 30 mm
3-wire DC or 2-wire AC models
normally open or normally closed
3-wire DC available NPN or PNP
Adjustable sensitivity
Detecting distance to 15mm
LED indication of output status
2 meter cable
IP66 (18mm) or IP65 (30mm)

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 11 -

Optical (Photoelectric) Sensors


Light sensors have been used for almost a century - originally
photocells were used for applications such as reading audio tracks
on motion pictures. But modern optical sensors are much more
sophisticated.
Optical sensors require both a light source (emitter) and detector.
Emitters will produce light beams in the visible and invisible
spectrums using LEDs and laser diodes. Detectors are typically built
with photodiodes or phototransistors. The emitter and detector are
positioned so that an object will block or reflect a beam when
present. A basic optical sensor is shown in Figure

In the figure the light beam is generated on the left, focused


through a lens. At the detector side the beam is focused on the
detector with a second lens. If the beam is broken the detector will
indicate an object is present. The oscillating light wave is used so
that the sensor can filter out normal light in the room. The light
from the emitter is turned on and off at a set
frequency. When
the detector receives the light it checks to make sure that it is at
the same frequency.
If light is being received at the right frequency then the beam is
not broken. The frequency of oscillation is in the KHz range, and too
fast to be noticed.
A side effect of the frequency method is that the sensors can be
used with lower power at longer Distances.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 12 -

Digital outputs devices

Digital outputs devices such that solenoids, valves

SOLENOIDS
Solenoids are the most common actuator components. The basic
principle of operation is there is a moving ferrous core (a piston)
that will move inside wire coil as shown in Figure 5.1. Normally the
piston is held outside the coil by a spring. When a voltage is applied
to the coil and current flows, the coil builds up a magnetic field that
attracts the piston and pulls it into the center of the coil. The piston
can be used to supply a linear force. Well known applications of
these include pneumatic values and car door openers.

VALVES
The flow of fluids and air can be controlled with solenoid controlled
valves. An example of a solenoid controlled valve is shown in Figure
the solenoid is mounted on the side. When actuated it will drive the
central spool left. The top of the valve body has two ports that will
be connected to a device such as a hydraulic cylinder. The bottom
of the valve body has a single pressure line in the center with two
exhausts to the side. In the top drawing the power flows in through
the center to the right hand cylinder port. The left hand cylinder
port is allowed to exit through an exhaust port. In the bottom
drawing the solenoid is in a new position and the pressure is now
applied to the left hand port on the Top and the right hand port can
exhaust. The symbols to the left of the figure show the schematic
equivalent of the actual valve positions. Valves are also available
that allow the valves to be blocked when unused.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 13 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 14 -

PLC in side view

The PLC mainly consists of a CPU, memory areas, and appropriate


circuits to receive input/output data. We can actually consider the
PLC to be a box full of hundreds or thousands of separate relays,
counters, timers and data storage locations. Do these counters,
timers, etc. really exist? No, they don't "physically" exist but rather
they are simulated and can be considered software counters,
timers, etc. These internal relays are simulated through bit
locations in registers. (More on that later)

What does each part do?


CPU - Central Processing Unit is the brain of a PLC controller.
CPU itself is usually one of the microcontrollers. Aforetime
these were 8-bit microcontrollers such as 8051, and now
these are 16- and 32-bit microcontrollers.
INPUT RELAYS-(contacts) these are connected to the
outside world. They physically exist and receive signals from
switches, sensors, etc. Typically they are not relays but rather
they may be transistors or opti-couplers.
Marker RELAYS -these do not receive signals from the
outside world nor do they physically exist. They are simulated
relays and are what enables a PLC to eliminate external
relays. There are also some special relays that are dedicated
to performing only one task. Some are always on while some
are always off. Some are on only once during power-on and
are typically used for initializing data that was stored.
COUNTERS-These again do not physically exist. They are
simulated counters and they can be programmed to count
pulses. Typically these counters can count up, down or both
up and down. Since they are simulated they are limited in
their counting speed. There are also high-speed counters that
are hardware based. We can think of these as physically
existing. Most times these counters can count up, down or up
and down.
Electro Hydraulic Automation (EHA)
(+202)4941760-499377
Fax.(+202)49192896
- 15 -

TIMERS-These also do not physically exist. They come in


many varieties and increments. The most common type is an
on-delay type and off-delay. Increments vary from 1ms
through 1s.
OUTPUT RELAYS-(coils) these are connected to the outside
world. They physically exist and send on/off signals to
solenoids, lights, etc. They can be transistors, relays, or triacs
depending upon the model chosen.
DATA STORAGE-Typically there are registers assigned
to simply store data. They are usually used as temporary
storage for math or data manipulation. They can also typically
be used to store data when power is removed from the PLC.
Upon power-up they will still have the same contents as
before power was removed. Very convenient and necessary!!

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 16 -

PLC SCAN CYCLE


A PLC works by continually scanning a program. We can think of
this scan cycle as consisting of 3 important steps. There are
typically more than 3 but we can focus on the important parts and
not worry about the others. Typically the others are checking the
system and updating the current internal counter and timer values.

Step 1-CHECK INPUT STATUS

First the PLC takes a look at each input to determine if it is on or


off. In other words, is the sensor connected to the first input on?
How about the second input? How about the third... It records this
data into its memory to be used during the next step.
Step 2-EXECUTE PROGRAM

Next the PLC executes your program one instruction at a time.


Maybe your program said that if the first input was on then it
should turn on the first output. Since it already knows which inputs
are on/off from the previous step it will be able to decide whether
the first output should be turned on based on the state of the first
input. It will store the execution results for use later during the next
step.
Step 3-UPDATE OUTPUT STATUS

Finally the PLC updates the status of the outputs. It updates the outputs based on
which inputs were on during the first step and the results of executing your program
during the second step. Based on the example in step 2 it would now turn on the first
output because the first input was on and your program said to turn on the first output
when this condition is true. After the third step the PLC goes back to step one and
repeats the steps continuously. One scan time is defined as the time it takes to execute
the 3 steps listed above.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 17 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 18 -

Hardware wiring

1.5

Input wiring
Dc 24v

Output wiring

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 19 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 20 -

Wiring precautions:
Re-check the input voltage for the input part. If a voltage over the
maximum switching capacity (24V) is applied, it can cause faults,
destruction or fire.
Before applying the power to part that has polarities, be sure to
check its polarities.
During drilling or wiring, do not allow any wire scraps to enter the
PLC. It can cause malfunction and fault.
Wiring I/O wires with high voltage cable or power supply line can
cause malfunction or disorder.
Be sure that any wire does not pass across during input LED (I/O
status will not be clearly identified).
If an inductive load has been connected to output part, connect
parallel surge killer or diode to a load. Connect the cathode of diode
to the + part of the power supply.

Be cautious that strong shock does not applied to the I/O part.
Do not separate the PCB from its case.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 21 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 22 -

Lesson 2

Main points
Ladder Logic
Memory Map
KGL Programming Software

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 23 -

2.1

Ladder Logic

Ladder logic is the main programming method used for PLCs.


Relay is a simple device that uses a magnetic field to control a
switch, when a voltage is applied to the input coil; the resulting
current creates a magnetic field the magnetic field pulls a metal
switch (or reed) towards it and the contacts touch, closing the
switch. The contact that closes when the coil is energized is called
normally open.
The normally closed contacts touch when the input coil is not
energized. Relays are normally drawn in schematic form using a
circle to represent the input coil.

Example1:
Now let's compare a simple ladder diagram with its real world
external physically connected relay circuit and see the differences.

Figure (1.6)

In the above circuit, the coil will be energized when there is a


closed loop between the + and - terminals of the battery. We can
simulate this same circuit with a ladder diagram. Aladder diagram
consists of individual rungs just like on a real ladder. Each rung
must contain one or more inputs and one or more outputs. The first
instruction on a rung must always be an input instruction and the
last instruction on a rung should always be an output (or its
equivalent).

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 24 -

Example 3:
MOTOR START WITH LATCH
Make a program to control motor through push button but motor
not stop after releasing the button but can stop by pushing push
button (P1)

P0
COM
K

24VDC
P1
P40
K

COM
24VDC
M

220VAC

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 25 -

[[[[[[[[[[[[[[[

memory mapping

2.2

To study PLC you must know the memory mapping of the data
memory of this PLC, the PLC data memory is divided into several
parts , every part have a name & special specifications , these parts
called devices .
MK 120S DATA MEMORY DEVIDED INTO

1- P area
2- M area
3- K area

1- P input &output image.


This device for real input and real outputs only, you can change
these device status (write in these bits) using hardware, if you put
24v on p0 input, and the bit of p0 get high (on)

Example:

P0 input for point labeled 0 on plc.


P40 output for point labeled 40 on plc.
Note:
No. of points (pxx) limited to plc
2- M auxiliary relay. (Markers)
This device for not real input and not real outputs, you can only
write in these bits using software instructions.

Example:

M0 internal imagine input or output in plc.

Note:
No. of points (mxx) limited to plc software point
For example for master k120s from m000 to
m191f (191*16= 3056 marker)

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 26 -

3- K keep relay
This device the same like m device but it can keep its value even if
power off and on again.

Example:
K0 internal imagine input or output in plc can
Keep its value even power off and on again.

Note:
No. of points (kxx) limited to plc software point
For example for master k120s from k00 to k31f
(31*16= 496) Keep relay.
(I.e. if power off while k0 was on, when power turn on again we
Will find k0 on)

4- F special relay. (Flags)


These special relays (flags) are predetermined flags each one
make one predetermined job only cant be changed

Example:
F10 always no flag.
F11 always off flag.
Note:
You can get list of flags by click f3 from the keyboard then select
flags

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 27 -

Programming software

2.3

The programming software of LG Master K PLC's is named KGLWIN,


KGLWIN is under windows package which you can use to write
ladder or mnemonic (statement) programs and to download it to
PLC also to emulate the downloaded

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 28 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 29 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 30 -

You can open an existing files b KGL win

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 31 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 32 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 33 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 34 -

Lesson3

Main points
Timers
Examples
Using Master controller tool

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 35 -

Timers

3.1

The most popular types of timers

1 TON

ON DELAY TIMER

2 TOFF

OFF DELAY TIMER

3 TMON

MONOSTABLE TIMER

Let's now see how a timer works. What is a timer? It's exactly what
the word says.. It is an instruction that waits a set amount of
time before doing something. Sounds simple doesn't it.

On-Delay timer
This type of timer simply "delays turning on". In other words, after
our sensor (input) turns on we wait x seconds before activating a
solenoid valve (output). This is the most common timer. It is often
called TON (timer on delay)

Off-Delay timer
This type of timer is the opposite of the on-delay timer listed
above. This timer simply "delays turning off". After our sensor
(input) sees a target we turn on a solenoid (output). When the
sensor no longer sees the target we hold the solenoid on for xseconds before turning it off. It is called a TOFF (timer off-delay)
and is less common than the on-delay type listed above. (i.e. few
manufacturers include this type of timer)
Let's now see how to use them. We typically need to know 2 things:
1. What will enable the timer? Typically this is one of the
inputs.(a sensor connected to input P0000 for example)
2. How long we want to delay before we react. Let's wait 5
seconds before we turn on a solenoid, for example.
When the instructions before the timer symbol are true the timer
starts "ticking". When the time elapses the timer will automatically
close its contacts. When the program is running on the plc the
program typically displays the elapsed or "accumulated" time for us
so we can see the current value. Typically timers can tick from 0 to
65535 times.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 36 -

Why this specified numbers? Again it's because LG MK PLCs have


16-bit timers. We'll get into what this means in a later chapter but
for now suffice it to say that 65535 is 16-bit binary. Each tick of the
clock is equal to x-seconds.
Typically LG MK series offers several different ticks. 10 and 100 ms
increments (ticks of the clock). An "ms" is a milli-second or
1/1000th of a second. MK 120s also offer 1ms increments. These
different increment timers work the same as above but sometimes
they have different names to show their time base. Shown below is
a typical timer instruction symbol we will encounter and how to use
it.

This timer is the on-delay type and is named T0. When the enable
input is on the timer starts to tick. When it ticks 10 (the preset
value) times, it will turn on its contacts that we will use later in the
program. Remember that the duration of a tick (increment) varies
with the time base used. (I.e. in MK 120s I can set some timers the
time base 100msec, others to the time base 10msec ...)

In this diagram we wait for input P0 to turn on. When it does, timer
T000 (a100ms increment timer) starts ticking. It will tick 100 times.
Each tick (increment) is 100ms so the timer will be a 10000ms (i.e.
10 second) timer. 100ticks X 100ms = 10,000ms. When 10 seconds
have elapsed, the T000 contacts close and P40 turns on. When
input P0 turns off (false) the timer T000 will reset back to 0 causing
its contacts to turn off (become false) thereby making output P40
turn back off.
To get help on timers just click F10 (dialogue box will appear)
then SELECT TON FROM the LIST THEN CLICK help

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 37 -

To put timer in the ladder diagram click F10 from the keypad,
dialogue box will appear then write the following expression

Instruction

op1 op2

Where:
Op1 is the timer number, in MK120s there are 256 timer
from T0 to T255
Op2 is the delay time multiplied by 0.1 sec
(To make 10 sec delay then make op2=100)
Example
To put on delay timer with 100sec delay do the following Click F10---write Ton Tn 1000 as n any number from 0-255
Hint:
Dont use the same timer more than one
Hint:
Every timer has a bit or contact take the same name of the timer
for example t10 is contact of the timer T10 this bit condition depend
on its timer condition.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 38 -

Examples

3.2

1-TON Example

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 39 -

Example: Lamp flickers

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 40 -

2-TOFF example:
Write a program to operate a lamp for 20 sec if I hit a button.
Solution connect the button with P0 and connect the lamp with P40,
the program are as following

When push the button P0 get on the contact T0 get on, when
release the button P0 get off T0 will keep on for 20 sec then get off

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 41 -

3- Monostable Timer example:

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 42 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 43 -

Extra

Examples

Example1:
Motor with two direction with time
OBJECT:
Make a program to control motor with two directions with two
DEFFERINT TIME.
SOLUTION:
When start p.b (P0) pushed motor run in forward direction so Till
certain time (T144) then motor stop running at forward direction
(P40 off ) and reverse direction Begin till certain time (T145) then
motor stop running at backward direction (P41 off ) and run
forward again and so on.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 44 -

Example 2
When click start pushbutton we want the conveyer to run with the
sequence C---10sec delayB20sec delay ---A when I click stop I
want the conveyer to stop with the sequence C10sec delayb-10
sec delay

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 45 -

Master Control

3.3

Let's now look at what are called master controls. Master controls
can be thought of as "emergency stop switches".
An emergency stop switch typically is a big red button on a
machine that will shut it off in cases of emergency. Next time
you're at the local gas station look near the door on the outside to
see an example of an e-stop.

Note:
We're not implying that this instruction is a substitute for a "hard
wired" e-stop switch. There is no substitute for such a switch!
Rather it's just an easy way to get to understand them.
The master control instruction typically is used in pairs with a
master control clear (reset). Abbreviated as MCS/MCSCLR (master
control/master control reset),

Here is the master control symbol looks.

Below is an example of a master control clear.

MCS & EXAMPLE

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 46 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 47 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 48 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 49 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 50 -

Lesson4

Main points
Counters
Examples
Using Positive edge and negative tool

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 51 -

Counters

4.1

There are four types of counters:-

1- CTR
2- CTU
3- CTD
4- CTUD

RING COUNTER
UP COUNTER.
DOWN COUNT
UP DOWN COUNTER

A counter is a simple device intended to do one simple thing count.


There are up-counters (they only count up 1, 2, 3...).
These are called CTU (count up), there are down counters (they
only count down 9, 8, 7...).
These are typically called CTD (count down) when they are a
separate instruction.
there are also up-down counters(they count up and/or down
1,2,3,4,3,2,3,4,5,...) these are typically called CTUD (up-down
counter) when they are separate instructions.

To get help on counters Just click F10 (dialogue box will


appear) then write CTU help
To put counter in the ladder diagram, click F10 from keypad
dialogue box will appear write in it the following expression CTU C0
10 ASCTU the counter type may be CTU or CTD or CTUD or CTR
every type is explained in details in the following pages C0 the
counter number, there are 256 counter in mk120s plc, from C0 to
C255, I can use every counter only once the set point of the
counter, it can from 0 to 65535

Hint:
every counter have a bit or a contact, these bit state change
depending on the state of it's counter for example if the counter is
CTU then it's bit will have 0 as the present value in the counter less
than the set point, when the present value in the counter is more
than or equal the set point the bit of this counter will be 1

Hint:
The bit of any counter take the same number of these counters, as
c100 is the bit of the counter c100

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 52 -

CTU+EXAMPLE

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 53 -

CTD+EXAMPLE

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 54 -

CTUD+EXAMPLE

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 55 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 56 -

CTR+EXAMPLE

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 57 -

MAKE A WATCH
Make a program to make out contact after 1 month
Solution:
make counter (C1) with enable F93 ( this is special clock flag for 1
sec ) C1 preset value is 60 his counter express seconds , so after1
minute (60 second) C1 make pulse to C2 (minute counter) and C2
after 60 minute (Pulse) give pulse to C3 ( hour counter) and when
hour counter reach 24 Hour (pulse) give C4 (month counter).

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 58 -

3- STORE EXAMPLE
OBJECT:
Store with maximum capacity 200 car, has two gates each one
has sensor make a program to output signal when store empty
and other one when full
Solution:
By up down counter, up enable (P0) from entrance gate and down
enable from exit Gate and compare counter value if less than 1 out
EMPTY signal (P40) and if
Greater Than 200 out FULL signal (P41)

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 59 -

D & D NOT INSTRUCTIONS

4.2

A one-shot (D& DNOT) is an interesting and invaluable


programming tool. At first glance it might be difficult to figure out
why such an instruction is needed. After we understand what this
instruction does and how to use it, however, the necessity will
become clear.
A one-shot is used to make something happen for ONLY 1 SCAN.
(You do remember what a scan is, right??) . The name of the
instruction is D / D NOT (differentiate up/down).

D Instruction, device may be any P,M,K,L device

Above is the symbol for a D (differentiate) instruction. A D NOT


instruction looks the same but inside the symbol it says "D NOT",
Lets now setup an application to see how this instruction actually
functions in a ladder. This instruction is most often used with some
of the advanced instructions where we do some things that MUST
happen only once. However, since we haven't gotten that far yet,
let's set up a flip/flop circuit. In simple terms, a flip/flop turns
something around each time an action happens. Here we'll use a
single pushbutton switch. The first time the operator pushes it we
want an output to turn on. It will remain "latched" on until the next
time the operator pushes the button. When he does, the output
turns off.

Here's the ladder diagram that does just that:


Now this looks confusing! Actually it's not if we take it one step at a
time.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 60 -

Rung 1-When NO (normally open) input P0000 becomes true


D M10 becomes true.
Rung 2- NO M10 is true, NO M15 remains false, NC M15
remains true, and NC M10 turns false. Since we have a true
path, (NO M10 & NC M15) OUT M15 becomes true.
Rung 3- NO M15 is true therefore OUT P40 turns true.
Next Scan

Rung 1- NO P0 remains true. M10 now becomes false. This is


because the D instruction is only true for one scan. (i.e. the
rising edge of the logic before it on the rung)
Rung 2- NO M10 is false, NO M15 remains true, NC M15 false,
NC M10 turns true. Since we STILL have a true path, (NO
M15 & NC M10) OUT M15 remains true.
Rung 3- NO M15 is true therefore OUT P40 remains true.

After 100 scans, NO P0 turns off (becomes false, user release the
push button connected P0). The logic remains in the same state as
"next scan" shown above. (D doesn't react therefore the logic
stays the same on rungs 2 and 3)
On scan 101 NO P0 turns back on. (Becomes true, user re push
the button)

Rung 1-When NO (normally open) input P0 becomes true D


M10 becomes true.
Rung 2- NO M10 is true, NO M15 remains true, NC M15
becomes false, and NC M10 also becomes false. Since we no
longer have a true path, OUT 1001 becomes false.
Rung 3- NO 1001 is false therefore OUT 500 becomes false

D mean differentiate , this instruction write 1 in the bit it


applied on for 1 scan cycle when the devices before it
translate from disconnect to connect state
Electro Hydraulic Automation (EHA)
(+202)4941760-499377
Fax.(+202)49192896
- 61 -

D NOT , this instruction write 1 in the bit it applied on for


1 scan cycle , when the devices before it translate from
connect to disconnect state

When P0 get on m10 get on for one scan cycle, when P0 get
off m12 get on for one scan cycle

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 62 -

EXAMPLE:
OBJECT:
Great knife driven by motor, make a program to operate this knife
through selector and when Overload occur knife sops and never
run again before make the selector off and ON again
Solution:
As it requested the run command hanged on the rising edge of the
SELECTOR So we have to take the rising edge of the SELECTOR by
D command on marker (m10 for example) And use this marker for
run the motor (P40) and when overload point come (P1) motor
stop and will not work till p1 return to its initial position and the
next rising edge come again by changing the SELECTOR from ON
to off and make it ON again

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 63 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 64 -

Lesson5

Main points
STEP CONTROLLER

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 65 -

Step controllers like no. of ladders each one contain of no. of stairs
Only one stair (step) can be on and all stairs for this ladder are off.

For example:
For ladder S00.00 (it varies from S00.00 to S00.99) Step S00.00
ON firstly and if any step come (like S00.07) S00.00 OFF.

There are two ways to use the step controller

Last in priority
(sequence command)
OUT Sxx.xx

Step controller
SET xx.xx

LAST IN PRIORITY OUT Sxx.xx


For this method we can move from any step to the other one
without any condition, but we must remember that only one step
will be ON

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 66 -

SEQUENCE COMMAND SET Sxx.xx

In this method I can only move from step to the next step (the
next only) by SET order, and there are two conditions
1- The previous step was ON before trying to SET this step (for
example to SET S00.02 S00.01 must be ON first)
2- Use SET order
Notes:
Only the first step (for example S00.00 for ladder S00) can come at
any time (i.e. If we SET S00.00 for ladder S00 at any time S00.00
will be ON)

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 67 -

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 68 -

Example:

This program shows briefly an example of sequential control by


using SET Sxx.xx instruction.
In this Example, there are 4 processes and each process is
performed in sequence. The process 2 starts after the process 1
ended, and process 3 starts after the process 2 finished.
When the process 4 is completed, the process 1 will start again.

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 69 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 70 -

Lesson6

Main points

How to choose suitable PLC for your application


General notes

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 71 -

How to choose suitable PLC for your application


1-determine number of digital inputs and digital outputs
2-if there are analog inputs or analogue outputs
Determine them number
3-if there are any other special inputs (Like RTD,
Thermocouple and high speed pulses (encoder)...etc)
Determine its number
after determine these data you can found more than plc
type match with these data , you will found that mk10s1
the most cheapest type , after that mk80S ,after that
mk120s, after that mk200s , after that mk300s

*there are no Thermocouple expansion modules in


MK120S
*there are no RTD expansion modules in MK200S
* For digital inputs and digital outputs it is preferable to
take plc
Have inputs outputs 120% of required inputs outputs
*for MK 200s, mk300s it is preferable to take baseboard
have
Two slots more the required number of slots

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 72 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 73 -

Memo

Electro Hydraulic Automation (EHA)


(+202)4941760-499377
Fax.(+202)49192896
- 74 -

You might also like