100% found this document useful (2 votes)
94 views

Rev 1 Module2 PLC

Uploaded by

Muhd Izzat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
94 views

Rev 1 Module2 PLC

Uploaded by

Muhd Izzat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 293

PLC BASIC INTRODUCTION

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)

Based on the diagram, we will say that


Device 1 Device 2 device 1 is sourcing the current while device
2 is sinking the current

In reverse, we will say that device 2 is


Device 1 Device 2 sourcing the current while device 1 is sinking
the current
Input & Output Wiring
Input & Output Wiring

Based on technical specifications, this


type of PLC can be wired as sinking or
sourcing.

If we wired our PLC as sinking, our input sensor need to sourcing.


If we wired or PLC as sourcing, our input sensor need to be sinking.

Some manufacturer labelled their sensor as NPN or PNP sensor.


If we wanted to use a PNP sensor, our PLC will have to be wired as sinking.
If it is NPN sensor, our PLC will have to be sourcing.
How to wire the PLC?
Input & Output Wiring
PNP Switch NPN Switch
(Sourcing) (Sinking)

Sinking PLC Sourcing PLC


Motor Starter Relay Circuit
Legends & Abbreviation

Every wiring diagram


typically have pages of
reference for component
symbols.
Electrical Wiring Diagram

Hardware Components All the components are


drawn on neutral condition
(non energized state)
Electrical Wiring Diagram

Wire tags

The power enters the terminal


blocks with the “X0” terminal strip.

3 phase power supply


Electrical Wiring Diagram

Wire tags on hardware


Addressing component in wiring diagram

All of them have a 2.0 number just beside the


arrow.
– By “2” it refers us to page two.
The page is divided to 10 separate columns. – By “0” it points out to the first column of page 2.
Each device is located in its column, so we will
used this as reference.
Addressing component in wiring diagram

As we can see, it continues right here.


Note that the incoming is label as 1.9
which is our previous page. For this contact, the wiring is coming
from page 130 on column 6.
Addressing component in wiring diagram

Below the coil, you see the 13-14


contact (NO Contact) of page two and
also the other NO and NC contacts of
this relay with the addresses they have
been used in this drawing.
Relay wiring example

1. Pin 13 & 14 is used to power up the relay.


2. Pin 9 & 12 is the common.
3. If we want to do NO connection, we will
connect pin 5 & 9.
4. For NC connection, we will use pin 1 & 9.
5. For this model, one relay can control 2
different output.
SIEMENS HARDWARE
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Siemens PLC Series
S7-1200 HARDWARE
1 2 3
1. Electrical source to power the PLC
2. Input source type
3. Output source type
CPU Operation Mode
• Yellow light indicates STOP
mode.
• Green light indicates RUN
mode.
• A flashing light indicates
STARTUP mode.
• ERROR LED for indicating
errors.
• MAINT LED for indicating a
maintenance requirement.
SIMATIC S7-1200: Modules
SIMATIC S7-1200: Installation and Mounting Positions
SIMATIC S7-1200: Signal, Communication or Battery Board
SIMATIC S7-1200/1500: Memory Card(s)
TIA Portal - Central Engineering Framework

The Totally Integrated Automation Portal constitutes the


working environment for an integrated
engineering with SIMATIC STEP 7 V16 and SIMATIC WinCC V16.
• Central engineering framework
• Automatic data and project consistency
• Uniform operator control concept for all automation tasks
• Powerful libraries covering all automation objects
STEP 7 Range of Products
WinCC Range of Products
Startdrive Range of Products and Licensing
SIEMENS SOFTWARE
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
TIA Portal: Portal View and Project View
Portal View
Project View
Menu Bar and Toolbar
Project Tree (First Level)
Project Tree (Second Level)
Task Cards
Inspector Window
Window Arrangement
Splitting and Arrangement of the Working Area
Keeping the Editor Window in the Foreground
(when Editor Space is Split)
Save / Manage / Use Window Layouts
Undo and Redo
Saving a Project
Archiving / Retrieving a Project
TIA Portal - Settings: User Interface Language
Help
Keyboard Shortcuts of the TIA Portal
Project Migration
Update Tool
Software and Hardware
Configuration
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Online Connection via Industrial Ethernet:
IP Address and Subnet Mask
Assigning an IP Address for PC/Laptop

