0% found this document useful (0 votes)
189 views313 pages

Basic PLC Programming For Beginners

Uploaded by

alexinho77
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)
189 views313 pages

Basic PLC Programming For Beginners

Uploaded by

alexinho77
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/ 313

Introduction

Chapter 1 PLC / PLC Program Overview


1-1 What is PLC
1-2 Familiar example of using PLC
1-3 Most frequently used PLC
1-4 PLC is also used in theme parks
1-5 Major Japanese PLC manufacturers
1-6 Difference between PLC and personal computer
1-7 Global standard for PLC programs
1-8 PLC programming language used in Japan
1-9 Reasons to use the ladder program
1-10 Download GX Developer / GX Simulator
1-11 Install GX Developer
1-12 Install GX Simulator
1-13 How to reset the trial period of GX Developer / GX Simulator trial version
Chapter 2 Basic operation of GX Developer
2-1 Create a new project
2-2 Save project
2-3 Open the saved project
2-4 Preparation before creating a program
2-5 How to create a program
2-6 Rename / new create of program data
Chapter 3 Input/output/self-holding circuit /AND OR circuit
3-1 Bit and Word
3-2 What is a bit device?
3-3 What is a word device?
3-4 X (input relay), Y (output relay)
3-5 "Momentary" and "Alternate"
3-6 Self-holding circuit
Exercises1 ( Shutter opening and closing operation )
Exercises1 Answer
Exercises2 ( Air purifier on / off operation )
Exercises2 Answer
3-7 AND circuit
3-8 OR circuit
Exercises3 ( Juice purchase at vending machine )
Exercises3 Answer
Exercises4 ( Printer color / black and white printing )
Exercises4 Answer
Chapter 4 Program operation check
4-1 Check program settings
4-2 Start simulation
4-3 Monitor mode/monitor (write mode)
4-4 Forced ON/OFF method for contacts
4-5 When the "Unable to communicate with PLC" message appears during conversion
Chapter 5 Frequently used devices
5-1 M (Auxiliary relay)
5-2 L (Latch relay)
Exercises5 ( Robot operating conditions )
Exercises5 Answer
Exercises6 ( Lamp lights up after plugging in )
Exercises6 Answer
5-3 T (Timer)
Exercises7 ( Washing machine Washing start / end )
Exercises7 Answer
Exercises8 ( Forced termination of computer )
Exercises8 Answer
5-4 C (counter)
Exercises9 ( Password lock / unlock )
Exercises9 Answer
5-5 D (Data register)
Exercises10 ( Microwave wattage display )
Exercises10 Answer
Exercises11 ( Microwave defrost button )
Exercises11 Answer
5-6 Simulation method of T, C, D
5-7 D latch method
Exercises12 ( Data retention )
Exercises12 Answer
Chapter 6 About the program
6-1 Scan time
6-2 Pulse contacts
Exercises13 ( After pressing the button, the lamp will light for 5 seconds )
Exercises13 Answer
Exercises14 ( After releasing the button, the lamp will stay on for 5 seconds )
Exercises14 Answer
6-3 Clock pulse
Exercises15 ( Vacuum cleaner paper pack full )
Exercises15 Answer
Exercises16 ( Temporary response in case of button failure )
Exercises16 Answer
6-4 Duplicated coil
Chapter 7 Command Words
7-1 Command words of PLC program
7-2 Transfer instruction
Exercises17 ( Backup of sphygmomanometer data )
Exercises17 Answer
Exercises18 ( Deletion of sphygmomanometer data )
Exercises18 Answer
Exercises19 ( Sphygmomanometer measurement result storage )
Exercises19 Answer
Exercises20 ( Sphygmomanometer display test )
Exercises20 Answer
7-3 Four arithmetic operations
Exercises21 ( Total score calculation for 3 exams )
Exercises21 Answer
Exercises22 ( Average score calculation for 3 exams )
Exercises22 Answer
7-4 Comparison instruction
Exercises23 ( Blood pressure normal / abnormal judgment )
Exercises23 Answer
7-5 Increment instruction / decrement instruction
Exercises24 ( Parking lot full / empty ramp )
Exercises24 Answer
At the end
OceanofPDF.com
Introduction
Thank you for picking up this book!

Recently, DX (digital transformation), IoT (Internet of Things), and AI


(artificial intelligence) have become a hot topic in the manufacturing
industry.

Then, when you want to specifically innovate or improve your business


using DX, IoT, and AI, where should you start?

I consider it a "manufacturing site".

This is because innovations and improvements in the "manufacturing site"


are most directly linked to sales and profits.

The manufacturing industry is a "company that makes things."


There is also a lot of manual work depending on the product to be
manufactured.
However, considering the era of declining birthrate and aging population in
the future, automation of manufacturing using machines and robots will be
promoted.

PLCs (programmable logic controllers) that issue various operation


commands to machines and robots and touch panels that enable the
operation and monitoring of machines and robots are indispensable for
automation technology in various manufacturing industries.

This book carefully explains how to create a PLC program used in the
manufacturing industry in an easy-to-understand manner.

I hope that by gaining knowledge of PLC programming, which is the main


product of FA (factory automation), it will be useful for improving on-site
efficiency and workability, and for on-site reform and improvement
utilizing DX, IoT, and AI.
Also,

「 I'm going to use it for work, so I want to learn about PLC programs! 」
「 There are many books on sequence control, but the PLC program is not
written in detail. 」
「 I read a book about PLC, but I don't feel like I can make a program just by
classroom lectures. 」
「 I'm studying a PLC program, but the content was boring and I was
frustrated on the way ... 」

I want these people to have fun learning to the end.

This book is created with three concepts. (The software uses the free trial
version.)

・ Contents specialized for PLC programs.


⇒ Deepen understanding of PLC programs.
・ Explaining things that are familiar to you as an example.
⇒ Easy to imagine.
・ Actually create a program with exercises.
⇒ Acquire practical skills.

※ Even those that are not actually controlled by the PLC are taken up as
examples to make the explanation easier to understand.

I have been involved in PLC programs for many years.


Until now, I thought that "PLC programs can only be learned through on-
site experience."

However, as a result, I have seen many people who disliked and quit in the
early stages.

I decided to make this book because I want many people who are thinking
about studying to think that the PLC program is unexpectedly fun.

In the coming era of declining birthrate, the number of people who can do
niche jobs like PLC programmers will decrease steadily.
However, on the contrary, because it is a niche, it is possible to become a
"valuable human resource with special skills".

I hope that this book will help you to become an excellent PLC programmer
who will be responsible for future factories and equipment.

OceanofPDF.com
Chapter 1 PLC / PLC Program Overview

1-1 What is PLC

A PLC (Programmable Logic Controller) is a "controller with a program


that controls a machine".

The photo below is a PLC made by Mitsubishi Electric.

By connecting this PLC to a robot or machine, various controls are


possible.

OceanofPDF.com
1-2 Familiar example of using PLC

For example, an elevator is a familiar item controlled by a PLC.

The main operations controlled by the PLC in an elevator are as follows.

・ Open the door


・ Close the door
・ Move to the pressed floor
・ If you press the "Open" button while the elevator is stopped, the door will
open.
・ If you press the "Close" button while the elevator is stopped, the door will
close.
・ The door does not open even if the "Open" button is pressed while the
elevator is operating.

OceanofPDF.com
1-3 Most frequently used PLC

The most common use of PLC is factory control.


PLCs are used in almost all factory equipment.

By controlling robots and conveyors (machines that convey things) with


PLC, FA (factory automation), that is, factory automation can be
promoted.

In addition, since we have factories all over the world, if we can program
PLC, we will be able to work at overseas factories.

PLC programs are a niche field compared to C language like IT engineers


and JAVA.
Therefore, few people have mastered the PLC program, and they can add
rare value to their skills.

In particular, it seems that few people who work at factories can modify,
add, or change PLC programs.

I think that learning the PLC program will increase the range of equipment
improvements, so take this opportunity to learn it.

OceanofPDF.com
1-4 PLC is also used in theme parks

For other purposes, PLCs are used to control various attractions in


automatic doors and theme parks.

Recently, Universal Studios Japan was looking for someone who could do a
PLC Program.

I find it very interesting to work on a PLC program at a theme park.

OceanofPDF.com
1-5 Major Japanese PLC manufacturers

There are various Japanese PLC manufacturers such as Panasonic, Hitachi,


Sharp, Yaskawa Electric, and Yokogawa Electric.
The most major PLC manufacturers are Mitsubishi Electric, Keyence, and
Omron.
It is said that these three companies account for about 90% of the total
market share.

Mitsubishi Electric Keyence Omron

Among them, Mitsubishi Electric has a particularly high market share.


If you have not decided which PLC manufacturer you want to study, we
recommend studying the PLC program of Mitsubishi Electric.

OceanofPDF.com
1-6 Difference between PLC and personal computer

In fact, it is possible to perform the same control as PLC with a personal


computer.

In fact, there are cases where a personal computer is used in a factory


inspection machine.

However, PLC is "highly stable because it specializes in machine


control", so we use PLC more often than personal computers.

A personal computer can perform various processes such as Excel and the
Internet.
However, executing multiple processes may cause the computer to freeze or
slow down.

Also, even if the performance of the personal computer improves in the


future and the stability is higher than that of the PLC, it is difficult to
replace the one currently controlled by the PLC with the personal computer.
This is because all the programs and communication settings with the
device will be redone.

For that reason, most factory controls use PLCs.

OceanofPDF.com
1-1 ~ 1-6 Summaries

・ A PLC (Programmable Logic Controller) is a "controller with a program


that controls a machine".
・ The most major PLC manufacturers are Mitsubishi Electric, Keyence,
and Omron.
・ However, PLC is "highly stable because it specializes in machine
control", so we use PLC more often than personal computers.

OceanofPDF.com
1-7 Global standard for PLC programs

Earlier, I explained that PLC is "a controller with a program that controls a
machine."
In order to control the machine with PLC, it is necessary to install the
program.

There is a universal standard "IEC 61131-3" that defines the programming


language for PLC by the International Electrotechnical Commission (IEC),
and the PLC programs are defined as the following five.

OceanofPDF.com
・ Ladder diagram (LD language)
・ Function block diagram (FBD language)
・ Structured text (ST language)
・ Instruction list (IL language)
・ Sequential function chart (SFC language)

