0% found this document useful (0 votes)
7 views

PPS Chapter 3

Uploaded by

Waghu Umair
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)
7 views

PPS Chapter 3

Uploaded by

Waghu Umair
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/ 9

Basics of PLC Programming

PLC programming languages


PLC programming languages are defined by the international electrotechnical commission (IEC) under
sections 61131-3 standards are explained below.
1. Ladder logic (LD)
2. Sequential function chart (SFC)
3. Functional block diagram (FBD)
4. Structured text (ST)
5. Instruction List (IL)

1. Ladder logic (LD):


• The Ladder Diagram was originally modelled from relay
logic which used physical devices such as switches,
mechanical relays, timers, counters and comparators to control processes.
• Ladder Diagram utilizes internal logic to replace all; except the physical devices that need an
electrical signal to activate them.
• The Ladder diagram is also called Ladder Logic.
• The ladder diagram is built in the form of horizontal rungs with two vertical rails that represent the
electrical connection on relay logic schematics.
• We can program all the necessary input conditions to affect the output conditions whether logical or
physical.
Advantages of the ladder diagram language are:
1. The runs allow it to be organized and easy to follow/ understand.
2. It supports online editing very successfully
3. Easy for troubleshooting.
Disadvantage:
There are some instructions that are not available which might make it more difficult for programming such
as motion control systems and Batch programming.

2. Sequential function charts (SFC)


• A sequential function chart is a graphical
programming language used for plc.
• This programming language is similar to
flowchart.
• The key concepts underlying SFCs are steps and
transitions.
• A step is basically some function within the
overall system as an individual machine process.
• A transition is just that the change from one step
to another step or state.
• Beyond the basics SFC programs can also
include standard logical programming
techniques such as feedback loops and branching
either parallel or alternative branches.
• SFCs can also be designed with the aid of state
diagrams.
• Less time in the commissioning phase because of the graphical programming interface.
• Minimal implementation effort because there are few possibilities for errors when generating code.
• High availability of the machine through process diagnostics functions (interlock and supervision).
• Fast error detection through PLC code display and criteria analysis on the HMI.
Basics of PLC Programming
3. Function block diagram (FBD)
• FBD describes functions between inputs and outputs
that are connected by connection lines.
• It is in the graphical form language with repeated
blocks.
• It is good for motion control programming.
• It can combine many lines of the program into a single
block.
• But it is difficult to troubleshoot using this language.
• The biggest advantage of the function block diagram is that:
• we can take many lines of programming and put them into one or several function blocks.

4. Structured text (ST)


• This language is a textual based language
• It is a very powerful tool that can execute complex tasks utilizing algorithms and mathematical
functions along with repetitive tasks.
• The code uses statements that are separated by semicolons and then
either inputs, outputs or variables are changed by these statements.
• You must write out each line of code and it uses functions such as for,
while, if, else, else if, in case.
• It is very organized and good at computing large mathematical
calculations.
• It will enable you to cover some instructions that are not available in some other languages like the
latter diagram.

5. Instruction list (IL)


• The instruction list is also a textual
based language.
• It is a low-level language and
resembles assembly, as the name
implies a program is a series of
instructions listed in much the
same way as an assembly program.
• An instructions list provides
programs with each instruction on
a new line as a sequence of
instructions.
• Each instruction is made up of an
operator followed by one or more
operands that is the operator's
subjects.
• When we use this plc programming
language we will use mnemonic codes such as LD (load) AND OR etc.

Advantages:
• program execution speed, as with assembly language in general instruction lists are a low overhead
language and execute faster than graphical languages.
• ILs also tend to take up less memory.
Basics of PLC Programming
Program Scan Cycle:
 The PLC program is executed as part of a repetitive process referred to as a scan.
 A typical PLC scan starts with the CPU reading the status of input.
 Next, the application program is executed.
 Next the CPU performs internal diagnostic and communication tasks.
 Finally, the status of all outputs is updated.
 This process is repeated continuously as long as the PLC is in the run mode.

Data Type

Addressing for Ladder Logic Programming


Basics of PLC Programming
PLC Programming Instructions
1. XIO
Examines if open. (Normally closed contact)
• The XIO instruction evaluates the data addressed by the associated Boolean tag.
• The evaluation is true if the data is zero and false if the data is one.
• This is an input instruction and must be followed by an output instruction
Devices
● Start/Stop push buttons
● Selectors
● Limit switch
● Proximity switch
● Light
● Internal bit

2. XIC
Examines if closed (Normally open contact)
If the data addressed by XIC is equal to 0 then the data addressed by OTE is equal to 0.
If the data addressed by XIC is equal to 1 then the data addressed by OTE is equal to 1
Devices
● Start/Stop push buttons
● Selectors
● Limit switch
● Proximity switch
● Light
● Internal bit

3. OTE
Turns a bit on or off.
Use OTE instruction in your ladder logic to turn on a bit when rung condition is evaluated as true.
Devices
● Light
● Motor run signal
● Internal bits

Latch / Unlatch instructions