You can put any


number. But it
cannot be the
same with PLC
Assigning IP Address for PLC CPU

Open TIA Portal, Select  "Online &


Diagnostics", and open the "project
view"
Assigning IP Address for PLC CPU

In the project tree under  "Online access", select the


network adapter that was set previously. If you click 
"Update accessible devices" here, you see the IP address (if
previously set) or the MAC address (if IP address not yet
assigned) of the connected SIMATIC S7-1200. Select  "Online
& Diagnostics" here.
Assigning IP Address for PLC CPU

Must be different
from PC

If the IP address was not successfully assigned, you


will receive a message in the  "Info" window
under  "General".

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

If the IP address could not be assigned, the


program data on the CPU must be deleted. This
is done by resetting the CPU. To reset the
controller, select the  "Reset to factory
settings" function and click  "Reset".
Create a new project
 Select the Totally Integrated Automation Portal for this, which is opened here with a
double-click (® TIA Portal V16)

 In the portal view under the "Start" menu, select the command  "Create new project".

Modify Project name, Path, Author and Comment


as appropriate and click  "Create".

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

The TIA Portal now switches automatically to the


project view and displays the selected CPU in the
1. Click "Add". device configuration on slot 1 of a rail.
Unspecified 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

1. Select the CPU.


2. Click “Detect”
3. The correct CPU type will be displayed.
Configure the Ethernet interface

1. Select the CPU with a double-click


2. Under  "Properties", open the 
"PROFINET interface [X1]" menu and select
the  "Ethernet addresses" entry.
Configure the Ethernet interface

1. Under "Interface networked with", only the


"Not networked" entry is available.
2. Add an Ethernet subnet with the  "Add
new subnet" button.
3. Keep the preassigned "IP address" and
"Subnet mask".
Configure the address areas

1. The next step is to check the address areas of the


inputs and outputs and adapt them if necessary.
2. DI/DO should have an address area of 0…1 and
AI/AO should have an address area of 64…67 and
64…65, respectively.
3. ( Device overview  DI 14/DQ 10_1  I
address: 0..1 Q address: 0...1  AI 2_1  I
address: 64…67  AQ 1x12BIT_1  Q address:
64…65)
Save and compile the hardware configuration

If the project was compiled without errors, you see the following
screen.

1. Save the project by clicking “Save project”


2. Select the "CPU_1214C [CPU1214C DC/DC/DC]“
3. Click the "Compile" icon
Download the hardware configuration to the device

1. Select the interface as shown.


2. The ® "Show all compatible devices"
check box must be selected.
3. Click “Start search”.

1. Select the ® "CPU_1214C [CPU1214C DC/DC/DC]"


2. Click the ® "Download" icon.
Download the hardware configuration to the device

1. You first obtain a preview.


2. Confirm the prompt  "Overwrite all"
3. continue with  "Load".
1. Select the "CPU 1214C DC/DC/DC”
2. Click “Load” button.  "Overwrite all" and continue
with  "Load".
Download the hardware configuration to the device

1. Click “Start all”


2. Click “Finish” button. 1. After a successful download, the project view will open
again automatically.
2. A loading report appears in the information field under
"General". This can be helpful when troubleshooting an
unsuccessful download
Download the hardware configuration to the
PLCSIM simulation
• If we do not have any physical hardware around, we can simulate our
project using PLCSIM.
• Open the PLCSIM by clicking “Start simulation” icon.

1. Click “Ok”.
PLCSIM Simulation

The "S7 PLCSIM" software is


started in a separate window in Select the interface as shown.
the compact view The "Show devices with the same
address" check box must be selected.
Click “Start search”.
PLCSIM Simulation

1. Press “Load”

1. Select the “CPU-1200 Simulation”


2. Click “Load” button.  "Overwrite all" and continue
with  "Load".
PLCSIM Simulation

1. Click “Start all”


2. Click “Finish” button.
1. After a successful download, the project view will open
again automatically.
2. A loading report appears in the information field under
"General". This can be helpful when troubleshooting an
unsuccessful download
PLCSIM Simulation

1. Click the button to


change to project view.
PLCSIM Simulation

1. Click Project  New


