Rev 1 Module2 PLC
Rev 1 Module2 PLC
WHAT IS A PLC?
• PLC stands for Programmable Logic Controller.
• It is an industrial computer control system that continuously monitors the state of
input devices and makes decisions based upon a custom program to control the
state of output devices.
• The PLC receives information from connected sensors or input devices, processes
the data, and triggers outputs based on pre-programmed parameters.
• There are 2 types of PLC:
• Compact PLC
• Modular PLC
History of PLC
• The PLC was invented in response to the needs of the American
automotive industry.
• Before the PLC, control, sequencing, and safety interlock logic for
manufacturing automobiles was accomplished using relays, timers
and dedicated closed-loop controllers.
• The process for updating such facilities for the yearly model change-
over was very time consuming and expensive, as the relay systems
needed to be rewired by skilled electricians.
• In 1968 GM Hydramatic (the automatic transmission division of
General Motors) issued a request for proposal for an electronic
replacement for hard-wired relay systems.
History of PLC
PLC
control
panel
Relay
control
panel
History of PLC
• The winning proposal came from Bedford Associates of Boston, Massachusetts.
• The first PLC, designated the 084 because it was Bedford Associates eighty-fourth
project, was the result.
• Bedford Associates started a new company dedicated to developing, manufacturing,
selling, and servicing this new product: Modicon, which stood for MOdular DIgital
CONtroller.
• One of the people who worked on that project was Dick Morley, who is considered to be
the "father" of the PLC.
• The Modicon brand was sold in 1977 to Gould Electronics, and later acquired by German
Company AEG and then by Schneider Electric, the current owner.
Disadvantages of Relay Control Panel
• Large amount of work required connecting wires
• Difficulty with changes or replacements
• Difficulty in finding errors; requiring skillful/experienced work force
• When a problem occurs, hold-up time is indefinite, usually long
Advantages of PLC
• Increased reliability: Since all the logic is contained in the PLC’s memory, there is
no chance of making a logic wiring error.
• More flexibility: It is easier to create and change a program in a PLC than to wire
and rewire a circuit.
• Lower Cost: Generally, if an application has more than about a half-dozen control
relays, it will probably be less expensive to install a PLC.
• Communications Capability - A PLC can communicate with other controllers or
computer equipment to perform such functions as supervisory control, data
gathering, monitoring devices and process parameters, and download and upload
of programs.
• Faster Response Time: Machines that process thousands of items per second and
objects that spend only a fraction of a second in front of a sensor require the
PLC’s quick-response capability.
• Easier to Troubleshoot: To find and fix problems, users can display the control
program on a monitor and watch it in real time as it executes.
Compact PLC
• Within a single case, there would be many modules.
• It has a fixed number of I/O modules and external I/O cards.
• So, it does not have the capability to expand the modules.
• Every input and output would be decided by the manufacturer.
• Some manufacturer allows to extend IO but up to certain number only.
Modular PLC
• This type of PLC permits multiple expansion through “modules”,
hence referred to as Modular PLC.
• I/O components can be increased.
• It is easier to use because each component is independent of each
other.
PLC Programming Languages
• 5 most popular types of PLC Programming Languages are:
1. Ladder Diagram (LD)
2. Sequential Function Chart (SFC)
3. Function Block Diagram (FBD)
4. Structured Text (ST)
5. Instruction List (IL)
PLC Block Diagram
Input & Output Type
Input & Output Type
Input & Output Type
Selection of PLC
Electromechanical Relay
• A Relay is an electromechanical device that can be used to make or
break an electrical connection.
• It consists of a flexible moving mechanical part which can be
controlled electronically through an electromagnet.
• Basically, a relay is just like a mechanical switch but you can control it
with an electronic signal instead of manually turning it on or off.
Electromechanical Relay
• Many machines and equipment use a higher voltage to run.
• To make it safer for the operators, we use a low voltage and current
for our controls.
• You wouldn’t want someone pushing a button with high voltage
attached to it.
480VAC
Electromechanical Relay
• When the coil receives the current, it creates a magnetic field, which attracts the
movable contact, or the armature.
• When the coil loses power, it loses its magnetic field, and a spring retracts the
contact.
• Mechanical relays can handle large amounts of current but are not as fast at
switching as other types of relays.
• They can be used with AC or DC currents, depending on the application and
design.
Solid State Relay
• Solid-state relays are solid-state electronic components that do not have
any moving components, which increases their long-term reliability.
• The control energy required is much lower than the output power,
resulting in a power gain that’s higher than that of most other relays.
• They’re generally the smallest relays and are also faster at switching
than other relays, and so they’re used for applications such as computer
transistors.
• Computers execute millions of instructions per second and need high-
speed transistor switches
Solid State Relay Output Circuit
• The most common application of solid state relays is in the switching
of an AC load.
Differences
• Unlike EMRs, SSRs have no moving parts that will wear out, and therefore
no contact bounce issues.
• Due to an opto-isolator rather than moving parts, the life span of the SSR is
often longer than the EMRs.
• The SSR is able to switch “ON” and “OFF” much faster than a mechanical
relay’s armature can move.
• When SSRs are in the on-state, substantial resistance is present, which can
lead to significant heat generation when current is flowing.
• Therefore, SSRs should be mounted on heatsinks. Solid-state relays
normally have only one output contact, while electromechanical relays can
multiple output contacts.
Relay application
• Solid-state relays can be used for:
• Applications requiring high speed and frequent switching operations
• Applications in high vibration environments
• Applications where the relay has to be located near sensitive automation
components, such as PLC’s, HMIs, and temperature controllers
• Electromechanical relays can be used for:
• Applications requiring a wide output range from the relay
• Applications using motors and transformers requiring high starting amps
• Applications where the initial installation budget is very limited
Thermal Overload Relay (TOR)
• Thermal overload relays are economic electromechanical protection
devices for the main circuit.
• They offer reliable protection for motors in the event of overload or
phase failure.
• The thermal overload relay can make up a compact starting solution
together with contactors.
Magnetic Contactor
• A contactor is a special type of relay designed to handle heavy power
loads that are beyond the capability of control relays.
• Contactors are designed to operate such loads as lights, heaters,
transformers, capacitors, and electric motors for which overload
protection is provided separately or not required.
Magnetic Motor Starter
• It is a combination of contactor and over load relay.
• In motor starter, contactor controls the flow of electric current to the connected
motor and repeatedly make and break (interrupt) the power circuit from main
power supply.
• The overload protection block in a starter protects the motor from drawing
excessive current and overheating and burning out the circuit.
PLC Control of Large Motor Load
Input/Output Addressing Example
Brand Input Output
Siemens I0.0 .. I0.7 , I1.0 .. I1.7 Q0.0 .. Q0.7 , Q1.0 .. Q1.7
Allen-Bradley I:0/0 .. I:0/7 , I:1/0 .. I:0/7 Q:0/0 .. Q:0/7 , Q:1/0 .. Q:1/7
Mitsubishi/Toshiba X4001, X4002 .. X4007 Y430, Y431 .. Y437
Omron 000.00, 000.01 .. 000.07 100.01, 100.02 .. 100.07
PLC & Electrical Wiring
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Hardwired Relay Diagram
Ladder Logic Diagram
Each input and output device is given an address which enable the
PLC to know where it should be connected.
Wiring Input
Wiring Output
Input & Output Wiring
• There are two types of input & output wiring which are PNP(Sourcing)
and NPN (Sinking)
Wire tags
Must be different
from PC
Under "Functions", you now find the "Assign IP address" item. Enter the following IP
address here (example): IP address: 192.168.0.1 Subnet mask 255.255.255.0. Click
"Assign IP address" and this new address will be assigned to your SIMATIC S7-1200
Restore the factory settings of the CPU
In the portal view under the "Start" menu, select the command "Create new project".
The project will be created and opened and the "Start" menu, "First
steps" will open automatically
Specified Hardware Configuration
• Example: Insert the CPU 1214C DC/DC/DC
In the "Start" portal, select "First steps" "Devices & 1. The "Show all devices" menu opens in the "Devices &
Networks" "Configure a device" Networks" portal.
2. Switch to the "Add new device" menu
Specified Hardware Configuration
1. The specified model of the CPU will now be added as a new device.
2. (Controllers SIMATIC S7-1200 CPU CPU 1214C DC/DC/DC
6ES7214-1AG40-0XB0 V4.2)
Specified Hardware Configuration
In the "Start" portal, select "First steps" "Devices & 1. The "Show all devices" menu opens in the "Devices &
Networks" "Configure a device" Networks" portal.
2. Switch to the "Add new device" menu
Unspecified Hardware Configuration
1. Create a new CPU. Use an unspecified model of the S7-1200 CPU with order number
6ES7 2XX-XXXXX-XXXX for this.
2. (Controllers SIMATIC S7-1200 CPU Unspecified CPU 1200 6ES7 2XX-
XXXXX-XXXX V4.2)
Unspecified Hardware Configuration
1. Click "Add". 1. The TIA Portal now switches automatically to the project view
and displays a notice there that this device is not specified.
2. In order to have the hardware configuration automatically
detected, start detection by clicking "detect" in the yellow
information box ( detect).
Unspecified Hardware Configuration
1. Select the type of your PG/PC interface ( Type of the PG/PC interface: PN/IE).
2. Select the network adapter you want to use to establish an Ethernet connection with the PLC ( PG/PC
interface: Intel(R) Ethernet Connection (4) I219-LM).
3. Click “Start search” button.
Unspecified Hardware Configuration
If the project was compiled without errors, you see the following
screen.
1. Click “Ok”.
PLCSIM Simulation
1. Press “Load”
1. Double click SIM table_1. 1. We can test the program by modify the
2. Empty sim table will be open. value in the box.
3. Click “Load Project Tags” button. 2. The box at the bottom can be use as
4. The project tag specified in the TIA momentary pushbutton.
portal will be displayed automatically.
PLCSIM Simulation
Finding / Replacing / Sorting PLC Tags Error Indication in the PLC Tag Table
Absolute and Symbolic Addressing
Renaming / Rewiring Tags
Monitoring using Watch Table
• We can simulate or test our system using watch table.
• However, it only works for internal memory (M0.0, M0.1 etc.)
• The modify function will not work for physical Input (I0.0) and Output
(Q0.0)
Creating Watch Table
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Creating a simple ladder
1. Create a new project.
2. In the program blocks, open “Main [OB1]”
Favorites Command
1. Insert a contact
Normally open
(NO)
Normally close
(NC)
Normally Open & Normally Close
1 2
Input Instructions
Example
When A is activated, the addition will
operate non stop. After C is deactivated,
the addition will stop.
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Inserting Timer Command
Data Block
Data Block Name
IN 2s 0.2s
If IN is on for 2s, the If IN is on for 0.2s, the
output will on for 1s only output will stay on for 1s
Timer ON Delay (TON)
• Timer On Delay instruction is used to delay an instruction before
become true/high. E.g. After 5 seconds, the motor will on.
TON Timing diagram
IN 10s 0.2s
If IN is on for 10s, the If IN is on for 0.2s, the
output will on after 3s output will not on.
delay. When IN is off, the
output will also off
TON Latching
• The problem with TON is that when we release the button before reaches the
preset time, the timer will reset.
• If the preset time is 30 seconds, it’s not practical for the operator to hold the start
button for 30 seconds before the motor is starting.
• To overcome this problem, we create TON Latching.
IN 3s
Once IN is activated,
output is on immediately.
Timer will start when IN
is deactivated.
Timer On Retentive (TONR)
• TONR as the name suggest, it keep the elapsed time value even the
input is off.
• It need a reset input to reset the elapsed time.
Addressing using %MD
• Since Time is double integer, we have to use MD.
• The address for each tag need to have 4 byte spacing between each
other to avoid conflicts.
• Recall back lesson from chapter 7.
Task 2
• Once the limit switch is ON, the red light and yellow light will on
simultaneously. After 30 seconds the heater will turn on and yellow
light is off. The red light stays on.
Task 3
• A start pushbutton (PB1) is used to start motor 1. A pilot light is used to indicate
that motor 1 is running. Motor 2 can only be started 10 seconds after motor 1 by
using a separate start pushbutton (PB2). Another pilot light is used to indicate
motor 2 running status. If the operator press PB2 when time<10s, motor 2 will
not start. Both motor will be stop if stop pushbutton or emergency pushbutton is
press.
Motor 1 PL 1
PB1 PB2
Motor 2 PL 2
STOP
Counter Operation
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Inserting Counter Operation
%MW2
Task 2
• Write a logic using CTD that count the number of students (I0.0)
passing through the gate (Q0.0). When there are 10 students pass
through, the gate will closed.
Counter Up and Down (CTUD)
• CTUD combines the two function of CTU and CTD together in one
block.
%MW4
Addressing using %MW
• Since counting value is integer, we have to use MW.
• The address for each tag need to have 2 byte spacing between each
other to avoid conflicts.
• Recall back lesson from chapter 7.
Task 3
• Create a ladder logic for car parking system. The parking lot has 10 space available for
parking. If the parking is available, green light is on. When the car reaches the gate, the
entrance sensor will detect the car and the gate will open for 5s. If the parking is full, red
light is on. When there is a car left the parking lot, exit sensor detects the card and green
light will turn back on.
Entrance Exit
1 2 3 4 5
6 7 8 9 10
Task 4
• Start PB is press to start the process. Once sensor A detect 10 pcs of material
inside a box, the conveyor will start running. When sensor B detect the box, the
conveyor will off and the painter will on for 10s. After 10s, the conveyor starts
again. When the box reaches sensor C, the process will repeat until reaches 5
boxes and all the process will stop. If Stop PB is press at anytime, all the process
will stop immediately.
Math Operation
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Inserting Math Operation
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Comparator Operation
• Comparator function is used to compared between two different
value of the same data type.
Both value
must be integer
Inserting Comparator Operation
Jump is activated
Network 2 is skipped.
Analog Operation
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Introduction to Analog Operation
• PLC can only work with the two values 0 and 1.
• This is due to the fact that a PLC or a microcontroller is really just
advanced electrical circuits made out of transistors.
• Since a transistor can only be either on or off, these two states will
then represent the values 0 and 1.
• In the real world, analogue signals have continuously changing values
which come from various sources and sensors which can measure
sound, light, temperature or movement, and many digital systems
interact with their environment by measuring the analogue signals
from such transducers.
Analog Signals in PLC
• A PLC can only work with the values 0 and 1
• Analog signals are continuous signals that can vary over time.
You can also use an external power supply for the 2-wire transmitter.
One wire that goes from A+ through the transmitter and back in another Connect the 0 V from the supply to AGND and 24 V through the
wire to AIN. The supply comes from A+, the transmitter controls the transmitter back to AIN. Although you would practically need 3 wires
current flow and the analogue current signal goes into AIN. for this, it is still considered a 2-wire analogue input connection.
Because the transmitter only has two wires
3-Wire Analog Input
• In a 3 wire current loop only the ground is shared
between the supply and the signal.
• The ground is connected to both AGND and on the
power supply (-).
• But the transmitter has 2 positive (+) wires. One that
goes to the power supply (+), and one that goes to
AIN.
• Though they share the ground a 3-wire transmitter
creates 2 loops.
• One for the signal and one for the supply.
• Now the sensor or transmitter can consume as much
current as it needs without interfering with out
analogue signal.
4-Wire Analog Input
• The 4-wire transmitter is also widely used
since it separates the supply from the signal.
• By giving the transmitter 4 wires, you can have
2 for the supply and 2 for the signal.
• Naturally, the 4-wire transmitter requires an
external power supply.
• Clearly the biggest advantage of using a 4-wire
transmitter is the complete separation
between supply and signal.
• They can be fully isolated or opto-isolated so
that disturbance in the supply shouldn’t affect
the signal.
Analog Output
• Analog outputs has a lot of similarities with analogue inputs. But there are
still some differences in both the way you wire them, and in the way you
use them in your PLC program. Just like the analogue input, the analogue
outputs can be divided in two types:
• Voltage
• Current
• Both principles are the same. Either we use voltage or current as analogue
signal.
• The device you connect to your analog output is what decides which type
of analog signal you should be using.
• If you want to control a valve with a 4-20 mA signal, then your analog
output should also be 4-20 mA
Voltage Analog Output Wiring
• For this you will only need 2 wires. A positive and a negative side of the voltage source. Which in this case is our
analogue voltage output. Here’s how a simple 2-wire analogue voltage output is wired:
Current Analog Output Wiring
• Most analogue outputs on PLC’s works very
much like a 3-wire transmitter.
• This might seem odd, since we only had 2
wires so far.
• But the PLC often provides an internal
power supply giving us the third wire. The
supply for the signal.
• This means that when you’re working with
current outputs, you will most times only
have to wire the signal current loop.
• Of course you will eventually also have to
wire the supply loop.
• But that is often needed to supply the
module itself so the PLC can see it.
Voltage vs. Current Measurement
• Voltage and current are the common measurement used in PLC.
• Both have their own advantages and disadvantages
• Voltage signal can easily be altered by magnetic fields.
Voltage Current
The range is
depends to our
requirement.
Example: Displaying Temperature
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Types of Program Block
Structured Programming
Functions (FC)
• Performs a specific operation on set of input values:
• To perform standard or reusable operation such as mathematical calculations
• To perform functional tasks such as for individual controls using bit logic operations
• FC can be called several times at different points in the program. This reuse simplifies
the programming of frequently recurring tasks
• For example, if you want to programmed for 10 different motors.
• All of the start sequence is the same.
• You can type the same program 10 times but what if there is 100 motors?
• By using FC, you only need to program it once and reuse it multiple times.
Creating Functions
Output at network 2
Input at network 3
Inserting FC to Main OB
Additional lectures
Introduction to HMI
• A very common HMI that you all encounter on a regular basis would
be an ATM machine.
• The screen and pushbuttons allow you to operate the machine to
dispense a certain amount of money, or to deposit money.
• An operator or maintenance personnel can operate and monitor the
machine from the HMI.
• They may include information like temperature, pressure, process
steps, and material counts.
• They can also show very precise levels in tanks and exact positioning
of machines.
Introduction to HMI
• For maintenance personnel, many HMIs can also connect to PLC logic
and display it on the screen for troubleshooting purposes.
• This can save valuable time compared to connecting a computer or
laptop every time.
PLC and HMI Connection
• HMI and PLC need to be compatible which means they need to be able to “talk”
to each other.
• Common protocols are Modbus, Ethernet/IP, and Profibus.
• Once the PLC and the HMI are “talking” then whatever is programmed into the
HMI can be used to monitor and control PLC functions.
Siemens HMI Series
Siemens KTP-400
Setting up PLC
1. Choose HMI_Start.
2. Let Bit = 0.
1. Create a button.
2. Under click, choose
ActivateScreen.
3. Choose screen name.
Changing Between Screen
Error- Alarms that is critical to the machine. The machine will not
work if the problem is not resolved. Example: motor is damaged,
the alarm will not go away until the motor is fixed.
Since elapsed time < 10, low Since elapsed time >25, high
level alarm is triggered. level alarm is triggered.