This document provides examples of ladder logic programming for basic PLC applications. It includes examples for priority determination in a game show buzzer circuit, on/off delay circuits, counting, timing, and a packaging line control application. Diagrams show the I/O assignments, timing diagrams, and ladder logic networks for each example. Instructions include LD, OR, AND, NOT, TIM, CNT, and OUT.
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 ratings0% found this document useful (0 votes)
3K views68 pages
PLCBeginnerguide110 177
This document provides examples of ladder logic programming for basic PLC applications. It includes examples for priority determination in a game show buzzer circuit, on/off delay circuits, counting, timing, and a packaging line control application. Diagrams show the I/O assignments, timing diagrams, and ladder logic networks for each example. Instructions include LD, OR, AND, NOT, TIM, CNT, and OUT.
By Using SYSWIN Programming SoItware, the design oI the buzzer control ladder diagram is shown as Iollow.
Host Player 1 Player 2 Player 3 Buzzer 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-21
Ladder Diagram . Main 1 Network 1
Main 1 F Who press Iirst (Priority Determination) This prigram to determine which player press the switch Iirst, aIter the host have Iinish asking a question.
Network 1 F Interlocked Interlocked network Ior the 3 player playing the game.
.
Network 2 F Buzzer ON Buzzer when any switch is pressed and timer will cut the buzzer aIter speciIied time
TIM 000 #0100
Network 3 F Player 1 Player 1 Network
Network 4 F player 2 Player 2 Network
Network 5 F Player 3 Player 3 Network
Network 6 F Reset Reset Ior the Game
Network 7
PB1 PLAYER 2 PLAYER 3 RST 005.00 010.00 BUZZER 000.00 010.02 010.03 000.03 PLAYER 1 010.01 010.01 PLAYER 1 PB2 PLAYER 1 PLAYER 3 RST 000.01 010.01 010.03 000.03 PLAYER 2 010.02 010.02 PLAYER 2 PB3 PLAYER 1 PLAYER 2 RST 000.02 010.01 010.02 000.03 PLAYER 3 010.03 010.03 PLAYER 3 005.01 RESET 000.03 RST END(01) 005.00 000.00 010.02 010.03 005.01 TIM000 000.01 PB1 PLAYER 2 010.01 010.03 010.01 010.02 000.02 PLAYER 3 PLAYER 3 PLAYER 2 RESET PB3 PB2 PLAYER 1 PLAYER 1 005.00 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-22
Y On and Off Delay Circuit
This circuit is used to delay the ON/OFF time oI an input signal Ior a given time.
Note : The timerIs present value can be monitored Irom the programming console by pressing.
To change the timer value
Set the mode selector switch to MONITOR
1)
2)
3)
Off delay circuit
TIM0 #25
TIM1 #25
CLR TIM MONTR A 0 MONTR SHIFT CONT 00000 01000 Input and output status can also be monitored by pressing. CLR TIM A 0 D 3 F 5 WRITE 0001 READ OFF TIM 000 0001 TIM DATA #0050 #???? CHG SRCH 0001 TIM DATA #0050 One-shot Circuit Note how similar they are OII-delay Circuit 1000 1001 1 1 TIM1 1001 TIM0 1000 0 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-24
Y Counter
CNT (counter) is a preset decremental counter. That is, itdecrements one count everytime an input signal goes Irom PFF to ON. The counter must be programmed with a count input, a reset input, a counter number and a set valie (SV) can range Irom 0000 to 9999.
Note : The counter number must not be duplicated with the timer number since both share the same data area within the PLC memory. The counter,s present value can be monitored Irom the programming console by pressing.
To change the counter value
Set the mode selector switch to MONITOR
1
2)
3)
*Timer/Counter value can also be changed via SYSWIN SoItware CP CNT 001 R 01002 END 00000 00002 CNT 001 Count Input Reset 10 counts CLR CNT MONTR MONTR B 1 SHIFT CONT 00000 01002 Input and output status can also be monitored by pressing. CLR CNT B 1 C 2 WRITE 0001 READ OFF CNT 001 0001 CNT DATA #0010 #???? CHG SRCH 0001 CNT DATA #0010 0 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-25
Use of CNT and TIM instructions
Example #1: Count to 20,000 counts
Address Instruction Data 00000 LD 00000 00001 AND 00001 00002 LD-NOT TIM 000 00003 OR CNT 001 00004 CNT 001 #0100 00005 LD CNT001 00006 LD-NOT 00000 00007 CNT 002 #0200 00008 LD CNT002 00009 OUT 01000 00010 END(01)
Example #2: Prolong time range to 1,000 hours
Address Instruction Data 00000 LD 00000 00001 AND-NOT TIM 001 00002 TIM 001 #6000 00003 LD TIM001 00004 LD 00001 00005 CNT 002 #6000 00006 LD CNT 002 00007 OUT 01000
Example : #3 Ladder diagram . Main 1 Network 1 Main 1 . Flicker Output This program makes output IR 01000 Ilicker ON/OFF (one second ON, one second OFF) ten times aIter input IR 00000 i s turned ON. Network 1 . SelI holding
Network 2 . 1 second timer
TIM 001 Timer 1 #0010
Network 3 . 2 second timer
TIM 002 Timer 2 #0020
Network 4 . Counter Preset Counter at 10
Network 5 . Flicker Output Flicker Ior 10 times
Network 6 - End
000.00 Start CNT000 Counter Hold 200.00 200.00 Hold Hold Timer 2 200.00 TIM002 200.00 TIM002 Timer 2 Hold 200.00 TIM001 CNT
000 Counter
#0010 Hold 200.00 Hold 200.00 TIM001 Flicker 010.00 Hold Timer 1 END(01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-27
The mnemonic list Ior the example program is shown in the 000 Iollowing table. Address Instruction Data Remarks 00000 LR 00000 00001 OR 20000 00002 AND NOT CNT 000 00003 OUT 20000 (1) SelI-holding bit 00004 LD 20000 00005 AND NOT TIM 002 00006 TIM 001 # 0010 (2) 1-second timer 00007 LD 20000 00008 AND NOT TIM 002 00009 TIM 002 # 0020 (3) 2-second timer 00010 LD 20000 00011 AND NOT TIM 001 00012 LD NOT 20000 00013 CNT 000 # 0010 (4) 10-count counter 00014 LD 20000 00015 AND NOT TIM 001 00016 OUT 01000 (5) Flicker output (10 counts) 00017 END(01) --- (6) END (001) instruction
6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-28
Y Example : Packaging Line Control
6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-29
Y Operation When PB1 (START Push Botton) is pressed, the box conveyor moves. Upon detection oI box present, the box conveyor stops and the Apple conveyor starts. Part sensor will count Ior 10 apples. Apple conveyor stops and box conveyor starts again. Counter will be reset and operation repeats until PB2 (STOP Push Button) is pressed.
Ladder diagram . Main 1 Network 1 Main 1 . Packaging Packaging line control Ior Apples Network 1 . Start condition
30
Network 2 . Apple conveyor
Network 3 . Counter Counter preset at 10
Network 4 . Box conveyor
Network 5 - END
Address Instruction Data Address instruction Data 0000 LD 00000 0008 LD NOT 00003 0001 OR 20000 0009 CNT 010 0002 AND NOT 00001 #0010 0003 OUT 20000 0010 LD CNT 010 0004 LD 20000 0011 OR NOT 00003 0005 AND NOT 01001 0012 AND 20000 0006 OUT 01000 0013 OUT 01001 0007 LD 00002
0014 END (01)
200.00 000.01 RUN 200.00 RUN 010.00 CONVYR 200.00 RUN PB2 000.00 PB1 CNT
010
#0010 000.02 SE1 010.01 Boxcon RUN 200.00 CNT010 010.01 BoxCon 000.03 SE2 000.03 SE2 END (01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-31
Y Application #3 : Control Circuit For Packaging Machine
The control circuit is used to detect and count the number oI products being carried on an assembly line. When it counts Iive products, the circuit energizes a solenoid. The solenoid is energized Ior a period oI two seconds and is then shunt oII, causing it to retract.
Others CNT 047 Product counter TIM 000 Solenoid energizer timer
Solenoid Sensor Conveyor 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-32
Question: Fill in the gaps below to make this circuit operate. S CNT 047 # R TIM 000 #0020 CNT 047 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-33 Application #4 : Drilling Control Operation
I/O Assignments
Input Device Output Device 00000 Auto Switch 1000 Auto Indicator 00001 Manual 1001 Manual Indicator 00002 Forward Switch (SW1) 1002 Motor Forward 00003 Stop Switch (SW2) 1003 Motor Reverse 00004 Reverse Switch (SW3) 1004 Auto Start Indicator 00005 Limit Switch (LS1) 00006 Limit Switch (LS2) 00007 Auto Start Button (PBS)
Procedure 1. Manual Operation 1.1 When SW1 is ON, Motor moves Iorward. It can be stopped by SW2. When the drill touches LS2, the Motor is cut-oII. 1.2 When SW3 is ON, Motor moves in reverse. It can be stopped by SW2. When he drill touches LS1, the Motor is cut-oII.
2. Auto-cycle 2.1 When PB and LS1 is ON, the Motor moves Iorward until LS2 is activated. The Timer then starts timing down. The Motor reverses when the timer reaches 2 seconds. When it returns to LS1 position, the cycle is repeated.
Auto Manual Forward Reverse Auto Start Stop (1003) Motor Reverse (1002) Motor Forward Manual Auto Auto-start Control Panel Indication Box LS1 (5) LS2 (6) (7) PBS 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-34 Answer Ladder diagram . Main 1 Network 1 Main 1 . Drilling Control Drilling control operation Network 1 . Manual indication
KEEP is used as a latch. It maintains an ON or OFF state oI a bit until one oI its two inputs sets or resets it. II the KEEP Iunction is used together with a HR relay, the state oI the latched output is retained even during a power Iailure.
DIFU and DIFD turns an output ON Ior one scan only. DIFU turns its output ON when it detects an OFF - ON transistion in its input signal. DIFD turns its output ON when it detects an ON - OFF transistion in its input signal.
Input
DIFU
DIFD
00000 00001 KEEP(11) 10000 END(01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-37 Application #5: Filling/Draining Control Operation
Procedure 1. As the PB1 is pressed, MV1 opens and the water begins to Iill the tank. At the same time, the stirring motor M starts operations. 2. When the water level passes TLB2 and reaches TLB1, the MV1 closes and the stirring motor stops. 3. Next, MV2 opens and starts draining the water. When the water levels drops below TLB2, MV2 closes. 4. When the cycle oI operation has repeated Iour times, the operation END indicator illuminates, and the Iilling and draining operation will not restart even iI PB1 is pressed.
PB1 (0) START STOP RESET END BUZZER PB2 (1) PB3 (2) PL (1004) BZ (1005) Control Panel M MV 1 MV 2 TLB1 (5) TLB2 (6) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-38 Ladder diagram . Main 1 Network 1 Main 1 . Fill / Draining Filling / Draining control operation Network 1 . Start condition
ShiIt Register (SFT) shiIts a 16-bit data in speciIied channel by 1 bit. Although this instruction shiIts data within channels, both a start channel and an end channel must be speciIied as the data.
Address Instruction Data 0000 LD 00002 0001 AND NOT 00003 0002 LD 00004 0003 LD 00005 0004 SFT(10) 200 200 0005 LD 20000 0006 OUT 1000 0003 END(01)
Note : When a reset input is applied to the ShiIt Register, all 16 bits are reset together. II the Holding Relay area is used, the data are retained during power Iailure.
SFT(10) S E I/O, Internal auxiliary Relay Holding Relay Ladder diagram Operand Data Areas IN CP R 00 01 02 15 Start CH End CH 00 01 02 15 00 01 02 15 Example circuit Ladder Diagram Mnemonic code
SFT(10) 200
200 00002 00003 00004 00005 20000 1000 End(01) Data Input Clock Pulse Reset 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-41 Application #6: Overhead Crane Control of Degreasing Operation
In this application, the part needs to be degreased in the degreasing tank beIore being passed to the next section.
When the PB1 is pressed, the roller will coil up the hook until the up-sensor (S3). The hook will then transverse leIt (via 01001) until it reaches the S4 position.
It will then stop and lower the product into the degreasing tank. When it reaches down to S2, the product will stay in the degreasing tank Ior 20 seconds. AIter the time is up, the product is liIted up and transverse leIt until S5 position and stop. It continue to come down. Until the down position, where the Buzzer will sound. The operator will collect the product and press the PB2 to return the crane back to the home position.
(S1) (S4) (S5) Degreasing Tanks Up Sensor (S3) 4 Down Sensor (S2) 3 Roller PB1 (Start) (0) PB2 (1) Buzzer (1004) Left (1001) Right (1003) Operator Operator Up (1000) Down (1002) (07) Reset Stop Button (8) 6 5 2 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-42 At anytime, the Stop Push Button can stop the crane Irom moving. Upon release, it will continue Irom where it stops. The Reset Push Button is used when you want to start over again Irom the beginning.
I/O Assignment
Input Device Output Device 00000 PB1 (Start button) 01000 Up motor 00001 PB2 (Return button) 01001 LeIt motor 00002 S1 (Sensor 1) 01002 Down motor 00003 S2 (Down sensor) 01003 Right motor 00004 S3 (Up sensor) 01004 Buzzer 00005 S4 (Degrease sensor) 00006 S5 (End sensor) 00007 RST (Reset button) 00008 Stop (Stop button latch)
6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-43 Ladder diagram . Main 1 Network 1 Main 1 . Program Ior degreasing tank Network 1 . Start Start operation
Network 2 . Set 1st bit on Set 1st bit oI HR 00 on
Network 3 . ShiIt Register
Network 4 . ShiIt operation The shiIt register clock input to control the sequence oI operation
IL(02) 000 08 Stop HR00.00 010.00 HR00.03 HR00.06 UP_ MOTOR UP1 UP2 UP3 HR00.01 010.00 HR00.04 LEFT_ MOTOR LEFT1 LEFT2 HR00.02 010.02 HR00.05 DOWN_ MOTOR DOWN1 DOWN2 HR00.08 DOWN3 TIM 000 #0200 HR00.02 DOWN1 HR00.05 DOWN2 S2 000.03 010.04 Buzzer HR00.07 RIGHT 010.03 FWD MOTOR ILC(03) END(01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-45 Application #7: Parts Sorting
In this application, eIIective products are detected and rejected Irom those being carried on the conveyor.
Photoelectric sensor (PH1) serves as the data input to the shiIt register. The signal output Irom this sensor turns ON when a deIective product has been detected, otherwise it remains OFF.
Photoelectric sensor (PH2) is used as a clock generator that serves as the clock input to the shiIt register. It generates one pulse each time the product, spaced at a Iixed interval Irom each other, has traveled a predetermined distance.
From the moment a deIective product is detected by PH1, it is traced by the shiIt register until the product arrives at the predetermined position on the conveyor where it is ejected by the magnetic valve MV.
SFT HR00 HR00 ShiIt Register 00002 00003 PH1 PH 01000 MV Valve open Ior deIective part END (01) 25314 HR0004 0000 0004 0006 Ladder diagram Mnemonic codes 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-47 Application #8: Robot Movement Control
This kind oI robot is seen in many automated Iactories. As is apparent Irom the Iigure, this robot picks up a work being carried on conveyor A and places it on conveyor B.
The operations and conditions are as Iollows. 1. When the start button is pressed, the robot rotates its arm clockwise. 2. When the robot arm has moved to the position oI the work on the conveyor A, arm grasps the work. 3. When the arm has grasped the work, it rotates counterclockwise. 4. When the arm has rotated to the position oI conveyor B, it releases the work.
Output Devices 1000 Sol 1 (clockwise rotation) 1001 Sol 2 (counterclockwise rotation) 1002 Sol 3 (grasping work) 1003 Conveyor A
Start Button Pressed? Arm at LS1? Arm rotates Clockwise No Conveyor A ON Photo eye sense workpiece? Conveyor A OFF Arm grasp work Arm rotates Counterclockwise Arm at LS2? Release workpiece Is LS3 OFF? No No Yes Yes Yes Yes Yes Yes Is LS3 ON? No No No 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-49 Ladder diagram . Main 1 Network 1 Main 1 . Robot control This program demonstrates that the Robot picks up a work piece Irom conveyor A and places it on conveyor B. Network 1 . Start condition
Network 2 . Start
Network 3 . Set 1st bit on Set 1st bit oI HR 00 on
Network 4 - ShiIt register
Network 5 . Clock input Clock input to shiIt register to control sequence oI operation
When the start button is pushed, the motor (M) will move Irom leIt to right. When LS2 is ON, the Motor stops, delay Ior 5 seconds and then moves back to Home. When LS1 (Home) is ON, Motor cuts oII, signiIying that the sequence is completed.
LS1 (1) Stop PB 0 Start PB (3) LS1 (2) M HOME 1000 (Motor Right) 1001 (Motor LeIt) 1000 TIM0 #50 1001 Motor (Right) 5 sec Delay Motor (LeIt) 1000 1 2 1 2 Start PB LS2 3 LS2 LS1 TIM0 1001 LS1 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-52 Example : PBC Packing Conveyor
In this application, a liIter motor is used to liIt a tray oI PCB boards up, beIore being pushed by the piston onto the conveyor Ior packing.
When the start button is pressed, the conveyor motor and the liIter motor will turn on. The proximity switch will temporarily stop the liIter motor Ior the piston to push the PCB onto the conveyor belt.
AIter the PCB is pushed, the piston will retract and the liIter motor starts again. The whole procedure will repeat itselI thereaIter. Start (0) Stop (1) RST (5) RS2 (3) RS1 (2) Proximity switch (4) Limit Switch (6) LiIter motor Up (1001) Down (1004) Tray Conveyor motor (1000) Piston 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-53 When all the PCBs have been pushed onto the conveyor belt, the liIter motor will move down until the limit switch (LSW) is being activated. ThereaIter, the whole procedure can only be started by the start switch.
I/O Assignment
Input Device Output Device 00000 Start Push Button 01000 Conveyor motor 00001 Stop Push Button 01001 Up LiIter motor 00002 RS1 (LeIt Limit) 01002 Right piston 00003 RS2 (Right Limit) 01003 LeIt piston 00004 Proximity Switch 01004 Down liIter motor 00005 Reset 00006 Limit Switch
6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-54 Ladder diagram . Main 1 Network 1 Main1 . PCB packing conveyor program utilising (Conventional method) Network 1 . Start / Stop control
Network 2 . LeIt limit LeIt limit reached Ior piston
Network 3 . LiIter up LiIter motor up
Network 4 . Index switch Proximity switch detect the next index oI PCB
Network 5 . LiIter up LiIt the PCB up one aIter another
#0020 Reset CNT001 HR00.00 010.01 LiIterup HR00.01 010.02 Pistonright HR00.02 010.03 PistonleIt HR00.04 010.04 LiIterdown End (01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-58 Y Application #10: Automatic Control Of Warehouse Door
The input ultrasonic switch is employed to detect the presence oI an approaching vehicle. A separate photosensor detects the passing oI a vehicle via the interruption oI the light beam. In response to these signals, the control circuit controls the outputs that drive the motor oI the door Ior opening and closing.
I/O Assignment
Input Devices Output Devices 00000 Ultrasonic switch 01000 Motor to raise door 00001 Photoelectric switch 01001 Motor to lower door 00002 Door upper limit switch 00003 Door lower limit switch
Door position Motor Ultrasonic Pushbutton Switch Photoelectric Switch CPM2A 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-59
Ladder diagram . Main 1 Network 1 Main 1 . Autodoor This program shows the automatic control oI warehouse door Network 1 . Raise door
Network 2 . Photosensor Sense until diIIerentiation down
Network 3 . Lower door
Network 4 . End
UpperLS Raisedoor 000.00 000.02 010.01 010.00 010.00 Ultraswitch Raisedoor Lowerdoor 000.01 DIFD(14) 200.00 Photosensor LowerLS Lowerdoor 200.00 000.03 010.00 010.01 010.01 Lowerdoor Raisedoor End (01) Timing diagram 00000 Ultrasonic switch 00002 Upper limit switch 10000 Motor to raise door 00001 Photoelectric switch 04000 DIFD 00003 Lower limit switch 10001 Motor to lower door 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-60 Y Application #11: Automatic Lubrication of Gear
When the gear is moved towards S1, the sensor S1 will detect the gear and signal the electromagnetic valve Ior oil supply on the gear. The valve (V1) will open Ior a short period oI time, supplying a predetermined quantity oI oil. When sensor S2 sense that the lubricating tank oil level is low, the oil shortage alarm indicator will be ON.
S2 (1) V1 (1000) Lubricating Oil Tank Oil shortage alarm indicator S1 (0) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-61 Ladder Diagram . Main 1 Network 1 Main 1 . Auto lubricate Auto lubricate oI gear Network 1 . Start
Network 2 . Open valve Open valve and delay 1.5 sec
Network 3 . Oil shortage
Network 4 . End
000.00 DIFU(13) 200.00 Positiondet Valveclose Valveopens 200.00 TIM000 010.00 010.01 Valveopens TIM 000 Valveclose #0015 000.01 010.01 Oilshortage Lowerlevel End (01) 1 scan time 1.5 sec 00000 04000 10000 TIM 000 00001 10001 Position detection DIFU Valve Opens Timer1s preset time Lower limit oI oil level Oil shortage alarm indicator Timing diagram 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-62 Y Application #12: Conveyor Belt Motor Control
In this application, the PLC is used to start and stop the motors oI a segmented conveyor belt. This allows only belt sections carrying an object (i.e. mental plate) to move. The position oI a mental plate is detected by a proximity switch located next to each belt segment. As long as the plate is within the detecting range oI the switch, the motor will work. II the plate moves beyond the range, a timer is activated and when this set time has lapsed, the motor oI that belt stops.
I/O Assignment
Input Devices Output Devices 00000 Sensor 1 01000 Motor 1 00001 Sensor 2 01001 Motor 2 00002 Sensor 3
01002 Motor 3
CPM2A Motor 3 (1002) Motor 2 Motor 1 (1000) Sensor 2 Sensor 3 Sensor 1 Copper plate 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-63 Ladder diagram . Main 1 Network 1 Main 1 . Conveyorcontrol Conveyor belt control application Network 1 . Motor2
Network 2 . Motor1
Network 3 . Delay Ior 2sec
Network 4 . Sensor1
Network 5 . Delay Ior 2sec
Network 6 . Motor3
Network 7 . End
Operation :
a) Motor 2 turns ON when Sensor 3 detects the product b) Motor 2 is ON until Motor 1 is turned ON and product is out oI detection range oI Sensor 2 c) Motor 1 turns ON when Sensor 2 detects the product d) Motor 1 is ON until product is out oI detection range oI Sensor 1
#0020 200.00 000.00 S1 253.13 010.02 Motor3 NC End (01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-64 Y Move . MOV(21)
MOV transIer source data (either the data in a speciIied channel or a Iour digit hexadecimal constant) to a destination channel. ThereIore, MOV requires two data parameters to be speciIied. the source channel or constant and the destination channel.
D IR, SR, AR, DM, HR, TC, LR, # IR, AR, DM, HR, LR S: Source channel D: Destination channel Operand Data Areas Ladder Symbols MOV(21) 000
200 25313 Example circuit Ladder diagram Source Destination 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-65 The Iollowing diagram illustrates the MOV operation.
In this case, data in Input Channel 000 is moved to Output Channel 200.
00000
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015 1
1
0
1
1
0
0
1
1
1
1
0
0
0
0
1 1
1
0
1
1
0
0
1
1
1
1
0
0
0
0
1 Channel 200 bit 00 to bit 15 Channel 000 bit 00 to bit 15 SOURCE INPUT CH 000 DESTINATION OUTPUT CH 200 Status Status 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-66 Y Application #13: Display Error Code Of Machine To Aid In Tracing The Source Of The Problem
1. Activation oI error input signal 00001 to 00004 will sound an alarm and at the same time display the error code. 2. Input 00005 serves to reset the error code displayed upon machine recovery.
010 000.05 Resetsw End (01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-69 Y Compare . CMP(20)
Compare (CMP) is used to compare the data in a speciIic channel, with the data in another channel, or a Iour-digit, hexadecimal constant. ThereIore, two data must be speciIied immediately aIter the CMP(20) instruction.
Address Instruction Data 0000 LD 25313 0001 OUT TR 0 0002 CMP(20) - #01F0 000 0003 AND 25505 0004 OUT 01000 0005 LD TR 0 0006 AND 25506 0007 OUT 01001 0008 LD TR 0 0009 AND 25507 0010 OUT 01002
CMP(20) Cp 1 Cp 2 IR, SR, AR, DM, HR, TC, LR, # IR, SR, AR, DM, HR, TC, LR, # Cp : First compare word Cp2 : Second compare word Operand Data Areas Ladder Symbols CMP(20) #01F0 000 25313 25505 () 25506 (=) 25507 (<) 01000 01001 01002 TR 0 Example circuit Ladder diagram 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-70
0
1
F
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
1
F
0
II the constant (#01F0) is GSWCN to Channel 000 data, special relay 25506 turns ON. However, special relay 25505 will turn ON iI the constant is ITGCVGT than Channel 000 data and special relay 25507 will turn ON iI the constant is NGUU than Channel 000 data. At any one time, only one result is true, either relay 25505() or 25506(=) or 25507(<) is ON.
The following diagram illustrates the CMP operation # DATA # Constant Compare with Channel 00015 00014 00013 00012 00011 00010 00009 00008 00007 00006 00005 00004 00003 00002 00001 00000
0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 CH 000 DATA 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-71 Y Example : A Time-out Warning
In this application, a 7-segment display & a buzzer is connected to the PLC. When the start button is pressed, the display will display a 9 and thereIore will decrement until 0 beIore the buzzer is being sound. These type oI circuit can be used as a warning circuit.
01000 01001 01002 01003 Display Buzzer (01005) Start (0) Stop (1) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-72 Ladder Diagram . Main 1 Network 1 Main 1 . Program to display 9 beIore decrement it to 0 Network 1 . Using the holding relay to decrement aIter every pulse
Network 2 . Move 9 Move 9 to channel 6
Network 3 . Timer To produce an ON/OFF pulse
Network 4 . Decrement Decrement every execution
Network 5 . Compare the o/p with 0, iI equal (25506 on) output 00500 turn on
Address Instruction Data 00000 LD 00000 00001 LD 01005 OR 1 00002 KEEP(11) HR 0100 00003 LD HR 0100 00004 gMOV(21) # 0009 6 00005 LD 25313 00006 AND NOT TIM 001 00007 TIM 1 #0012 00008 LD HR 0100 00009 AND TIM 1 00010 gDEC(39) 6 00011 LD 25313 00012 OUT TR 0 00013 AND HR 0100 00014 CMP(20) 6 # 0000 00015 LD TR 0 00016 AND 25506 00017 OUT 00500 00018 LD 00500 00019 OR 01005 00020 AND NOT TIM 0 00021 AND NOT 1 00022 OUT 01005 00023 LD 00500 00024 OR 00501 00025 OUT TR 0 00026 AND NOT 1 00027 AND NOT TIM 000 00028 OUT 00501 00029 LD TR 0 TIM 000 00030 # 0050 00031 LD 00001 00032 OR TIM 000 00033 MOV(21) # 0000 6 00034 LD 600 00035 OUT 1000 00036 LD 601 00037 OUT 1001 00038 LD 602 00039 OUT 1002 00040 LD 603 00041 OUT 1003 00042 END(01)
<<< Program to Display 9 before Decrement it to 0>>> Comment Comment Statement Start Pb Clk Pulse STOP PB Holding Relay Move 9 to Decrement o/p every clk Compare the o/p with Condition meet ON bit On BUZZER Timer to cut the buzzer RESET CH 1 2 4 8 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-75 Add . ADD(30)
ADD totals the data in two diIIerent channels, or one channel and a constant and then outputs the sum to a third channel. ThereIore, three data parameters must be speciIied . an augend, an addend and a result channel.
R IR, SR, AR, DM, HR, TC, LR, # IR, SR, AR, DM, HR, TC, LR, # Au: Augend channel Ad: Addend channel Operand Data Areas Ladder Symbols IR, AR, DM, HR, LR R: Result channel Example circuit Ladder diagram ADD(30) HR04 #1234 200 00000 CLC(41) Augend Addend Result 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-76 In the program, when input 00000 is turned ON, the data in internal relay HR040 is added to the constant 1234. The result oI the addition is output to CH 200. II a carry is generated as a result oI the addition, the carry Ilag (special relay 25504) is turned ON. II the result oI the addition is 0000, special relay 25506 (the K=L Ilag) is turned ON.
The Iollowing diagram illustrates the ADD operation.
In the above example, beIore executing ADD, the Carry Flag/CY (special relay 25504) is turned OFF by the Clear Carry (CLC). The addition and subtraction instructions include CY in the calculation as well as in the result. Be sure to clear CY iI its previous status is not required in the calculation, and to use the result placed in CY, iI required, beIore it is changed by execution oI any other instruction.
The augend and addend must be in BCD, iI not special relay 25503 (Error Flag) is turned ON and ADD is not executed.
ADD is executed each time the CPU scans the program. To execute it only once.
SUB Iinds the diIIerence between the data in one channel and the data in another channel or a constant, and then outputs the result to a third channel. ThereIore, three data must be speciIied . an minuend, an subtrahend and a result channel.
In the above example, beIore executing SUB, the Carry Flag (special relay 25504) is turned OFF by the Clear Carry (CLC). The addition and subtraction instructions include CY in the calculation as well as in the result. Be sure to clear CY iI its previous status is not required in the calculation, and to use the result placed in CY, iI required, beIore it is changed by execution oI any other instruction.
The minuend and subtrahend must be in BCD, iI not special relay 25503 (Error Flag) is turned ON and ADD is not executed.
SUB is executed each time the CPU scans the program. To execute it only once.
SUB(31)
Mi
Su
R IR, SR, AR, DM, HR, TC, LR, # IR, SR, AR, DM, HR, TC, LR, # Mi: Minuend channel Su: Subtrahend channel Operand Data Areas Ladder Symbols IR, AR, DM, HR, LR R: Result channel Example circuit Ladder diagram SUB(31) HR04 #1234 200 00000 CLC(41) Minuend Subtrahend Result 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-78 Application #14: Measuring The Life Of A Cutting Knife
A kniIe is used to cut 3 products A, B and C and has to be changed aIter cutting 1000 pieces oI A or 500 pieces oI B or 100 pieces oI C. but the products come at random. A buzzer is sound when the liIe oI the kniIe is up.
3 sensors are assign to diIIerentiate the 3 products. Another sensor is used to signal cutting completion. A pushbutton to start the process.
I/O Assignment
Input Device Output Device 00000 Cutter Sensor 01000 Buzzer 00001 Product A 01001 Cutter (KniIe) 00002 Product B 00003 Product C 00004 Start pushbutton 00005 Reset
Product A, B or C Knife (1001) Cutting Machine Start Push-button (4) Reset Push-button (5) Buzzer (1000) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-79
Address Instruction Data 0000 LD 20000 0001 OR 01001 0002 AND NOT 00000 0003 OUT 01001 0004 LD 00004 0005 DIFU(13) 20000 0006 LD 20000 0007 AND 00001 0008 CLC(41) 0009 ADD(30) HR00 #0001 HR00 0010 LD 20000 0011 AND 00002 0012 CLC(41) 0013 ADD(30) HR00 #0002 HR00 0014 LD 20000 0015 AND 00003 0016 CLC(41) 0017 ADD(30) HR00 #0010 HR00
Start 200.00 000.00 010.01 010.01 Cutter Cutsensor Cutter Ladder Diagram . Main 1 Network 1 Main 1 F KniIe liIt Application . Measuring the liIe oI a cutting liIe Network 1 F Cutter Cutter activation Network 2 F Cutter Cutter start pushbutton DIFU(13) 200.00 Start 000.04 Startpb Network 3 F Add 1 ADD(30) HR00 add2 #0001 HR00 add 2 200.00 000.01 ProductA Start CLC(41) Network 4 F Add 2 200.00 000.02 CLC(41) ADD(30) HR00 add2 #0002 HR00 add 2 ProductB Start Network 5 F Add 10 200.00 000.03 CLC(41) ProductC Start ADD(30) HR00 add2 #0010 HR00 add 2 Mnemonic codes 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-80
Address Instruction Data 0015 LD 25313 0016 OUT TR 0 0017 CMP(20) - #1000 HR00 0018 AND 25506 019 OUT 20001 0020 LD TR 0 0021 AND 25507 0022 OUT 20002 0023 LD 20001 0024 OR 20002 0025 OUT 01000 0026 LD 00005 0027 MOV(21) - # 0000 HR00 0028 END(01)
Network 6 F Compare 253.13 255.06 =Flag NC CPM(20) #1000 HR00 add2 255.07 <Flag 200.01 200.02 Network 7 F Buzzer 200.01 200.02 010.00 Cutter Network 8 F Reset 000.05 Reset MOV(21) #0000 HR00 add2 Network 9 F End End (01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-81
Application #15: Car Park Control
This is a simple car park control system that allows only a maximum oI 100 cars parking space. Everytime a car comes in, the PLC will automatically add one through sensor S1. Any car that goes out will automatically be subtracted by one through sensor S2. When 100 cars are registered, the car park Iull sign will be lighted to inIorm oncoming vehicles not to enter.
Ladder Diagram . Main 1 Network 1 Main 1 F Carpark control Application . Car Park Control Network 1 F Car in Mnemonic codes 000.00 S1 DIFU(13) 200.00 Carin Network 2 F Add 1 200.00 CLC(41) Carin ADD(30) HR00 #0001 HR00 Network 3 F Car out 000.01 S2 DIFU(13) 200.01 Carout Network 4 F Subtract 1 200.01 CLC(41) S2 SUB(31) HR00 #0001 HR00 Network 5 F Compare 253.13 255.06 =Flag NC CPM(20) HR00 #0100 255.05 Flag 010.00 CarparkIull Network 6 F End End (01) 6. APPLICATION EXAMPLES OF BASIC COMMANDS 6-83
Example: Ball Sorter Mechanism
In this application, the system is to sort out the black & white balls into 2 diIIerent container.
The start button will start the operation, Ball sensor (S1) will sense the presence oI the ball in the hopper. The top solenoid will release the ball Ior the colour sensor (S2) to diIIerentiate the colour beIore being release into the container.