2. Give the project name
3. Click “Create”
PLCSIM Simulation

1. You can see the downloaded


configuration with the status of all
inputs and outputs in the project
view by double-clicking  "Device
configuration".
2. Here you can also create your own
 “Sim tables“ with selected input
and output signals.
3. You can modify the input signals
used in your program to test the
program in the PLCSIM simulation.
PLCSIM Simulation

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

1. If there is a new tag created, manually


update sim table.
2. Click the empty box and click the icon
on the right.
3. Choose the new tag.
4. DO NOT PRESS LOAD TAG AGAIN.
Archive the project

1. Click Project  Archive


2. Click “Yes”.
3. Select a folder where you want to
archive your project.
4. Save it as file type "TIA Portal project
archive"
PLC Tags, Memory & Data
Types
Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Data Types
• 1 BIT = 0 or 1
• 1 BYTE = 8 bit
• 1 WORD = 16 bit
• 1 DOUBLE WORD = 32 bit
Bool, Byte, Word, and DWord data types
Integer data types
Floating-point real data types
Addresses of PLC Tags
PLC Tag tables
Creating PLC Tags

1. Double click on “Show all tags” or “Default tag table”.


2. Click on the “<Add new>” and give name for the tag.
Creating PLC Tags

1. Choose the correct data type and address.


2. Since pushbutton only give signal either 0 or 1, Bool data type is used.
3. Pushbutton is an input device so operand identifier “I” is used.
4. 0.0 is used because it is the first unused bit.
Creating PLC Tags

1. Stop Pushbutton also an input and it


use the next available bit which is I0.1
2. Lamp is an output device so “Q” is used
with the first available bit 0.0
Creating PLC Tags

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

1. Double click “Add new watch table”.


2. Click on the “<Add new>” and choose
the PLC tag that we wanted to use for
monitoring
Modifying Watch Table

1. Right click on the modify value.


2. Choose modify to 1.
Creating Force Table

1. Double click “Force table”.


2. Click on the “<Add new>” and choose the
PLC tag that we wanted to use for forcing
Modifying Force Table

1. Right click on the force value.


2. Choose force to 1.
Bit Logic Operation

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

To insert the command, just drag and drop.

This symbol appears if the network is not complete.


The network is complete when it has input and output.
Inserting branch
1. Click the left rail.
2. Click open branch

1. Insert a contact

1. Click the arrow and hold.


OR
2. Release at the desired location.
1. Click the arrow.
2. Click close branch
Inserting command to favorite toolbar

1. Choose any command on the right.


2. Click and hold the command.
3. Release it at the favorite area.
Normally Open & Normally Close

Normally open
(NO)

Normally close
(NC)
Normally Open & Normally Close

Task 1: Create simple ladder logic as shown on the


left and simulate it using PLCSIM (Refer chapter 6).
IO Address Location

The IO address can be different for each CPU.


We can check the available address:
1. Open devices & Networks.
2. Click on the PLC>Properties>IO tags.
Logic Gates in PLC Ladder Logic
Logic Gates in PLC Ladder Logic
Logic Gates in PLC Ladder Logic
Task 2
• Draw the ladder diagram for the following logic gate.

1 2
Input Instructions
Example
When A is activated, the addition will
operate non stop. After C is deactivated,
the addition will stop.

When B is activated, the addition will


operate once.

When C is activated, the addition will


not operate. After C is deactivated, the
addition will happen.
Output Instructions

Output Set: When the coil is energize,


the output will be high. Output will stay
high even the coil is de-energize.
Output Reset: When the coil is energize,
the output will be reset.
Output Energize: When the coil is
energize, the output will be high.
Set and Reset command must be used together. Output will be low when the coil is de-
The address for both must be the same. energize.
Output Instructions
Multiple Output
• If we have multiple output to be on at the same time, arranged it in
parallel.

Series: If Lamp 1 fail to ON,


Lamp 2 will not ON
Parallel: If Lamp 1 fail to ON,
Lamp 2 still can ON
Seal-in Instructions (Latching)
• If we use a momentary pushbutton to turn on an output, we need
something to hold the output value.
• It is not logical for the operator to keep holding the pushbutton in
order for the output to stay on.
• Other than using Set/Reset instructions, we can use seal-in or
latching method.
Seal-in Instructions (Latching)

