0% found this document useful (0 votes)
47 views179 pages

ALL Lec. Software (رابع)

The document outlines various PLC programming languages standardized by IEC 61131, including Ladder Diagram, Instruction List, Function Block Diagram, Sequential Function Chart, and Structured Text. It explains the PLC scan cycle process, detailing how inputs are read, programs executed, and outputs updated in a continuous loop. Additionally, it covers solenoids and solenoid valves, their operation, and applications in automation, alongside examples of ladder logic programming for various control scenarios.

Uploaded by

hfchgfkhv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views179 pages

ALL Lec. Software (رابع)

The document outlines various PLC programming languages standardized by IEC 61131, including Ladder Diagram, Instruction List, Function Block Diagram, Sequential Function Chart, and Structured Text. It explains the PLC scan cycle process, detailing how inputs are read, programs executed, and outputs updated in a continuous loop. Additionally, it covers solenoids and solenoid valves, their operation, and applications in automation, alongside examples of ladder logic programming for various control scenarios.

Uploaded by

hfchgfkhv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 179

PLC Programming Languages

• The term PLC programming language refers to the method by which the user
communicates information to the PLC.

• The standard IEC 61131 was established to standardize the multiple languages
associated with PLC programming by defining the following five standard
languages:
1. Ladder Diagram (LD)
• Ladder diagram language is the most commonly used PLC language and is
designed to mimic relay logic.
2. Instruction List (IL)
• The instructional list consists of a series of instructions that refer to the basic AND,
OR, and NOT logic gate functions.
3. Function Block Diagram (FBD)
• Functional block diagram programming uses instructions that are programmed as
blocks wired together on screen to accomplish certain functions. Typical types of
function blocks include logic, timers, and counters.
4. Sequential Function Chart (SFC)
• Sequential function chart programming language is similar to a flowchart of your
process. SFC programming is designed to accommodate the programming of more
advanced processes.
5. Structured Text (ST)
• Structured text uses statements to define what to execute.
PLC scan cycle
•The PLC program is executed as part of a repetitive process referred to as a scan.
1. A typical PLC scan starts with the CPU reading the status of inputs.
2.Then, the application program is executed.
3.Once the program execution is completed, the status of all outputs is updated.
4. Next, the CPU performs internal diagnostic and communication tasks.
This process is repeated continuously as long as the PLC is in the run mode.
• Here a mixer motor is to be used to automatically stir the liquid in a vat when the
temperature and pressure reach preset values. In addition, direct manual operation
of the motor is provided by means of a separate pushbutton station. The process is
monitored with temperature and pressure sensor switches that close their respective
contacts when conditions reach their preset values.
• This control problem can be solved using the relay method for motor control
shown in the relay ladder diagram of Figure. The motor starter coil (M) is energized
when both the pressure and temperature switches are closed or when the manual
pushbutton is pressed.
An input scan
During the input scan, data is taken from all input modules in the system
and placed into an area of PLC memory referred to as the input image
area.
An Execute user program scan
During the program scan, data in the input image area is applied to the
user program, the user program is executed and the output image area is
updated
• The cycle time: is the time required to execute a one full cycle of the program
(moving from any network and returning to it again). The time required to make a
single cycle can vary from about 1 to 20 ms.
An Output scan
During the output scan, data is taken from a the output image area and
sent to all output modules in the system.
•The scan cycle time, the time required to complete a scan cycle
(Read inputs, Execute program, Update outputs)
•The scan cycle time provide a measure of the speed of response of the
PLC.
The scan time is a function of the following:
•The speed of the processor module
•The length of the ladder program
•The type of instructions executed
•The actual ladder true/false conditions
Step 1 Update the input image table by sensing
the voltage of the input terminals. Based on the
absence or presence of a voltage, a 0 or a 1 is
stored into the memory bit location designated
for a particular input terminal.
Step 2 Solve the ladder logic in order to
determine logical continuity. The processor
scans the ladder program and evaluates the
logical continuity
of each rung by referring to the input image
table to see if the input conditions are met. If the
conditions controlling an output are met, the
processor immediately writes a 1 in its memory
location, indicating that the output will be
turned ON; conversely, if the conditions are not
met a 0 indicating that the device will be turned
OFF is written into its memory location.
Step 3 The final step of the scan process is to update the actual states of the output devices by
transferring the output table results to the output module, thereby switching the connected
output devices ON (1) or OFF (0). If the status of any input devices changes when the
processor is in step 2 or 3, the output condition will not react to them until the next processor
scan.
Each instruction entered into a program requires a certain amount of time for the instruction
to be executed. The amount of time required depends on the instruction. For example, it takes
less time for a processor to read the status of an input contact than it does to read the
accumulated value of a timer or counter. The time taken to scan the user program is also
dependent on the clock frequency of the microprocessor system. The higher the clock
frequency, the faster is the scan rate. Typical processor clock frequencies range between 1 to
10 MHz.
Ladder Diagram (LD)
• Ladder diagram language is the most commonly used PLC language and is
designed to mimic relay logic.
Example: On/off latched process
Example: On/off latched process
Bit-Level Logic Instructions
•The ladder diagram language is basically a symbolic set of instructions used to
create the controller program.
Bit-Level Logic Instructions
•The control scheme is drawn between two vertical supply lines. All the
components are placed between these two lines, called rails or legs, connecting the
two power lines with what look like rungs of a ladder—thus the name, relay ladder
schematic.
•Each rung is a combination of input conditions (symbols) connected from left to
right, with the symbol that represents the output at the far right. The symbols that
represent the inputs are connected in series, parallel, or some combination of the
two to obtain the desired logic.
•In a rung of any hardwired circuit there must be electrical continuity in order for
the load to energize. The rung has electrical continuity only when the current flow is
established in a path from one side of the power rail to the other. There is no
electrical continuity in the PLC ladder logic program. Instead, the rung must be
evaluated in terms of logical continuity rather than electrical continuity.
Bit-Level Logic Instructions
•The memory bit is set to 1 or 0 depending on the status of the input (physical)
device or internal ( logical) relay address associated with that bit.
•A 1 corresponds to a true status or on condition.
•A 0 corresponds to a false status or off condition
Ladder Diagram (LD)
• The three fundamental symbols that are used to translate relay control logic to
contact symbolic logic are Examine If Closed (XIC), Examine If Open (XIO), and
Output Energize (OTE)