OceanofPDF.com
1-8 PLC programming language used in Japan

Overseas, "structured text (ST language)" written in a form similar to C


language is used, but in Japan, "ladder diagram (LD language)" is
overwhelmingly used.

The ladder diagram (LD language) is the following program.

It is called a "ladder program" because it looks like a ladder.

OceanofPDF.com
1-9 Reasons to use the ladder program

When there was no PLC, all the controls had to be made up of electrical
components and wiring.
An electric circuit diagram (electrical drawing) is indispensable for
making this control.

This schematic and the ladder program are similar.

In other words, the "ladder program" is a program developed to make it


easier to create a PLC program if you used to use an electric circuit
diagram.

This book introduces the Mitsubishi Electric PLC ladder program.


Mitsubishi Electric PLC has the largest market share in Japan and is in the
top 5 in the world market share, so if you wear it firmly, you can expect
global success including overseas companies.

OceanofPDF.com
1-7 ~ 1-9 Summaries

・ In order to control the machine with PLC, it is necessary to install the


program.
・ The Japanese PLC program is the "ladder program".
・ the "ladder program" is a program developed to make it easier to create a
PLC program if you used to use an electric circuit diagram.

OceanofPDF.com
1-10 Download GX Developer / GX Simulator

Now, we will explain the download and installation procedure of Mitsubishi


Electric's PLC program development software GX Developer and PLC
program simulation software GX Simulator, which are required to create a
PLC program (ladder program).

1. Move to Mitsubishi Electric's FA HP.


https://www.mitsubishielectric.co.jp/fa/

OceanofPDF.com
2. Select " メンバー登録 " at the top right of the HP to register as a member. (You
can register as a company or as an individual)

OceanofPDF.com
This is the procedure for member registration.

① After selecting " メンバー登録 ", enter your e-mail address, check " 同意する " to the
terms, and click " 同意して次へ ".

OceanofPDF.com
② The message "The registration procedure guidance email has been sent"
is displayed. Please check your email and complete the registration process.

OceanofPDF.com
③ Select your country of work.

OceanofPDF.com
④ After entering the following items, press " 入力内容を確認する ".

お名前= name フリガナ= Furigana 生年月日= Birthday


会社・団体名= Company / organization name
※会社 / 団体に所属していない方は、チェックを入れてください
= If you do not belong to a company or organization, please check it.

OceanofPDF.com
事業所名= Office name 所属部署名= Department name
役職= Position 業種= Industry 職種= Occupation
郵便番号= Postal code 都道府県州= Prefectures
市区町村= Municipality 市区町村に続く住所= Address following the city
電話番号= phone number 固定電話= Fixed-line phone 携帯電話= mobile phone
FAX 番号= Fax number

OceanofPDF.com
メンバーズ ID = Member's ID
メールアドレスを使用する= Use your email address
希望するメンバーズ ID を入力する= Enter the desired member's ID
パスワード= password パスワード ( 確認用 ) = For password confirmation
メールニュース配信= Email news delivery 希望する= Hope 希望しない= Not hope

OceanofPDF.com
⑤ If there is no problem with the input contents, apply for registration.
After applying, the following screen will be displayed.

OceanofPDF.com
⑥ Member registration is complete when you receive the registration
completion email below.
* It may take several days to complete the registration.

OceanofPDF.com
3. Move to Mitsubishi Electric's FA HP again.
https://www.mitsubishielectric.co.jp/fa/

OceanofPDF.com
4. Move the cursor to the upper tab " ダウンロード " on HP and click " 制御機器 " → " エン
ジニアリングソフトウェア " → " ソフトウェア ".

OceanofPDF.com
5. Select the English version (" 英語版 ") as the language.
Afterwards, you can download the trial version by clicking "the " 体験版 " of
the setting / programming product "GX Developer" and clicking " ソフトウェアをダウン
ロード ".

OceanofPDF.com
6. You can download the trial version by clicking "the " 体験版 " of the setting /
programming support tool "GX Simulator" and clicking " ソフトウェアをダウンロード ".

OceanofPDF.com
1-11 Install GX Developer

1. Unzip the downloaded zip file.

2. Execute "SETUP.EXE" in the unzipped folder.

OceanofPDF.com
3. The message "Please close all applications" will appear. After closing all
applications, click "OK".

OceanofPDF.com
4. A message will appear with notes on installation, so click "Next".

OceanofPDF.com
5. Enter your name and company name (anything is OK) and press "Next".

OceanofPDF.com
6. A confirmation screen for registration information will appear. If there
are no problems, click "Yes".

OceanofPDF.com
7. The product ID input screen will appear. Enter "904-999559933" and
press "Next".

OceanofPDF.com
8. The component selection screen will appear, but since the ST language
will not be used this time, do not check it and press "Next".

OceanofPDF.com
9. The component selection screen will appear again, but do not check this
either and press "Next".

OceanofPDF.com
10. The component selection screen will appear again, but do not check this
either and press "Next".

OceanofPDF.com
11. The installation destination is OK as it is so click "Next". If you want to
change the installation destination, click the "Browse" button.

OceanofPDF.com
12. This completes the GX Developer installation process.

OceanofPDF.com
1-12 Install GX Simulator

1. Unzip the downloaded zip file.

2. Execute "SETUP.EXE" in the unzipped folder.

OceanofPDF.com
3. The message "Please close all applications" will appear. After closing all
applications, click "OK".

OceanofPDF.com
4. A message will appear with notes on installation, so click "Next".

OceanofPDF.com
5. Enter your name and company name (anything is OK) and press "Next".

OceanofPDF.com
6. A confirmation screen for registration information will appear. If there
are no problems, click "Yes".

OceanofPDF.com
7. The product ID input screen will appear. Enter "904-999559933" and
press "Next".

OceanofPDF.com
8. The installation destination is OK as it is so click "Next". If you want to
change the installation destination, click the "Browse" button.

OceanofPDF.com
9. This completes the GX Simulator installation process.

OceanofPDF.com
1-13 How to reset the trial period of GX Developer / GX
Simulator trial version

By uninstalling the trial version of GX Developer / GX Simulator and then


installing it again, the trial period will be reset and you will be able to use it
again.

* Information as of October 25, 2020.


Please note that it may not be possible depending on the company's
response and PC environment.

OceanofPDF.com
Chapter 2 Basic operation of GX Developer
Now that the installation of GX Developer is complete, we will explain the
basic operation methods required to create a program. (GX Simulator will
be explained later)

2-1 Create a new project

1. Open GX Developer.

2. Select the "Project" tab ⇒ "New project" in the upper left.

OceanofPDF.com
3. A screen for selecting the PLC series, PLC type, Program type, and Label
setting will appear. Set as follows and press "OK".

[PLC series]
Select the PLC type.
Select the PLC series to be actually used.
In this program creation, the default QCPU (Q mode) is used.

[PLC type]
There are multiple types of PLCs, depending on the program capacity and
functions.
Select the PLC model to actually use.
In this program creation, select Q02 (H).

[Program type]
"Ladder" and "SFC" can be selected.
The program language used in Japan is almost a ladder program, so we will
use the default "ladder".

[Label setting]
You can select "Do not use label" or "Use label".
Since ST program, FB, and structure are not used in this program creation,
select "Do not use label".

OceanofPDF.com
4. A new project will be created.

OceanofPDF.com
2-2 Save project

1. Select the "Project" tab ⇒ "Save as" in the upper left.


If you want to overwrite the project, select "Save".

OceanofPDF.com
2. Give the project a name and press "Save".
* If you want to save to the desktop, set the drive / path to "C: ¥ Users ¥
account name ¥ Desktop".

OceanofPDF.com
2-3 Open the saved project

1. Open GX Developer.

2. Select the "Project" tab ⇒ "Open Project" in the upper left.

OceanofPDF.com
3. Select the saved file and press "Open".

OceanofPDF.com
2-4 Preparation before creating a program

1. Open the "View" tab ⇒ "Toolbar", check "LD symbol" and press "OK".

OceanofPDF.com
2. If checked, a toolbar like this will be displayed.
Use this toolbar when creating a program.

OceanofPDF.com
3. Select the Tools tab ⇒ Options.

OceanofPDF.com
4. In the "Program Common" tab
・ Comment input "Continues during command write"
・ Double coil check setup "Checks for double coils during write"
Check the box and press "OK".

OceanofPDF.com
The double coil of "Checking the double coil" will be explained in the
following chapters.

Regarding "Enter label comment and device comment in succession", if you


check this, you will be able to enter the comment for the program together
when you write the program.

The comment itself does not affect the program, but if there is no comment,
only the person who created the program will be able to understand it, so
please add a comment to the program.

In addition to inputting continuously, there is a method of inputting a


comment by clicking the plus mark of "Device comment" in the project data
list and selecting "COMMENT", but this time I will explain in this way.

OceanofPDF.com
2-5 How to create a program

We will explain how to create a program using the procedure for creating a
sample program.

The contents of the program are as follows.


・ When X0 (switch 1) and X2 (switch 3) are pressed at the same time, Y0
(lamp) lights up.
・ When X1 (switch 2) is pressed, Y0 (lamp) lights up.
・ When X3 (switch 4) is pressed, Y0 (lamp) goes out.

Here, we will learn how to make this program.

OceanofPDF.com
First, before creating the program, make sure that the mode is set to write
mode.
If you are not in this mode, you will not be able to create programs.

"Edit" tab ⇒ Make sure you are in write mode.


In the write mode, the frame on the program is only the blue frame.
(Monitor mode is filled with blue)

If it is not in write mode, press the above operation or F2 to enter write


mode.
Now let's create a program.

OceanofPDF.com
1. First, create X0 (Switch 1).
Place the cursor on the part you want to enter and use F5 on the toolbar or
F5 on the computer keyboard.
The circuit input bar will be displayed. Enter "X0" and press "OK".

OceanofPDF.com
2. A comment input bar will be displayed. Enter "Switch 1" and press "OK".

OceanofPDF.com
3. X0 has been entered, but no comments are displayed.
To display the comment, select the "View" tab ⇒ "Comment", or press
Ctrl + F5 on the computer keyboard.

OceanofPDF.com
4. Create X2 (Switch 3) in the same procedure as 1-3.

If you make a mistake, you can double-click the wrong part or re-enter it
with Enter on your computer keyboard.