Seal-in area: Use NO contact with the


output address that we wanted to latch

Holding the pushbutton Release the pushbutton


Task 3
• Create a ladder logic to start a conveyor with a start pushbutton. The
conveyor will always stays on until stop pushbutton is pressed.
Task 4
• Create a ladder logic to start a conveyor with a pushbutton. When
the conveyor is started, 2 green light will turn on simultaneously. The
conveyor will always stays on until stop pushbutton is pressed. When
the conveyor is stop or not working, red stop light will turn on.
Timer Operation

Prepared by:
Mohamad Hafiz Bin Ahmad
[email protected]
Jabatan Latihan
Kulim Advanced Technologies Sdn. Bhd.
Inserting Timer Command

Drag & Drop Can change the data block name


Timer Pulse
• Timer Pulse (TP) timer generates a pulse with a preset width time.

Data Block
Data Block Name

Elapsed Time (current time)


Preset time Must use %MD address
32 bits (Double integer)
Example preset time:
T#24d_20h_31m_20s_800ms
Timer Pulse Timing Diagram

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.

We use the data block name with .IN


Task 1
• Write a ladder logic to turn on 3 lamp with TON function. Lamp 1 will
on after 3 seconds being activated. 3 seconds after lamp 1 is turned
on, lamp 2 will also turn on. 3 seconds after lamp 2 is on, lamp 3 will
turn on. Each lamp will turn on with 3 seconds delay each.

Lamp 1 Lamp 2 Lamp 3


3s 3s 3s
ON
Timer OFF Delay (TOF)
• Used Timer Off Delay instruction to delay an instruction before
become false/low. E.g. To fill the water inside tank for 5s before off.
TOF Timing Diagram

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

Drag & Drop

Can change the data block name


Counter Up (CTU)
• The count value (CV) will increase by 1 when the input signal (CU) is
transition from 1 to 0.
• If the CV >= to preset value (PV), the output signal (Q) will be 1.
• Reset count (R) is used to reset the CV to 0.
Task 1
• Write a logic to latch the Motor (Q0.0) using a start pushbutton (I0.0).
When the counter reaches 10 counts, the motor is stop (unlatch). A
reset button (I0.1) is used to reset the count.
Counter Down (CTD)
• The count value (CV) will decrease by 1 when the input signal (CD) is
transition from 1 to 0.
• If CV<=0, the output (Q) will be high.
• Load count (LD) is used to load the PV to the CV.

%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

Drag & Drop


Data Type

• We can choose the data type for our


calculation.
• If the number is whole number, use Int, DInt
• If our calculation involves decimal places, we
need to choose Real or LReal
Changing Display Format

The value is displayed


in hexadecimal.

Right click on the tag


name and change the
display format to
decimal
Modify Operand Value
Make sure the format
is in decimal

Right click on the tag


name and click
modify operand
Data Type Range Values
Addition & Subtraction
Multiplication & Division
Mod & Calculate
Increment & Decrement
Get Minimum/Maximum
Set Limit
Example
Task 1
• Convert Fahrenheit to Celsius. Take F= 120.
• The formula:
Task 2
• Convert Celsius to Fahrenheit. Take C = 37
Comparator 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

Drag & Drop


Exercise
Task 1
• The operator needs to enter the speed for the motor. The speed must
be from 0 -1750 rpm. If the value entered is outside limit, the motor
wont start. *use modify operand to enter the motor speed
Task 2
• The temperature limit for the oil is between 0-100 Celsius. If the
temperature reach outside the limit, red light will turn on. Create the
ladder logic using limit instruction. *use modify operand to enter the
oil temperature
Task 3
• Create a ladder logic for batch counting operation to sort part
automatically for quality control. A sensor is used to detect and count
the defective part. If the defective part is equal or more than 8 pcs,
red light will on. If the defective part is less than 8, green light is on.
Reset pb is used to reset the counter when there is new batch coming
in.
Move Operation
• Copies the contents of the operand at the IN input (Tag_1) to the
operand at the OUT1 output (Tag_2).
Convert Operation
• Read the content of the IN parameter (Tag_5) and converts it
according to the specified data type.
Jump and Label Instructions
• Jump and Label instructions need to be use in pair.
• The instruction will not complete if either one is not present in the
ladder.
• If the Jump instruction is activated, it will goes straight to the jump
label.
• It will skip any ladder that is between the jump and label instructions.
Inserting Jump and Label Instructions

