128 bytes(X0 to X127)
128 bytes (Y0 to Y127)
256 bytes (F0 to F255)
256 bytes (G0 to G255)
P:10
1.2 What ’s a Sequence Program
A sequence program is a program for sequence control of machine tools and other systems.
The program is converted into a format to enable CPU execute encoding and arithmetic
processing, and stored into RAM. CPU reads out every instruction stored in the memory at a
high-speed and execute the program by arithmetic operation
The sequence program is written firstly from ladder.
3
GSK 25i Milling CNC System User Manual
1.3 Assignment of interface specifications(step 1)
After deciding the control object specification, calculate the number of input/output signal points,
create the interface specification.
For input/output interface signals, see Chapter 4.
1.4 Establishment of ladder diagram(step 2)
Express the control operations decided by 25i ladder diagram. For the timer, meter, etc, which
cannot be expressed with the functional instructions.
The edited ladder should be converted into the corresponding PLC instruction i.e. instruction list
to store.
1.5 Sequence program debugging(step 3)
The sequence program can be debugged in two ways:
1) Debug by simulator
Instead of the machine, connect a simulator (consisting of lamps and switches). Switch
ON/OFF stands for the input signal state of machine, lamp ON/OFF for the output signal state.
2) Actual operation debugging
Debug sequence program through operating the machine. Do measures against the
unexpected affairs before debugging.
4
Volume Ⅱ PLC Programming and Connection
2 Sequence Program
Since PLC sequence control handled by software and operates on principle difference from a
general relay circuit, the sequence control method must be fully understood in order to design PLC
sequence program.
2.1 Execution process of sequence program
In general relay control circuit, each relay operates at approximately the same time, in the figure
below for example, when relay A operate, the relay D and E operate at approximately the same
time(when contacts B and C are off)., In PLC sequence control, each relay of circuit operates
sequentially. When relay A operates, relay D operates, then relay E(see Fig.2-1). Thus each relay
operates in sequence which can be written as a ladder diagram. (Programmed sequence).
Fig. 2-1(a)
Fig.2.1(b) and (c) illustrate operations varying from the relay circuit to PLC programs.
Fig. 2-1(b)
Fig.2-1(c)
A
A C
A C
A
A
A
B
D
E
B
C
C
C
B
5
GSK 25i Milling CNC System User Manual
(1) Relay circuit
In Fig. 2.1(b) and (c), the operations are the same. Turning on A turns on B and C. Turning on C
turns off B.(2) PLC program
In Fig.2.1(b), as in the relay circuit, turning on A turns on B and C, and after one cycle of the PLC
sequence, turns off B. But in Fig.2.1(c), turning on A turns on C, but does not turn on
2.2 Repetitive cycle
The PLC executes the ladder diagram from the beginning to the end . When the ladder diagram
ends, the program starts over from the beginning. This is called repetitive operation.
The execution time from the beginning to the end of the ladder diagram is called the sequence
processing time. The shorter the process time is, the better the signal response becomes.
2.3 Priority of execution(1
GSK25i PLC consists of two parts: 1st level sequence part, 2nd level sequence part. They have
different execution period.
st
The 1
level sequence part operates every 8 ms, which can deal with the short pulse signal with
st
level, and 2nd level)
high-speed response).
nd
The 2
level sequence part operates every 8*n ms. Here N is a dividing number for the 2nd level
sequence part. The 2nd level sequence part is divided into V part, and every part is executed every
8ms.
st
1
level
sequence part
END1
Specifies the end of the
1st level sequence part
Division 1
Division 2
nd
2
level
sequence program
END2
Division n
Fig. 2-2
Specifies the end of the
2nd level sequence part
6
Volume Ⅱ PLC Programming and Connection
GSK 25i PLC is solely executed in PLC-AVR single chip, and the first 1ms of each 8ms is the
communication time of CNC reading or writing PLC data. The fifth 1ms is the time that the PLC
receives the system control signal(F, X )and uploads the control result data(G, Y p ar am et er )to the
external I/O interface(X, Y), except for the time responding the interruption to exchange the data, the
PLC executes the ladder operation at the rest time.
1stlevel
nd
2
level
CNC use
8 ms
3 ms
Division 1
3 ms
Division 2
8 ms
8 ms
3 ms
Division n
Fig. 2-3
After the last 2nd level sequence part (division n) is executed, the sequence program is executed
again from the beginning. Thus, when the dividing number is n, the cycle of execution is 8*n ms. The
st
1
level sequence operates every 8ms, and the 2nd level sequence every 8*n ms. If the steps of the
st
1
level sequence is increased, the steps of the 2nd level sequence operating within 4ms becomes
less, thereby increasing the dividing number and making the processing time longer. Therefore, it is
desirable to program so as to reduce the 1
st
level sequence to a minimum.
2.4 Sequence program structure
With the conventional PLC, a ladder program is described sequentially. By employing a ladder
language that allows structured programming, the following benefits are derived:
1. A program can be understood and developed easily
2. A program error can be found easily.
3.When an operation error occurs, the cause can be found easily.
Three major structured programming capabilities are supported:
1) Subprogram
A subprogram can consist of a ladder sequence as the processing unit.
Fig. 2-4
7
GSK 25i Milling CNC System User Manual
2) Nesting
The Ladder subprograms can call the other ladder subprogram to execute the job.
Main program
Subprogram 2 Subprogram 1
Job A
Job A1
Job A11
Job B
Job An
Job A12
Fig. 2-5
3) Conditional branch
The main program loops and checks whether conditions are satisfied. If a condition is satisfied, the
corresponding subprogram is executed. If the condition is not satisfied, the subprogram is jumpped.
Main program
State 1
Subprogram 1
Process 1
Process 11
State 2
Process 2
Process 12
Fig. 2-6
Process 13
2.5 Processing I/O (input/output) signals
Input signal processing:
CNC
8ms
CNC—PLC
Input signals from
machine tool
IO interface
PLC
2nd sequence part
starting memory
2nd sequence part
input signal memory
Fig. 2-7
1st level
sequence
part
2nd level
sequence
part
8
Output signal processing:
CNC
CNC—PLC
Share memory
output memory from
machine tool
8ms
IO interface
2.5.1 Input signal processing
Volume Ⅱ PLC Programming and Connection
PLC
Fig. 2-8
1st level
sequence part
nd
2
level
sequence part
(1)Input memory of NC
The input signals from NC are loaded in memory of NC and are transferred to the PLC at
intervals of 8ms. Since the 1
st
level sequence part directly refer to these signal and process
operations.
(2)Input signal memory to machine tool
The input signal memory stores signals transferred from the machine tool at intervals of 8ms
period. Since the 1
(3)2
nd
level input signal memory
st
level sequence part directly refer to these signal and process operations.
The 2nd level input signal memory is also called as 2nd level synchronous input signal memory.
The stored signals are processed by the 2
synchronizes with that of 2
nd
level sequence part.
Input memory Signals from NC and machine tool are transferred to the 2
memory only at the beginning of execution of the 2
nd
2
level synchronous input signal memory does not change from the beginning to end of the
execution of the 2
nd
level sequence part.
nd
level sequence part. State of the signals set this memory
nd
level input signal
nd
level sequence part. Therefore, the state of the
2.5.2 Output signal processing
(1)NC output memory
The output signals are transferred form the PLC to the NC output memory at intervals of 8ms.
(2)Output signals to machine tool
Output signal to the machine tool from PLC output signal memory to the machine tool at intervals
of 8ms.
9
GSK 25i Milling CNC System User Manual
Note:
The state of the NC input memory, NC output memory, input signals from machine, input/output
memory signals to machine can be checked by using the PC self-diagnosis function. The
self-diagnosis number specified is the address number used by the sequence program.
2.5.3 Synchronous processing the short pulse signal
1st program can process the short pulse signal. When the short pulse signal change is less than
8ms, i.e.when the system executes the 1
followings.
st
program, the input signal state can change to cause the
Fig. 2-9
When A=0 and B1=1,A becomes 1, at the moment, the system executes the next
ladder statement to make B2=1. so, B1 and B2 become 1.
A
R
R
B1
R
B2
END1
Fig. 2-10
When the medium relay R synchronously processes the signal A, B1, B2 are not 1 at the same
time.
10
Volume Ⅱ PLC Programming and Connection
2.5.4 Difference state of signals between 1st level and 2nd level
The state of the same input signal may be different in the 1st level and 2nd level sequences. That
is, at 1
performed using the 2
sequence execution at the worst, compared with a 1
This must be kept in mind when writing the sequence program.
st
level, processing is performed using input signal memory and at 2nd level, processing is
nd
level synchronous input signal memory. Therefore, it is possible for a 2nd level
st
level input signal.
nd
2
division of 2nd
level sequence part
Fig. 2-11
When the processing is 1st 8ms, A=1, and B=1 after 1st sequence part is executed. At the same
time, 2nd sequence part is started to execute A=1 is stored to the 2nd sequence part and the 1st
division of 2nd sequence part is executed.
When the processing is 2nd 8ms, A=0, and B=0 after 1st sequence part is executed. And then
2nd division of 2nd sequence part is executed, at this time, A is still 1. So C=1.
So, B and C are different.
2.6 Interlocking
Interlocking is externally important in sequence control safety.
Interlocking with the sequence program is necessary. However, interlocking with the end of the
electric circuit in the machine tool magnetic cabinet must not be forgotten. Even though logically
interlocked with the sequence program (software), the interlock will not work when trouble occurs in
the hardware used to execute the sequence program. Therefore, always provide an interlock inside
the machine tool magnetic cabinet panel to ensure operator safety and to protect the machine from
damage.
11
GSK 25i Milling CNC System User Manual
3 Address
An address shows a signal location. Addresses include input/output signals with respect to the
machine, the input/output signals with respect to the CNC, the internal relays, the meters, the keep
relays, and data table. Each address consists of an address number and a bit number. Its serial
number regulations are as follows:
Address regulations:
The address comprises the address type, address number and the bit number in the format as
shown below:
Type: including X, Y, R, F, G K, A, D ,C, T
Address number: decimal serial number stands for one byte.
Bit number: octal serial number, 0~7 stands for 0~7 bit of byte of front address number
GSK25i PLC address type is as follows Fig.3-1:
Emergency stop, jump and other
high-speed signals
Machine to PLC
Input signal
MT
PLC to machine
Output signal
X
Y
Nesting
PLC
Fig. 3-1
G
F
PLC to NC
NC to PLC
25i
CNC
12
Volume Ⅱ PLC Programming and Connection
Table 3-1
Address Address explanation Address range
X machine→PLC(128 bytes)
Y PLC→machine(128 bytes)
F CNC→PLC(256 bytes)
G PLC→CNC(256 bytes)
R Internal relay(1100 bytes)
D Data register(1860 bytes)
C Counter (400 bytes)
T Timer (200 bytes)
A Timer preset data register (32 bytes)
K
Keep relay(32 bytes) K0~K31
3.1 Machine →PLC address(X)
X0~X127
Y0~Y127
F0~F255
G0~G255
R0~R1099
D0~D1859
C0~C 399
T0~T199
A0~A31
X addresses of GSK25i PLC are divided into two:
1. X addresses are assigned to IO input interface.
2. X addresses are assigned to the input press keys on MDI panel.
3. X addresses are assigned to other external interfaces, such as the spindle, MPG control signal
input.
3.1.1 Assignment of IO module X address
The addresses are from X9 to X119. Its type is INT8U, 111 types.
The signal specification of X addresses can be customized by customer according to the actual
operation. X addresses are used to connect the machine tool with the ladder. For the initial definition
of input address, see Chapter Four Connection.
3.1.2 Assignment of MDI panel X address
The addresses are from X0 to X8, 9 bytes. They correspond to the press keys on MDI panel.
The corresponding relationship between them and the press keys on the standard panel is as Fig.