Also, if you want to delete the entered part itself, you can delete it by right-
clicking on the part you want to delete ⇒ "Cut" or Delete on the computer
keyboard.

OceanofPDF.com
5. Create X3 (Switch 4).
Place the cursor on the part you want to enter and press F6 on the toolbar
or F6 on the computer keyboard. Subsequent steps are the same as 1-3.

OceanofPDF.com
6. Create Y0 (ramp).
Place the cursor next to X3 and press F7 on the toolbar or F7 on your
computer keyboard.
Subsequent steps are the same as 1-3.

The horizontal line is automatically drawn to the end.

OceanofPDF.com
7. Create X1 (Switch 2).
First, insert a row.
To insert a line, press the "Edit" tab ⇒ "Insert line" or Shift + Insert on
the computer keyboard.

OceanofPDF.com
8. Create X1 (Switch 2).
The procedure is the same as 1-3.

OceanofPDF.com
9. Create a horizontal line.
Place the cursor next to X1 and press F9 on the toolbar or F9 on your
computer keyboard.
Then enter the number of horizontal line inputs (1 this time) and press OK
to enter the horizontal line.
* In the case of horizontal line 1, the number of inputs 1 can be omitted.

OceanofPDF.com
If you want to erase the horizontal line, move the cursor to the part you
want to erase and press cF9 on the toolbar or Ctrl + F9 on the computer
keyboard.
Then enter the number of horizontal lines you want to delete (1 this time)
and press OK to delete the horizontal lines.
* In the case of horizontal line 1, the number of inputs 1 can be omitted.
If you want to delete them one by one, you can also delete them with
"Delete" on your computer keyboard.

OceanofPDF.com
10. Then create a vertical line.
Place the cursor on X3 and press sF9 on the toolbar or Shift + F9 on your
computer keyboard.
Then enter the number of vertical line inputs (1 this time) and press OK to
enter the vertical lines.
* In the case of horizontal line 1, the number of inputs 1 can be omitted.

OceanofPDF.com
If you want to erase the vertical line, move the cursor to the part you want
to erase and press cF10 on the toolbar or Ctrl + F10 on the computer
keyboard.
Then enter the number of vertical lines you want to delete (1 this time) and
press OK to delete the vertical lines.
* In the case of horizontal line 1, the number of inputs 1 can be omitted.

OceanofPDF.com
11. Create Y0 (ramp) under X1 by the same procedure as 7-10.

OceanofPDF.com
12. Finally, perform the conversion.
Press the "Convert" or F4 on your computer keyboard.
Conversion is complete when the gray part turns white.

OceanofPDF.com
13. This completes the program creation.
Don't forget to save it.

OceanofPDF.com
2-6 Rename / new create of program data

The created program data is named "MAIN" by default. If you want to


change this name, click the plus mark of "Program", select "MAIN", right-
click and select "Rename".

OceanofPDF.com
Please change the data name to "SAMPLE" this time.

OceanofPDF.com
If you want to add program data, select "Program", right-click and select
"New".

OceanofPDF.com
On the input screen for creating new data, enter the data name "EX1" and
press OK to create the program data "EX1".

This "EX 1" will be used in the exercises that follow, so save it as the
project name "TEST".

OceanofPDF.com
Chapter 3 Input/output/self-holding circuit /AND
OR circuit

3-1 Bit and Word

To create a PLC program, you first need to understand the "device" that is
the component for creating a PLC program.

"Device" includes "bit device" and "word device".

First, I will explain the "bit" of "bit device" and the "word" of "word
device".

A "bit" is the smallest unit handled by a computer and can represent 0 or 1.

A "word" can handle large numbers such as 1000 and 10000 by using
multiple bits (16 bits).

OceanofPDF.com
3-2 What is a bit device?

Bit devices include X (input relay), Y (output relay), M (auxiliary relay),


etc., and since they are "bits", they are represented by 0 or 1.

For example, it is a device that can be expressed as OFF (0) when the
button is not pressed, ON (1) when the button is pressed, and so on.

OceanofPDF.com
3-3 What is a word device?

Word devices include D (data register) and W (link register), and since they
are "words", they represent large numbers such as 1000 and 10000.

For example, if you put in 500 yen at a vending machine, 500 will appear in
the amount display area. It is a device that can store such numerical values.

OceanofPDF.com
3-4 X (input relay), Y (output relay)

The following describes each device.

X (input relay) is a device that receives input from the outside (switch or
sensor), and Y (output relay) is a device that outputs to the outside (lamp or
motor).
Also, add a number to the end of the device to identify what the signal is,
such as X0, X1, and X2.

For example, a touch type automatic door opens when you touch it by hand.
If you write this operation in a PLC program, it will look like this.

The above program shows the state of not touching, but when you touch it,
X2 turns ON, the connected Y2 also turns ON, and the door opens.

In this way, a device that represents an external input signal is represented


by X (input relay), and a device that represents an external output signal is
represented by Y (output relay).

OceanofPDF.com
3-1 ~ 3-4 Summaries

・ There are two types of devices: "bit device" and "word device".
・ Bits can represent 0 or 1.
・ A word can express a numerical value from -32768 to 32767 by
combining multiple bits (16 bits).
・ X (input relay) is a device that receives input from the outside (switch or
sensor).
・ Y (output relay) is a device that outputs to the outside (lamp or motor).

OceanofPDF.com
3-5 "Momentary" and "Alternate"

In the description of the PLC device, I wrote that the lamp lights up when
the switch is pressed, but there are two types of switches.

Since it is necessary knowledge to understand the following explanation,


we will explain two types of switches.

A switch that stays on only while the button is pressed is called


"momentary", and a switch that stays on even if you release the button after
pressing it is called "alternate".

OceanofPDF.com
First, let's consider one of them, taking familiar ones as an example.

For example, suppose you have a fan with "off", "weak", "medium", and
"strong" buttons.

OceanofPDF.com
The "weak( 弱 )", "medium( 中 )", and "strong( 強 )" buttons of the electric fan
are "alternate" because they remain ON when pressed.

OceanofPDF.com
The "OFF( 切 )" button of the electric fan turns on when pressed, the
"weak( 弱 )", "medium( 中 )" and "strong( 強 )" buttons are reset, and when you
release your hand, it returns to the OFF state, so it is "momentary".

OceanofPDF.com
Also, like the power button on a smart phone, pressing it once turns on the
monitor, and pressing it again turns off the monitor. This is “alternate”.

In the future, many switches will appear in explaining PLC programs, but
the operation will differ depending on whether the switch is "momentary"
or "alternate".

In the following explanation, which switch is used will be described. Keep


in mind the difference between these two types of switches.

OceanofPDF.com
3-5 Summaries

・ The switch that turns on only while it is pressed is "momentary".


・ The switch that holds ON or OFF when the button is pressed is
"Alternate".

OceanofPDF.com
3-6 Self-holding circuit

I will explain the self-holding circuit using the X (input relay) and Y (output
relay) that came out in the previous explanation.
The self-holding circuit is one of the basics of PLC programs.

First, I will explain a program that does not hold itself.

For example, the crane game operation does not use self-holding circuits.
If you write a PLC program that moves the hand to the right by pressing the
right move button (momentary), it will look like this.

In the PLC program, this right movement button is called "A contact", and
the hand right movement command is called "coil".

In addition, the "right move button" and "hand right move command"
written on the program are called "comments" and can be described so that
you can see what the signal is when you look at the program.

OceanofPDF.com
The "move right button" represents the input signal and uses the input
device X.
When a person presses the "right move button", X3 (A contact) turns ON
(energized).

OceanofPDF.com
The "hand right move command" represents the output signal and uses the
output device Y.
When X3 (A contact) turns ON (energized), Y3 (coil) connected by a wire
also turns ON (energized), the motor rotates, and the hand moves to the
right.

OceanofPDF.com
Then, when you release your hand at the position you want to stop, X3 (A
contact) turns off (non-energized), Y3 (coil) also turns off (non-energized),
and the hand stops.

In this way, in the case of a crane game, you only have to move while
pressing the button, so there is no need to use a self-holding circuit.

OceanofPDF.com
Now let's talk about programs that require self-holding.

For example, if you put something you want to warm in the microwave and
press the start button, it will warm up and end with a sound.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
When you press the start button X4 (momentary) of the microwave oven,
the warming command Y4 turns ON.
And Y4 under X4 is also ON.

OceanofPDF.com
Even if you take your hand off the start button X4 of the microwave oven in
this state, the command Y4 will continue to turn on.
Such a circuit is called a "self-holding circuit".

When the warming is completed, the warming completion signal X5 is


turned on for 1 second from the microwave oven, and the self-holding of
Y4 is cut off.

The X5 to the right of this X4 is called the "B contact".


At "B contact", X5 is ON and de-energized, and X5 is OFF and energized.

OceanofPDF.com
Then, when the completion signal X5 is turned on, the completion
notification command Y5 is turned on and a sound is output.

OceanofPDF.com
Since the completion signal X5 is ON for 1 second, it returns to the initial
state after 1 second.

In the case of a microwave oven like this, even if you release your hand
after pressing the button, you want to keep warming, so you need to make it
a self-holding circuit.

OceanofPDF.com
3-6 Summaries

・ If you want to operate only while pressing the button like a crane game,
you do not need to use a self-holding circuit.
・ If you want to continue the operation even if you press the button and
release your hand like a microwave oven, you need to use a self-holding
circuit.

OceanofPDF.com
Exercises1 ( Shutter opening and closing operation )

Only while pressing the open button X6 (momentary), the shutter open
command Y6 is issued to open the shutter.
Also, create a program that closes the shutter by issuing the shutter close
command Y7 only while pressing the close button X7 (momentary).
(Create in the program "EX1" in the project name "TEST")

OceanofPDF.com
Exercises1 Answer

OceanofPDF.com
Exercises2 ( Air purifier on / off operation )

When you press the ON switch X8 (momentary), the air purifier operation
command Y8 is issued and the air purifier operates. If you press the off
switch X9 (momentary), the operation of the air purifier will stop. Create a
program like this.
(Create in the program "EX2" in the project name "TEST")

OceanofPDF.com
Exercises2 Answer

OceanofPDF.com
3-7 AND circuit

An AND circuit is a circuit that outputs an output signal when multiple


conditions are met.