Drag & Drop


Jump and Label Instructions

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.

The Question Is Now: How Do A PLC Deal


With All These Different Values? Let’s Say You
Have An Analog Signal At 5 Volts Going Into
The PLC. We Cannot Represent It With
Boolean Values, Because They Can Only Have
The Values 0 And 1

Answer: Converting analogue value to binary value


Analog-to-digital Conversion
• It is necessary to have an electronic circuit which can convert
between the two different domains of continuously changing
analogue signals and discrete digital signals, and this is where
Analogue-to-Digital Converters (A/D) come in.
• There are 3 types of analog signal:
• Voltage
• Current
• Resistance
Resolution of Analog Signal
• Resolution is the number of bits per conversion cycle that the
converter is capable of processing.
• For example, a converter with 12 bits of resolution is often referred to
as “12 bits wide,” since 12 bits get processed in each conversion cycle.
Resolution of Analog Signal
• If you need accurate voltage level for your system to read, then the
bit resolution is important to know.
• The resolution depends on both the bit length and the reference
voltage.
This is accurate as the digital system will be
able to tell when the voltage changes on an
accuracy of 1.22mV for 12 bits.
Analog Input
• Analog inputs can come from a variety of sensors and transmitters or
both.
• For example the thermocouple types connected to a transmitter, which is
then connected to a PLC analog input.
• The job of the sensor or transmitter is to transform that into an electrical
signal. Few of the things you can measure with analog sensors:
• Level
• Flow
• Distance
• Viscosity
• Temperature
Analog Input
• A transmitter is often needed because the sensor in itself cannot provide us with
an analog signal.
• Or at least not one that fits a PLC analog input. It is possible to buy analog input
modules where you can connect a temperature sensor for example directly.
• But most often you will have a voltage or current input module where you
connect a transmitter.

Calibration is very important


when talking about transmitters.
You have to know how much
those mA or volts represents in
the physical value
Wiring Analog Input
• Two basic analog input signal (commonly used):
• Voltage
• Current
• These two types of analog signals works in very different ways, you
will also have to wire them differently on the analog input module.
• Mistakes in the wiring can potentially destroy the input module, so be
careful!
Voltage Analog Input Wiring
• All analog voltage has 2 terminals:
• AGND: The ground or reference for analog inputs
• AIN: Analog input
• It is between AGND and AIN that the PLC measures how many volt there are on
the analog input.
• When you’re connecting the analog voltage source, the AIN is where you connect
the positive (+) side of it.
• The negative side (-) should be connected to AGND. Those are the two main wires
for the analog signal.
Voltage Analog Input Wiring
• But if you only connect those two you will end up with a very vulnerable signal.
• Electromagnetic compatibility (EMC) can easily alter your analog signal.
• As you can see below, this is solved by shielding the wires and connecting the
shield to ground.
• Be aware though that this is NOT the same ground as the AGND!
Current Analog Input Wiring
• Instead of voltage you can also use current as analogue signal. They
might be a little more tricky to wire, but in general they are more stable.
• The current in analogue signals is usually measured in mill amperes (mA).
A typical range here is between 0 and 20 mA.
• First of all, you need a closed loop for current to flow.
• Even though the wiring of the first type of current transmitter is the same
as with voltage, something different goes on here.
• Current is the flow of electrons from one pole to another. That is why you
will always need a closed loop for measuring current.
Current Analog Input Wiring
• Wiring of current analogue inputs. They can generally be divided in three
types:
• 2-wire analogue input
• 3-wire analogue input
• 4- wire analogue input
• When talking about 2, 3 and 4 wires what we’re talking about here is really
the transmitters or transducers.
• Current transmitters can be wired in different ways and therefore with a
different number of wires.
• The difference is really the power supply for the signal.
• Sometimes the transmitter will supply the circuit, and sometimes you have
to use an external supply.
2-Wire Analog Input
• The simple way is to connect a 2-wire transmitter and connect it to be loop-powered. Basically this means that the PLC will supply the current loop. Only
2 wires are needed here. In order for the PLC to supply the current we need to use another terminal on the analogue input module:

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

