Basic PLC Programming For Beginners
Basic PLC Programming For Beginners
This book carefully explains how to create a PLC program used in the
manufacturing industry in an easy-to-understand manner.
「 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 ... 」
This book is created with three concepts. (The software uses the free trial
version.)
※ Even those that are not actually controlled by the PLC are taken up as
examples to make the explanation easier to understand.
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
OceanofPDF.com
1-2 Familiar example of using PLC
OceanofPDF.com
1-3 Most frequently used PLC
In addition, since we have factories all over the world, if we can program
PLC, we will be able to work at overseas factories.
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
Recently, Universal Studios Japan was looking for someone who could do a
PLC Program.
OceanofPDF.com
1-5 Major Japanese PLC manufacturers
OceanofPDF.com
1-6 Difference between PLC and personal computer
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.
OceanofPDF.com
1-1 ~ 1-6 Summaries
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.
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
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.
OceanofPDF.com
1-7 ~ 1-9 Summaries
OceanofPDF.com
1-10 Download GX Developer / GX Simulator
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 " 入力内容を確認する ".
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
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
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
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)
1. Open GX Developer.
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
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.
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.
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.
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.
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.
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.
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
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
To create a PLC program, you first need to understand the "device" that is
the component for creating a PLC program.
First, I will explain the "bit" of "bit device" and the "word" of "word
device".
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?
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)
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.
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.
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".
OceanofPDF.com
3-5 Summaries
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.
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".
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
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
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
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 )
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.
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
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)
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).
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
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.
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.
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.
・ 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.
This unit is 0.1 seconds, and T0 turns on when it remains on for 60 seconds
(1 minute).
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.
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.
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.
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)
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).
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.
OceanofPDF.com
This time, C0 is reset 5 seconds after the dehydration start command Y61 is
turned on.
OceanofPDF.com
5-4 Summaries
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)
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")
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.
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")
OceanofPDF.com
When you press the 2CH button X72, 2 enters D10 and Y72 turns ON.
OceanofPDF.com
5-5 Summaries
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.
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.
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.
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
"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
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."
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.
OceanofPDF.com
This program is a program in which the start button X45 of the microwave
oven is used as the "rising pulse contact".
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".
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.
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.
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)
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.
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
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".
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.
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
So far, we have only explained contacts and coils, but from now on, we will
explain "command words".
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
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.
OceanofPDF.com
7-1 Summaries
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)
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).
OceanofPDF.com
No amount entered 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)
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.
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.
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
OceanofPDF.com
Exercises17 ( Backup of sphygmomanometer data )
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 (+,-, *, /).
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
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)
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.
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.
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
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 (=, <>, <, <=,>,>
=).
=、 <>
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.
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.
To write "> =", press F8, enter "> = D170 K50", press "OK", enter a
comment for D170, and then press "OK" to reflect it in the program.
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.
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
OceanofPDF.com
Exercises23 ( Blood pressure normal / abnormal judgment )
OceanofPDF.com
Exercises23 Answer
OceanofPDF.com
7-5 Increment instruction / decrement instruction
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.
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
"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
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.
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