For example, when the washing machine power ON / OFF button X10
(alternate) is ON and the washing start button X11 (momentary) is pressed,
the washing machine operation command Y10 is turned ON and washing
starts.
In addition, washing is completed when the washing completion signal X12
is ON.
If you write it with such a PLC program, it will look like this.

OceanofPDF.com
Even if you press the washing start button X11 while the washing machine
is not turned on, the washing machine operation command Y10 will not
turn on and washing will not start because the conditions are not met.

OceanofPDF.com
Therefore, in order to meet the conditions, first turn on the power ON / OFF
button X10 (alternate).

OceanofPDF.com
In this state, if you press the start button X11 (momentary), the conditions
are met, so the washing machine operation command Y10 turns ON and
washing starts.

OceanofPDF.com
The washing machine operation command Y10 is a self-holding circuit, so
you can continue washing even if you release your hand.

OceanofPDF.com
When the washing is finished, the washing completion signal X12 turns on
for 1 second, and the washing machine operation command Y10 turns off.

OceanofPDF.com
Also, even if the power is turned off while the washing machine is running,
the operation cannot be continued, so the washing machine operation
command Y10 is turned off.

When both X10 and X11 are turned on, a circuit with multiple output
conditions in series, such as Y10 turned on, is called an "AND circuit".

OceanofPDF.com
3-8 OR circuit

Next is the OR circuit, which is a circuit that outputs an output signal


regardless of which of the multiple conditions is turned on.

For example, the automatic hot water in the bath can be operated with the
remote control of the bathroom or the remote control of the additional
living room.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
In this case, bathroom remote control bath automatic button X15
(momentary), living remote control bath automatic button regardless of
which of X16 (momentary) is pressed, the automatic hot water filling start
command Y15 turns on.

When either X15 or X16 is turned on, a circuit with multiple output
conditions in parallel, such as Y15 turned on, is called an "OR circuit".

OceanofPDF.com
3-7 ~ 3-8 Summaries

・ A circuit in which multiple conditions are connected in series to the output


conditions is called an "AND circuit".
・ A circuit in which multiple conditions are parallel to the output conditions
is called an "OR circuit".

OceanofPDF.com
Exercises3 ( Juice purchase at vending machine )

On the vending machine, press the ice-free button X18 (alternate) and then
the juice button X19 (momentary) to turn on the ice-free juice creation start
command Y18 and create ice-free juice.
After completion, turn on the iceless juice completion signal X20 for 1
second and turn off Y18.
Create such a program using a self-holding circuit.
(Create in the program "EX3" in the project name "TEST")

OceanofPDF.com
Exercises3 Answer

OceanofPDF.com
Exercises4 ( Printer color / black and white printing )

Pressing either the black-and-white print start button X21 (momentary) or


the color print start button X22 (momentary) on the printer turns on the
print start output Y21 and printing starts.
Also, when starting black-and-white printing, turn on the black-and-white
ink output Y22, and when starting color printing, turn on the color ink
output Y23. Then, when printing is completed, the print completion signal
X23 turns on for 1 second. Please create this program.
(Create in the program "EX4" in the project name "TEST")

OceanofPDF.com
Exercises4 Answer

OceanofPDF.com
Chapter 4 Program operation check
So far, I have created 4 exercises, but those programs
You can use the GX Simulator to see if it actually works.

I'll show you how to do that.

OceanofPDF.com
4-1 Check program settings

First, register the program data for simulation in the program settings.
Click the plus mark of "Parameter" in the project data list, and double-click
"PLC Parameter".
If the project data list is not displayed, click the "View" tab ⇒ "Project data
list" to display it.

OceanofPDF.com
Press the "Program" tab and insert the program you want to simulate.

OceanofPDF.com
This time, insert the sample and EX1, EX2, EX3, EX4.
Select "SAMPLE" on the left, repeats the operation of pressing the insert
button until "EX4", and press the end button on the lower right.
The simulation is now ready.

OceanofPDF.com
4-2 Start simulation

Select the "Tools" tab ⇒ "Start ladder logic test".

OceanofPDF.com
Although it is a simulation, writing of each program to the PLC starts.
When all is done, the ladder logic test tool RUN will turn yellow.

OceanofPDF.com
Now the simulation is possible.
As shown in the program below, the parts where the conditions are met are
blue.

To end the simulation, select the Tools tab ⇒ End ladder logic test.

OceanofPDF.com
4-3 Monitor mode/monitor (write mode)

The state in which the simulation is started is "monitor mode".


In this state, you can monitor the execution status of the program.

If for some reason you are no longer in monitor mode, "Online" tab ⇒
"Monitor" ⇒ "Monitor mode" or press F3 on the computer keyboard to
switch to monitor mode.

OceanofPDF.com
In monitor mode, the cursor is filled with blue.

OceanofPDF.com
"Online" tab ⇒ "Monitor" ⇒ "Monitor (Write Mode)" or press Shift + F3
on the computer keyboard to display the screen below. Press "OK" to
switch to monitor (write mode).

In this state, the program can be changed and written to the PLC on the
simulation.

If the result of the simulation does not work as expected, use this monitor
(write mode) to add or modify the program.

However, the free trial version does not support writing during RUN, so
please exit the simulation mode once, add or modify the program, and then
start the simulation mode.

OceanofPDF.com
On the monitor (write mode), the cursor has no blue fill.

OceanofPDF.com
[Reference * because the free trial version is not supported]

This is the procedure for changing the program on the monitor (write
mode).
For example, if you want to add X4 (Switch 5) next to X1 (Switch 2) in the
sample program, first add X4 (Switch 5).
* Free trial version is not supported.

OceanofPDF.com
After adding the program, press the "Convert" tab ⇒ "Convert (Online
change)" or Shift + F4 on the computer keyboard, and a message will
appear. Select "Yes" to write the program.
This completes writing during RUN.

OceanofPDF.com
4-4 Forced ON/OFF method for contacts

The simulation is performed while actually turning the contacts on and off.
The program data "EX1" will be explained as an example.

1. Only while pressing the open button X6 (momentary), the shutter open
command Y6 is issued to open the shutter.
Also, only while pressing the close button X7 (momentary), the shutter
close command Y7 is issued and the shutter closes.

OceanofPDF.com
First, turn on the open button X6.
Hover over X6 and select the "Online" tab ⇒ "Debug" ⇒ "Device test".
(Alt + 1 is OK)

OceanofPDF.com
Confirm that X6 is included in the device label on the current value change
screen, and press "FORCE ON" to turn X6 ON.
Press "FORCE OFF" to turn X6 OFF.
You can also check the operation of the close button X7 by following the
same procedure.

In this way, you can check the operation using the simulation function.

OceanofPDF.com
You can also turn it on / off by moving the cursor to X6 and Shift + Enter
on your computer keyboard without using the "Online" tab ⇒ "Debug" ⇒
"Device test" (Alt + 1).

This is easier, so let's check the operation of the remaining exercises 2, 3


and 4 using this method in the future.

OceanofPDF.com
4-5 When the "Unable to communicate with PLC" message
appears during conversion

After the simulation is completed, the following message may appear when
the program is changed and converted.

OceanofPDF.com
If this message appears, change "Tools" tab-> "Options" "After conversion
writing behavior" from "Write during RUN (while PLC is running)" to "Do
not write to PLC" Then press "OK".

OceanofPDF.com
Chapter 5 Frequently used devices

5-1 M (Auxiliary relay)

M (auxiliary relay) is a device used as a signal inside the PLC.


The usage will be explained using an actual program.

Let's take the washing machine settings as an example.

OceanofPDF.com
For example, water volume 29L setting (X24 is ON), washing 15 minutes
setting (X25 is ON), rinsing 2 times setting (X26 is ON), dehydration 3
minutes setting (X27 is ON), ion auto ON setting (X28 is ON) with all five
conditions in place, turn on the setting condition an output Y24.

In addition, water volume 29L setting (X24 is ON), washing 15 minutes


setting (X25 is ON), rinsing 2 times setting (X26 is ON), dehydration 3
minutes setting (X27 is ON), ion auto OFF setting (X29 is ON) with all five
conditions in place, turn on the setting condition B output Y25.

OceanofPDF.com
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
The only difference between setting condition A and setting condition B is
the ON/OFF of the ion coat and all other conditions are the same.
If you use M (auxiliary relay) in such a case, it will look like this.

The signals of X24 to X27 are received once by the auxiliary relay M0, and
that M0 is added to each condition.

In this way, it is possible to make the circuit easy to understand by grouping


the parts where it is troublesome to insert the AND circuit every time with
M (auxiliary relay).

OceanofPDF.com
5-2 L (Latch relay)

L (latch relay) is also a device used as a signal inside the PLC, but M
(auxiliary relay) is turned off when the PLC power is turned off due to a
power failure or the like and then turned on again.

On the other hand, L (latch relay) is in the ON state, and when the power is
turned on again after the PLC power is turned off due to a power failure
etc., the state before the power is turned off is maintained.

OceanofPDF.com
For example, in Exercise 2, when the on switch X8 (momentary) is pressed,
the air purifier operation command Y8 is issued and the air purifier
continues to operate, and when the off switch X9 (momentary) is pressed,
the operation of the air purifier stops.

If the outlet is unplugged and plugged in again while Y8 is ON, Y8 will not
operate because it cannot maintain the state before the power was turned
off.

OceanofPDF.com
Next, if self-holding is performed using M (auxiliary relay) instead of Y8,
M1 cannot hold the state before the power was turned off, so it turns off,
and as a result Y8 also turns off and does not operate.

OceanofPDF.com
If you want to operate the air purifier by unplugging it while the air purifier
is running and plugging it in again, use L (latch relay).
Since L1 retains the state before the power was turned off, it remains ON,
and as a result Y8 also turns ON, and when the outlet is plugged in, the air
purifier operates.

OceanofPDF.com
In this way, use L (latch relay) where you want to keep the state before the
power was turned off.

5-1 ~ 5-2 Summaries

・ M (auxiliary relay) and L (latch relay) are both devices used as signals
inside the PLC.
・ M (auxiliary relay) can be used to group the parts where it is troublesome
to insert the AND circuit every time.
・ L (latch relay) retains the state before the power was turned off when the
power was turned on again after the power was turned off.

OceanofPDF.com
Exercises5 ( Robot operating conditions )

This is a program that summarizes the start able conditions for two robots
on the production line of a factory.
Use the auxiliary relay M2 to make it easier to understand.
(Create in the program "EX5" in the project name "TEST")