Wiring Easy to wiring More difficult to wiring

Magnetic Field Affected Does not affect


Checking the address for all module

1. Double click on the PLC.


2. Properties bar will open
Checking the address for all module
Checking the address for all module

1. Other method to check the address is clicking the IO tags.


2. From here, it will list out all the available address to be used
Task 1
• Create a project with this device configuration:
• CPU: 215-1BG40-0XB0
• DI/DQ: 223-1PL32-0XB0
• AI/AQ: 234-4HE32-0XB0
• Identify all the input and output address for signal module DI/DQ and
AI/AQ.
Changing Measurement Type

1. We can choose the measurement type and


voltage range depending on our sensor
application.
Current Range
• If current is used as measurement type, there are two available
current range.
• Both can be used but 4-20mA is more preferable.
Analog Scaling
• NORM_X: Receive an input signal and normalize it to a value between
0 and 1 (real number).
• SCALE_X: Receive the value from NORM_X and scale it to the desired
range that we want to use.

Drag & Drop


Example: Displaying Temperature

The range is fix


to 0-27648

The range is
depends to our
requirement.
Example: Displaying Temperature

• 13824 is ½ from the 27648.


• The display value must be ½
from 100, which is 50

• If the scale value is change to


0-200, the display will change
to 100
Modular Programming

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

1. Double click add new block.


2. Choose Function (green icon).
3. Give the block name.
Creating “Local Tags”

1. Here we can create the internal input &


output tags.
2. The InOut is used when the variable is used
as an input and output.
3. Temp is used for temporary data.
4. Constant is used for defining constant value.
Inserting Local Tags

Drag & Drop


Example for InOut

Output at network 2

Input at network 3
Inserting FC to Main OB

Open Main OB, drag


and drop FC1

Give the input and


output address.
Task 1
• By using FC, create a program to start the conveyor by using on and
off pushbutton. There are total of 5 conveyor with their own start and
stop PB.
• After creating the program, simulate it using Factory IO.
Function Block (FB)
• An FB is a code block whose calls can be programmed with block parameters.
• The FB stores the input (IN), output (OUT), and in/out (IN_OUT) parameters in
variable memory that is located in a data block (DB), or "instance" DB.
• The instance DB provides a block of memory that is associated with that instance
(or call) of the FB and stores data after the FB finishes.
• You typically use an FB to control the operation for tasks or devices that do not
finish their operation within one scan cycle. To store the operating parameters so
that they can be quickly accessed from one scan to the next, each FB in your user
program has one or more instance DBs.
• When you call an FB, you also open an instance DB that stores the values of the
block parameters and the static local data for that call or "instance" of the FB.
These values are stored in the instance DB after the FB finishes.
• You can associate different instance DBs with different calls of the FB.
Creating FB

1. Double click add new block.


2. Choose Function Block (blue icon).
3. Give the block name.
Creating “Local Tags”

1. Everything is the same as in FC.


2. FB has additional tag which is “Static”.
3. Static is something in which variable value
can be stored.
Task 2
• By using FB, create a program to fill water inside the tank by using fill
PB and release PB to drain the water.
• There are total of 3 tank that has their own preset time.
• Tank 1 fill water for 8 seconds, tank 2 for 5 seconds and tank 3 for 3
seconds.
• After the tank reaches preset time, the fill valve will be closed.
• After creating the program, simulate it using Factory IO.
Human Machine Interface (HMI)

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. All connected device must have


the same subnet to “talk” to
each other.
2. Each device must have different
node (1 device 1 node).
Adding HMI Device to TIA Portal

1. Create new project as usual.


2. On add new device, select HMI.
3. Choose any type of display.
4. Click Add
Adding HMI Device to TIA Portal

1. If we have setup a PLC


early on, we can choose
at “Browse”.
2. Click “Next” or “Finish”
if you don’t want to
change any settings.
Adding HMI Device to TIA Portal
Connecting HMI & PLC

1. If we add plc after HMI, we need


to connect both together.
2. Click “Devices & networks”.
3. Click “Network view”.
4. Click the green square and drop
to another.
Connecting HMI & PLC

1. If we have setup a PLC


