PLC Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

HUST PLC Editor

OPERATOR'S MANUAL

Version 1.0

October, 1994

HUST Automation Inc.


No. 80 Kon Yei Road, Toufen, Miaoli, Taiwan, R.O.C.
Tel: (037) 623242
Fax: (037) 623241
TABLE OF CONTENT

1 SYSTEM INTRODUCTION

1.1 PLC Introduction 1


1.2 CNC/PLC/Machine Tool Interface Description 1
1.3 PLC Signal Bits Description 2
1.4 PLC Editor Screen Description 2

2 PLC EDITOR OPERATION

2.1 PLC Editor System Startup 3


2.2 Editing Methods and The Keyboard Keys 3
2.2.1 Keyboard Keys For Editing 5
2.3 Function Keys For Editing (Edit Module) 6
2.3.1 "Ladder Edit" Function Keys 7
Insert, Delete, Find, Merge, End
2.3.2 "Element Edit" or "Component Edit" Function Keys 8
Horizontal Connecting Line, Vertical Connecting Line
Label, Jump
2.4 Compile Module 10
2.5 Print Module 10

3 DESCRIPTION OF LADDER COMPONENTS

Normal-Open Contact 11
Timer Normal-Open Contact 11
Counter Normal-Open Contact 11
Normal-Close Contact 11
Timer Normal-Close Contact 11
Counter Normal-Close Contact 12
Normal-Positive Relay Output 12
Normal-Negative Relay Output 12
Positively Trig. Relay Output 13
Negatively Trig. Relay Output 13
Arithmetic Addition 14
Arithmetic Subtraction 15
Arithmetic Multiplication 16
Arithmetic Division 17
Data MOVE 18
Compare 19
Logic AND 20
Logic OR 21
Logic XOR 22

i
Timer 23
Up Counter 24
Down Counter 25
Ring Up Counter 26
Ring Down Counter 27
Counter Setting 29
Ladder END 28

ii
HUST PLC Editor

1 SYSTEM INTRODUCTION

1.1 PLC Introduction

Ladder diagram is a sequential control chart for PLC (Programmable Logic


Controller), which is a part of HUST CNC system control. Its function is to process
the I/O signal flow between the CNC controller and the machine tool, thereby to
control the machine cutting actions in a sequential manner.

Ladder diagram, ladder, and PLC are all referring to the same thing -- PLC. A
standard PLC is an integral part of HUST CNC products but it can be edited to suit
the specific functional requirement of each individual machine. "PLC Editor" is an
optional PC software that HUST provides you to accomplish the PLC editing. This
manual describes the use of HUST's "PLC Editor".

HUST's PLC Editor provides the following functions which are shown at the
bottom of the first screen when you activate the PLC Editor.

1. EDIT (F1) -- To edit the ladder diagram


2. COMPile (F3) -- To produce a EPROM writing file
3. PRINT (F5) -- To produce a ladder text file for printing

1.2 CNC/PLC/Machine Tool Interface Description

The signals flowing between the CNC and the machine tool are processed by the
PLC. The PLC bits (I/O/C/S/A-bit) that are used in all HUST PLC systems are
described below. The meanings and the applications of the PLC bits are discussed
in all HUST CNC Connecting Manuals. In addition to the PLC bits, HUST's PLC
Editor also provides Timer, Counter, and Register for additional control.

I-bit : Input signal from external I/O unit (machine tool) to PLC.
O-bit : Output signal from PLC to I/O unit for driving external devices.
C-bit : Command signal from PLC to the CNC controller.
S-bit : Status signal from the CNC controller to PLC.
A-bit : Auxiliary internal bit for I/O/C/S-bit processing in PLC.

HUST PLC External


HUST CNC C-Bits I-Bits
A-Bits I/O Unit
S-Bits Timer O-Bits
Controller
Counter (Machine Tool)

1
HUST PLC Editor

1.3 PLC Bits Description

PLC Bits Address Range Description


I 0 ~ 127 * Input signals
O 0 ~ 127 * Output signals
C 0 ~ 127 * Command bits (PLC→CNC)
S 0 ~ 127 * Status bits (CNC→PLC)
A 0 ~ 127 * Auxiliary bits
Timer 0 ~ 31 # Base unit: 50 ms, 0.1 sec, 1 sec
Counter 0 ~ 31 # Type: Up, Down, Ring-up, Ring-down, Set
Register 0 ~ 31 # Register

For HUST 3-series, * 0 ~ 255, # 0 ~ 63.

I000~I007 of HUST I-0 and I-3 series CNC or I018 of HUST 10/11-series CNC are
designated as input signals of G31 SKIP function. If you use SKIP function is your
program, be careful in handling of these I-bits. Otherwise, all the PLC bits in the
table are available for customer's use.

1.4 PLC Editor Screen Description

1. Header Area : Display current editing mode.


2. Main Area : Display ladder diagram area. Also display messages when
compiling a ladder.
3. Status Line : Prompt help and warning/error message.
4. Command Line : Display user's command input.
5. Function Keys : F1 ~ F10 Function-keys area.

(1) <EXC>:Ladder HUST - Ladder Editor

(2)