OceanofPDF.com
Exercises5 Answer

OceanofPDF.com
Exercises6 ( Lamp lights up after plugging in )

When you press the switch-on button X40 (momentary), the lamp Y40 self-
holds and lights up. Press the switch off button X41 (momentary) to turn off
the lamp.
Please Use the latch relay L2 to create a program that turns on the lamp
after plugging and unplugging the outlet while the lamp is on.
(Create in the program "EX6" in the project name "TEST")

OceanofPDF.com
Exercises6 Answer

OceanofPDF.com
5-3 T (Timer)

T (timer) is a device that counts the ON time and turns ON when the set
time is reached.

For example, if the power supply X42 (alternate) is ON, the output 600W
setting X43 (alternate) is ON, and the warming time is 1 minute, pressing
the start button X45 (momentary) will turn on the warm start output Y42.
If you write it in a PLC program, it will look like this.

OceanofPDF.com
In this program, a device called T0 of T (timer) is used.

And this T0 is set to the number "600".


The leading "K" is a decimal numbers symbol.
(Decimal numbers are represented by numbers from 0 to 9)

This unit is 0.1 seconds, and T0 turns on when it remains on for 60 seconds
(1 minute).

This T0 will be reflected when you press F7 on the toolbar or F7 on your


computer, then enter "T0 K600" and press "OK", enter a comment for T0
and press "OK".

By using this T0, T0 turns on after 60 seconds (1 minute), and this signal
can be used to turn off the self-holding of the start output Y42.

OceanofPDF.com
30 seconds have passed since Y42 turned on
⇒ T0 does not turn on

OceanofPDF.com
60 seconds (1 minute) have passed since Y42 was turned on
⇒ T0 is turned on and Y42 is turned off

OceanofPDF.com
When Y42 turns off, T0 also turns off.

By using T (timer) in this way, it is possible to control the operation to


end after a certain period of time has elapsed.

OceanofPDF.com
It can also be used to "delay the start" as another use.

For example, when you press the bathroom remote control bath automatic
button X50 (momentary), you need to make sure that the bath plug is closed
before the hot water comes out. Therefore, 10 seconds after pressing the
button, the automatic hot water filling start command Y50 turns on.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
In this program, T1 is used and T1 is set to "100".
Since the unit is 0.1 seconds, T1 will turn ON if it continues to be ON for
10 seconds.

By using this T1, T1 turns on 10 seconds after pressing X50.


In other words, you can turn on the automatic hot water start command Y50
10 seconds after pressing X50.

OceanofPDF.com
T1 does not turn on 5 seconds after X50 turns on and self-holding M50
turns on.

OceanofPDF.com
10 seconds after X50 is turned on and M50 is turned on, T1 is turned on and
Y50 is also turned on.

OceanofPDF.com
When the automatic hot water filling completion signal X51 is turned on,
M50 and T1 are turned off, and Y50 is also turned off.

By using T (timer) in this way, it is possible to control the operation to


start after a certain period of time.

OceanofPDF.com
5-3 Summaries

・ T (timer) is a device that counts the ON time and turns ON when the set
time is reached.
・ By using T (timer), it is possible to control the operation to end after a
certain period of time has elapsed.
・ By using T (timer), it is possible to control the operation to start after a
certain period of time.

OceanofPDF.com
Exercises7 ( Washing machine Washing start / end )

If you press the start button X54 (momentary) while the power supply X52
(alternate) is ON and the automatic setting X53 (alternate) is ON in the
washing machine, the washing start command Y54 will be ON and will be
completed in 30 minutes.
Please write this operation in the PLC program.
Also, use T5 for T (timer).
(Create in the program "EX7" in the project name "TEST")

OceanofPDF.com
Exercises7 Answer

OceanofPDF.com
Exercises8 ( Forced termination of computer )

Press and hold the power button X55 (momentary) of the personal computer
for 5 seconds to turn on the forced power off command Y55 of the personal
computer.
Please write this operation in the PLC program.
Use T6 for T (timer).
(Create in the program "EX8" in the project name "TEST")

OceanofPDF.com
Exercises8 Answer

OceanofPDF.com
5-4 C (counter)

C (counter) is a device that turns on when the set value is reached by


counting the number of times it is turned on.
I will explain the usage.

Let's take the setting of the number of rinses of the washing machine as an
example.
For example, after rinsing twice, dehydration is performed.
For the rinse completion signal X60, dehydration start command Y61, and
dehydration completion signal X61, the PLC program will look like this.

OceanofPDF.com
This program uses a device called C0 of C (counter).

And this C0 is set to 2.


The unit is times, and when C0 is turned on twice, C0 is turned on.

This C0 will be reflected when you press F7 on the toolbar or F7 on your


computer, then enter "C0 K2" and press "OK", enter a comment for C0 and
press "OK".

By using this C0, C0 turns ON after the rinsing is completed twice, and the
dehydration start command Y61 of the next process can be turned ON.

OceanofPDF.com
The first rinse completion signal X60 is ON, and 1 is entered in C0, but C0
is not ON.

OceanofPDF.com
The second rinse completion signal X60 is ON, C0 is 2 and C0 is ON.
Then, when C0 is turned on, the dehydration starts command Y61 is turned
on and self-holding.

OceanofPDF.com
Also, once the counter C0 is turned on, it remains in the ON state.
You need to use a command word called "RST" to turn off C0.

"RST" will be reflected when you press F8 on the toolbar or F8 on your


computer, then enter "RST C0" and press "OK".

OceanofPDF.com
This time, C0 is reset 5 seconds after the dehydration start command Y61 is
turned on.

In this way, by using C (counter), it is possible to control the operation to


start and end after a certain number of times.

OceanofPDF.com
5-4 Summaries

・ C (counter) turns ON when the set value is reached by counting the


number of ON times.
・ C (counter) is turned off by using the command word "RST".
・ By using C (counter), it is possible to control the operation to start and end
after a certain number of times.

OceanofPDF.com
Exercises9 ( Password lock / unlock )

If the password error signals X65 turns ON five times, the password lock
command Y65 turns ON.
The number of password errors will be canceled when the password success
signal X66 or password unlock signal X67 is turned on.
Please write this operation in the PLC program.
Use C1 for C (counter).
(Create in the program "EX9" in the project name "TEST")

OceanofPDF.com
Exercises9 Answer

OceanofPDF.com
5-5 D (Data register)

D (data register) is a device that can store numerical values.


I will explain the usage.

For example, if the TV is currently displaying 1CH and you press the 2CH
button X72 (momentary) on the TV remote control, turn on the 2CH
switching signal Y72 to switch to 2CH, 2 is entered in the screen display
device D10, and the screen "2" is displayed.

Also, if you press the 1CH button X71 (momentary) for 2CH, turn on the
1CH switching signal Y71 to switch to 1CH, 1 will be entered in the screen
display device D10, and "1" will be displayed on the screen.

OceanofPDF.com
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
In this program, D10 of D (data register) is used.
When you press the 2CH button, "2" will be entered in D10.

Also, "MOV" sends the number on the left to the device on the right.
(This "MOV" will be explained later in the "Transfer Command")

After pressing F8 on the toolbar or F8 on your computer, enter "MOV K1


D10" and press "OK", enter a comment for D10 and press "OK" to reflect it
in the program.

OceanofPDF.com
If you press the 2CH button X72 while the TV is on 1CH, Y72 will turn ON
and D10 will contain 2.

OceanofPDF.com
If you press the 1CH button X71 while the TV is on 2CH, Y71 will turn ON
and D10 will contain 1.

By using D (data register) in this way, numbers can be displayed using


signals.

OceanofPDF.com
Conversely, by entering a number in D10, you can also output a switching
signal that matches that number.

For example, if you press the 1CH button X71, 1 will be entered in D10,
and Y71, which is output when D0 = 1, will turn ON.

OceanofPDF.com
The "=" will conduct if the number on the left matches the device on the
right.
("=" will be explained later in "Comparison command")

After pressing F8 on the toolbar or F8 on your computer, enter "= K1 D10"


and press "OK", enter a comment for D10 and press "OK" to reflect it.

OceanofPDF.com
When you press the 2CH button X72, 2 enters D10 and Y72 turns ON.

By entering the channel number pressed by the remote control into D0 in


this way, it is also possible to control which switching signal is output using
that number.

OceanofPDF.com
5-5 Summaries

・ D (data register) is a device that can store numerical values.


・ D (data register) can display numbers using signals.
・ D (data register) can control which switching signal is output using
numbers.

OceanofPDF.com
Exercises10 ( Microwave wattage display )

When you press the 600W button X74 (momentary) of the microwave oven,
"600" is displayed on the wattage display monitor (D12).
Please write this operation in the PLC program.
(Create in the program "EX10" in the project name "TEST")

OceanofPDF.com
Exercises10 Answer

OceanofPDF.com
Exercises11 ( Microwave defrost button )

When you press the Microwave defrost button X75 (momentary) of the
microwave oven, "8" is displayed on the mode display monitor (D14) and
the Microwave defrost mode setting (Y75) is turned on.
Please write this operation in the PLC program.
(Create in the program "EX11" in the project name "TEST")

OceanofPDF.com
Exercises11 Answer

OceanofPDF.com
5-6 Simulation method of T, C, D

You can also enter values for the T (timer) time, C (counter) count, and D
(data register) numbers by simulation.

For example, if the microwave oven warms up for 10 minutes (600


seconds), waiting 10 minutes to check the operation is quite long.

OceanofPDF.com
In that case, when T0 is counting, move the cursor to T0 and press Shift +
Enter to display the current value change screen.

For example, if you enter 5950 as the value and press set, you can enter
5950 in T0 and have 5 seconds left to complete the process.

OceanofPDF.com
You can set the values for C (counter) and D (data register) in the same
way.

OceanofPDF.com
5-7 D latch method

When the power of the PLC is turned off due to a power failure while the M
(auxiliary relay) is ON and then turned on again, the M (auxiliary relay) is
turned off.

On the other hand, I explained that L (latch relay) retains the state before
the power was turned off when the power was turned on again after the
power was turned off.

As with M (auxiliary relay), D (data register) loses the stored numerical


data when the power is turned on again after the power is turned off.