Representations of contacts and coils are the basic symbols of the logic
ladder diagram instruction set.
Bit-Level Logic Instructions
•Contacts.

Normally open contacts (NO) Normally closed contacts (NC)

•Output Energize

Rule number: 1/2 Dealing with NO inputs


START/STOP
Example 1:

START/STOP using 2 pushbutton start (NO)


Bit-Level Logic Instructions
•Contacts.

Normally open contacts (NO) Normally closed contacts (NC)

•Output Energize

Rule number: 3/4 Dealing with NC inputs


START/STOP
Example 2:

START/STOP using 2 pushbutton stop (NC)


Deal with NC input connected to plc
Bit-Level Logic Instructions
•Contacts.

Normally open contacts (NO) Normally closed contacts (NC)

•Output Energize

Rule number: 5

One input can be used in multiple times


in one program
Bit-Level Logic Instructions
•Contacts.

Normally open contacts (NO) Normally closed contacts (NC)

•Output Energize

Rule number: 6

One output cannot be used in multiple


times in one program
Bit-Level Logic Instructions
•Contacts.

Normally open contacts (NO) Normally closed contacts (NC)

•Output Energize
Rule number: 7

Output (or coils) can be used in


parallel.
Plc vs relay logic
An output might not go on immediately in sequence as it would
in a relay logic system.
y0 or y1 is on when x0 is on?
Current Flow concept
Ladder logic follows a left to right principle. In the example below,
the current flows through paths started from either X0 or X3.
Reverse current flow
When a current flows from right to left, which makes a reverse
current logic, an error will be detected when compiling the program.
Example 3:
START/STOP using start and stop push button
Example 4: START/STOP using start and stop push button
Example 5:
START/STOP with 2 indicators (Red ➔ Run & Green➔
stand by (stop) ). Using start and stop push button
Example 6:

Write a program such that when X0 is on y0

should be on,

when x1 is on and y0 is on y1 should be on


Example 6:

Write a program such that when X0 is on y0 should be on,

when x1 is on and y0 is on y1 should be on


Example 7:

Write a program such that when X0 is on y0 should be on,

when X1 is on and y0 is OFF y1 should be on


Example 7:

Write a program such that when X0 is on y0 should be on,

when X1 is on and y0 is OFF y1 should be on


Example 8: (Interlock program)
Write a program such that when X0 is on y0 should be on,

when x1 is on y1 should be on.

but y0 and y1 should not be on in the same time


Example 9:
Write a program such that when X0 is on and y2 is off y0
should be on,

and when x1 is on and y0 is on y1 should be on,

and when x2 is on or x3 and y1 is off y2 should be on.


Example 10: Controlling the tank

Control process:
• Press START, the pump begins to
pump in the water;

• Press STOP OR when the tank is


full, the pump stops working.

• Note
(START, STOP and
Level switch are NO)
Example 11:
Figure shows the sketch of a drilling process that requires the drill press to turn on only if there is
a part present and the operator has one hand on each of the start switches. This precaution will
ensure that the operator’s hands are not in the way of the drill.

The sequence of operation requires that switches 1 and 2 and the part sensor
all be activated to make the drill motor operate.
Example 12: (All switches are NO)

Write a program when S0 AND S1 is ON,


Y0 should be ON, And latched
when S2 AND S3, Y0 should be OFF
Example 12: (All switches are NO)

Write a program when S0 AND S1 is ON,Y0 should be ON, And


latched
when S2 AND S3 y0 should be OFF
Example13: Controlling the conveyor (All inputs are NO)
Example 14: Controlling the conveyor (All inputs are NC)
Example: Automatic PLC Control - Cardboard Cutter (All inputs are NO)
Solenoids
• Solenoids An electromechanical solenoid is a device that uses electrical energy to
magnetically cause mechanical control action.

• A solenoid consists of a coil, frame, and plunger (or armature, as it is sometimes


called). Figure shows the basic construction and operation of a solenoid. The coil
and frame form the fixed part. When the coil is energized, it produces a magnetic
field that attracts the plunger, pulling it into the frame and thus creating
mechanical motion.
Solenoids
• When the coil is deenergized the plunger returns to its normal position through
gravity or assistance from spring assemblies within the solenoid. The frame and
plunger of an AC-operated solenoid are constructed with laminated pieces instead
of a solid piece of iron to limit eddy currents induced by the magnetic field. The
choice of using DC- or AC-operated solenoid coils is usually predetermined by the
type of supply voltage available. Most solenoid applications use DC.
Differences between DC and AC operated solenoids include:
• AC solenoids tend to be more powerful in the fully open position than DC. This is
due to inrush current, which at maximum stroke can be more than 10 times the
closed current. The coil current for DC solenoids is limited by coil resistance only.
The resistance of an AC solenoid coil is very low, so current flow is primarily
limited by the inductive reactance of the coil.

• AC - solenoids must close completely so that the inrush current falls to its normal
value. If an AC solenoid plunger sticks in the open position, a burnout of the coil is
likely. DC solenoids take the same current throughout their stroke and cannot
overheat through incomplete closing.
• AC - operated solenoids are usually faster than DC, but with a few milliseconds variation
in response time, depending on the point of the cycle when the solenoid is energized. DC
solenoids are slower but they repeat their closing times accurately against a given load.

• A good AC solenoid, correctly used, should be quiet when closed, but only because its
fundamental tendency to hum has been overcome by correct design and accurate
assembly. Dirt on the mating faces or mechanical overload may make it noisy. A DC
solenoid is naturally quiet.
• There are two main categories of solenoids:

linear and rotary.

The direction of movement, either rotary or linear, is based on the mechanical assembly
within which the electromagnetic circuit is encased. Rotary solenoids incorporate a
mechanical design that converts linear motion to rotary motion. Linear solenoids are
usually classified as pull (the electromagnetic path pulls a plunger into the solenoid body)
or push (the plunger shaft is pushed out of the frame case).

• The linear solenoid application shown is used in part rejection processes in which
electronic interfacing with a sensor produces an actuation signal to the solenoid.

• In the rotary solenoid application, the solenoid is used in a sorting conveyor to control a
diverter gate.
Solenoid Valves
• Solenoid valves are electromechanical devices that work by passing an
electrical current through a solenoid, thereby changing the state of the
valve. Normally, there is a mechanical element, which is often a spring,
that holds the valve in its default position. A solenoid valve is a
combination of a solenoid coil operator and valve, which controls the
flow of liquids, gases, steam, and other media. When electrically
energized, they either open, shut off, or direct the flow of media.
• The valve body contains an orifice in which a disk or
plug is positioned to restrict or allow flow. Flow
through the orifice is either restricted or allowed
depending on whether the solenoid coil is energized or
deenergized. When the coil is energized, the core is
drawn into the solenoid coil to open the valve.
• The spring returns the valve to its original
closed position when the current coil is
deenergized. A valve must be installed with
direction of flow in accordance with the arrow
cast on the side of the valve body.
Pneumatic Actuators
• Solenoid valves are commonly used as part of tank filling and emptying processes.
Figure shows the circuit for a tank filing and emptying operation. The operation of
the control circuit can be summarized as follows:

• Assuming the liquid level of the tank is at or below the empty level mark,
momentarily pressing the FILL push button will energize control relay 1CR.

• Contacts ICRI and ICR2 will both close to seal in the ICR coil and energize
normally closed solenoid valve A to start filling the tank.

• The stop button may be pressed at any time to halt the process.
Example: Automatic PLC Control - cardboard Cutter
Introduction to latch /unlatch
In the Last examples we have learned how to latch an output using
normally open contacts related to the outputs.

But this is not the only method for latching outputs. Another method

used for latching the outputs is the Set/Reset coils method.


Set instruction
When the SET instruction is driven, its designated device will be ON and
latched whether the SET instruction is still being driven or not driven.

OR Taking another definition (THE SAME )


This coil is activated when a positive edge trigger it.
Being activated by an edge means that even if the HIGH signal is cut off
the coil after it has been activated, it will still conduct current to the
output associated with it.
Set instruction
The best method to understand how these work is to take an
example.

When x0 is true the output YO become true and latched


The network number 1 is similar to network number 2.
The Reset instruction
RST instruction can be applied to turn off the device after
activating it by using set instruction.

When x1 is true, rest will driven and the output y0 turn off
Set coil
The SET function sets the bit associated with it to 1.

Reset coil
The RESET function sets the bit associated with it to zero.
Set/Rst vs start stop with latched
Example 15
Example 16: (Using Set/Rst )

Write a program when X0 AND X1 is ON,


Y0 should be ON, and latched
when X2 AND X3 is on Y0 should be OFF

(X0 AND X1 are NO) & (X2 AND X3 are NC)


Example 16: (Using Set/Rst )
Write a program when X0 AND X1 is ON,
Y0 should be ON, and latched
when X2 AND X3 is on Y0 should be OFF
Example 17: Controlling the tank (Using Set/Rst )

Control process:
• Press START, the pump begins to
pump in the water;

• Press STOP OR when the tank is


full, the pump stops working.