(3) Replace
(4)
(5) F1 EDIT F2 F3 COMP F4 F5 PRINT F6 F7 F8 F9 F0 END
Fig 1-1 Screen Display When Activating PLC Editor

2
HUST PLC Editor

2 PLC EDITOR OPERATION

2.1 PLC Editor System Startup

♦ System requirements:

Hardware: IBM PC-AT compatible or higher with EGA/VGA monitor or


higher.
Software: HUST's PLC Editor (plc1.exe or plc2.exe and ASCII.15)
plc1.exe for HUST 0-series and 10/11-series, plc2.exe for 3-series.

♦ Copy PLC Editor into your PC as follow:

Insert PLC Editor diskette provided into your PC's drive A or B.


C:\>md\plc<CR>
C:\>cd\plc<CR>
C:\plc>copy a: plc1.exe (or plc2.exe)<CR>
C:\plc>copy a: ascii.15<CR>

♦ PLC Editor startup:

C:\plc>plc1 (or plc2)<CR>

When you enter the execution file "plc1.exe" (or plc2.exe), a screen as shown in Fig
1-1 will be displayed. The three operations that you can do with HUST's PLC
Editor are shown at the bottom of the screen in the function-key area. "F3 COMP"
and "F5 PRINT" operations are normally used only after the entire ladder file
editing (F1 EDIT) have been finished.

1. F1 EDIT (Edit module) -- To edit a new ladder file or revise an existing file.
2. F3 COMP (Compile mod.) -- To produce a "*****.tsk" file for EPROM
writing.
3. F5 PRINT (Print module) -- To produce a ladder text file for printing.
4. F0 END -- To quit PLC Editor operation.

2.2 Editing Methods and The Keyboard Keys (Edit Module)

PLC Editor is of manu-driven type. The operation you want to do is explicitly


shown at the bottom screen in the Function key area (5). There are two (2) ways
to enter the operation. Let's assume that you want to edit a file (F1 EDIT). All you
have to is to do one of the followings:

1. Function-key -- Press the corresponding function-key on the keyboard "F1", or


2. Direct input -- Type in the command word (or symbol) "EDIT" as shown in
the Function-key area (5), then press ENTER key.

3
HUST PLC Editor

Once you have done one of the above, the operation you keyed in will be displayed
in the Command Line area (4), and the Function-key area (5) with a message in area
(3) will display the next step you should do. When you finish all the steps required,
press ENTER key and the data in the Command Line area (4) will be entered into
the Main area (2). If you made an error while editing, an error message would be
displayed in the Message area (3) when you press ENTER key. Both input methods
can be used inter-changeably.

The complete steps to bring an existing ladder file onto screen for editing are as
follows. Throughout this book, the information inside the bracket "<xxxxx>" are
the data that require user's input.

F1 EDIT + <filename> + ENTER (F1~F10 function-key method)


EDIT + <filename> + ENTER (direct input)

<filename> for EDIT, COMP, or PRINT is the file that has "LAD" extension such
as "xxxxx.LAD". When you key in the filename for EDIT, COMP, or PRINT, the
"LAD" extension can be omitted. Once you press ENTER key, the ladder diagram
as shown in Fig 2-1 will be displayed in the Main area (2) for an existing file.

(1) <EXC>:Ladder HUST - Ladder Editor

( )
S001 C001
( )
(2) A110 A103 C001 A013

A013 A094

(3) Status:Enter PLC EDIT


(4) EDIT filename
(5) F1 CONT F2 COIL F3 TIMER ………………………… F0-NEXT

Fig2-1 Existing File Display

If it's a new file, a screen as in Fig2-2 will be displayed. Once a ladder file as in
Fig2-1 or Fig2-2 is displayed, the file is ready for editing. The next step you should
do is displayed at the Function-key area (5) and the Message area (3). We'll discuss
these functions in detail later.

4
HUST PLC Editor

(1) <EXC>:Ladder HUST - Ladder Editor


=== TOP OF FILE ===
Vcc Gnd

(2)
=== END OF FILE ===

(3) Status:Enter PLC EDIT


(4) EDIT filename
(5) F1 CONT F2 COIL F3 TIMER ………………………… F0-NEXT

Fig2-2 New File Display

2.2.1 Keyboard Keys For Editing

The special keys on the keyboard that are to be used during PLC editing will be
discussed below:

♦ "Esc" Key : Toggle between the Command mode and the Ladder mode

During PLC ladder editing, there are two windows existed for operation. They
can be toggled back and forth with "Esc" key. As to which window being active
is displayed at the top left-hand corner in the Header area (1) by <Esc>:Ladder
or <Esc>:Command. The best way to distinguish which window being active is
to check the two cursors on the screen. One is a big square cursor in the ladder
Main area (2) and the other is a line cursor in the Command Line area (4).

<ESC>:Ladder -- Command Mode


The cursor in the Command Line area (4) is active (cursor blinking) and it can
be moved in this area by pressing the arrow keys on the keyboard. Thereby you
can edit or revise the data in this area. When pressing ENTER key, the edited
data in this area will be transferred to the ladder Main area (2) at the big square
cursor location.

<ESC>:Command -- Ladder Mode