If the numerical data is lost when the power is turned off, it may cause a
problem.
In that case, you can set the PLC program to maintain the state before the
power was turned off.

OceanofPDF.com
This time, I will explain how to do it.

1. Open GX Developer.

OceanofPDF.com
2. Create a new project.
(If you already have a program created, open it)

OceanofPDF.com
Click the plus mark of "Parameter" in the project data list, and double-click
"PLC Parameter".
If the project data list is not displayed, click the "View" tab ⇒ "Project data
list" to display it.

OceanofPDF.com
4. Select "Device" from the tabs.

OceanofPDF.com
5. For example, if you want to keep the state before the power is turned off
from D2000 to D2999, enter 2000 at the beginning of the latch (1) and
2999 at the end of the latch (1) of the data register, and press the "End"
button.
Alternatively, enter 2000 at the beginning of the latch (2) and 2999 at the
end of the latch (2), and press the "End" button.

By making this setting, you can maintain the state of the specified device
before the power was turned off.

With PLC, you can perform an operation called latch clear.


Latch (1) loses data with this operation, but latch (2) retains its state.

In other words, use latch (2) if you don't want to lose data no matter what
you do.

OceanofPDF.com
5-7 Summaries

・ When the power of D (data register) is turned off and then turned on
again, the stored numerical data will be lost.
・ However, by changing the settings of the PLC program, it is possible to
maintain the state before the power was turned off.
・ Set in "Parameter" ⇒ "PLC parameter" ⇒ "Parameter setting" of the
navigation.
・ If you do not want to lose data no matter what you do, use latch (2)
instead of latch (1).

OceanofPDF.com
Exercises12 ( Data retention )

Change the parameters of the PLC program so that the D0 to D1000 can be
operated in the same state as before the power was turned off.

OceanofPDF.com
Exercises12 Answer

OceanofPDF.com
Chapter 6 About the program

6-1 Scan time

There is a concept of "scan time" in PLC programs.

"Scan time" is the time to execute (scan) all PLC programs once.

OceanofPDF.com
The PLC scan time is fairly fast, typically a few ms to a few tens of ms.
For higher performance PLC, The PLC has a scan time in microseconds.
ms (milliseconds): 1ms = 1/1000 seconds
μ s (microseconds): 1 μs = 1 / 1000,000 seconds

Basically, the program runs in order from the top.

OceanofPDF.com
For example, if the program is as follows, pressing the 2-channel button
X80 (momentary) will put 2 in D20, and the program below it will put 2 in
D20, and the conditions will be met.
In other words, Y80 turns on in the first scan and switches to channel 2.

OceanofPDF.com
So what happens if you swap the top and bottom programs?

In this case, if you press the 2-channel button X80, 2 will be entered in
D20, but in the first scan, 2 will not be entered in D20 of the upper
program.
Therefore, Y80 turns on in the second scan and switches to channel 2.

In this way, the timing at which the signal is turned on changes depending
on how the program is written.

OceanofPDF.com
You might think.
"The PLC scan time is as fast as a few ms to a few tens of ms, so it doesn't
affect that much."

Certainly, a circuit like the one above has little effect.


For example, even if the screen changes with a delay of several ms to
several tens of ms after pressing the switch, it will not be noticeable to the
human eye.

However, when programming complex controls such as factory machines,


be aware that if you do not know the concept of this scan, it may not work
as intended.

OceanofPDF.com
6-1 Summaries

・ Scan time is the time to execute (scan) all PLC programs once.
・ Basically, the program is executed in order from the top.
・ The timing at which the signal is turned on will change depending on how
the program is written.

OceanofPDF.com
6-2 Pulse contacts

A pulse contact is a contact that turns on only while the PLC program is
executed (scanned) once.
Let's take an example.

For example, if the power supply X42 (alternate) is turned on, the output
600W setting X43 (alternate) is turned on, and the warming time is 1
minute, pressing the start button X45 (momentary) turns on the warming
start output Y42.

OceanofPDF.com
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
For example, what happens if the start button X45 of a microwave oven
breaks and is always on?

In this case, after 1 minute, T0 turns ON and Y42 turns OFF to finish
warming.

OceanofPDF.com
However, since X45 remains ON, Y42 turns ON and warming starts again
for 1 minute.
One minute later, and even after that, it will continue to operate, and in the
worst case, there is a risk of fire.

OceanofPDF.com
To prevent such malfunctions, use "pulse contacts".
"Pulse contact" includes "rising pulse contact" and "falling pulse contact".

With normal A contact, the signal turns on while the button is pressed.

OceanofPDF.com
On the other hand, the "rising pulse contact" is turned on only while the
PLC program is executed (scanned) once when the button is pressed.

OceanofPDF.com
The "falling pulse contact" is turned on only while the PLC program is
executed (scanned) once when the button is pressed and the hand is
released.

By using such "rising pulse contact" and "falling pulse contact", it is


possible to prevent the signal from remaining ON.

OceanofPDF.com
This program is a program in which the start button X45 of the microwave
oven is used as the "rising pulse contact".

After pressing sF7 on the toolbar or Shift + F7 on your computer, enter


"X45" and press "OK", enter a comment for X45 and press "OK" to reflect
it in the program.

In this program, even if the start button X45 of the microwave oven is
broken and always turned on, the start button X45 will only turn on for one
execution (scan) at the moment of pressing.

Therefore, the warming starts from the moment the button is pressed, and it
does not operate again even after 1 minute has passed.

OceanofPDF.com
After 1 minute, T0 turns on and Y42 turns off.

OceanofPDF.com
Since Y42 is OFF, T0 is OFF, and X45 is not ON at the rising contact, it
will not start warming up.

OceanofPDF.com
This program is a program in which the start button X45 of the microwave
oven is used as a "falling pulse contact".

After pressing sF8 on the toolbar or Shift + F8 on your computer, enter


"X45" and press "OK", enter a comment for X45 and press "OK" to reflect
it in the program.

In this program, even if the start button X45 of the microwave oven is
broken and always turned on, it will be turned on only during one execution
(scan) at the moment when the start button X45 is pressed and the hand is
released.

Therefore, from the moment you release the button, warming starts and it
does not operate again even after 1 minute has passed.

OceanofPDF.com
6-2 Summaries

・ A pulse contact is a contact that turns on only while the PLC program is
executed (scanned) once.
・ The "rising pulse contact" is turned on only while the PLC program is
executed (scanned) once when the button is pressed.
・ The "falling pulse contact" is turned on only while the PLC program is
executed (scanned) once when the button is released.

OceanofPDF.com
Exercises13 ( After pressing the button, the lamp will light for 5
seconds )

The lamp Y82 lights up from the moment the switch X82 (momentary) is
pressed. After that, create a PLC program in which T30 turns on and Y82
turns off after 5 seconds even if you keep pressing the switch.
(Create in the program "EX13" in the project name "TEST")

OceanofPDF.com
Exercises13 Answer

OceanofPDF.com
Exercises14 ( After releasing the button, the lamp will stay on
for 5 seconds )

The lamp Y83 lights up from the moment you press the switch X83
(momentary) and release it. Then, after 5 seconds, create a PLC program in
which T31 turns on and Y83 turns off.
(Create in the program "EX14" in the project name "TEST")

OceanofPDF.com
Exercises14 Answer

OceanofPDF.com
6-3 Clock pulse

A clock pulse is a pulse signal that repeats ON and OFF at regular intervals.
Let's take an example.

For example, a car turn signal flashes 60 to 120 times a minute.


If it blinks 60 times per minute, it will repeat ON / OFF every 0.5 seconds.
If the left turn signal switch X85 (alternate) and the left turn signal lighting
command are Y85, the PLC program that blinks the turn signal will be like
this.

OceanofPDF.com
In this way, by inserting the SM412 (1 second clock) before the left turn
signal lighting signal, it becomes a program that repeats lighting /
extinguishing at 0.5 second intervals.

SM412 turns off for 0.5 seconds.

After that, it turns on for 0.5 seconds.


Repeat this.

OceanofPDF.com
This SM412 (1 second clock) is a signal that the PLC has that "does this
kind of operation" and is called a "special relay".
One of these special relays is the "clock pulse" introduced this time.
(Here, we introduce the special relay of Q series PLC)

In addition to the SM412 (1 second clock) introduced this time, SM413 (2


second clock), SM400 (always ON), SM401 (always OFF), etc. are often
used in "special relays".

SM413 (2-second clock) is a special relay that turns on and off every
second.
If you change the SM412 of the left turn signal program to SM413, the turn
signal will turn on and off every second.

OceanofPDF.com
SM400 (always on) is a special relay that is always on, and SM401 (always
off) is a special relay that is always off.
It is often used when you want to always turn it on / off, or when you want
to disable conditions or programs.

Condition C is no longer needed, so condition C is disabled using SM400


(always on).

OceanofPDF.com
The lamp broke, so use SM401 (always off) to keep Y95 off all the time.

By making good use of special relays in this way, the program can be
simplified.
Please remember the four introduced above.

OceanofPDF.com
6-3 Summaries

・ A clock pulse is a pulse signal that repeats ON and OFF at regular


intervals.
・ By using SM412 (1 second clock), you can create a program that repeats
output ON / OFF at 0.5 second intervals.
・ The signal that the PLC has that "does this kind of operation" is called a
"special relay".
・ SM412 (1 second clock), SM413 (2 second clock), SM400 (always ON),
SM401 (always OFF) are often used in "special relays".

OceanofPDF.com
Exercises15 ( Vacuum cleaner paper pack full )

When the paper pack full signal X100 (always ON when full) of the
vacuum cleaner turns ON, the paper pack replacement lamp Y100 repeats
turning on / off every second.
Please write this behavior in a PLC program using a special relay.
(Create a new project name "TEST2", create a new "Problem 15", and then
create it.)

OceanofPDF.com
Exercises15 Answer

OceanofPDF.com
Exercises16 ( Temporary response in case of button failure )

When you press the A button X101 (momentary) and the B button X102
(momentary) at the same time, the lamp Y101 lights up. If you press the C
button X103 (momentary), the lamp Y101 will turn off.
One day, the B button X102 was broken, so I would like to change to a
program that lights the lamp Y101 by pressing only the A button X101 until
it is repaired.
Please change the program below using a special relay.
(Create in the program "EX16" in the project name "TEST2")

OceanofPDF.com
Exercises16 Answer

OceanofPDF.com
6-4 Duplicated coil