1. OTL
• This instruction functions much the same as the OTE with the
exception that once a bit is set with an OTL, it is "Latched" on, once
an OTL bit has been set "ON" (1 in Memory) it will remain "ON" even
if the rung condition goes false the bit be reset with an OTU instruction.
• Latch and unlatch instructions must be assigned the same address in your logic program.
2. OTU
• Use this output instruction to unlatch (Reset) a latched (Set) bit which
was set by an OTL instruction.
• The OTU address is identical to the OTL address which originally set
the bit.
Basics of PLC Programming
Use of Timer and its types
1. TON- Timer, On Delay
• A timer on-delay (TON) instruction is a
programming instruction used to delay the start of a
machine or process for a set period of time.
• A TON instruction starts timing when the logic
preceding the TON instruction on a rung change from
false to true.
• When a TON instruction starts timing, the accumulated value begins to count time base intervals until
the accumulated value equals the preset value.
• When the logic preceding a TON instruction changes from true to false, the TON instruction stops
timing and the accumulated value is reset to zero.

2. TOF- Timer, Off Delay


• A timer off-delay (TOF) instruction is a PLC programming instruction used to delay the shut down
of machinery, such as an external cooling fan when a motor has been stopped.
• A TOF instruction starts timing when the logic
preceding the instruction on the rung changes from
true to false. When a TOF instruction starts timing,
• The accumulated value begins to count time base
intervals until the accumulated value equals the
preset value.
• When the logic preceding a TOF instruction on a
rung changes from false to true, the TOF
instruction stops timing and the accumulated value is reset to zero.

3. RTO- Retentive Timer, On Delay


• A retentive timer (RTO) instruction is a PLC
programming instruction used to track the
length of time a machine has been operating or
to shut down a process after an accumulative
time period of recurring faults.
• A timer starts timing when the logic preceding
an RTO instruction on a rung changes from
false to true.
• When an RTO instruction starts timing, the accumulated value begins to count time base intervals
until the accumulated value equals the preset value.
Basics of PLC Programming
• When the logic preceding an RTO instruction on a rung changes from true to false before the
accumulated value equals the preset value, an RTO instruction stops timing and the accumulated
value is retained.

Use of Counter
1. Counters are used in applications that require items or products to be counted.
2. The CTU and CTD instructions are used to increment or decrement a counter at each false-to-true
rung transition.
● When the CTU rung makes a false-to-true transition, the accumulated value is incremented by one count.
● The CTD instruction operates the same, except the count is decremented.
• The bits and words of counter instructions have addresses that can be used in the program of a PLC.
• bit 15—Count up (CU) enable
• bit 14—Countdown (CD) enable
• bit 13—done (DN)
• bit 12—overflow (OV)
• bit 11—underflow (UN)

1. CTU- Count Up
• A count up (CTU) instruction is a PLC programming
instruction used to count the number of operations or
products produced by a system.
• A CTU instruction counts up on every false to true
transition of the logic preceding the instruction on a rung.
• The accumulated value of a CTU instruction increases by one for every false to true transition.
• A CTU instruction will allow a counter to continue to count past the preset value.
• An identically addressed RES instruction is required to reset a CTU instruction.

2. CTD- Count Down


• A CTD instruction counts down on every false to
true transition of the logic preceding the
instruction on a rung.
• The accumulated value of a CTD instruction
decreases by one for every false to true transition
of the logic preceding a CTD instruction on a rung.
Conversely.
• A single identically addressed RES instruction is required to reset CTD instruction.
Basics of PLC Programming
Math instructions

1. Add instruction
Use the ADD instruction to add one value to another value (Source A + Source
B) and place the sum in the destination.

2. Subtraction instruction
Use the SUB instruction to subtract one value from another value (Source A -Source
B) and place the sum in the destination.

Compare instructions: Equal and not equal to instruction


Basics of PLC Programming
Greater than or equal to and Less than or equal instruction

Limit instructions:

Move and Copy instructions


MOV instruction
1. Source and Destination can be different data sizes.
The source is converted to the destination size when the
instruction executes.
2. If the signed value of the Source does not fit in the Destination,
the overflow is handled as follows:
● If the Math Overflow Selection Bit is clear, a saturated result
is stored in the Destination. If the Source is positive, the
Destination is 32767 (word). If the result is negative, the
Destination is -32768.
● If the Math Overflow Selection Bit is set, the unsigned truncated value of the Source is stored in the
Destination.
3. The source can be a constant or an address.

2. Copy instruction
• The COP instruction copies blocks of data from one location into another.
• The source and destination file types must be the same except
bit (B) and integer (N); they can be interchanged.
• It is the address that determines the maximum length of the
block to be copied.
Basics of PLC Programming
ANALOG DATA
Analog signal programming: SIGNAL WORD
Converting analog data
N=Vin x 1023/10 0V 0
Where,
Vin (analog signal) is in volts (V)
5V 512

10V 1023

Scale with parameter


• The SCP instruction produces a scaled output value that has a linear
relationship between the input and scaled values.

JSR instruction
• The JSR instruction causes the controller to start executing a
separate subroutine file within a ladder program.
• JSR moves program execution to the designated subroutine
(SBR file number).
• After executing the SBR, control proceeds to the instruction following the JSR instruction.

Return instruction
• The RET instruction marks the end of subroutine execution or the end of the subroutine file.
• It causes the controller to resume execution at the instruction following the JSR instruction, user
interrupt, or user fault routine that caused this subroutine to execute.

You might also like