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

Ch6 - Intermediate Programming Application

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

Ch6 - Intermediate Programming Application

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

BTS3153 PLC BASICS AND

APPLICATIONS
Intermediate Programming Application
We will learn about some other PLC
instruction such as:
Move (MOV)
Compare (CMP)
Interlocking (IL and ILC)
Shift Register (SFT)
Differentiate Up (DIFU)
Differentiate Down (DIFD)
Some of this are very useful for analog input
purposes
Memory
Before we learn about these
instructions, it is better to have a
sufficient knowledge about the PLC’s
memories
Any instruction/operation in PLC can
be monitored to/from their memory
PLC’s memory is divided into several
area
We can attempt to write/modify any
of these memory areas, however, BE
CAREFUL as some modification will
resort in malfunction of an operation
Memory
Most of the instruction that we have learn before
only revolve around the CIO area
CIO is the memory area where all the possible input
and output addresses and their contents are located
The CIO memory area can be manually written and
monitored at the same time in online mode
As the Omron CJ2M-CPU11 contained a 16-bit
microcontroller inside, all of its memory is also in 16-
bit form, which are usually represented as 4-digit
hexadecimal number (commonly use in ladder
diagram)
Lets examine some of our previous exercises in terms
of the memories that they have occupied
MOV Instruction
MOV instruction is an instruction to copy and
paste a content (source) from word or memory to
another memory (destination)

If the content is a word which means it is a


manually inserted number, ‘#’ will be written in
front of it
However, if the content is from a memory, the
address of it is written instead
Exercise 18
Turn ON all the lights on the panel during
activation
The ladder diagram:
Start

Push Push
Start Stop
button button

All Light All Light


ON OFF
Recall back from previous chapter, only a
single output address is allowed in the whole
ladder diagram
However, by using several MOV instruction,
it can act like writing multiple output from
the same output address
Exercise 19
During activation:

PB4 PB3 RL BL YL PL GL CL
0 0 ON ON OFF OFF OFF OFF
0 1 ON OFF ON OFF ON OFF
1 0 OFF ON OFF ON OFF ON
1 1 OFF OFF OFF OFF ON ON
Exercise 19
The ladder
diagram:
Is it hard and a bit confusing to determine
which pushbutton are pressed/released or
which light are turn ON/OFF?
This is because we usually see the input and
output as components
Now, by using MOV instruction and monitoring
the CIO area memory, we need to think the
input and output as a binary data (just like in
microprocessor class)
As for that, the previous Exercise 19 can be
better understood if we write the truth table in
address sorting
Did you notice that we have done an if/else
condition in Exercise 19?
This is one way of implementing an if/else
condition on a ladder diagram
The better way of doing an if/else condition is
by combining a CMP (compare) and MOV
instruction together
CMP Instruction
Compares two unsigned binary values (from a manually
inserted word or/and content of an address) and out­puts
the result to the Arithmetic Flags in the Auxil­iary Area

The arithmetic flag outputs are:


 P_EQ = equal (=) flag
 P_NE = not equal (≠ or !=) flag
 P_GE = greater than or equal (>=) flag
 P_GT = greater than (>) flag
 P_LE = less than or equal (<=) flag
 P_LT = less than (<) flag
Exercise 20
Redo Exercise 19 by combining the CMP and
MOV instructions
Lets rewrite the truth table by viewing it as
an address contents rather than components

0.03 0.02 2.05 2.04 2.03 2.02 2.01 2.00


0 0 0 0 0 0 1 1
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
1 1 1 1 0 0 0 0
Exercise 20
The ladder diagram:
Exercise 20
Ladder diagram continue:
Did you notice that after you have been
experimenting with all the conditions, the start
and stop button now have no effects on the
ladder diagram?
This is because that by using CMP and MOV
instruction, we attempt to manipulate the
content of the memory, not the component
As for that, the memory will stay at its last
content according to the if/else conditions
This can be resolve by writing #0000 to input
and output address when the stop button is
pressed
Exercise 21
Edit Exercise
20 by adding
the
deactivation
operation
The ladder
diagram:
Exercise 21
Ladder Diagram continue:
IL and ILC Instructions
Interlocks all outputs between IL (Interlock)
instruction and ILC(Interlock Clear)
instruction when IL input is OFF.
Any timer or counter counting will be paused

This can be act as a section activation


