APPENDIX I LADDER DIAGRAM USAGE GUIDE OF GSK218MC SERIES WITH
CONE TYPE TOOL-MAGAZINE..................................................................................... 245
I. Cautions When Using the Cone Type Tool-Magazine Ladder Diagram .. 245
II. Configuration and Definition of PLC I/O Address and Internal Software
Components …………………………………………………………………….245
III. The Usage and Maintenance of the Cone Tool Magazine.................... 270
IV. The Macro Note Matching with the Cone Tool Magazine..................... 278
APPENDIX II LADDAR DIAGRAM USE GUIDE OF GSK218MC SERIES
MATCHING WITH DISC TOOL MAGAZINE................................................................. 281
I. The application precautions of the disc tool magazine......................... 281
II. The Configuration and Definition of the PLC I/O Address and Internal Soft
Component ……………………………………………………………………281
III. The Usage and Maintenance with Manipulator Tool Magazine.............. 310
IV. Macro Note with Disk Tool Magazine ....................................................... 317
APPENDIX III FILE FORMAT OF LADDER DIAGRAM CONFIGURATION........ 319
I. F Signal and Meaning of the M Code M00---M99....................................... 319
II. That the “%” Takes One Single Line Means that the M code Information
Storage is End …………………………………………………………………….319
III. The Code and Meaning of the X Signal X0.0---X6.7 ................................ 319
IV. The Code and Meaning of the Y Signal Y0.0---Y5.7 ................................ 320
V. The Code and Meaning of the K Signal K6.0---K63.7............................... 320
VI. The Code and Meaning of the A Signal A0.0---A31.7 ........................... 320
VII. end//End Mark.....……………………………………………………………….320
XVI
Page 17
VOLUME I PROGRAMMING
Volume I
Programming
1
Page 18
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
CHAPTER ONE SQUENCY PROGRAMMING COMPILATION
1.1 GSK218MC Series PLC Specification
GSK218MC series PLC specification is shown below:
Volume I Programming
SCHEDULE
Table 1-1-1
Specification GSK218MC Series PLC
Programming language Ladder
Program level 2
The 1st level program execution cycle 8ms
Basis code average treatment time 5μs
Programming capacity 4700 steps
Code Basis code + function code
Internal relay (R)
PLC alarm detection (A)
Nonvolatile memory area
Timer (T)
Counter (C)
Data base (D)
Nonvolatile relay (K)
Counter prevalue data register (DC)
Timer prevalue data register (DT)
Subprogram (P)
Mark (L)
Input signal of NC side (F)
Signal outputs to the NC side (G)
I/O module (X)
(Y)
0~511 (byte)
0~31(byte)
0~127 (word)
0~127 (word)
0~255 (word)
0~63 (byte)
0~127(word)
0~127(word)
0~99
0~99
0~63(byte)
0~63(byte)
0~63 (byte)
0~47 (byte)
1.2 Concept of the Sequence Programming
The so-called sequence programming is the one that performing the logic control to the
machine tool and its relative equipments.
After the programming is converted into some kind of format, CPU can be performed its code
and calculation treatment for it, and its fruits can be memorized to RAM. CPU can be rapidly read
each code stored in the memory, which can be performed the programming according to the
calculation operation.
2
Page 19
Chapter One Squency Programming Compilation Schedule
The compilation of the sequence programming starts with the ladder diagram.
1.3 Distribution Interface (Step one)
The interface can be distributed after confirming the control object and calculating the points of
the corresponding input/output signal.
Refer to the Chapter Four Input/output interface signal table in the Volume Four Installation and
Connection when distributing the interface.
1.4 Ladder Diagram Compilation (Step two)
The required control operation can be expressed by the ladder diagram with the on-line
Volume I Programming
Volume I Programming
compilation of the Gsk218MC series ladder diagram. The functions, such as the timer and counter,
can not be expressed by relay symbols, which can be indicated by the specified function code
symbols.
The compiled ladder diagram should be stored and converted into the corresponding PLC
codes before operating, namely, the so-called instruction list.
1.5 Sequence Programming Debugging (Step 3)
The sequence programming can be debugged using the following methods:
Debugging with emulator
The machine tool can be replaced by an emulator (it composes of the lights and switches).
ON/OFF of the switch means the signal input state of the machine tool, and the ON/OFF of
the light is the signal state output.
Debugging with actual operation
Debug on the actual machine tool. It is better to prepare the precautions before debugging,
otherwise an unexpected behavior may occur.
3
Page 20
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Volume I Programming
4
Page 21
Chapter Two Sequence Programming
CHAPTER TWO SEQUENCE PROGRAMMING
The operation principle is different with the common relay circuit, because the PLC sequence
control is carried out by compiling the on-line diagram; and therefore, it is better to thoroughly
comprehend the sequence control principle when designing the PLC sequence programming.
2.1 Performance Process of Sequence Programming
In the general relay controlling circuits, each of them can be simultaneously operated. When the
relay A is operated in the following figure, the replay D and E can be operated (when the contactor A
and B are entirely closed) at the same. Each replay in the PLC sequence control is operated in turn.
The relay D is operated before relay A, and then the relay E operates (refer to the following figure).
Namely, each relay is operated based upon the sequence of the ladder diagram (compilation
sequence).
A
A
B
D
C
E
Fig. 2.1 (a) Circuit illustration
The differences between the relay circuit and PLC programming operation are shown below in
the Fig. 2.1 (b) and Fig. 2.1 (c).
Volume I Programming
A
A
C
B
C
Fig. 2.1 (b)
5
Page 22
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
A
C
(1) Relay circuit
Both Fig. 2.1 (b) and Fig. 2.1 (c) are shared a same operation. B and C are switched on after A
is turned on. B is cut off after C is ON.
Volume I Programming
(2) PLC program
A same relay is shared a same circuit, refer to the Fig. 2.1 (b); B and C are switched on after A
is turned on. B is cut off after one cycle of the PLC program is performed. In the Fig. 2.1 (c), C is ON
instead of B, after C is turned on.
2.2 Cycle Performance
A
C
B
Fig. 2.1 (c)
PLC performs from the beginning to the end of the ladder diagram. It performs again from the
beginning of the ladder diagram after this diagram is performed, which is called cycle performance.
The performance time from the beginning to the end of the ladder diagram is abbreviated as a
period of a cycle treatment. The shorter of the treatment period is, the stronger of the response
capacity of the signal is.
2.3 Priority Sequence of the Execution (the 1st Level, the 2nd level)
GSK218MC Series PLC program are composed of two parts: the 1st level program and the 2nd
level program, which are inconsistent with the performance period.
st
The 1
required for fast response.
The 2
PLC may divide the 2nd level program into N parts when the 2nd level program is executed. It is
level program performs once each 8ms, which can be treated the short pulse signal
nd
program performs once each 8*nms. N is the partition number of the 2nd level program.
performed one part for each 8ms.
6
Page 23
Chapter Two Sequence Programming
Fig. 2-3-1
PLC in the GSK218MC series is separately performed in the PLC-AVR SCM. The 1ms of each
8ms is the communication time for reading the PLC data from the CNC. The 5ms is that the PLC
gains the system control signal (F, X), and uploads the control result data (G and Y parameters)
external port I/O (X and Y). PLC is always performed the ladder diagram calculation other than the
interruption of the response exchange data.
Volume I Programming
Fig. 2-3-2
nd
When the last partition number of the 2
level program of the n is performed, the program then
executes from its beginning. In this case, when the partition number is n, the performance time of one
cycle is 8*n ms. The 1st level program performs once each 8ms; the 2nd level program performs once
each 8*n ms. If its steps of the 1
st
level program is increased, and therefore the steps of the 2nd level
program within 8ms should be reduced correspondingly; the partition number may be increased, and
the treatment time of the overall programs will be longer. So, the compilation of the 1
st
level program
should be shorter.
2.4 Sequence Program Structure
The ladder diagram compiles in turn in the traditional PLC. However, it owns the following
advantages in the ladder diagram language allowing the structured programming:
1. The program is easy to comprehend and compile.
2. It is more convenient to find the faults during the programming.
7
Page 24
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
3. It is easy to find some reasons when the operation malfunction occurs.
There are 3-kind of structuring programming methods:
Sub-program
The subprogram is regarded as a treatment unit based on the ladder diagram.
Volume I Programming
Nesting
One subprogram can be performed the task by calling another one.
Task A
Task B
Main program
Task A
Task B
A
A
C
B
.
.
.
.
C
Fig. 2-4-1
Subprogram 1Subprogram 2
Task A1
Task An
Task A11
Task A12
Fig. 2-4-2
Conditional branch
The main program is performed circularly, and checks whether its conditions are suitable. If does,
perform the corresponding subprograms, vice versa.
Fig. 2-4-3
8
Page 25
Chapter Two Sequence Programming
2.5 Input/output Signal Treatment
Input signal treatment:
Volume I Programming
Output signal treatment:
CNC
8ms
CNC—PLC
Shared register
Machine tool
input register
IO terminal
Fig. 2-5-1
Fig. 2-5-2
PLC
The 1
level
program
nd
The 2
level
program
st
2.5.1 Input Signal Treatment
(1) NC input register
The NC input signals from the NC are memorized into the NC input register, which are
transferred to PLC each 8ms. The 1
state of these signals.
(2) Machine tool input register
st
level program performs the corresponding treatment using
9
Page 26
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
The machine tool input register is scanned and memorized its input signal from the machine
each 8ms. The 1
st
level program is also performed the corresponding treatment by using this signals
directly.
(3) The 2
nd
level program input latch
The 2nd level program input signal latch is also called the 2nd level program synchronic input
signal register. Wherein, the stored input signal is treated by the 2
in the register is synchronic with the 2
nd
level one.
nd
level program. This signal state
The signals both in the NC and machine tool input latch can be locked to the 2nd level program
input latch, as long as the 2
during the performance of the 2
nd
level program performs. The signal state in this latch keeps invariable
nd
level program.
Volume I Programming
2.5.2 Treatment of the Output Signal
(1) NC output register
The output signal transfers to the NC output register from the PLC each 8ms.
(2) Machine tool output register
The signal memorized in the machine tool output register conveys to the machine tool each
8ms.
Note: The signal states, such as the NC input register, NC output register, machine input register and machine
output register, which can be displayed by the self-diagnosis function. The diagnosis number is the address
number in the sequence programming.
2.5.3 Distinguish of Signal State Between 1st Level and 2nd Program
As for the same input signal, their states may different between the 1st and 2nd level
programming, that is the reason that different registers are used between two levels programming.
Namely, the input signal used with the 2
therefore, the signal in the 2
nd
level program is later than the 1st level one. At the worst case, one 2nd
nd
level program is the one of the 1st level who is locked. And
level program performance cycle can be lagged.
It is better to remember this point when programming the ladder diagram.
10
Page 27
Chapter Two Sequence Programming
A
A
.
.
.
.
END1
.
.
.
.
B
C
It belongs to the 2nd partition
of the 2
nd
level program
Fig. 2-5-3-1
A=1 performs the 1st level program when the 1st 8ms is performed, then B=1. And therefore, the
nd
2
level program is performed, the A=1 is latched to the 2nd level program, and then the first partition
of the 2
therefore, the 2
nd
level program is completed.
A turns into 0 to perform the 1
nd
partition of the 2nd level program is performed; in this case, the state of the A is still
st
level program when the 2nd 8ms is performed, then B=0. And
latched as the one last time. So, C=1.
In this way, the state both B and C are different.
Volume I Programming
2.6 Interlocking
In the sequence control, the interlocking is very important from the safety issue.
It is necessary to use the interlocking in the sequence control programming. Simultaneously,
the hard interlocking is used in the relay control circuit of the strong electric cabinet of the machine
tool sides. This is the reason that the interlocking is disabled when the hardware of the performance
sequence programming malfunctions, even if the interlocking is logically used in the sequence
program (software). And therefore, the interlocking can be ensured the safety for the user, and
prevent the machine tool from damaging in the strong electric cabinet of the machine sides.
11
Page 28
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Volume I Programming
12
Page 29
Chapter Three PLC Address
CHAPTER THREE PLC ADDRESS
An address can be used for distinguishing a signal. Different address is separately
corresponding to the I/O signal at the side of the machine tool, the I/O signal at the side of the CNC,
the internal relay, the counter, the timer, the keep relay and the data list. Each address is composed
of the address number and bit number, and its number is as shown below:
Address number rules:
Address number consists of Address Type, Address Number and Bit Number.
Address type: X, Y, R, F, G, K, A, D, C and T
Address number: Decimal number means one byte.
Bit number: Octonary number system, 0~7 are separately indicated the bytes (0~7 bits) in the
front of the address number.
The address type of the GSK218MC PLC is shown below:
Add. Address explanation Length
X Machine →PLC (64 bytes) INT8U
Y PLC → machine tool (48 bytes) INT8U
F CNC → PLC (64 bytes) INT8U
G PLC → CNC (64 bytes) INT8U
R Intermediate relay (512 bytes) INT8U
D
DC The data register of the counter preset value INT16U
C
A PLC alarm detection INT8U
T
DT The data register of the timer preset value INT16U
K Keep relay (64 types) INT8U
Data register (0~255)
Counter (0~127)
Timer (0~127)
X 000 . 6
Type Address No. Bit No.
Table 3-1
INT16U
INT16U
INT16U
Volume I Programming
INT8U data type is 8-bit character type without symbol, INT16U data type is 16-bit integral type
without symbol.
3.1 Machine → PLC address (X)
The X address of the GSK218MC PLC composes of two types:
13
Page 30
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
1. The X address is assorted with the three I/O input terminals, namely, XS40, XS41 and
XS42.
2. The X address is assorted with the input button on the MDI panel of the system.
3.1.1 X Address on I/O Input
The addresses (48 addresses) are defined as INT8U from X0 to X5, which are distributed on
the three I/O input terminals, for example, XS40, XS41 and XS42.
Users can define the signal significance of the X address of the I/O ports based upon the actual
cases, which can be connected the machine tool and compiled the corresponding ladder diagram.
Volume I Programming
Refer to the appendix one (GSK218MC CNC system PLC I/O address) and the configuration and
definition of the internal software components for the initial definition of the input address.
3.1.2 X Address on MDI Panel
There are 11 types from the addresses X20 ~ X30 of which these addresses are corresponding
with the button input on the MDI panel one by one. User can not modify its signal definition. The
buttons on the MDI panel should be firstly responded by CNC, and then conveys the X signal to
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
5.1 END1 (The 1st Level Sequence Program End)
Function:
This function can be specified once in sequence program at the end of the 1
it can be performed at the beginning of the 2
execute. The first program can be compiled up to 500 steps.
Format:
Volume I Programming
5.2 END2 (The 2nd Sequence Program End)
Function:
It specifies at the end of the 2
Format:
nd
Fig. 5-1-1
nd
level program.
st
level program, or
level program when the 1st level program does not
END1
END2
Fig. 5-2-1
5.3 CALL (Call Subprogram)
Function:
Call one specified subprogram
It owns the following characters and limitations:
Subprogram can be nested and called other subprograms up to 18 layers, as for the endless
repetition caused by the closure call, the system may alarm. The system allows that the maximum
subprogram call number is 100 for controlling the performance data value. The subprogram call can
not be performed at the 1
after SPE, or before SP, the system can not be performed, and then alarms.
st
level program. The code or network wrote between END2 AND SP, or
Format:
28
Page 45
ACT
Chapter Five PLC Function Code
Subprogram
CALL
number
Control condition:
ACT=0, Perform next code followed with CALL.
ACT=1, call subprogram of the specified subprogram number
Parameter:
indicated at 0~99.
Subprogram number: Specify the called subprogram number. The subprogram number is
Fig. 5-3-1
5.4 CALLU (Unconditionally Call Subprogram)
Function:
Unconditionally call one specified subprogram
It owns the following characters and limitations:
Subprogram can be nested and called other subprograms up to 18 layers, as for the endless
Volume I Programming
repetition caused by the closure call, the system may alarm. The system allows that the maximum
subprogram call number is 100 for controlling the performance data value. The subprogram call can
not be performed at the 1
after SPE, or before SP, the system can not be performed, and then alarms.
Format:
st
level program. The code or network wrote between END2 AND SP, or
Subprogram
CALLU
Fig. 5-4-1
Parameter:
Subprogram serial number: Specify the called subprogram number, and its range is 0~99.
number
29
Page 46
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
5.5 SP (Subprogram)
Function:
SP is used to generate a subprogram. The subprogram number is regarded as its name. The
range of the subprogram is specified by the SP code and the after-mentioned SPE code together.
Notice:
1. The subprogram should be compiled followed END2.
2. Another subprogram can not be set inside one subprogram.
Format:
Volume I Programming
Parameter:
Subprogram number: specify a called subprogram mark number, its range is 0~99.
5.6 SPE (End of Subprogram)
Function:
* Use SPE and SP together to specify the range of subprogram.
* The control will return to the main program of the called subprogram when this function
code is performed.
* The subprogram should be compiled after END2.
Figure format
SP
Subprogram
number
Fig. 5-5-1
For example
30
SPE
Fig. 5-6-1
Page 47
Chapter Five PLC Function Code
CALL P33
END2
SP P33
SPE
Fig. 5-6-2
5.7 SET (Replacement/Setting)
Function:
Set 1 in the specified address.
Format:
ACT
SET
Controllable condition:
Add.b
Fig. 5-7-1
Volume I Programming
(Address)
ACT=0, the state of the add.b remains invariable.
ACT=1, the add.b is set to 1.
Parameter:
Add.b: setting component address bit can be treated as the output coil, Add = Y, G, R, K and A.
5.8 RST (Resetting)
Function:
Set 0 on the specifying place.
Format:
31
Page 48
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Fig. 5-8-1
Controllable condition:
ACT=0, the state of the add.b remains invariable.
ACT=1, add.b is set to 0.
Parameter:
Add.b: resetting component address can be treated as output coil, Add = Y, G, R, K and A.
Volume I Programming
5.9 JMPB (Mark Number Skip)
Function:
JMPB immediately transfers the control to program following with mark number in the ladder
diagram programming.
The characters and limitations are shown below:
Format:
* Multiple skip codes can be shared with the same mark number.
* The skip can not be performed each other between the 1
* The skip can not be performed among the subprograms.
* Rebound is allowable, but users should hold the endless cycle which may be caused by
it.
* The skip can not be performed between main program and subprogram.
st
and the 2nd level programs.
Controllable condition:
ACT=0, Do not skip, perform the next code followed JMPB.
ACT=1, Perform the next code after the mark number when the skip jumps to the specified
mark number.
Parameter
32
Lx: Specify a skip object mark number. Any value (from 0 to 99) can be specified.
ACT
JMPB
Destination
mark number
Fig. 5-9-1
Page 49
Chapter Five PLC Function Code
5.10 LBL (Mark Number)
Function:
Specify one mark number in the ladder diagram, namely, it is a specified skip destination for
JMPB.
It is very important to notice that one mark number with xx only can be specified once using LBL.
It may alarm if it uses repeatedly.
Format:
Parameter:
For example:
LBL
xx: Specify a skip object mark number, its range is 0~99.
JMPB 33
LBL 33
JMPB 33
Mark number
Fig. 5-10-1
Volume I Programming
5.11 TMR (Timer)
Function:
Delay conducting timer.
Format:
ACT
TMR
Fig. 5-10-2
TIMER (Timer
number)
Fig. 5-11-1
(W)
33
Page 50
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Controllable condition:
ACT=0, close the timer.
ACT
=1, start the timer.
The concrete operation is as follows:
ACT
W
Volume I Programming
Parameter:
TIMER : The timer number indicates by xxx (it expresses by numbers from 0 to 127).
Output:
W : Output coil. W=1 when it reaches to the resetting value, W=0 means it does not reach
Note: TIMER performs once each 8ms, its setting unit is ms, and 8ms is the performance radix, complete 8ms if it is
insufficient. For example: the setting is 54ms, 54=6*8+6, complete 2ms, the actual performance is 56ms. The
time of the timer is set in the [TMR] of the [PLCPAR] under the program-controlled interface. The sequence
number of the timer may be detected its range by the system directly. The alarm may occur when the
sequence number repeats or exceeds its range.
5.12 TMRB (Fixed Timer)
to it.
TIMER= Setting time
Fig. 5-11-2
Function:
Delay conducting timer
Format:
ACT
TMRB
Controllable condition:
ACT=0, Close the timer
ACT
=1, Start the timer
The concrete operation is as follows:
34
Timer
accuracy
Fig. 5-12-1
Timer
number
Presetting
time
(W)
Page 51
Chapter Five PLC Function Code
ACT
W
TIMER = Setting time
Fig. 5-12-2
Parameter:
TIMER: Fix the timer number, it is indicates by xxx, xxx is numbers from 0 to 127.
Table 5-12-1 (Timer accuracy)
Timer
Setting No. Timer range setting Error range
accuracy
8ms 0 From 8ms to 524.280s
48ms 1 From 48ms to
Scan period from 0 to the 1st level program
Scan period from 0 to the 1st level program
31.456min
1s 2 From 1s to 546 min
10s 3 From 10s to 182 h
1min 4 From 1min to 65535min
1ms 5 From 1ms to 65.4s
Scan period from 0 to the 1st level program
Scan period from 0 to the 1st level program
From 0 to 1s
Scan period from 0 to the 1st level program
Presetting time
The time setting of the fixed timer, its numerical range is: 0~65535.
Output
W : Coil output. W=1, it reaches to the presetting. W=0, it does not reach.
Note: As for the sequence of the timer, the system may check its range automatically, if the repeated sequence or
out of the range, the system may alarm. The presetting time in timer is solidified in the ROM along with the
ladder diagram, so, the time of the timer only can be changed by modifying the ladder diagram file.
Volume I Programming
5.13 TMRC (TIMER)
Function
Delay conducting timer
Format
ACT
Controllable condition
ACT=0, Close the timer
TMRC
Timer
accuracy
Fig. 5-13-1
Timer
number
(W)
35
Page 52
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
ACT=1, Start the timer
The concrete operation is as follows:
ACT
W
Parameter
TIMER: The timer number indicates by xxx (xxx expresses by numbers from 0 to 127).
Volume I Programming
Timer
precision
8ms 0 From 8ms to 524.280s
48ms 1 From 48ms to 31.456
1s 2 From 1s to 546 min
10s 3 From 10s to 182 h
1min 4 From 1min to 65535min
1ms 5 From 1ms to 65.4s
Output:
Setting
No.
TIM ER=S etting tim e
Fig. 5-13-2
Table 5-12-1 (Timer accuracy)
Setting time range Error range
Scan period from 0 to the 1st level program
Scan period from 0 to the 1st level program
min
Scan period from 0 to the 1st level program
Scan period from 0 to the 1st level program
From 0 to 1s
Scan period from 0 to the 1st level program
W : Output coil. W=1, it reaches to the presetting, W=0, it does not reach to it.
Note: The time of the timer is set in the [TMR] in the [PLCPAR] controlling by the program control surface. TMRC and
TMR timers are shared with a same address, so, the TMRC and TMR timers can not be repeatedly used. The
system may automatically check the range of the timer sequence. It may alarm when the sequence number is
repeated or exceeded its range.
5.14 CTR (Binary Counter)
Function:
The data in the counter are binary system, which have the following functions based upon the
applications.
1) Presetting counter
2) Ring-counter
If the count reaches to the output signal of presetting value, preset the numerical value.
36
Page 53
Chapter Five PLC Function Code
When the counter reaches to the presetting value, it inputs the count signal and resets the initial
value and performs the count again.
3) Addition and subtraction counter
This is treated as the forward-backward counter, which can be used both addition and
subtraction.
4) The selection of the initial value
The initial value can be regarded as 0 or 1.
Format:
Volume I Programming
Controllable condition:
Specify initial value (CN0):
CN0=0, counter begins with 0.
CN0=1, counter begins with 1.
Specify rising or descending counter (UPDOWN):
UPDONW=1, subtraction counter
UPDOWN=0, addition counter
Reset (RST):
RST=0, Remove the reset
RST=1, reset: W resets to 0, and the counter value reset to initial value. The RST is set
to 1, as long as the reset is required.
Counting signal (ACT):
ACT=1: Count performs when ACT is at the rising edge.
ACT=0: Counter does not operate, W holds unchangeable.
Fig. 5-14-1
Parameter:
COUNTER: Specify the number of the counter, which is indicated by xxx (xxx is No. 0 to
No.127).
Output:
W : Coil output, W=1, it reaches to the presetting value.
Note 1: The system may automatically check the sequence number range of the timer, it may alarm if the sequence
37
Page 54
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
is repeated or exceeded its range.
Note 2: The current value of the timer may automatically clear, after the ladder diagram is converted and
downloaded.
Reset the counter by the pulse signal before counting for ensuring the reliable of the counter.
5.15 DEC (Binary Decoding)
Function:
DEC can be decoded for the binary system code data, one of the consecutive data of the
specified 8-bit (1 type) or 16-bit (2 types) is same as the code data. The corresponding output data
Volume I Programming
bit is 1; the output data is 0 without any same number.
This code is used for the data decode of M or T function.
Format:
Controllable condition:
ACT=0: Reset all of the output bits.
ACT
=1: Perform the data decode; the treated result is set at the output data address.
Parameter:
Length: Set the dimension of the code data at the 1
0001: The code data is binary system code data of one byte.
0002: The code data is binary system code data of two bytes.
S1: Code data address. Specify an address of the storage code data.
S2: Decoding specifying No. Specify the 1
decoded (1 byte) or 16-bit (two bytes).
S3: Decode result address. Specify an address output the decoding result. The register area
must be output with one byte or two bytes areas.
For example:
Fig. 5-15-1
st
bit data of the parameter.
st
bit with the consecutive number of the 8-bit to be
38
ACT
DEC
1F108R4
Fig. 5-15-2
Page 55
Chapter Five PLC Function Code
When ACT=1, F10=8, R4=0000,0001;
When ACT
=1, F10=9, R4=0000,0010;
………………………….
When ACT
=1,F10=15, R4=1000,0000;
5.16 COD (Binary System Code Conversion)
Function:
COD code may automatically produce a corresponding table under its function block when it
inputs the data capacity, which is used for inputting the conversion table data for the user. 10 grids of
each row in this table, it calculates based upon the quotient +1 if it can not be exactly divided, but the
capacity data does not change, and then the address of the table number may not display.
Format:
Volume I Programming
S1
S2
S1
S2
Controllable condition:
Reset (RST):
RST=0, Do not reset.
RST=1, It will output W resetting incorrectly
Working code (ACT):
ACT
=0: Do not perform the COD.
=1: Perform the COD. The value of the “conversion input data address (S1)” is
ACT
regarded as the table number of the conversion table, the corresponding
conversion data of the table number is taken out from conversion table to
Fig. 5-16-1
Table 5-16-2
0129
XXXYYYAAA
101112N-1
………
………
………
………………………………
………
UUU
output the “output address to the conversion data (S2)”.
39
Page 56
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Fig. 5-16-2
Volume I Programming
Parameter:
Output:
If the abnormal occurs during the COD code performs. W=1, it indicates that the error issues.
Note: The capacity of the conversion data table is up to 100 bytes (bits), this table is compiled between the
Length1: Specify the byte number of the binary system data of the conversion data in the
conversion table.
1: Binary system of 1 byte.
2: Binary system of 2 bytes.
Up to 512 bytes.
Length2: The capacity of the conversion table data. Each conversion table capacity can
not more than 100, it is 100 bytes when 1 type format is specified; it is 100 bits
when 2 bytes format are specified. The total capacity of the entire COD codes
conversion table should be less than 512 bytes.
S1: The data in the conversion table can be taken out by the specifying table number,
and the address of the specifying table number is regarded as the input address of
the conversion data. This address should be supplied a register with one byte.
S2: The output address of the conversion data. Specify the byte numbers of the register
in the form specification beginning with the address.
parameter conversion data output address and error output (W).
5.17 COM (Concentric Line Control)
Function
COM specifies the control until the coil working within the public end code COME range. The
system may alarm if the public end code does not specified.
Format:
40
Page 57
Controllable condition:
Chapter Five PLC Function Code
Fig. 5-17-1
When ACT=0, the coil within the specified range is cut off without any condition (W=0).
When ACT=1, it is same as the end of COM code.
Note 1: Do not specify another COM code within the range of one COM code.
Note 2: When the ACT = 0 of the COM, the coil within the specified range WRT NOT is set to 1 at any time (WRT
NOT = 1).
Note 3: The function codes, such as JMPB, END1, END2, CALL, CALLU, LBL, SP, SPE, COM and COME, can not
be used between COM and COME, otherwise the system may alarm.
5.18 COME (Concentric Line Control End)
Function:
This code is specified the controllable range of the concentric control line code (COM), which
can not be used separately; it must be used with COM together.
Format
COME
Volume I Programming
Fig. 5-18-1
5.19 ROT (Binary Rotation Control)
Function:
It is used for the revolving control, such as the tool post and rotation worktable. The code is
with some functions, refer to the following:
1. Select the revolving direction with the short path.
41
Page 58
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
2. Count the steps from the current position to the objective one; or count the steps from the
previous position of the current one to the previous position of the objective one.
3. Count the position number at the objective previous position or the steps at the objective
previous position.
Format:
Volume I Programming
Controllable condition:
Parameter:
CNO
DIR
ROT
position address
Current position
Objective position
Rotary table
address
S1
S2
address
S3
Calculation result
output address
(W)
S4
POS
INC
ACT
Fig. 5-19-1
Specify the initial number of the rotary table (CN0):
CNO=0, counter begins with 0.
CNO=1, counter begins with 1.
Check whether the short path can be selected the rotation direction (DIR):
DIR=0, Do not select; the selection direction is only positive.
DIR=1, Selection; the selection direction can be divided into positive or negative.
Specify the operation condition (POS):
POS=0, counting objective position
POS=1 the previous position of the counting object
Specify the position numbers and steps (INC):
INC=0, counting position number. Specify INC=0 and POS=1 if the previous position of
the objective one is to be calculated.
INC=1, counting steps. Perform the code (ACT) when the code INC=1 and POS=0, if
the distance between the current position and the objective one is to be
calculated.
Performance code (ACT):
ACT= 0, do not perform the ROT code. W is without change.
ACT
=1, perform the ROT code. Generally, set the ACT=0, if the operation result is to
be required, and then set the ACT=1.
S1 : Provide the rotary position number.
S2 : Provide the address storing the current position.
S3 : Specify the address (or code value) storing the objective position. For example,
store the address of the T code outputting from the CNC.
S4 : The calculation outputs to address, compute the steps to be rotated of the rotary,
42
Page 59
Chapter Five PLC Function Code
which reaches to the objective position or the previous position. Always check
whether the ACT is 1 when using the calculation result.
Output:
W : Rotation direction output. It outputs to the W by the short-circuit rotation direction,
its direction is positive (FOR) when W=0; it is the negative direction (REV) when
W=1. The definitions of the FOR and REV are shown below, the increase direction
of the position number of the revolving table is positive (FOR); it is the negative
direction in the decrease state. The address of W can be selected freely, however,
if the W results should be used, always check the condition of the ACT=1.
For example: One revolving table is shown below:
Volume I Programming
Fig. 5-19-2
Fig. 5-19-3
Perform the short path rotation, and calculate the position No. of the previous one for the
objection position.
Current position No. S2=1, revolving index position No. S1
=12, CNO=1, DIR=1, POS=1 and
INC=0
Wherein:
S3=10, S4
S3=8, S4
=11, W=1, when the objective position is A in the ACT = 1.
=9, W=1, when the objective position is B in the ACT = 1.
43
Page 60
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
S3=5, S4=4 and W=0, when the objective position is C in ACT = 1.
S3=3, S4
5.20 SFT (Register Displacement/Shifting)
Function:
This code can be shifted 1 byte (8-bit) based upon the digits specifying by the code parameter
each time. The “1” that overflows from cycle shifting will be added from the negative direction, for
example, the top bit “1” is overflown when shifting to left, the lowest bit supplies “1”, vice versa.
Format:
Volume I Programming
=2 and W=0 when the objective position is D in the ACT = 1.
Controllable condition:
Specify the shifting direction (DIR)
DIR=0, left shift
DIR=1, right shift
State specifying (CONT)
CONT=0, Do not perform the cycle shifting
CONT=1, perform the cycle shifting
Reset (RST)
Reset shifting output data (W=1) is (W=0)
RST=0, W does not reset
RST=1, W resets (W=0)
Execution condition (ACT)
ACT=0, Do not perform the SFT code.
Fig. 5-20-1
44
ACT=1, Perform the shifting, set ACT to 0 after the code is performed, if only 1 bit is
moved.
Page 61
Chapter Five PLC Function Code
Parameter:
S1 : Set the shifting data address, it composes of one storage area by 1 byte.
Length: it is a 4-digit, which is shown in the following figure:
Fig. 5-20-2
L: its range is 0~8
A: It is treated as bit-parameter, it is always shifted when ACT =1 during A =0, and it moves
once each period.
ACT is regarded as the pulse signal when A = 1, and when the value turns into 1 from 0, it
Volume I Programming
moves once.
Output:
W : “1” state does not move out when the W = 0 shifting operation is performed.
“1” state moves out when the W = 1 shifting operation is performed.
5.21 DIFU (Rising Edge Detection)
Function:
This code is set the output signal to 1 during the scan period of the input signal rising edge.
Format
ACT
DIFU
L Rising edge
number
Fig. 5-21-1
( W)
Controllable condition:
Input signal: The output signal is set to 1 at the rising edge (0
Output signal: The output signal keeps to 1 during one scan period of the ladder diagram when
the function code is performed.
Parameter:
L : The range of the rising number is 0~255. The system alarm may occur when another
DIFU code or DIFD code is used the same number in the ladder diagram.
Operation:
1) of the input signal.
45
Page 62
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Fig. 5-21-2
The system may automatically check the range of the series number of the rising edge, as for
the repeated series number or the exceeding range, the system alarm may occur.
Volume I Programming
5.22 DIFD (Descending Edge Detection)
Function:
This code outputs 1 signal of one scan period when inputting the signal descending edge.
Format:
Controllable condition:
Input signal: The output signal is set to 1 at the descending edge (10) of the input signal.
Output signal: The state in the output signal keeps one scan period of the ladder diagram when
ACT
DIFD
L Descending
edge number
Fig. 5-22-1
(W)
this function code is performed.
Parameter:
L : The range of the descending edge number is 0~255. The system alarm may occur when
another DIFU code or DIFD code is used the same number in the ladder diagram.
Operation:
46
Page 63
Chapter Five PLC Function Code
Fig. 5-22-2
The system may automatically check the range of the series number of the descending edge,
as for the repeated series number or the exceeding range, the system alarm may occur.
5.23 COMP (Comparison of Binary Number)
Function:
Compare the dimensions of two binary number data. Specify the enough bytes to store the input
data and comparison data in the memory block.
Format:
Volume I Programming
Fig. 5-23-1
Controlled condition:
ACT=0, Do not perform the COMP code. W value is invariable.
ACT
=1, Perform the COMP code
Parameter:
Length: Input the specified format (constant or address) and the specified data length (1 byte
or 2 bytes) of the data.
Fig. 5-23-2
S1, S2: The contents both the comparison 1 and comparison 2 can be regarded as constant
and address number.
Address No.: Type R, X, Y, F, G, K, A, D and C
Output:
W =0: Data input
W = 1: Data input ≤ Data comparison
> Data comparison
47
Page 64
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
5.24 COIN (Consistency Comparison)
Function:
This code can be detected whether the input value and comparison value are consistent.
Format:
Controllable condition:
Volume I Programming
ACT=0, Do not perform the COIN code. W value is invariable.
ACT
Parameter:
Length: Input the specified format (constant or address) and the specified data length (1 byte
or 2 bytes) of the data.
ACT
COIN
Length
format
specifying
=1, Perform the COIN code.
S1
Input value
Fig. 5-24-1
S2
Comparison
value address
(W)
Fig. 5-24-2
S1 : The input data can be specified both the constant and storage address.
S2 : Compare the storage address of the data.
Output:
W : W = 0: input value ≠ comparison value
W = 1: input value = comparison value
5.25 MOVN (Data Transmission)
Function:
The data of the source address or the specified binary data is transferred to the destination
address.
Format:
48
Page 65
Chapter Five PLC Function Code
Fig. 5-25-1
Controllable condition:
ACT=0, No data to be transferred
=1, The byte specified by the quantity is transferred.
ACT
Parameter:
Length: The byte numbers or data number to be transferred.
S1 : Resource start address or constant.
Select the transfer form based upon the S1:
1. If the S2 is single byte address, S1 is the constant, the resolution of the S1 based
upon the byte is copied to the address where it is corresponding Length type at the
beginning with S2; the S1 should be evaluated based upon the bit, if S2 is the bit
address; the bit address corresponding Length begins with the S2 address.
2. The address type both S1 and S2 will not be considered whether it is matched, which
is transferred the data by the byte address.
S2 : Destination start address.
For example:
Fig. 5-25-2
1. When S1 is regarded as constant 5, and the S2 is treated as R60, then
R60=00000101
Volume I Programming
2. When S1 is regarded as constant 5, and the S2 is treated as D60, then D60=5.
3. When S1 is address D50, and S2 is treated as D60, then D60=D50.
W=1, the specified quantity bytes are transferred.
W=0 No data transfer
The quantity range that exceeds the parameter type is detected when transferring, the system
alarm may occur.
5.26 MOVB (Transmission of 1 Byte)
Function:
49
Page 66
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
The MOVB code transfers the 1 byte data to a specified destination address from a specified
resource address.
Format:
Fig. 5-26-1
Controllable condition:
ACT=0, No data transfers.
ACT
=1, 1 byte is transferred.
Volume I Programming
Parameter:
S1 : Resource address or constant
S2 : Destination address
5.27 MOVW (Transmission of Two Bytes)
Function:
MOVW code transfers the 2 bytes data to a specified destination address from a specified
resource address.
Format:
If the S2 is single byte address, the S1 should be copied to the S2 address based
upon the byte value; if S2 is bit address, the S1 should be copied to the S2 lower
byte address based upon the byte value.
Controllable condition:
ACT=0, No data transfers.
ACT
=1, 1 byte is transferred.
Parameter:
S1 : Resource address or constant
S2 : Destination address
50
Fig. 5-27-1
Page 67
Chapter Five PLC Function Code
5.28 XMOV (Binary Indexed Data Transmission)
Function:
This function code is used to read or write the data from the data table. The data number
(table-capacity) in this table can be specified by address; the data table can be operated by PLC
based upon the user’s setting during operating.
Format:
Volume I Programming
Fig. 5-28-1
Controllable condition:
Specify the operation (read or write) (RW)
RW=0: Read the data from the data table.
RW=1: Write the data to the data table.
Reset (RST)
RST=0: Release the reset
RST=1: Reset W=0.
Execution code (ACT)
ACT=0: Do not execute the XMOV code, W keeps invariable.
=1: Execute the XMOV code.
ACT
Parameter:
Length: The format specifies the length of the transmission data.
1: 1 byte length.
2: 2 bytes length.
S1 : The data capacity storage address of the data table is used to store the data capacity
of the data table; the occupied byte number should be suitable for the specified length
of the Length. The valid range of the data is determined by the specified byte length of
the Length 1 format.
1 byte length: From 1 to 512.
2 byte length: From 1 to 256, that is, 256×2
of the PLC data table.
S2 : Set the address of the data table head. The storage area of the data table = byte length
× data number of its table. The address of the table head should be the value in which
is set inside the data table.
=512 bytes, which is the capacity
51
Page 68
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
S3 : Input/output address. Set and place the address from the reading when the data is read.
S4 : Storage address of the table number. It is used to store the table number to be read or
Output:
When the value in the table number exceeds the S1, W=1, the read or write of the data table
does not perform.
W=0, Without error
Volume I Programming
W=1, Error
Set and place the address from writing when the data is write. Its byte numbers should
be suitable from the setting of the Length format. This address is defined as D register.
write. It occupied bytes should be suitable for the specifying in the Length. If the setting
of the table number is more than the data registered in the S1, it outputs W=1 in a
wrong way.
5.29 DSCH (Binary Data Index)
Function:
This function code can be use for indexing the binary data in the data table. The data number
(table capacity) in the data table can be specified by address. In this case, the table capacity still can
be changed even if the program is written into ROM.
Format:
Fig. 5-29-1
Controllable condition:
Detection repetition (REP)
REP=0: Perform DSCH code, start to search it from the first address of the data table, it
will not consider the destination data may generate repeatedly; it may stop the
search outputting its address when detecting the destination data at the first
time. W=1, if the indexed data does not find.
REP=1: Perform DSCH code. If the indexed data does not find or it has two or above
data, W=1.
Reset (RST)
52
Page 69
Chapter Five PLC Function Code
RST=0, Release the reset.
RST=0: Reset W=0.
Performance code (ACT)
ACT=0: Do not perform DSCH code, W keeps invariable.
ACT
=1: Perform DSCH code. Output its table number if the indexed data is found; if it is
not found or it has two more above data, W=1.
Parameter:
Length : Format specifies the length of the index data.
1: 1 byte long
2: 2 bytes long
S1 : Data number storage address of the data table. The byte length specified by this
address is distributed the storage area for the requirement of the byte. The data number
of the data table is n+1 (table head is 0, the end of the table is n).
S2 : Set the data table head address.
Volume I Programming
S3 : Set the input address of the index address.
S4 : The address output of the index result. Actual address = head address + table number,
table number is 0
indexing: output its number from the list if the index data is found. The table number is
outputted to the index result output address of which the required storage byte number
should be suitable for the specified format.
Output:
W=0, Find the indexed data.
W=1, Do not find the indexed data.
~(S1-1), the actual address can not exceed the data table. After
5.30 ADD (Binary Addition)
Function:
This function code is used for the add operation of the 1 byte or 2 bytes binary data. The
addend data and the add operation output the data should be set the storage address with the
corresponding byte length.
Format:
Fig. 5-30-1
53
Page 70
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Controllable condition:
Reset (RST):
Execution code (ACT)
Parameter:
Length : Specify the data length (1 byte or 2 bytes) and the specifying method of the
Volume I Programming
RST=0 : Release the reset.
RST=1 : Reset W=0.
ACT
=0: Do not execute ADD code, W keeps invariable.
=1: Execute the ADD code.
ACT
addend (constant or address).
Fig. 5-30-2
S1 : Specify the storage addend address.
S2 : The specifying method of the addend is determined by the specification of the Length.
S3 : Specify the output operation address.
Output:
W=1: Operation is abnormal.
W=0: Operation is normal.
When the add operation result exceeds the specified data length, W=1.
5.31 SUB (Binary Subtraction)
Function:
This code is used for the subtraction of the 1 byte or 2 bytes binary data. The minuend and the
subtraction output data should be set the storage address with the corresponding byte length.
Format:
54
Fig. 5-31-1
Page 71
Chapter Five PLC Function Code
Controllable condition:
Reset (RST):
RST=0: Release the resetting.
RST=1: Reset W=0.
Execution code (ACT):
ACT
=0: Do not execute the SUB code, W keeps invariable.
=1: Execute the SUB code.
ACT
Parameter:
Length: Data length specified (1 or 2 bytes) and the addend specifying method (constant or
address).
Volume I Programming
Fig. 5-31-2
S1 : Specify and store the minuend address.
S2 : The specifying method of the subtractor is determined by Length.
S3 : Specify and output the address of the operation result.
Output:
W=0: Normal operation.
W=1: Abnormal operation.
The subtraction result exceeds the specified data length, W=1.
5.32 ANDF (Bit-by-bit AND)
Function
This code is performed the AND with a constant (or the content from the address B) from the
content of the address A (or the one from the address B), and its result is stored to address C.
Format:
Fig. 5-32-1
55
Page 72
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Controllable condition:
ACT=0: Do not execute ANDF code.
=1: Execute the ANDF code.
ACT
Parameter:
Length : Specify the data length (1 byte or 2 bytes), input the data format (constant or
address).
Volume I Programming
S1: Specify the input data that will to be performed by AND. The address is then begins and the
data length is consistent with the Length.
S2: The input data is performed with the one of the AND. When the format specifying is
S3: It is used for storing the address of ANDF operational result. The result from the ANDF is
For example: When the address A and B have the following data, which are shown below:
Address A
Address B
The operational result of the ANDF is shown below:
Address C
Fig. 5-32-2
selected the address, the address is then started, and the data length is consistent with the
length.
stored from this address, and the data length is consistent with the one of the Length.
1 1 1 0 0 0 1 1
0 1 0 1 0 1 0 1
0 1 0 0 0 0 0 1
5.33 ORF (Bit-by-bit OR)
Function:
This code is performed the OR with a constant (or the content from the address B) from the
content of the address A, and its result is stored to address C.
Format:
56
Page 73
Controllable condition:
ACT=0: Do not execute the ORF code.
=1: Execute the ORF code.
ACT
Parameter:
Chapter Five PLC Function Code
Fig. 5-33-1
Volume I Programming
Fig. 5-33-2
Length : Specify the data length (1 byte or 2 bytes), input the data format (constant or
address).
S1 : Specify the input data that will to be performed by NOT. The address is then begins
and the data length is consistent with the length.
S2 : The input data is performed with the one of the OR. When the format specifying is the
address specification, and therefore, the address starts, and the data length is
consistent with the specified Length..
S3 : It is used for storing the address of ORF operational result. The result from the ORF is
stored from this address, and the data length is consistent with the one of the length.
For example: When the address A and B have the following data, which are shown below:
Address A
Address B
The operational result of the ORF is shown below:
Address C
1 1 1 0 0 0 1 1
0 1 0 1 0 1 0 1
1 1 1 1 0 1 1 1
5.34 NOT (Bit-by-bit NOT)
Function: This code is reversed to each content in address A, and store the result to the address B.
Format:
57
Page 74
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
Controllable condition:
ACT=0, Do not execute the NOT code.
ACT
Parameter:
Length: Specify the data length (1 byte or 2 bytes)
Volume I Programming
Fig. 5-34-1
=1, Execute the NOT code.
Fig. 5-34-2
S1 : The input data is reversed bit-by-bit. The address is started and the data length is
consistent with the length.
S2 : It is used for outputting NOT operational result. The result of the NOT operation starts
to store from this address, and the length of the data is consistent with the one of the
length.
For example:
When the address A and B have the following data, which are shown below:
Address A
The operation result of the NOT is shown below:
Address B
1 1 1 0 0 0 1 1
0 0 0 1 1 1 0 0
5.35 EOR (Exclusive OR)
Function:
This code is performed the Exclusive OR with a constant (or the content from the address B)
from the content of the address A, and its result is stored to address C
58
Page 75
Chapter Five PLC Function Code
Format:
Fig. 5-35-1
Controllable condition:
ACT=0 : Do not execute the EOR code.
ACT
=1: Execute the EOR code.
Parameter:
Length : Specify the data length (1 byte or 2 bytes), input the data format (constant or
address).
Volume I Programming
Fig. 5-35-2
S1 : Specify the input data that will to be performed by Exclusive OR. The address is then
begins and the data length is consistent with the length.
S2 : The input data is performed with the one of the Exclusive OR. When the format
specifying is selected the address, the address is then started, and the data length is
consistent with the length.
S3 : It is used for storing the address of EOR operational result. The result from the EOR
is stored from this address, and the data length is consistent with the one of the
length
For example: When the address A and B have the following data, which are shown below:
Address A
1 1 1 0 0 0 1 1
Address B
0 1 0 1 0 1 0 1
The operational result of the EOR is shown below
Address C
1 0 1 1 0 1 1 0
59
Page 76
GSK218MC Series Machining Center CNC System PLC & Installation Connection Manual
CHAPTER SIX COMPILATION LIMIT OF LADDER DIAGRAM
1. The program should with the codes END1 and END2, which are regarded as the end symbol
st
of the 1
2. It is only support the parallel output instead of the multi-level output.
3. The result output address in the overall basis codes, output function codes can not be set as