early on, we can choose
at “Browse”.
2. Choose the PLC.
Example
• Create a simple On and Off Lamp.

1. Click the HMI device.


2. Click HMI tags.
3. Open Default tag table.
Creating HMI Tags

1. Create an HMI start button.


2. Under “PLC Tag”, choose the
Start button I0.0
Creating HMI Tags

1. Create all remaining PLC Tags.


Creating HMI Interface

1. Open Root screen.


2. Edit whatever we wanted to
display.
Creating HMI Interface

1. Click the start button.


2. On the properties, we
can edit many things.
1. Drag & Drop
Linking PLC Tags and HMI tags

1. Under Events, click on 1. Click Add function.


“Press” 2. Choose “SetBitWhileKeyPressed”
Linking PLC Tags and HMI tags

1. Choose HMI_Start.
2. Let Bit = 0.

1. Initially, the bit is 0.


2. When we press HMI_Start. The
bit will become 1.
3. If we release it, the bit will back
to 0 (reset).
4. Repeat for all tags stop and lamp.
Change Appearance
Creating Lamp Animation

1. Choose HMI_Lamp tag

1. Set bit 0 for green color.


2. Bit 1 for red color.

1. Under Animations, click Add new


animation.
2. Choose appearance to change the
lamp color.
Simulate HMI using WINCC

1. Click on the HMI device.


2. Click compile.
3. The download option will be
available if we have HMI
hardware.
4. Click on start simulation.
Simulate HMI using WINCC

1. Start button is pressed.

1. Stop button is pressed


HMI Numeric Input/Output

1. Create ladder & HMI as


shown.
2. Using memory bit (M30)
as an input is faster than
using (I0.0) for simulation.
HMI Numeric Input

1. Click on the preset time.


2. Link it to the HMI tag.
3. Set the type as Input
HMI Numeric Output (Display)

1. Click on the elapsed time.


2. Link it to the HMI tag.
3. Set the type as Output
Simulation

1. Press on the preset time.


1. Enter preset time.
2. Click enter.

1. Since the format is in


milliseconds, we need to
enter 5000 for 5 seconds.
Exercise
• Edit the ladder logic where the operator entered the preset time in seconds, not
in milliseconds. The elapsed time also should be display in seconds.
• Hint: use mathematical operations
Animating Object/Graphics

There are many objects and


graphics available under the
toolbox>graphics.
1. We can insert our own
graphics.
2. Scroll down, right click my
graphics folder > Link.
3. Choose the folder that
contains our graphics.
Inserting Graphics

1. Click Text and graphic lists.


2. Open Graphic lists.
3. Add the graphic name.
4. Drag and drop any graphic
Drag & Drop
Inserting Graphics

Drag & Drop

1. Choose the tag as usual.


1. Float the screen.
2. Open Root Screen.
3. Drag the icon and drop
it into the Root screen.
Inserting Graphics
Creating Tank Level Animation

1. Add a new screen.


2. Insert Bar.
3. Insert pumps and pipes.
Changing Between Screen

1. Create a button.
2. Under click, choose
ActivateScreen.
3. Choose screen name.
Changing Between Screen

1. Create a button to go back to


root screen.
2. Repeat the same step as
before.
Creating Tank Level Animation

1. Edit the ladder logic as shown.


2. Click on tank, choose the tags.
3. Simulate the HMI.
Alarm Class

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.

Warnings-Alarms that can be reset or acknowledge immediately.


Example: motor is tripped due to sudden current surge. If there is
no current surge anymore, simply turn on back the overload relay.
Creating Discrete Alarm

Create a new screen ‘Error’.


Drag and drop the error controls into the
screen.
Creating Discrete Alarm
The Trigger tag cannot accept “Bool” type.
It must be either Dword or Word.
Output coil can only accept Bool.

1. Edit the ladder as shown.


2. Open HMI alarms.
3. Give the alarm name, text, class and trigger tag.
Testing the alarm
Creating Analog Alarms

For demonstration purpose, I will be using the


elapsed time as the analog water level.
IF the water level is less than 10, low level alarm
will be shown.
If the water level is more than 20, high level
alarm will be shown.
Testing Analog Alarms

Since elapsed time < 10, low Since elapsed time >25, high
level alarm is triggered. level alarm is triggered.

You might also like