Duplicated coil (double coil) means that there are two or more coils of the
same type and the same device number in the program.
Let's take an example.

For example, a program in which the lamp C Y110 lights up only while the
button A X110 (momentary) or the button B X111 (momentary) is pressed
can be written in this way using the OR circuit.

OceanofPDF.com
If you mistakenly write this program like this, it will be a "duplicated coil".

Also, since "Check duplicated coil" is set in the setting of GX Developer,


the following message will be displayed if it becomes a duplicated coil.

OceanofPDF.com
In this program, there are two Y110s, so there are two coils of the same type
and device number in the program.

In this case, the programs are basically executed in order from the top, so
even if X110 is turned on, Y110 will not be turned on because Y110 will be
turned off by the programs of X111 and Y110 below.

OceanofPDF.com
When X111 is turned on, Y110 is turned on.

If the program conditions are met but the signal does not turn on,
"duplicated coil" is also a factor, so you need to be careful.

OceanofPDF.com
Regarding the duplicated coil, "Check duplicated coil" is set in the setting
of GX Developer, so basically it does not become a duplicated coil.
However, it will not be checked if the program is copied or pasted.

Therefore, after creating a PLC program, let's carry out a "Check Program".

OceanofPDF.com
The execution method of "Check Program" is as follows.

1. Select the "Tools" tab ⇒ "Check program".

OceanofPDF.com
2. Confirm that "Double coil check" is checked on the program check
screen, set the check target to whole program, and press "Execute".

OceanofPDF.com
3. If you look at the execution result and find a duplicated coil error, correct
the program.

By performing the "check program" in this way, you can easily check the
presence or absence of the duplicated coil.

Be sure to check after creating the program so that the program does not
behave unexpectedly.

OceanofPDF.com
6-4 Summaries

・ Duplicated coil (double coil) means that there are two or more coils of the
same type and device number in the program.
・ If the program conditions are met but signal does not turn on, "duplicated
coil" is also a factor.

OceanofPDF.com
Chapter 7 Command Words

7-1 Command words of PLC program

So far, we have only explained contacts and coils, but from now on, we will
explain "command words".

Most programs will be understandable if you understand the contacts, coils,


and basic commands.

When creating a PLC program, it is OK to first learn only the following


three types of basic command words that are often used.

OceanofPDF.com
1. Transfer instruction
(MOV 、 DMOV 、 BMOV 、 FMOV) ・・・ Instruction to transfer data

Example) Display 110 on the selling price display device D30 under the
drink in the vending machine.

OceanofPDF.com
2. Four arithmetic operations instruction
( + 、 - 、 * 、 /) ・ ・ ・ Instruction for adding, subtracting, multiplying, and
dividing data

Example) Every time 100 yen is inserted into a vending machine and the
100 yen input signal X120 is turned on, the input amount display device
D31 increases by 100.

Not input

100 yen input

Add another 100 yen

OceanofPDF.com
3. Comparison instruction
(= 、 < 、 <= 、 > 、 >=) ・・・ Instruction to compare two data

Example) if the amount of money put into the vending machine is 110 yen
or more, the purchase button lamp Y120 will light up.

100 yen input

Add another 100 yen

Each detail will be explained later.

OceanofPDF.com
7-1 Summaries

・ Most programs can be understood if you understand the contacts, coils,


and basic command words.
・ As basic instruction words, it is OK if you first learn three types (transfer
instruction, four arithmetic operations instruction, and comparison
instruction).

OceanofPDF.com
7-2 Transfer instruction

Now, I will explain each of the transfer instructions (MOV, DMOV, BMOV,
FMOV) using examples.

OceanofPDF.com
MOV (16-bit transfer instruction)

"MOV" is an instruction to transfer 1 word (16 bits) of data.


16 bits can represent numbers from -32768 to 32767.

For example, when you press the 7 button X130 (momentary) on the
calculator, 7 is displayed on the calculator monitor D40.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
Press F8 on the toolbar or F8 on your computer keyboard, then type "MOV
K7 D40" and press "OK".

OceanofPDF.com
Then, after entering the comment of D40, press "OK" and it will be
reflected in the program.

It means "transfer the number 7 to the D40 box and put it in".

OceanofPDF.com
DMOV (32-bit transfer instruction)

I explained that "MOV" can transfer 16-bit data, but if you want to transfer
a value larger than the value of -32768 to 32767 that can be represented by
16 bits, use "DMOV".
"DMOV" can transfer 32-bit data (-2147483648 to 2147483647).

For example, when withdrawing 100,000 yen at an ATM, enter 100000 in


the operation screen amount input devices D50 and D51, and press the
withdrawal execution button X132 (momentary) to enter "100000" in the
withdrawal amount devices D52 and D53. Then, the withdrawal execution
output Y132 turns ON.
If this operation is written in a PLC program, it will be as follows.

OceanofPDF.com
No amount entered on the operation screen

Enter 100000 on the operation screen

Withdrawal execution

OceanofPDF.com
After pressing F8, enter "DMOV D50 D52" and press "OK", enter
comments for D50 and D52, and then press "OK" to reflect them in the
program.

It means "transfer the number 100000 in D50 and D51 to the boxes of D52
and D53".

OceanofPDF.com
BMOV (Bulk transfer)

"MOV" is an instruction to transfer 1 word (16 bits) and "DMOV" is an


instruction to transfer 2 words (32 bits), but "BMOV" is an instruction to
transfer the specified number of words at once.

For example, suppose that step count data for 5 days is stored in D60 to
D64.
This data is saved in the devices D70 to D74 when the backup button X134
(momentary) is pressed.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
After pressing F8, enter "MOV D60 D70 K5" and press "OK", enter
comments for D60 and D70, and then press "OK" to reflect them in the
program.

It means "transfer 5 words from D60 to 5 words from D70 at once".

OceanofPDF.com
To check if the data is transferred without any problem, select "Online" tab
⇒ "Monitor" ⇒ "Device batch" when starting the simulator.

OceanofPDF.com
Enter the device you want to monitor in "Device:" and you can check the
value in the device.

OceanofPDF.com
When the backup button is not pressed

OceanofPDF.com
With the backup button pressed

OceanofPDF.com
FMOV (Batch transfer of the same data)

"FMOV" is an instruction to transfer the same data for the specified number
of words at once.

For example, let's say you have 5 types of drinks on the vending machine
and all prices are 150 yen.
If there are 5 prices display devices under the drink, D80-D84, put 150 in
all D80-D84.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
After pressing F8, enter "FMOV K150 D80 K5" and press "OK", enter a
comment for D80, and then press "OK" to reflect it in the program.

It means "transfer 150 to all 5 words from the first D80".

These transfer instructions are used to exchange data and are the most
commonly used instructions in programs.
Let's learn so that you can use it well.

OceanofPDF.com
7-2 Summaries

・ "MOV" is an instruction to transfer 1 word (16 bits) of data.


・ "DMOV" is an instruction to transfer 2-word (32-bit) data.
・ "BMOV" is an instruction to transfer the specified number of words in a
batch.
・ "FMOV" is an instruction to transfer the same data for the specified
number of words at once.

OceanofPDF.com
Exercises17 ( Backup of sphygmomanometer data )

Blood pressure data for 5 days is included in D90-D99.


Please create a program to transfer backup data D120 to D129 by pressing
the backup button X140 (momentary).
(Create in the program "EX17" in the project name "TEST2")

OceanofPDF.com
Exercises17 Answer

OceanofPDF.com
Exercises18 ( Deletion of sphygmomanometer data )

Please create a program that sets the blood pressure data D90 to D99 for 5
days to 0 by pressing the clear button X141 (momentary).
(Create in the program "EX18" in the project name "TEST2")

OceanofPDF.com
Exercises18 Answer

OceanofPDF.com
Exercises19 ( Sphygmomanometer measurement result
storage )

Please create a program that transfers the measured lower blood pressure 72
to D90 and the upper blood pressure 172 to D91 when you press the
measurement result save button X142 (momentary).
(Create in the program "EX19" in the project name "TEST2")

OceanofPDF.com
Exercises19 Answer

OceanofPDF.com
Exercises20 ( Sphygmomanometer display test )

Please create a program that displays "99999" on monitors D130 and D131
by pressing the display test button X143 (momentary).
(Create in the program "EX20" in the project name "TEST2")

OceanofPDF.com
Exercises20 Answer

OceanofPDF.com
7-3 Four arithmetic operations

Next, we will explain each of the four arithmetic instructions (+,-, *, /).

+ (Addition instruction) 、- (Subtraction instruction)

"+" Is an instruction to add two data.


"-" Is an instruction to subtract two data.

If you put 100 yen into the vending machine, the 100 yen input signal X120
will turn on and the input amount display device D31 will increase by 100.

In this case, if you add another 100 yen, X120 will turn on again and the
amount display D31 will be 200.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
Not input

100 yen input

Add another 100 yen

OceanofPDF.com
After pressing F8, enter "+ D31 K100 D31" and press "OK", enter a
comment for D31, and then press "OK" to reflect it in the program.

It means "sum the numbers stored in D31 and 100 and put them in D31".

The point to note here is that you need to use a "rising pulse contact" on the
X120.

In the case of A contact, if X120 is ON for 1 second and the scan time is
100ms (0.1 seconds), this program will be executed 10 times in 1 second, so
1000 will be displayed on the amount display D31.

OceanofPDF.com
There is also a method of making a rising pulse on the command word side.
In that case, add P after +, such as "+ P D31 K100 D31".

OceanofPDF.com
Next, the deposit display of the vending machine is 200 yen (D31 = 200),
and if you purchase by pressing the 150 yen drink purchase button X121
(momentary), the deposit display D31 will be 200-150 = 50.
If you write this operation in a PLC program, it will look like this.

After pressing F8, enter "-D31 K150 D31" and press "OK", enter the
comment of D31, and then press "OK" to reflect it in the program.

It means "subtract 150 from the number stored in D31 and put it in D31".

OceanofPDF.com
*( Multiplication instruction) 、 /( Division instruction)

"*" Is an instruction to multiply two data.


"/" Is an instruction to divide two data.

For example, it is used when switching units.


The data of 5 minutes "5" is stored in D32, and when you press the minute
⇒ second switching button X122 (momentary), this data in seconds is
stored in D34.
If you write this operation in a PLC program, it will look like this.