The cursor in the Main area (2) is active and it can be moved in this area by
pressing the arrow keys on the keyboard. Wherever the cursor is moved to, it
means that the element at the cursor will be replaced by the data in the
Command Line area (4).

5
HUST PLC Editor

♦ Keys that are active in Command mode

<Ins> : Insert characters at the Command Line area.


<Del> : Delete characters at the Command Line area.
←,→ : Move the cursor left or right at the Command Line area.
<Home> : Move the cursor to the beginning position of the command line.
<End> : Move the cursor to the ending position of the command line.
<Enter> : Command execution key.

♦ Keys that are active in Ladder mode

←,→ : Move the cursor left or right at the ladder Main area (2).
↑,↓ : Move the cursor up or down at the ladder Main area.
PgUp,PgDn : Scroll screen one page up or down at the ladder Main area.
Ctrl Home : Move cursor to the top of file.
Ctrl End : Move cursor to the end of file.

♦ Keys that are active in both modes

ALT-L : Mark lines in the ladder Main area.


ALT-U : Undo mark.
ALT-D : Delete marked lines.
ALT-Z : Copy marked lines to the area below the square cursor.
ALT-Q : Quit PLC Editor system without save.
ALT_F9 : Clear data-string in the Command Line.
F1~F10 function, character and numerical keys.
<Enter> : Command execution key.

2.3 Function Keys For Editing (Edit Module)

Once you have entered into EDIT mode for a ladder file, the Function-key area (5)
displays the function keys as follows:

F1 CONT., F2 COIL, F3 TIMER, F4 COUNT, F5 RETN, F6 ARITH


F7 LOGIC, F8 LABEL, F9 JUMP, F0-NEXT.

We call this as "Element Edit" or "Component Edit", which will let you choose the
component for the ladder diagram. If you press F0-NEXT key, the Area (5) function
keys will scroll to the next page, called "Ladder Edit", which has the following
function keys for ladder editing.

F1 INS, F3 DEL, F7 FIND, F8 MERGE, F9 END, F0-NEXT.

If you press F0-NEXT key again, you'll go back to the "Element Edit" page.

6
HUST PLC Editor

2.3.1 "Ladder Edit" Function Keys

♦ Insert -- Insert one line below the square cursor in ladder Main area (2).

F1 INS + ENTER (function-key method)


INS ENTER (direct input from keyboard)

♦ Delete

To delete a line, move square cursor to the line and press ALT-L to mark the
line, then press ALT-D (or delete). To delete multiple lines, use ALT-L to mark
the first line, move cursor to the last line and press ALT-L again, then press
ALT-D.

F3 DEL + F1 LINES + ENTER (function-key method)


DEL LINES ENTER (direct input)

To delete the upper-left vertical line at the square cursor position.

F3 DEL + F2 | + ENTER (function-key method)


DEL | ENTER (direct input)

To delete a component (or element) at the cursor position.

F3 DEL + F3 ELEM + ENTER (function-key method)


DEL ELEM ENTER (direct input)

♦ FIND -- Find a component.

F7 FIND + F1 LINE + <number> + ENTER (function-key method)


FIND LINE <number> ENTER (direct input)

<number> represents the line number. To find the I/O/C/S/A-bit (address


number 0~127), use the steps shown below. Once you press the ENTER key, the
square cursor will move the specified line number or I/O/C/S/A-bit. Note that
the FIND command is effective only for the line or bit number below the cursor.

F7 FIND + F2 I_BIT + <number> + ENTER (function-key method)


FIND I_BIT <number> ENTER (direct input)

<number> represents the bit address number, 0~127. For finding O/C/S/A-bit
location, you simply replace F2 I_BIT in the steps by F3 O_BIT, F4 C_BIT, F5
S_BIT, or F6 A_BIT.

7
HUST PLC Editor

♦ Merge -- Merge the selected ladder file to the end of the current file.

M8 MERGE + <filename> + ENTER (function-key method)


MERGE <filename> ENTER (direct input)

<filename>: the filename selected for merging. (No extension required)

♦ End -- Quit the file editing session.

F9 END + <filename> + ENTER (function-key method)


END <filename> ENTER (direct input)

"END" without filename will save the ladder in the current default file.
"END" with a filename will save the ladder with the filename as indicated.
Both file saves will do open/short circuit check. If you do not intent to save the
file, use the following steps. The original file will remain intact.

F9 END + F2 nSave + ENTER (function-key method)


END nSave ENTER (direct input)

2.3.2 "Element Edit" or "Component Edit" Function Keys

The ladder components are divided into normal components and functional
components. These components will be discussed in Chapter 3. F8 and F9
function-keys on the Function-key area (5) are for ladder subroutine control.

1. Normal components : Contacts and Coils.


2. Functional components : Arithmetic, Logic, Timer, and Counter.

When pressing F1 CONT. key, the Function-key area (5) turns to next page. The
horizontal and the vertical connecting line are in F7 and F8, respectively.

♦ Horizontal Connecting Line: -----

F1 CONT. + F7 ----- + ENTER (function-key method)


CONT. ----- ENTER (direct input)

♦ Vertical Connecting Line: |