• Note
(START, STOP and
Level switch are NO)
Be aware when using set/rst
When set and rst become true in the same time The priority is
given to the one come in the last network
Be aware when using set/rst
You can using set /rst more than one for the same output which isn't
allowed by out instruction
Be aware when using set/rst
You can using set /rst more than one for the same output which isn't
allowed by out instruction
RS vs SR function blocks
A RS/SR function block has a Set input and a Reset input. The operand
is set or reset, depending on which input has an priority = "1".
If there is a signal state at both inputs at the same time, the priority of the
operation decides whether the operand is set or reset.
Example 19: All inputs are NO (using set/rst)
Example 20: All inputs are NO
Internal Relay Instructions
Most PLCs have an area of the memory allocated for what are known as
internal storage bits.
These storage bits are also called internal outputs, internal coils, internal
control relays, or simply internal bits.
Internal outputs are on/off signals generated by programmed logic. Unlike a
discrete output, an internal output does not directly control an output field
device. The internal output operates just like any output that is controlled by
programmed logic; however, the output is used strictly for internal purposes.
Example 21: All inputs are NO
Detection operation
One-Shot Instruction
• One-Shot Rising (Positive Edge)
• One-Shot Falling (Negative Edge)
One-Shot Rising (Positive Edge)
The state of this contact is TRUE for one scan Cycle
when a positive transition (OFF to ON) is detected on the assigned
positive edge INPUT.
Power flows in the network for one program scan from the time where a
positive edge is triggered.
One-Shot Falling (Negative Edge)
The state of this contact is TRUE for one scan
when a negative transition (ON to OFF) is detected on the assigned
negative edge INPUT.
Power flows in the network for one program scan from the time where
edge is triggered.
Example 22:
Write a program that when x0 is pressed, y0 gets latched.
And when x1 is released y1 gets latched
Example 23: (All inputs are NO)
Write a program that when x0 is pressed, y0 gets latched.
When x1 is pressed nothing should happen, but when x1 is released y0
should unlatched
Example 24: (All inputs are NO)

The Indicator Light will starts only if ‘Start’ push button is


pressed twice, and will stop when ‘Stop’ push button is
pressed.
Using start/ stop with latched (Negative edge)
Using start/ stop with latched (Positive edge)
Using set/ rst
Example25:
Write a program that
y0 will ON if x0 push button is pressed twice,
and y0 will off when x1 push button is pressed.
Automatic
Water Supply Valve

Upper Level Switch

Lower Level Switch

Drain Valve

Stirring Motor
Automatic filling/draining the tank
1. As the start is pressed, water supply valve opens and water
begins to fill the tank, at the same time the stirring motor
turns on
2. when the water level passes lower level switch and reaches
upper level switch the water supply valve stop also the
stirring motor
Then the draining valve starts draining the water
Automatic filling/draining the tank
3.when the water levels drop below lower level switch the
draining valve stop also the cycle is repeated back to
1,2 step automatically
4.When the cycle of operation has repeated for 2 times
only the operation will not restart again and until you press
start again
Example 1
Design a program such that when XO is pressed for 10 seconds
YO gets on and latched and when press x1 y0 gets off
Using 3 kind of timers (TMR -100ms, 10ms & 1 ms)
Example 2
Design a program such that when X0 is pressed Y0 gets on and
latched only for 10 sec.
Using 3 kind of timers (TMR - 100 ms, 10 ms & 1 ms)
Application- Sequential Delay Output (Starting 3 Motors Sequentially)
Starting the oil pump motor immediately when START is pressed.
The main motor will be started after a 10 sec delay and then the auxiliary motor
after a 5 sec delay. In addition, stopping all motors immediately when STOP is
pressed.
Application- Sequential Delay Output (Starting 3 Motors Sequentially)
Using comparisons
Starting the oil pump motor immediately when START is pressed.
The main motor will be started after a 10 sec delay and then the auxiliary motor
after a 5 sec delay. In addition, stopping all motors immediately when STOP is
pressed.
Applications- traffic light control
Enabling the traffic lights to work by Start button X0 and to stop by
Stop button X1.
Retentive Timer
The same as the general timer but current value or present value will not be cleared
when timing is interrupted and resumes timing from where it was paused. Also
when the plc is in stop mode or power is off still the current value not be cleared
Wash Cars
Ensuring that the customers wash their cars for entire 5 minutes no
matter how many times the sprayer valve stops.

You might also like