After pressing F8, enter "* D32 K60 D34" and press "OK", enter the
comments for D32 and D34, and then press "OK" to reflect them in the
program.

It means "multiply the number stored in D32 by 60 and put it in D34".

OceanofPDF.com
Also note that the device that stores the calculation results uses 2 words (32
bits).

In the above program, since it is 32767 or less, which is the upper limit of
16 bits, it is stored only in D34, but in the case of 5 x 30000 = 150000, for
example, it is stored in D34, D35.

OceanofPDF.com
When the display format is monitored with a 16-bit integer

OceanofPDF.com
When the display format is monitored with a 32-bit integer

OceanofPDF.com
Next, the data "180" for 180 minutes is stored in D36, and when you press
the minute ⇒ hour switching button X122 (momentary), this data in hours
is stored in D38.
If you write this operation in a PLC program, it will look like this.

After pressing F8, enter "/ D36 K60 D38" and press "OK", enter the
comments for D36 and D38, and then press "OK" to reflect them in the
program.

It means "divide the number stored in D36 by 60 and put it in D38".

OceanofPDF.com
In the case of division, the device that stores the calculation result uses 2
words (32 bits).
For example, if D38 contains 200 minutes and you switch to the hour unit,
3 will be stored in D38 and the remainder 20 will be stored in D39.

OceanofPDF.com
The "+", "-", "*", and "/" of the four arithmetic instructions introduced
above are used to calculate one word (16 bits).

If you want to calculate 2 words (32 bits), add D in front of each to make
"D +", "D-", "D *", "D /".

The four arithmetic operations are also often used in actual programs.
The operation will change depending on the difference between the four
arithmetic operations, the command with D, and the command with P, so be
sure to remember the difference.

OceanofPDF.com
7-3 Summaries

・ "+" Is an instruction to add two data.


・ "-" Is an instruction to subtract two data.
・ "*" Is an instruction to multiply two data.
・ "/" Is an instruction to divide two data.
・ If you want to calculate 2 words (32 bits), add D before the four arithmetic
symbols.
・ If you want to execute only one scan when the conditions are met, add P
after the four arithmetic symbols.

OceanofPDF.com
Exercises21 ( Total score calculation for 3 exams )

The result of Mr. Tanaka's test was 80 points in Japanese, 90 points in math,
and 40 points in English.
Put each score in D150 to D152 under the condition of SM400 (always ON)
and press the total score calculation button X150 (momentary) to store the
total score in D155.
Please create this program.
(Create in the program "EX21" in the project name "TEST2")

OceanofPDF.com
Exercises21 Answer

OceanofPDF.com
Exercises22 ( Average score calculation for 3 exams )

If you press the average score calculation button X151 (momentary) of Mr.
Tanaka's 3 subjects, the average score will be stored in D158.
Please create this program.
(Create in the program "EX22" in the project name "TEST2")

OceanofPDF.com
Exercises22 Answer

OceanofPDF.com
7-4 Comparison instruction

This section describes each of the comparison instructions (=, <>, <, <=,>,>
=).

=、 <>

"=" Is an instruction to compare two data and conduct if they match.


"<>" Is an instruction to compare two data and conduct if they do not
match.

For example, the password "1234" of the personal computer is stored in


D160, and the password entered from the personal computer is stored in
D162.
After entering the password, press the password verification button X160
(momentary), and if the passwords match, turn on the login success output
Y160. If the passwords do not match, turn on the login error output Y161.

OceanofPDF.com
If you write this operation in a PLC program, it will look like this.

Password match

Password unmatched

OceanofPDF.com
After pressing F8, enter "= D160 D162" and press "OK", enter the
comments for D160 and D162, and then press "OK" to reflect them in the
program.

It means "comparing the numbers stored in D160 and D162 and conducting
if they match".

To write "<>", press F8, enter "<> D160 D162", press "OK", enter the
comments for D160 and D162, and then press "OK" to reflect them in the
program.

It means "comparing the numbers stored in D160 and D162 and conducting
if they do not match".

OceanofPDF.com
< 、 <= 、 > 、 >=

"<" Is an instruction to compare two data and conduct if the data on the left
is smaller than the data on the right.
"<=" Is an instruction to compare two data and conduct if the data on the
left is less than or equal to the data on the right.
">" Is an instruction to compare two data and conduct if the data on the left
is larger than the data on the right.
"> =" Is an instruction to compare two data and conduct if the data on the
left is greater than or equal to the data on the right.

OceanofPDF.com
For example, when classifying smart phones, smart phones with an
evaluation score of D170 lower than 50 are ranked C, smart phones with 50
or more and 80 points or less are ranked B, and smart phones with an
evaluation score of more than 80 are ranked A.

When you press the rank judgment button X170 (momentary), one of A
rank judgment Y170, B rank judgment Y171, and C rank judgment Y172
turns ON.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
First, use ">" in programs where smart phones with an evaluation score
higher than 80 are classified as A class.

To write ">", press F8, enter "> D170 K80", press "OK", enter a comment
for D170, and then press "OK" to reflect it in the program.

It means "if D170 is greater than 80, it will conduct".

OceanofPDF.com
Next, use "<=" and "> =" in a program that sets smart phones with an
evaluation score of 50 points or more and 80 points or less as B class.

To write "<=", press F8, enter "<= D170 K80", press "OK", enter a
comment for D170, and then press "OK" to reflect it in the program.

It means "conduct if D170 is 80 or less".

To write "> =", press F8, enter "> = D170 K50", press "OK", enter a
comment for D170, and then press "OK" to reflect it in the program.

It means "if D170 is 50 or more, it will conduct".

OceanofPDF.com
Finally, use "<" in programs that use smart phones with a rating of less than
50 as C class.

To write "<", press F8, enter "<D170 K50", press "OK", enter a comment
for D170, and then press "OK" to reflect it in the program.

It means "if D170 is less than 50, it will conduct".

In this way, the comparison instruction is used when you want to make a
comparison using numbers in a program.

Also, if you want to compare two words (32 bits), add D before each, as in
the four arithmetic operations.

OceanofPDF.com
7-4 Summaries

・ "=" Is an instruction to compare two data and conduct if they match.


・ "<>" Is an instruction to compare two data and conduct if they do not
match.
・ "<" Is an instruction to compare two data and conduct if the left data is
smaller than the right data.
・ "<=" Is an instruction to compare two data and conduct if the data on the
left is less than or equal to the data on the right.
・ ">" Is an instruction to compare two data and conduct if the data on the
left is larger than the data on the right.
・ "> =" Is an instruction to compare two data and conduct if the left data is
more than the right data.
・ If you want to compare two words (32 bits), add D before the comparison
command symbol.

OceanofPDF.com
Exercises23 ( Blood pressure normal / abnormal judgment )

Blood pressure measurement was performed.


If the lower blood pressure is 50 or more and the upper blood pressure is
170 or less, it is normal, otherwise it is abnormal.
The lower blood pressure is stored in D180, and the upper blood pressure is
stored in D181.
When the judgment button X180 (momentary) is pressed, the blood
pressure normal signal Y180 or the blood pressure abnormal signal
Y181Suppose you want to output either.
Please write this operation in the PLC program.
(Create in the program "EX23" in the project name "TEST2")

OceanofPDF.com
Exercises23 Answer

OceanofPDF.com
7-5 Increment instruction / decrement instruction

For command words, it is enough to learn transfer commands, four


arithmetic operations, and comparison commands.
Also, the "increment instruction" and "decrement instruction" are useful
instructions to remember, so I will introduce them at the end.

INC (Increment instruction)


DEC (decrement instruction)

"INC" is an instruction to add the value of the specified device by 1.


"DEC" is an instruction to subtract the value of the specified device by 1.

OceanofPDF.com
For example, a motion sensor X190 is attached above the entrance of a
convenience store, and the number of visitors is stored in the D190 and
counted according to the number of times the motion sensor is turned on.
If you write a PLC program using the four arithmetic operations, it will
look like this.

OceanofPDF.com
This program can be made simpler by using "INC".

To write "INC", press F8, enter "INC D190", press "OK", enter a comment
for D190, and then press "OK" to reflect it in the program.

It means "add 1 to D190".

OceanofPDF.com
At the parking lot, when the car warehousing signal X195 is ON, one car
will be added to the number of cars in the parking lot D195.
Then, when the car exit signal X196 is ON, one car is deducted from the
number of cars in the parking lot D195.
If you write this operation in a PLC program, it will look like this.

OceanofPDF.com
One car enters the parking lot

One car leaves the parking lot

"INC" and "DEC" are very convenient for counting the number of times
and managing entry and exit in this way.
If you have such a purpose, please remember and use it.

OceanofPDF.com
7-5 Summaries

・ "INC" is an instruction to add the value of the specified device by 1.


・ "DEC" is an instruction to subtract the value of the specified device by 1.
・ "INC" and "DEC" are very convenient for counting the number of times
and managing entry and exit.

OceanofPDF.com
Exercises24 ( Parking lot full / empty ramp )

In a parking lot where up to 20 cars can be parked, if you press the parking
ticket button X200 (momentary), 1 will be added to the number of parking
lots D200.
When the payment completion signal X201 turns ON, subtract 1 from the
number of parking lots D200.
Also, when the number of parked cars reaches 20, the full lamp Y200 will
be turned on.
If there are 19 or less cars, turn on the empty car lamp Y201.
Please write this operation in the PLC program.
(Create in the program "EX24" in the project name "TEST2")

OceanofPDF.com
Exercises24 Answer

OceanofPDF.com
At the end
Thank you for reading to the end.

As with any programming, you can create a program, run the program,
repeat trial and error, and when you finally finish what you want to make,
you can feel the indescribable impression.

And repeating that is the fastest way to improve your skills.

By repeating the exercises in this book, you will acquire basic skills, but
after that, please think about your own tasks and what you want to do and
try programming.

「 I'm going to use it for work, so I want to learn about PLC programs! 」
「 There are many books on sequence control, but the PLC program is not
written in detail. 」
「 I read a book about PLC, but I don't feel like I can make a program just by
classroom lectures. 」
「 I'm studying a PLC program, but the content was boring and I was
frustrated on the way ... 」

I hope these people will read this book and find the PLC program fun.

I'm looking forward to the success of everyone who read this book in the
PLC industry!

OceanofPDF.com

You might also like