PLC Application Exercise - LD
PLC Application Exercise - LD
Application
Exercises
1. Basic Program Design Examples
Y0
X1
X0
Control Purpose:
Detecting the standing bottles on the conveyor and pushing the fallen bottles out
Devices:
Device Function
Program Description:
If the bottle on the conveyor belt is upstanding, the input signal from monitoring photocell at both
bottle-bottom and bottle-neck will be detected. In this case, X0 = ON, and X1 = ON. The normally
open (NO) contact X0 will be activated as well as the normally closed (NC) contact X1. Y0 remains
OFF and pneumatic pushing pole will not perform any action.
If the bottle from the conveyor belt is down, only the input signal from monitoring photocell at the
bottle-bottom will be detected. In this case, X0 = ON, X1 = OFF. The state of output YO will be ON
because the NO contact X0 activates and the NC contact X1 remains OFF. The pneumatic pushing
pole will push the fallen bottle out of the conveyor belt.
Y0 X1
X0
Control Purpose:
Setting up a lighting system for users to switch on/off the light whether they are at the bottom or
the top of the stairs.
Devices:
Device Function
Program Description:
If the states of the bottom switch and the top switch are the same, both ON or OFF, the light will
be ON. If different, one is ON and the other is OFF, the light will be OFF.
When the light is OFF, users can turn on the light by changing the state of either top switch at the
bottom switch of the stairs. Likewise, when the light is ON, users can turn off the light by
changing the state of one of the two switches..
Control Purpose:
Creating a pulse of one program scan cycle as the condition to trigger the indicator or other devices
when the switch (X0) is turned on.
X0
M10
Y0
Devices:
Device Function
X0 Switch )
M10 Creating a trigger pulse for one program scan cycle
Y0 Indicator
Control Program:
Program Description:
When X0 is turned on (Rising-edge triggered), PLS instruction will be executed, and M10 will
When M10 = ON, [SET Y0] instruction will be executed and Y0 will be ON. In this case, the
X0 Y0(Electromagnetic valve )
Control Purpose:
Creating a pulse of one program scan cycle as the condition to trigger the electromagnetic valve or
other devices when the switch is turned off.
X0
M10
Devices:
Device Function
X0
M10 Creating a trigger pulse for one program scan cycle
Y0 Electromagnetic valve
Control Program:
Program Description:
When X0 is turned on (Falling-edge triggered), PLF instruction will be executed, and M10
will send a pulse for one program scan cycle.
When M10 = ON, [RST Y0] instruction will be executed and Y0 will be OFF. In this case, the
electromagnetic valve will be shut down.
Y0
X0
START
X1
STOP
X2
TEST
Control Purpose:
Controlling the running state of the ceiling-fan by pressing START and STOP.
Checking if the ceiling-fan is running normally by pressing TEST.
Devices:
Device Function
Control Program:
Program Description:
Press START lightly and X0 = ON. The ceiling-fan will keep running if no error occurred (X3
= OFF). The action can be practiced by a latching circuit which takes output Y1 as one of the
input condition to keep the fan running even if the START button is not pressed.
When STOP is pressed, X1 = ON and Y1 = OFF. The ceiling-fan will stop running.
If error occur (X3 = ON), Y1 will be OFF and the ceiling-fan will stop running.
When TEST is pressed (X2 = ON), Y1 = ON. The ceiling-fan will start running if no error
occurred (X3 = OFF). On the contrary, when TEST is released, the ceiling-fan will stop
running. The testing function is performed by this process.
Y1
Y0
X0 X1
Control Purpose:
The Entry/Exit of the parking lot is a single lane passage. By controlling the indicators, the program
ensures that only one car can pass through the Entry/Exit so as to prevent car accident between
entering and leaving cars
Devices:
Device Function
X0 Car entering sensor. When a car passes through the sensor, X0 = ON.
X1 Car leaving sensor. When a car passes through the sensor, X1 = ON.
Y0 Entering car indicator ON means “GO”, OFF means “STOP”
Y1 Leaving car indicator ON means “GO”, OFF means “STOP”
Control Program
Program Description:
In the parking lot, there are two indicators individually directing the entering and leaving cars.
By the interlock control circuit, only one indicator will show “GO” signal and the car accident
will thus be prevented.
When an entering car draws near the vehicle control barrier, X0 will be ON and so will Y0.
The entering car indicator will show “GO”. At the same time, the leaving car indicator will
show “STOP.” Car entering is allowed but leaving is prohibited in this case.
When a leaving car draws near the vehicle control barrier, X1 will be ON and so will Y1. The
leaving car indicator will show “GO” and the entering car indicator will show “STOP.”
X1
Initialization b utton
Control Purpose:
When the machine is powered up, all the parameters will be initialized automatically and the
machine will be ready. Users don’t need to set the parameters manually.
Users can initialize parameters by pressing Initialization button at any time when the
machine is running.
Devices:
Device Function
Program Description:
When PLC begins running, M1002 will be ON once and create a pulse with the width of one
scan cycle. This action will be executed for just once during the PLC running process and is
generally used to initialize devices such as D (data register), C (counter) and S (step point)
By pressing X1, users can initialize parameters at any time during the program running
process, that is, setting PLC Slave ID as No. 1, COM2 communication format as 9600, 7, E,
1 and Y0 to be ON.
Control Purpose:
Turn on the switch, the light will be ON; turn off the switch, the light will be OFF.
Devices:
Device Function
Control Program:
Program Description:
In the above examples, when X0 goes from OFF to ON, Y0 will stay in ON state. When X1
goes from OFF to ON, Y1 will stay in OFF state
When X0 and X1 are enabled at the same time, it will be “Stop First”, that is, Y1 and the
indicator will be OFF.
X0
START
X1
STOP
X2
Y0
Control Purpose:
Press START, the pump begins to pump out the water; press STOP or when the water is
empty, the pump stops working.
Devices:
Device Function
Program Description:
X2 will be ON If there is water in the container. When START is pressed, X0 = ON, and SET
instruction will be executed. Y0 will be set, and the pump motor begins pumping the water.
There are two situations for stopping the motor. First, when STOP is pressed, X1 = ON. PLS
instruction will be executed and M0 will be ON for one scan cycle. RST instruction will thus
be executed, and Y0 will be reset to stop pumping. Second, when the water in the
container is empty, X2 will be OFF and PLS instruction will be executed to trigger M0 for
resetting Y0. In this case, the pump motor will stop pumping as well.
Control Purpose:
Setting the light ON by pressing the switch for the 1st time, the 3rd time, 5th time, etc.; setting
the light OFF by pressing the switch for the 2nd time, 4th time, 6th time, etc.
Restoring the indicator to the state before power off when the device is powered up again.
Devices:
Device Function
Program Description:
Pressing X1 for the 1st time (or odd number of times):
When the switch X1 is pressed, X1 will be ON and the [PLS M10] instruction will be
executed for triggering M10 to be ON for one scan cycle. In this case, M10 is ON and Y1 is
OFF, SET and RST instructions at line 2 will thus be executed. On the contrary, SET and
RST instructions at line 3 will not be executed due to the open loop of Y1. At line 4, coil Y1 is
ON because of the results of Line 2: M512 is ON and M513 is OFF. When the 2nd scan cycle
is started, SET/RST at both line 2 and line 3 will not be executed because M10 is OFF in this
scan cycle. As a result, the light will be ON until the switch is pressed next time.
Pressing X1 for the 2nd time (or even number of times):
When the switch X1 is pressed again, X1 will be ON and M10 will be ON for one scan cycle.
According to the result of pressing X1 for the first time, the state of Y1 has been ON.
SET/RST instructions at line 3 will thus be executed. In addition, SET/RST instructions at
line 2 won’t be executed due to the open loop of Y1. In this case, M513 will be ON and M512
will be OFF. When the 2nd scan cycle is started, SET/RST at both line 2 and line 3 will not be
executed because M10 is OFF in this scan cycle. As a result, the light will remain OFF until
the switch is pressed next time.
Alternate output(ON/OFF) function can also be performed by using API 66 ALT instruction
Y0 X0 X2
START STOP
Main Motor
Y1
Main Motor
Control Purpose:
Providing lube for the gear box before the lathe spindle starts to run which aims to ensure
that the oil pump motor starts first and the main motor starts subsequently.
Devices:
Device Content
Program Description:
This program is a typical application of the conditional control circuit. Y0 = ON when Oil
Pump START button is pressed. Therefore, the oil pump will start to provide lube for the gear
box of main motor(Y1)
Under the precondition of the operating state of the Oil pump, the main motor (Y1) will be
ON when the Main motor START button is pressed.
During the operation of main motor (Y1), oil pump (Y0) needs to provide lube continuously.
The oil pump will be stopped when Oil pump STOP button X2 is activated, and the main
motor will be stopped when Main motor STOP button X3 is activated.
X0 Y0 X1 X2 Y1 X3 Y2 X4
Pupil Group High School Professor Group
Student Group
X5
Host
Control Purpose:
There are 3 groups participating in the quiz game: pupils, high school students and
professors. If they want to get the chance of answering the question from the host, they
must press the answer button on their table first. Other groups’ pressing will be invalid if any
group gets the chance successfully
There are 2 answer buttons for the pupil group and professor group and 1 answer button for
the high school student group. In order to give preferential treatment to the pupil group, Y0
will be ON if any one of X0 or X1 is pressed. However, in order to limit the professor group,
Y2 will be ON when X3 and X4 are pressed at the same time. For the high school student
group, Y1 will be ON when X2 is pressed.
If the host presses X5 (Reset button), Y0, Y1 and Y2 will be OFF.
Devices:
Device Function
Program Description:
If the host didn’t press the reset button X5, [MC N0] instruction will be executed and the
program between MC and MCR will also be executed normally.
The answer buttons are connected in parallel connection for the pupil group, and in series
connection for the professor group. For the high school student group, there is only one
answer button. If one group presses the answer button successfully, its indicator will form a
latching circuit, that is, the indicator will be ON even the button is released.
Through the interlock circuit, any other button pressings will be invalid as long as one
indicator is ON
When the host presses the reset button, X5 = ON. [MC N0] instruction and the program
between MC and MCR will not be executed. Y0, Y1 and Y2 will be out of power, and all the
indicators for the 3 groups will be OFF. When the host releases the button, X5 = OFF. The
program between MC and MCR will be executed normally again, and the new round will
begin as well.
Control Purpose:
There are 4 buttons corresponding to 4 indicators. The program is to turn on the indicators
corresponding to pressed buttons and to turn off the previous ON indicators.
Devices:
Device Function
Program Description:
When a button is pressed, the corresponding device X will go from OFF to ON. In this scan
cycle, PLS instruction is executed, and the corresponding internal relay M is enabled as well.
CMP instruction will be executed and the compared result is K1M0>0 which makes M10 ON
but M11 OFF. [MOV K1M0 K1Y0] instruction will then be executed and sent out the state of
M to its corresponding output Y. At the same time, the previous ON indicator(Y) will be
turned off.
When it comes to the 2nd scan cycle, PLS instructions will not be executed and the value of
M0~M3 will be 0. Therefore, the CMP instruction will be executed and set M11 to be ON
(K1M0 = 0). [MOV K1M0 K1Y0] instruction will not be executed, and the 0 state of device M
will not be sent out, either. In this case, Output Y will remain its original state until any other
button is pressed next time.
X1
Y1 Y2 Red Light Green Light
Y1 Y2
Entry/Exit of the Ground Floor X2
Control Purpose:
The entry/exit of the underground car park is a single lane passage which needs the traffic
lights to control the cars. Red lights prohibit cars entering or leaving while green lights allow
cars to enter or leave.
When a car enters the passage from the entry of the ground floor, the red lights both on the
ground floor and the basement will be ON, and the green lights will be OFF. Any car entering
or leaving is prohibited during the process till the car passes through the passage completely.
When the passage is clear, the green lights will be ON again and allow other cars entering
from the ground floor or the basement.
Similarly, when a car leaves the basement and enters the passage, any other car entering or
leaving is prohibited till the car passes from the passage to the ground completely.
When PLC runs, the initial setting of traffic lights will be green lights ON and red lights OFF.
Devices:
Device Function
X1 Photoelectric switch at the ground floor entry/exit. X1 will be ON when a car passes.
X2 Photoelectric switch at the basement entry/exit. X2 will be ON when a car passes.
M1 M1 will be ON for one scan cycle when a car from the ground floor passes X1.
M2 M2 will be ON for one scan cycle when a car from the basement passes X1.
M3 M3 will be ON for one scan cycle when a car from the basement passes X2.
M4 M4 will be ON for one scan cycle when a car from the ground floor passes X2
M20 M20 = ON during the process of a car entering the passage from the ground floor.
M30 M30 = ON during the process of a car entering the passage from the basement.
Y1 Red lights at the entry/exit of the ground floor and the basement
Y2 Green lights at the entry/exit of the ground floor and the basement
Control Program:
Program Description:
The ground floor and the basement share the same red light signal Y1 and green light signal
Y2.
The key of the program is to identify that the car is entering or leaving the passage at the
ground floor entry/exit when M1 is ON to activate Y1 because [PLS M1] will be executed in
both entering and leaving conditions. Therefore, the confirming signal M20 is required for
confirming that the car is entering the passage from the ground floor.
Also, it needs to identify that the car is entering or leaving the passage at the basement
entry/exit when M3 is ON because [PLS M3] will be executed in both entering and leaving
conditions. Therefore, the confirming signal M30 is required for confirming that the car is
entering the passage from the basement.
Forward
Forward
Reverse
Reverse Stop
Control Purpose:
Controlling the motor to run forward when Forward is pressed, run reverse when Reverse is
pressed and stop when Stop is pressed.
Devices:
Device Function
Control Program:
Program Description:
X0 = ON when Forward is pressed. After 1 second, contactor Y0 will be enabled, and the
motor begins to run forward. On the other hand, X1 = ON when Reverse is pressed. After 1
second, contactor Y1 will be enabled, and the motor begins to run reverse. Besides, Y0 and
Y1 will be disabled and the motor will stop running when X2 is pressed.
The two timers in the program are used to avoid the interphase short-circuit when the motor
changes its running mode. The short circuit may occur if another contactor is enabled
instantly while the electric arc in the disabled contactor still exists.
Green
X3 Yellow Blue
Y0 Y1
Yellow X1 X2 Blue
Color Selection
X0
Control Purpose:
There are pigments of 3 colors. By controlling different switches, operators can fill the cans
with corresponding pigments.
Devices:
Device Function
Control Program
Program Description:
The master switch of filling control needs to be turned on (X0 = ON) before filling started.
When both yellow and blue are filled at the same time, it will become green.
When the switch of filling yellow pigment is turned on, X1 = ON. The first MC ~ MCR
instruction will be executed. Y0 = ON, and the system begins to fill the yellow color.
When the switch of filling blue pigment is turned on, X2 = ON. The second MC ~ MCR
instruction will be executed. Y1 = ON, and the system begins to fill the blue color.
When the switch of filling green pigment is turned on, X3 = ON, both of the two MC ~ MCR
instructions will be executed, and the system begins to fill the green color.
X0 Clip
Auto
Transfer
X1
Manual Release
Conveyor A
Conveyor B
Control Purpose:
When the button Manual is pressed, the robotic arm will begin to execute the manual control
process: pressing Clip to clip the product from conveyor A, pressing Transfer to move the
product to the conveyor B, and pressing Release to release the product and send it away by
conveyor B.
When the button Auto is pressed, the robotic arm will begin to execute the auto control
process once: clip product (keep holding this product before releasing) transfer product
(the action takes 2 sec) release the product. Auto control process can be performed one
more time if the button Auto is pressed again.
Manual control process and auto control process are interlocked.
Devices:
Device Function
Control Program:
Program Description:
When X0 goes from OFF to ON, the auto control process will be executed once, whereas
when X1 goes from OFF to ON, the manual control process will be executed. In the manual
control, the clipping and releasing actions require pressing the corresponding button for one
time. However, the button Transfer should be pressed for 2 sec during the moving process
till the product is moved to Conveyor B.
X0 and X1 are interlocked. When the auto control process is executed, the robotic arm will
perform the following actions: first “clipping”, then “transferring” (for 2 sec.), and “releasing.”
When the manual control process is executed, the controlling actions will be performed by 3
corresponding buttons: clipping product by turning on Y0, transferring product by pressing
Y1 and releasing product by turning off Y0.