F1 CONT. + F8 | + ENTER (function-key method)


CONT. | ENTER (direct input)

8
HUST PLC Editor

Function Keys For Subroutine Control

♦ F8 LABEL

F8 LABEL + <name> + ENTER (function-key method)


LABEL <name> ENTER (direct input)

<name> is the subroutine name which has a max. of 6 characters, starting with a
capital letter of A~Z. Character #2~#6 can be letters or numbers. LABEL
command occupies one line of space and it will erase everything on the cursored
line. The max. number of LABEL (subroutine) allowed in a program is 128. Use
F5 RETN or F2 RTS for the last line of the subroutine.

♦ F9 JUMP

This key is for branching to another subroutine. When pressing this key, the next
line displays F1 ]JMP[ and F2 ]JSR[.

F1 ]JMP[

F9 JUMP + F1 ]JMP[ + <name> + ENTER (function-key method)


JUMP ]JMP[ <name> ENTER (direct input)

<name> is the subroutine name. When you use this command to branch into the
specified subroutine, the program will execute this subroutine till the end but the
program will not return to the original calling point.

F2 ]JSR[

F9 JUMP + F2 ]JSR[ + <name> + ENTER (function-key method)


JUMP ]JSR[ <name> ENTER (direct input)

<name> is the subroutine name. When you use this command to branch into the
specified subroutine, the program will execute this subroutine till the end and
the program will return to the original calling point.

Note that the ]JMP[ and ]JSR[ command should be preceded with a decision
statement (true or false) such as:

--| |-------------------------]JSR Axxxxx[--------


I001

9
HUST PLC Editor

2.4 Compile Module

F3 COMP + <filename> + ENTER (function-key method)


COMP <filename> ENTER (direct input)

<filename> is the ladder filename to be compiled. (no extension required) You use
this command to compile ladder file only if you decide to produce a xxxxx.tsk file
for EPROM writing. When compiling a file, the module will do the following
things:

1. Check if there is any short/open circuit.


2. Compile the ladder diagram
3. Prompt warning message if there is some non-reusable components that have
been multiply used.
4. If the compiled result is in error, it will generate an error message as

*.err → compile error.

5. If the compiled result is OK, it will generate a message as

Open circuit check : OK


Short circuit check : OK
Compiling pass in xxxx Rung.
Compile complete total xxxx bytes.

When compiling a ladder, the result will produce three (3) files as follows:

1. xxxxx.tsk -- File for EPROM writing.


2. xxxxx.crf -- Component listing for cross reference.
3. xxxxx.ncd -- File for ladder simulation.

2.5 Print Module

F5 PRINT + <filename> + ENTER (function-key method)


PRINT <filename> ENTER (direct input)

<filename> is the ladder filename to be printed. (no extension required) PRINT


command will produce a "xxxxx.prn" file. Both "xxxxx.prn" and "xxxxx.crf" are
text file which can be printed out using a text editor.

10
HUST PLC Editor

3 DESCRIPTION OF LADDER COMPONENTS

When editing the ladder components, both function-key and direct input methods
can be used as discussed in Chap 2. All the letters and symbols in the Function-key
area (5) are available from the keyboard. For simplicity, we will show the input
steps by function-key method only. If you use the direct input method, the data you
type in from the keyboard should be exactly the same as that in the Function-key,
including the period ".". In the explanation below, the data inside the bracket <> are
to be typed in from the keyboard.

♦ Normal-open Contact: --| . |--

F1 CONT. + F1 --| . |-- + F1 I_BIT + <ADDR> + ENTER


F1 CONT. + F1 --| . |-- + F2 O_BIT + <ADDR> + ENTER
F1 CONT. + F1 --| . |-- + F3 C_BIT + <ADDR> + ENTER
F1 CONT. + F1 --| . |-- + F4 S_BIT + <ADDR> + ENTER
F1 CONT. + F1 --| . |-- + F5 A_BIT + <ADDR> + ENTER

<ADDR> is the bit address, 0~127

♦ Timer Normal-open Contact: --| T. |--

F1 CONT. + F3 --| T. |-- + <T_NO:> + ENTER

<T_NO:> is the timer number, 0~31

♦ Counter Normal-open Contact: --| C. |--

F1 CONT. + F5 --| C. |-- + <C_NO:> + ENTER

<C_NO:> is the counter number, 0~31

♦ Normal-close Contact: --| / |--

F1 CONT. + F2 --| / |-- + F1 I_BIT + <ADDR> + ENTER


F1 CONT. + F2 --| / |-- + F2 O_BIT + <ADDR> + ENTER
F1 CONT. + F2 --| / |-- + F3 C_BIT + <ADDR> + ENTER
F1 CONT. + F2 --| / |-- + F4 S_BIT + <ADDR> + ENTER
F1 CONT. + F2 --| / |-- + F5 A_BIT + <ADDR> + ENTER

<ADDR> is the bit address, 0~127

♦ Timer Normal-close Contact: --| T/ |--

F1 CONT. + F4 --| T/ |-- + <T_NO:> + ENTER

<T_NO:> is the timer number, 0~31

11
HUST PLC Editor

♦ Counter Normal-close Contact: --| C/ |--

F1 CONT. + F6 --| C/ |-- + <C_NO:> + ENTER

<C_NO:> is the counter number, 0~31

♦ Normal-positive Relay Output: Input --( . ) Output

F2 COIL + F1 --( . ) + F2 O_BIT + <ADDR> + ENTER


F2 COIL + F1 --( . ) + F3 C_BIT + <ADDR> + ENTER
F2 COIL + F1 --( . ) + F5 A_BIT + <ADDR> + ENTER

<ADDR> is the bit address, 0~127

Example:

( )
I001 O005
When the input I001 is ON, the output O005 is also ON.
When the input I001 is OFF, the output O005 is also OFF.

ON
Input Signal I001 OFF
ON
Output Signal O005 OFF
♦ Normal-negative Relay Output: Input --( / ) Output

F2 COIL + F2 --( / ) + F2 O_BIT + <ADDR> + ENTER


F2 COIL + F2 --( / ) + F3 C_BIT + <ADDR> + ENTER
F2 COIL + F2 --( / ) + F5 A_BIT + <ADDR> + ENTER

<ADDR> is the bit address, 0~127

Example:

( )
I001
When the input I001 is ON, the output O005 is OFF. O005
When the input I001 is OFF, the output O005 is ON.

ON
Input Signal I001 OFF
Output Signal O005 ON OFF

12
HUST PLC Editor

♦ Positively Trig. Relay Output: Input --( ^ ) Output

F2 COIL + F3 --( ^ ) + F2 O_BIT + <ADDR> + ENTER


F2 COIL + F3 --( ^ ) + F3 C_BIT + <ADDR> + ENTER
F2 COIL + F3 --( ^ ) + F5 A_BIT + <ADDR> + ENTER

<ADDR> is the bit address, 0~127. When the input signal is from OFF to ON, the
output produces one time-cycle (one-shot) signal.

Example:
( )
I001 O005
When the input I001 is from OFF to ON, the output O005 is ON for one time
cycle. (one-shot)
ON
OFF
Input Signal I001
Output Signal O005
1time cycle

♦ Negatively Trig. Relay Output: Input --( v ) Output

F2 COIL + F4 --( v ) + F2 O_BIT + <ADDR> + ENTER


F2 COIL + F4 --( v ) + F3 C_BIT + <ADDR> + ENTER
F2 COIL + F4 --( v ) + F5 A_BIT + <ADDR> + ENTER

<ADDR> is the bit address, 0~127. When the input signal is from ON to OFF, the
output produces one time-cycle (one-shot) signal.

Example:

( )
I001 O005
When the input I001 is from ON to OFF, the output O005 is ON for one time
cycle. (one-shot)
ON
OFF
Input Signal I001
Output Signal O005
1time cycle

13
HUST PLC Editor

♦ ARITH ADD:

XXXX
Input ADD Output
YYYY

F6 ARITH + F1 ADD.W + F1 # + <Data> + <RegNo> + ENTER


F6 ARITH + F1 ADD.W + <RegNo> + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031

Add the value in XXXX to YYYY and put the result into YYYY. The value that
both XXXX and YYYY can hold is in the range of -32767~+32767. If the result
after arithmetic operation is outside this range, the result is overflowing. In this case,
it will trigger the output signal to ON.

Example 1:
#1234
ADD ( )
I001 R001 O005

When I001 is ON, do arithmetic ADD operation.


Assuming the initial value, R001 = 9999 (a decimal)
Adding the number, 1234
The result, R001 = 11233

Since 11233 is in the range of -32767~+32767, O005 will be OFF.

Example 2:

R002
ADD ( )
I001 R001 O005

When I001 is ON, do arithmetic ADD operation.


Assuming the initial value, R001 = 9999
Adding the value of R002 = 1234
The result, R001 = 11233

Since 11233 is in the range of -32767~+32767, O005 will be OFF.

14
HUST PLC Editor

♦ ARITH SUB:

SUB XXXX
Input Output
YYYY

F6 ARITH + F2 SUB.W + F1 # + <Data> + <RegNo> + ENTER


F6 ARITH + F2 SUB.W + <RegNo> + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031

Subtract the value in XXXX from YYYY and put the result into YYYY. The value
that both XXXX and YYYY can hold is in the range of -32767~+32767. If the
result after arithmetic subtraction is zero (0), it will trigger the output signal to ON.

Example 1:

#1234
SUB ( )
I001 R001 O005
When I001 is ON, do arithmetic SUB operation.
Assuming the initial value, R001 = 9999 (a decimal)
Subtracting the number, 1234
The result, R001 = 8765

Since 8765 is not equal to zero, O005 will be OFF.

Example 2:

R002
SUB ( )
I001 R001 O005

When I001 is ON, do arithmetic SUB operation.


Assuming the initial value, R001 = 9999
Subtracting the value of R002 = 9999
The result, R001 = 0

Since the result is zero (0), O005 will be ON.

15
HUST PLC Editor

♦ ARITH MUL:

Input XXXX Output


MUL
YYYY

F6 ARITH + F3 MUL.W + F1 # + <Data> + <RegNo> + ENTER


F6 ARITH + F3 MUL.W + <RegNo> + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031

Multiply the value in YYYY by XXXX and put the result into YYYY. The value
that both XXXX and YYYY can hold is in the range of -32767~+32767. If the
result after arithmetic operation is zero (0), it will trigger the output signal to ON.

Example 1:

#1234
MUL ( )
I001 R001 O005
When I001 is ON, do arithmetic MUL operation.
Assuming the initial value, R001 = 2 (a decimal)
Multiplying the number, 1234
The result, R001 = 2468

Since 2468 is not equal to zero, O005 will be OFF.

Example 2:

R002
MUL ( )
I001 R001 O005

When I001 is ON, do arithmetic MUL operation.


Assuming the initial value, R001= 2
Multiplying the value of R002 = 1234
The result, R001 = 2468

Since 2468 is not equal to zero, O005 will be OFF.

16
HUST PLC Editor

♦ ARITH DIV:

XXXX
Input DIV Output
YYYY

F6 ARITH + F4 DIV.W + F1 # + <Data> + <RegNo> + ENTER


F6 ARITH + F4 DIV.W + <RegNo> + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031

Divide the value in YYYY by XXXX and put the result into YYYY. The value that
both XXXX and YYYY can hold is in the range of -32767~+32767. If the result
after arithmetic operation is zero (0), it will trigger the output signal to ON.

Example 1:

#1234
DIV ( )
I001 R001 O005
When I001 is ON, do arithmetic DIV operation.
Assuming the initial value, R001 = 1234 (a decimal)
Dividing by the number, 1234
The result, R001 = 1

Since the result is not equal to zero, O005 will be OFF.

Example 2:

R002
DIV ( )
I001 R001 O005
When I001 is ON, do arithmetic DIV operation.
Assuming the initial value, R001 = 1234
Dividing by the value of R002 = 1234
The result, R001 = 1

Since the result is not equal to zero, O005 will be OFF.

17
HUST PLC Editor

♦ DATA MOVE:

XXXX
Input MOV Output
YYYY

F6 ARITH + F5 MOV.W + F1 # + <Data> + <RegNo> + ENTER


F6 ARITH + F5 MOV.W + <RegNo> + <RegNo> + ENTER
F6 ARITH + F5 MOV.W + I_BIT + <ADDR> + <RegNo> + ENTER
F6 ARITH + F5 MOV.W + S_BIT + <ADDR> + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031
I_Bit and S_Bit address must be in an increment of 16 because 16-bit of
information are moved at a time, ie, I000, I016, I032, I048 ............, I112 and
S000, S016, S032, S048, ......., S112.

Move the data in XXXX to YYYY. When MOVE command is completed, the
output signal will be ON.

Example 1:
#1234
MOV ( )
I001 R001 O005

When I001 is ON, do MOV operation.


Assuming the initial value, R001 = 9999 (a decimal)
After MOV operation, R001 = 1234

O005 will be set ON when MOV operation is completed.

Example 2:

I016
MOV ( )
I001 R001 O005
When I001 is ON, do MOV operation.
Assuming the initial value, R001 = 9999
and I016~I031 = 0000 0100 1101 0010 in binary
The result after MOV, R001 = 0000 0100 1101 0010 in binary or 1234

O005 will be set ON after executing MOV.

18
HUST PLC Editor

♦ COMPARE (>, =, <):

CMP XXXX
Input Output
? YYYY

F6 ARITH + F6 CMP.W + F1 # + <Data> + F1 > + <RegNo> + ENTER


F6 ARITH + F6 CMP.W + F1 # + <Data> + F2 < + <RegNo> + ENTER
F6 ARITH + F6 CMP.W + F1 # + <Data> + F3 = + <RegNo> + ENTER
F6 ARITH + F6 CMP.W + <RegNo> + <Data> + F1 > + <RegNo> + ENTER
F6 ARITH + F6 CMP.W + <RegNo> + <Data> + F2 < + <RegNo> + ENTER
F6 ARITH + F6 CMP.W + <RegNo> + <Data> + F3 = + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031

Compare the data in XXXX with that in YYYY. After comparison, the output
signal will be ON if the statement is TRUE, and OFF if FALSE.

Example 1:

CMP R002
( )
I001 > R001 O005
When I001 is ON, do CMP operation.
Assuming the initial value, R001 = 1234, R002 = 9999
Compare if R002 (9999) > R001 (1234)
After CMP, the statement is TRUE and O005 will be set ON.

Example 2:

CMP #1234
( )
I001 = R001 O005

When I001 is ON, do CMP operation.


Assuming the initial value, R001 = 9999
Compare if 1234 = R001 (9999)
After CMP, the statement is FALSE and O005 will be OFF.

19
HUST PLC Editor

♦ LOGIC AND:

AND XXXX
Input Output
YYYY

F7 LOGIC + F1 AND.W + F1 # + <Data> + <RegNo> + ENTER


F7 LOGIC + F1 AND.W + <RegNo> + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031

AND the value in YYYY with XXXX and put the result into YYYY. Before doing
logic AND operation, all the values in XXXX and YYYY will be converted into
binary form, then do ANDing operation. If the result after AND operation is zero
(0), it will trigger the output signal to ON.

Logic AND table:


X Y Result
1 1 1
1 0 0
0 1 0
0 0 0

Example 1 :

R001
AND ( )
I001 R001 O005

When I001 is ON, do LOGIC AND operation.


Assuming the initial value, R001 = 8972 or 0010 0011 0000 1100 in binary
ANDing the value of R002 = 1234 or 0000 0100 1101 0010 in binary
The result, R001 = 0 0000 0000 0000 0000 in binary

Since the result is equal to zero (0), O005 will be ON.

20
HUST PLC Editor

♦ LOGIC OR:

OR XXXX
Input Output
YYYY

F7 LOGIC + F2 OR.W + F1 # + <Data> + <RegNo> + ENTER


F7 LOGIC + F2 OR.W + <RegNo> + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031

OR the value in YYYY with XXXX and put the result into YYYY. The value that
both XXXX and YYYY can hold is in the range of -32767~+32767. Before doing
logic OR operation, all the values in XXXX and YYYY will be converted into
binary form, then do ORing operation. If the result after OR operation is zero (0), it
will trigger the output signal to ON.

Logic OR table:
X Y Result
1 1 1
1 0 1
0 1 1
0 0 0

Example 1:
#1234
OR ( )
I001 R001 O005
When I001 is ON, do LOGIC OR operation.
Assuming the initial value, R001 = 9999 or 0010 0111 0000 1111 in binary
ORing the value of 1234 or 0000 0100 1101 0010 in binary
The result, R001 = 10207 or 0010 0111 1101 1111 in binary

Since the result is not equal to zero (0), O005 will be OFF.

21
HUST PLC Editor

♦ LOGIC XOR:

XOR XXXX
Input Output
YYYY

F7 LOGIC + F3 XOR.W + F1 # + <Data> + <RegNo> + ENTER


F7 LOGIC + F3 XOR.W + <RegNo> + <RegNo> + ENTER

XXXX (Data) : A constant with value ranging #-32767~+32767, or


a register number R000~R031
YYYY (RegNo) : A register number R000~R031

XOR the value in YYYY with XXXX and put the result into YYYY. The value that
both XXXX and YYYY can hold is in the range of -32767~+32767. Before doing
logic XOR operation, all the values in XXXX and YYYY will be converted into
binary form, then do XORing operation. If the result after XOR operation is zero
(0), it will trigger the output signal to ON.

Logic XOR table:


X Y Result
1 1 0
1 0 1
0 1 1
0 0 0

Example 1:

#1234
OR ( )
I001 R001 O005
When I001 is ON, do LOGIC XOR operation.
Assuming the initial value, R001 = 9999 or 0010 0111 0000 1111 in binary
ORing the value of 1234 or 0000 0100 1101 0010 in binary
The result, R001 = 9181 or 0010 0011 1101 1101 in binary

Since the result is not equal to zero (0), O005 will be OFF.

22
HUST PLC Editor

♦ TIMER:

TMR XXXX
Input Output
tttt YYYY
Where "tttt" is the Timer base unit, 50 ms, 0.1 sec., 1 second .

F3 TIMER + <T_NO:> + F1 50ms + <VALUE> + ENTER


F3 TIMER + <T_NO:> + F2 0.1s + <VALUE> + ENTER
F3 TIMER + <T_NO:> + F3 1sec + <VALUE> + ENTER

XXXX (T_NO:) : A Timer number, T000~T031


YYYY (Value) : A Timer setting value, 0~+32767.

When the input signal is ON, the Timer XXXX starts counting. When the time is
equal to (tttt * YYYY), the output signal will be turned ON. For example, if
YYYY=100 with timer base unit of 50 ms, the total elapses time = 100 x 50 = 5000
ms before the output signal is turned ON.

Example 1:

TMR T002
( )
0.1sec #10
I001 O005
( )
TM001 O007

Input Signal I001 10 秒


Output Signal O005
Input Signal TM001
Output Signal O007
When I001 is ON, Timer T001 becomes active and starts counting. When the
time in T001 timer reaches 1 second, the output O005 will be ON. Timer stops
counting and resets to zero (0) when I001 is OFF.

Every timer has an internal contact, acting like a normal contact. TM001 is the
internal contact of Timer T001. When the time in T001 is ON, TM001 is also
ON. Consequently, the output O007 is ON also.

23
HUST PLC Editor

♦ Up Counter:

CNT XXXX
Input Output
UP YYYY

F4 COUNT + <C_NO:> + F1 UP + <VALUE> + ENTER

XXXX (C_NO:) : A Counter number, C000~C031


YYYY (Value) : A Counter setting value, 0~+32767.

When the input signal is ON, the Counter XXXX starts counting UP the number of
times that the input signal comes in. When the Counter counts UP to the number
specified by YYYY, the output signal will be turned ON. Once the count reaches
YYYY, this number will stay in the counter unless you use Counter Set to re-define
its value.

Note that the starting value in the Counter XXXX is very important. If it's a 0, the
number of times that the input signal comes in will be equal to YYYY. If it's greater
than YYYY, the counter will not count at all and the output will never be turned
ON.

Example 1:

CNT C001
( )
UP #5
I001 O005
( )
CNT001 O007

Count in C001 1 2 3 4 5 5 5 5
Input Signal I001
Output Signal O005
Input Signal CNT1
Output Signal O007

When the input signal I001 is ON five (5) times as registered by C001
(assuming that C001=0 initiallt), the output O005 will be ON.

Every counter has an internal contact, acting like a normal contact. CNT001
is the internal contact of Counter C001. When the number in C001 is up to 5,
CNT001 is also ON. Consequently, the output O007 is ON also.

24
HUST PLC Editor

♦ DOWN Counter:

CNT XXXX
Input DOWN
Output
YYYY

F4 COUNT + <C_NO:> + F2 DOWN + <VALUE> + ENTER

XXXX (C_NO:) : A Counter number, C000~C031


YYYY (Value) : A Counter setting value, 0~+32767.

When the input signal is ON, the Counter XXXX starts counting DOWN the
number of times that the input signal comes in, as specified by YYYY. When the
Counter counts to zero (0), the output signal will be turned ON. For next count, you
have to use Counter Set to reset the starting value in the counter.

Example 1:

CNT C001
DOWN
( )
I001 #5 O005
( )
CNT001 O007

Count in C001 5 4 3 2 1 0
Input Signal I001
Output Signal O005
Input Signal CNT1
Output Signal O007
Each time the signal I001 is ON, Counter C001 (=5 initially) counts down
one step. When C001 becomes zero (0), the output O005 will be ON.

Every counter has an internal contact, acting like a normal contact. CNT001
is the internal contact of Counter C001. When the number in C001 is down
to zero (0), CNT001 is also ON. Consequently, the output O007 is ON also.

25
HUST PLC Editor

♦ Ring_Up Counter:

CNT XXXX
Input RING- Output
-UP YYYY

F4 COUNT + <C_NO:> + F4 R_UP + <VALUE> + ENTER

XXXX (C_NO:) : A Counter number, C000~C031


YYYY (Value) : A Counter setting value, 0~+32767.

When the input signal is ON, the Counter XXXX starts counting UP the number of
times that the input signal comes in. When the Counter counts UP to the number
specified by YYYY, the output signal will be turned ON. Once the count reaches
YYYY, the counter will reset to zero (0) and is ready for the next count.

Example 1:
CNT C001
RING- ( )
I001 -UP #5 O005
( )
CNT001 O007

Count in C001 1 2 3 4 5 0 1 2
Input Signal I001
Output Signal O005
Input Signal CNT1
Output Signal O007
When the input signal I001 is ON five (5) times as registered by C001, the
output O005 will be ON. The counter will then reset to zero (0) and is ready
for the next count.

Every counter has an internal contact, acting like a normal contact. CNT001
is the internal contact of Counter C001. When the number in C001 is up to 5,
CNT001 is also ON. Consequently, the output O007 is ON also. When C001
repeats counting from 0, the output signal will turn OFF.

26
HUST PLC Editor

♦ Ring_Down Counter:

CNT XXXX
Input RING- Output
-DN YYYY

F4 COUNT + <C_NO:> + F5 R_DN + <VALUE> + ENTER

XXXX (C_NO:) : A Counter number, C000~C031


YYYY (Value) : A Counter setting value, 0~+32767.

When the input signal is ON, the Counter XXXX starts counting DOWN the
number of times that the input signal comes in, starting from the number specified
by YYYY. When the Counter counts to zero (0), the output signal will be turned
ON. The counter will reset to YYYY and is ready for the next count.

Example 1:
CNT C001
RING- ( )
I001 DN #5 O005
( )
CNT001 O007

Count in C001 5 4 3 2 1 0 5 4
Input Signal I001
Output Signal O005
Input Signal CNT1
Output Signal O007
When the input signal I001 is ON, Counter C001 will start counting down
from 5 for each I001 ON signal. Once the count in C001 becomes 0, the
output signal O005 will be turned ON. Counter will then reset to 5 and is
ready for the next count. At the same time, the output signal O005 will be
turned OFF until C001 reaches 0 again.

CNT001 is the internal contact of Counter C001. It acts the same way as
explained before.

27
HUST PLC Editor

♦ Counter Setting:

CNT XXXX
Input Output
SET YYYY

F4 COUNT + <C_NO:> + F3 SET + <VALUE> + ENTER

XXXX (C_NO:) : A Counter number, C000~C031


YYYY (Value) : A Counter setting value, 0~+32767.

This command is used to set a value specified by YYYY into the Counter XXXX.
The current number in the counter XXXX will be replaced by the specified value.

Example 1:

CNT C001
( )
DOWN # 5 O005
I001

Count in C001 2 replaced by 5


Input Signal I001
Output Signal O005
When the input signal I001 is from OFF to ON, the number (2) in C001 is
replaced by 5. At the same time, the output O005 will be turned ON.

♦ Ladder END:

- - - - ] END [ - - - - - - - -

F5 RETN + F1 ] END [ + ENTER

End of ladder program. Each ladder diagram must have this statement at the end.

28

You might also like