controller where a section of ladder diagram
can be turn ON/OFF with IL and ILC
instructions
Exercise 22
Redo Exercise 16 (from Chapter 5), and put
interlock for all the counter and operation
part
The ladder diagram:
Exercise 22
The ladder diagram continue:
Exercise 22
The ladder diagram continue:
Observation from Exercise 22, it is clearly
seen that all outputs are turn OFF during
interlocking
Any attempt on pressing the count button has
no effect and the output remains at its
previous condition when the interlocking is
release again
Exercise 23
Redo Exercise 22, but move the ILC
instruction to the rung after counter part
The ladder diagram:
Exercise 23
The ladder diagram continue:
Exercise 23
The ladder diagram continue:
Now, the output will remains ON at its
previous condition during interlocking
This is because that only the counter part is
being interlock
As for that, only the counting is paused while
the output still shows its previous condition
SFT Instruction

This instruction will shift one bit of content into St until


E
The content is shifted from right to left (LSB  MSB)
St and E needs to be an address (CIO area)
Data input: The data that is going to be inserted at LSB
Shift input: During rising edge, the shifting operation
will be executed
Reset input: To reset all content from St to E as 0
Exercise 24
Lets experiment with the SFT instruction
Turn ON each light in the panel one by one
As we know that all the lights in the panel are
located in address 2, so we set St and E as 2
The ladder diagram:
Rather than a bit is inserted one by one for
the content of output address, we can also
shift a content that has been written in
memory to the output address
Because that SFT instruction can only shift
from right to left, the content needs to be
written from one address before the output
address
If the content will be transferred originally
without any modification, so the data input is
not needed
Exercise 25
Redo Exercise 24, but the content has been
already set in the address before the output
address
The ladder diagram:
DIFU Instruction
Differentiate Up (DIFU) turns the designated
bit (B) ON for one cycle when the execution
condition goes from OFF to ON (rising edge).
This means that DIFU only produce a pulse

In an unstable input condition (such as


analog), it is very useful where DIFU can
detect any rising edge and declare it is as an
ON
DIFU Instruction
If a pushbutton is pressed and release, the
DIFU bit should be generated such as:
DIFU Instruction
DIFU can be an alternative instruction to
construct a holding circuit
However, as DIFU only generate a pulse, it
needs to be supported with an output source
(that becomes input) so that it can hold the
circuit ON
This means that in order for DIFU to act as a
holding circuit, two rungs are needed to be
constructed
Exercise 26
Construct a holding circuit using DIFU
instruction:
DIFD Instruction
Differentiate Down (DIFD) turns the designated
bit (B) ON for one cycle when the execution
condition goes from ON to OFF (falling edge).
This means that DIFD only produce a pulse

In an unstable input condition (such as analog),


it is very useful where DIFD can detect any
falling edge and declare it is as an OFF
DIFD Instruction
If a pushbutton is pressed and release, the
DIFD bit should be generated such as:
DIFD Instruction
DIFD can be an alternative instruction to
construct a holding circuit
However, as DIFD only generate a pulse, it
needs to be supported with an output source
(that becomes input) so that it can hold the
circuit ON
This means that in order for DIFD to act as a
holding circuit, two rungs are needed to be
constructed
Exercise 27
Construct a holding circuit using DIFD
instruction:
By combining DIFU and DIFD instruction with SFT
instruction, we can simplify the operation of shifting
a bit into a designated address
Previously, when we are using the SFT instruction,
we need to insert a solid data while switching the
Shift so that data is shifted into the designated
address
This is impossible to be done if we are working with
only pushbuttons, as they only act as ON during
pressing and return back as OFF when the button is
release (for a normally-open pushbutton)
DIFU and DIFD bits can replace the Shift input in
SFT instruction
The idea now is two have two pushbuttons as
Data input for SFT instruction, where one is
to insert 1 and the other is to insert 0 (NOT
instruction)
Then, both of these pushbuttons can be
inserted as input for DIFU and DIFD
instructions
Now, by pressing any pushbutton will insert
its value into Data input and when releasing
them, the DIFU and DIFD bits will trigger the
Shift input of the SFT instruction
Exercise 28
The figure shows an electronic safe
box system that needs to be
developed by using PLC. An ON/OFF
switch is used to activate and
deactivate the system. Once the
system is activated, the PASSWORD
needs to be set in CIO memory. To
open the safe box, the user needs to enter an access number (in
binary) using buttons ONES (0.00) and ZEROS (0.01). Once the
access number has been completely keyed in, the user needs to
press the ENTER button. If the access number is correct, the
LOCK MOTOR will be turned ON and it will release the locking
mechanism. If the access number is not correct, the LOCK
MOTOR stays OFF and the locking mechanism will not be
released. All buttons are momentarily normally-open
pushbuttons.
Exercise 28
The ladder diagram:

You might also like