0% found this document useful (0 votes)
13 views46 pages

Ladder Programming and Development.

The document provides detailed information on Ladder Programming and Development for machine tools, focusing on the functions and purposes of M/S/T codes used in NC programs. It outlines the execution process of these codes, how to write them, and the structure for alarm management within the ladder diagram. Additionally, it includes guidelines for macro calling functions and user-defined alarms, ensuring effective control and monitoring of machine operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views46 pages

Ladder Programming and Development.

The document provides detailed information on Ladder Programming and Development for machine tools, focusing on the functions and purposes of M/S/T codes used in NC programs. It outlines the execution process of these codes, how to write them, and the structure for alarm management within the ladder diagram. Additionally, it includes guidelines for macro calling functions and user-defined alarms, ensuring effective control and monitoring of machine operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Ladder Programming and Development.

匯出日期:2022-09-29
修改日期:2019-12-26
机床产品/Machine Tool Products

Ladder Programming and Development.

–2
机床产品/Machine Tool Products

Ladder Programming and Development.

1 M/S/T Code

1.1 Functions and Purposes of M/S/T Code

NC programs normally use M code to drive the auxiliary devices like oil cooler or lubricant; use S code to set up
spindle speed; use T code to change tool.
By applying M/S/T code, it'll be able to execute synchronous control of external devices in NC program
through the ladder diagram.

NC Program Action Instruction

N1 G00 X50.0 Y100.0 N1 X axis/Y axis move to 50./100.mm with G00


N2 T1 N2 Change to tool No.1
N3 S1000 M3 N3 Spindle rotates at 1000 RPM CW
N4 G01 Z-10.0 F3000 N4 Z axis moves to -10.mm with G01
N5 M8 N5 Open cutting fluid
N6 G01 Z-15. F500 N6 Z axis moves to -15.mm with G01

In the example above, the tool changing is executed with T1 in second line of the program; the spindle speed is
set to 1000 RPM with S1000 and the CW rotation is started with M3 in the third line; the cutting fluid is opened
with M8 in the fifth line.
As for how the controllers deal with M/S/T code and drive the auxiliary devices correctly, there will be an
introduction to the structure in following chapters.

1.2 Process of M/S/T Code Actions

M/S/T Code – 3
机床产品/Machine Tool Products

Ladder Programming and Development.

• When the kernel of the controller executes the M/S/T code in NC programs, contents of the M/S/T code
will be saved in R1/R2/R3 registers.
• For example, when executes M3, the kernel saves 3 into R1, which means R1=3; when executes
T5, the kernel saves 5 into R3, which means R3=5.
• When the kernel of the controller executes the M/S/T code, it'll send M/S/T code reading flags to ladder
diagram, M/S/T code correspond to S29/S54/S69 respectively.
• For example, when executes M code, S29 will be triggered and can be used as the start signal of
some specific actions.
• The ladder diagram starts executing the organized actions right after received the M/S/T code reading
flags.
• If the M/S/T code are written in the same block of the NC program, the kernel will send S29/S54/S69 to
the ladder diagram at the same time when executing that block.
• After the organized actions of M/S/T codes are all done, C38 needs to be triggered in ladder diagram as
the M/S/T code finish flag.
• The kernel will continue to execute the NC program after receiving C38 signal.
• When editing the ladder diagram, please pay attention to the timing of C38 ON/OFF. The relation
between C38 and S29/S54/S69 is shown below.
• The action in red box is the rule of editing ladder diagram.
• The action in green box is the natural specification after the kernel detected C38 signal.

1.3 How to write M/S/T code

Basic Rules
• For M code needs completion confirmation, please write the ladder diagram with the concept of
"Machine State Diagram(MSD)".
• In normal state or when not running M/S/T code, it suggests C38 to stay triggered.
• As for M code that don't need completion confirmation such as cutting fluid, working LED, chip
conveying device, no need to turn off C38 while executing M code.
• As for M code that need completion confirmation such as spindle CW/CCW rotation, workpiece
gripping, spindle orientation, please turn off C38 while executing M code and activate it again after M
code is finish.

M/S/T Code – 4
机床产品/Machine Tool Products

Ladder Programming and Development.

MSD Example
• The picture below separates the execution of M/S/T code with 2 states.
• When M/S/T code are in ready state(A50), C38 is conducted.
• When M/S/T code are in execution state(A51), C38 is off to make the controller wait.

• M code that don't need completion confirmation:Take M8/M9 cutting fluid on/off as example,
organize 2 contacts A108/A109 to directly trigger the completion condition of M code, A70, and the
controller doesn't need to wait.
• M code that need completion confirmation:Take M3/M4 spindle CW/CCW rotation as example,
organize 2 contacts A103/A104. Since the spindle rotation is influenced by the acceleration time of the
motor, the machining process can only be proceed after the spindle reaches target speed. Thus, in M3/
M4 execution state, C38 needs to be off till the speed reaching signal I0 is activated for 0.5 sec, then can
be triggered again.

M/S/T Code – 5
机床产品/Machine Tool Products

Ladder Programming and Development.

M/S/T Code – 6
机床产品/Machine Tool Products

Ladder Programming and Development.

Component List:

I0 Spindle speed reaching A103 M3 Spindle CW rotation

A50 MST ready A104 M4 Spindle CCW rotation

A51 MST executing A108 M8 Cutting fluid ON

A70 No need to wait for M code A109 M9 Cutting fluid OFF

1.4 M/T Code Macro Calling Function

SYNTEC controller provides 10 sets of M code macro calling function and 1 set of T code macro calling
function.
So M/T code can also use the full macro function besides organizing actions in ladder diagram.
When controller executes the macro calling M/T code, it'll first execute the corresponding macro content and
won't trigger S29/S69 or set values into R1/R3.
But S29/S69 or R1/R3 will still be executed if M/T code are written in the macro.

M code macro calling function setup


• Register the macro calling M code in controller parameter Pr3601~3610.
• Prepare the calling macro first and save it in the path below:
• DOS system:C:CNC/MACRO
• CE system:DiskC/OpenCnc/MACRO
• The file name of the macro should correspond to the macro calling M code. For example, if Pr3601=50,
the macro file name should be M0050(no extension).

T code macro calling function setup


• Set Pr3215 as you need, reference:Pr3215 *Enable T code call mode.

M/S/T Code – 7
机床产品/Machine Tool Products

Ladder Programming and Development.

• Prepare the T code calling macro first and save it in the path below:
• DOS system:C:CNC/MACRO
• CE system:DiskC/OpenCnc/MACRO
• The file name of T code calling macro is always T0000(no extension).

1.5 M/S/T Code Additional Notifications

G/M code in the same block


When G code and M code appear in the same block, the controller sends G code action command and M code
reading flag(S29) at the same time.
With different properties, some M code can be executed with G code simultaneously(For example:M8
Cutting fluid On); some others can only be executed after G code is completed(For example: M5 Spindle
stop).
When dealing with the latter situation, it's suggested to use S30(G code completion signal in same block) to
add G code completion waiting state in MSD for protection.

Example:When G01 and M5 are in the same block, G01 must be completed first before executing M5.

M/S/T Code – 8
机床产品/Machine Tool Products

Ladder Programming and Development.

Multiple M code executing function


In some applications, users need to execute multiple M code at the same time instead of executing one by one.
For the situations, it's suggested to turn on the multiple M code executing function to satisfy the requirement.
• Please refer to the parameter manual: Pr3810 *Paralleled executing multiple M code in one block.
• Table below shows the related PLC components of 4 M/S/T channels after activating Pr3810.

1st Channel M code read S29 S11 S12 S13 S14

M code content R2050(R1) R2051 R2052 R2053 R2054

M code finish C38

M/S/T Code – 9
机床产品/Machine Tool Products

Ladder Programming and Development.

2nd Channel M code read R615.24(R615.2) R615.2 R615.2 R615.2 R615.2


5 6 7 8

M code content R2060(R616) R2061 R2062 R2063 R2064

M code finish R615.0

3rd Channel M code read R619.24(R619.2) R619.2 R619.2 R619.2 R619.2


5 6 7 8

M code content R2070(R620) R2071 R2072 R2073 R2074

M code finish R619.0

4th Channel M code read R623.24(R623.2) R623.2 R623.2 R623.2 R623.2


5 6 7 8

M code content R2080(R624) R2081 R2082 R2083 R2084

M code finish R623.0 1

• Example:The method below is able to output O1 and O2 at the same time no matter the order of M
code is M51 M52 or M52 M51.

M/S/T Code – 10
机床产品/Machine Tool Products

Ladder Programming and Development.

M/S/T Code – 11
机床产品/Machine Tool Products

Ladder Programming and Development.

2 How to send alarms with ladder diagram

The alarms sent by ladder diagram will be recorded into the history alarms of the controller automatically for
further analysis.
When alarms happened, the controller will only show the alarm on the screen and won't stop any executing actions.
Users should design the actions in the ladder diagram separately if any process needs to be suspended or stopped.

2.1 System Built-in Alarms

When R40 ~ R43 are outputted in the ladder diagram, alarm windows pop-up on the controller screen
according to the table below.

Alarm Number Output Alarm Message

001 R40.0 X+ hardware stroked limit exceed

002 R40.1 X- hardware stroked limit exceed

003 R40.2 X not yet back home

004 R40.3 X servo driver alarm

009 R40.8 Y+ hardware stroked limit exceed

010 R40.9 Y- hardware stroked limit exceed

011 R40.10 Y not yet back home

012 R40.11 Y servo driver alarm

017 R41.0 Z+ hardware stroked limit exceed

018 R41.1 Z- hardware stroked limit exceed

019 R41.2 Z not yet back home

020 R41.3 Z servo driver alarm

How to send alarms with ladder diagram – 12


机床产品/Machine Tool Products

Ladder Programming and Development.

025 R41.8 A+ hardware stroked limit exceed

026 R41.9 A- hardware stroked limit exceed

027 R41.10 A not yet back home

028 R41.11 A servo driver alarm

033 R42.0 B+ hardware stroked limit exceed

034 R42.1 B- hardware stroked limit exceed

035 R42.2 B not yet back home

036 R42.3 B servo driver alarm

041 R42.8 C+ hardware stroked limit exceed

042 R42.9 C- hardware stroked limit exceed

043 R42.10 C not yet back home

044 R42.11 C servo driver alarm

049 R43.0 Spindle driver alarm

050 R43.1 Coolant motor overload

051 R43.2 Oil press system alarm

052 R43.3 Air pressure too low

053 R43.4 Lube too little

054 R43.5 Coolant level too low

055 R43.6 Clamper not close

056 R43.7 Tool exchange system alarm

How to send alarms with ladder diagram – 13


机床产品/Machine Tool Products

Ladder Programming and Development.

057 R43.8 CPU temperature over than 100 degree

Alarm triggering
As the picture below, the external signal I-10 triggers R40.0, and R40.0 corresponds to PLC Alarm No.01.

2.2 User-defined Alarms

SYNTEC controller provides 96 PLC Alarms, 96 PLC Warnings and 319 PLC Hints for users to define, the Alarm/
Warning/Hint number and corresponding R bit is shown in the table below.
PLC Alarm number 01~64 are for system built-in alarms, please do not reuse.

Type R Bit Number Alarm Number

PLC Alarm R44.0 ~ R44.15 65 ~ 80

R45.0 ~ R45.15 81 ~ 96

R46.0 ~ R46.15 97 ~ 112

R47.0 ~ R47.15 113 ~ 128

R48.0 ~ R48.15 129 ~ 144

R49.0 ~ R49.15 145 ~ 160

PLC Warning R44.16 ~ R44.31 315 ~ 330

R45.16 ~ R45.31 331 ~346

R46.16 ~ R46.31 347 ~ 362

How to send alarms with ladder diagram – 14


机床产品/Machine Tool Products

Ladder Programming and Development.

R47.16 ~ R47.31 363 ~ 378

R48.16 ~ R48.31 379 ~ 394

R49.16 ~ R49.31 395 ~ 410

PLC Hint R590.1 ~ R590.31 1 ~ 31

R591.0 ~ R591.31 32 ~ 63

R592.0 ~ R592.31 64 ~ 95

R593.0 ~ R593.31 96 ~ 127

R594.0 ~ R594.31 128 ~ 159

R595.0 ~ R595.31 160 ~ 191

R596.0 ~ R596.31 192 ~ 223

R597.0 ~ R597.31 224 ~ 255

R598.0 ~ R598.31 256 ~ 287

R599.0 ~ R599.31 288 ~ 319

Note 1. PLC Alarms will be saved in history alarm, but PLC Warning and PLC
Hint won't.
2. PLC Hint doesn't need self-hold, the alarm window can be shown on
the screen continuously.
3. PLC Alarm and PLC Warning need self-hold in the ladder diagram to
make the alarm window stay on the screen.

DOS System Alarm String File


• File Path
Traditional/Simplified Chinese:C:CNC/APP/APPCHI.STR
English:C:CNC/APP/APPENG.STR
Others:C:CNC/APP/CNCLOC.STR
• File Format
20xxx="1;MSG=Alarm Content", xxx corresponds to PLC Alarm/Warning number, please note that the
identification code is 20。

How to send alarms with ladder diagram – 15


机床产品/Machine Tool Products

Ladder Programming and Development.

23xxx="1;MSG=Alarm Content", xxx corresponds to PLC Hint number, please note that the
identification number is 23。
• APPCHI.STR example:
20001="1;MSG=X轴超过正向硬体行程极限"
23010="1;MSG=第10号提示"
• APPENG.STR example:
20001="1;MSG=X+ hardware stroked limit exceed"
23010="1;MSG=10th Hint"

CE System Alarm String File


• File Path(before version 10.114.46)
Chinese:DiskC/OCRes/CHT/String/AlarmMsg_CHT.xml
English:DiskC/OCRes/Common/String/AlarmMsg_common.xml
• File Path(after version 10.114.46)
Traditional Chinese:DiskC/OCRes/CHT/String/AlarmPLC_CHT.xml
Simplified Chinese:DiskC/OCRes/CHS/String/AlarmPLC_CHS.xml
English:DiskC/OCRes/Common/String/AlarmPLC_COM.xml
• File Format
<Message ID="AlarmMsg::MLC::ID=xxx" Content="Alarm Content" />, xxx corresponds to PLC Alarm/
Warning number, please note that the identification string is MLC。
<Message ID="AlarmMsg::MLCHint::ID=xxx" Content="Alarm Content" />, xxx corresponds to PLC Hint
number, please note that the identification string is MLCHint。
The string length of the alarm content is 48 English characters or 31 Chinese words, the rest of the
string will exceed the alarm window and won't be shown.
• Example
• AlarmPLC_CHT.xml:
• <Message ID="AlarmMsg::MLC::ID=1" Content="X轴超过正向硬体行程极限" />
• <Message ID="AlarmMsg::MLCHint::ID=10" Content="第10号提示" />
• AlarmPLC_COM.xml:
• <Message ID="AlarmMsg::MLC::ID=1" Content="X+ hardware stroked limit exceed " />
• <Message ID="AlarmMsg::MLCHint::ID=10" Content="10th Hint " />

How to send alarms with ladder diagram – 16


机床产品/Machine Tool Products

Ladder Programming and Development.

3 Operation Panel Application Example

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation

Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG
Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Controller Mode(R13) is composed of three I bits, I-109/ I-110/ I-111, in


binary form.
The input/output transfer relationship are shown in the table below.

Input Output

I-111 I-110 I-109 R13

1 1 1 7:HOME

1 1 0 3:MDI

1 0 1 5:INJOG

1 0 0 4:JOG

0 1 1 2:Auto

0 1 0 6:MPG

0 0 1 6:MPG

0 0 0 6:MPG

Ladder Diagram Example:

Operation Panel Application Example – 17


机床产品/Machine Tool Products

Ladder Programming and Development.

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation

Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG
Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Spindle Override(R15) is composed of three I bits, I-106/ I-107/ I-108, in


binary form.
The input/output transfer relationship are shown in the table below.

Operation Panel Application Example – 18


机床产品/Machine Tool Products

Ladder Programming and Development.

Input Output

I-108(+4) I-107(+2) I-106(+1) R15

1 1 1 1+0+0+0=1:50%

1 1 0 1+0+0+1=2:60%

1 0 1 1+0+2+0=3:70%

1 0 0 1+0+2+1=4:80%

0 1 1 1+4+0+0=5:90%

0 1 0 1+4+0+1=6:100%

0 0 1 1+4+2+0=7:110%

0 0 0 1+4+2+1=8:120%

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation

Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG
Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Operation Panel Application Example – 19


机床产品/Machine Tool Products

Ladder Programming and Development.

MPG/INJOG Feed(R14) and G00 Override(R18) are composed of two I


bits, I-104/ I-105, in binary form.
The input/output transfer relationship are shown in the table below.

Input Output

I-105(+2) I-104(+1) R14 R18

1 1 1+0+0=1:*1 1+0+0=1:F0

1 0 1+0+1=2:*10 1+0+1=2:25%

0 1 1+2+0=3:*100 1+2+0=3:50%

0 0 1+2+1=4:*1000 1+2+1=4:100%

Note:To setup R14, please refer to Pr2001 MPG 4th scaling factor.

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation

Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG

Operation Panel Application Example – 20


机床产品/Machine Tool Products

Ladder Programming and Development.

Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

G01(R16) and JOG Override(R17) is composed of 4 I bits, I-100/ I-101/


I-102/ I-103, in binary form.
The input/output transfer relationship are shown in the table below.

Input Output

I-103(+8) I-102(+4) I-101(+2) I-100(+1) R16 & R17

1 1 1 1 0+0+0+0+0=0:0%

1 1 1 0 0+0+0+0+1=1:10%

1 1 0 1 0+0+0+2+0=2:20%

1 1 0 0 0+0+0+2+1=3:30%

1 0 1 1 0+0+4+0+0=4:40%

1 0 1 0 0+0+4+0+1=5:50%

1 0 0 1 0+0+4+2+0=6:60%

1 0 0 0 0+0+4+2+1=7:70%

0 1 1 1 0+8+0+0+0=8:80%

0 1 1 0 0+8+0+0+1=9:90%

0 1 0 1 0+8+0+2+0=10:100%

0 1 0 0 0+8+0+2+1=11:110%

Operation Panel Application Example – 21


机床产品/Machine Tool Products

Ladder Programming and Development.

0 0 1 1 0+8+4+0+0=12:120%

0 0 1 0 0+8+4+0+1=13:130%

0 0 0 1 0+8+4+2+0=14:140%

0 0 0 0 0+8+4+2+1=15:150%

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation

Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG
Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Operation Panel Application Example – 22


机床产品/Machine Tool Products

Ladder Programming and Development.

MPG Simulation can only be activated by C20 in the ladder diagram.


When switch to Auto or MDI mode with C20 triggered, G00/G01/G02/G03
speed will be decided by MPG rotation speed after Cycle Start.
The machine moves faster when MPG rotates faster; the machine stops when
MPG stops. Applicable in trial processing stage.

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation

Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG

Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Program Dry Run can only be activated by C42 in the ladder diagram.
When C42 is triggered, the machine will move in dry run speed when
executing moving G code.
For G01 block is 5 times the program speed, for G00 block is just G00
speed.

Operation Panel Application Example – 23


机床产品/Machine Tool Products

Ladder Programming and Development.

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG

Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Optional Stop can only be activated by C44 in the ladder diagram.


When C44 is triggered, the controller will switch to B-stop state when
executing M01.
When C44 is off, the controller will ignore M01 and proceed to the next
block.

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG

Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Operation Panel Application Example – 24


机床产品/Machine Tool Products

Ladder Programming and Development.

Optional Skip can only be activated by C41 in the ladder diagram.


When C41 is triggered, the controller will skip the block with the skipping
symbol "/" and proceed to the next block.

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG

Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Single Block can only be activated by C40 in the ladder diagram.


When C40 is triggered, the machining process stops every time after finishing
a block, and run the next block by pressing Cycle Start.

Ladder Diagram Example:

Operation Panel Application Example – 25


机床产品/Machine Tool Products

Ladder Programming and Development.

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG

Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Emergency Stop can only be activated by C36 in the ladder diagram.


When C36 is triggered, the controller will stop all actions and switch to Not Ready state.
After C36 is off, the system restores to Ready state.

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG

Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

In JOG mode, the controller moves by pressing the arrow keys of


corresponding axes and activate the C bit in the table below.
If applied with rapid moving(C23) activated, the axis will be moving in the
speed of G00.

PS:The I bit table below is only the corresponding number of one of the
standard panel, not all panels are the same.

Axis/Direction X+ X- Y+ Y- Z+ Z-

C Bit C06 C07 C08 C09 C10 C11

Lathe I-65 I-71 I-64 I-70 I-69 I-67

Operation Panel Application Example – 26


机床产品/Machine Tool Products

Ladder Programming and Development.

Milling Machine I-85 I-87 I-93 I-79 I-80 I-94

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG

Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Cycle Start can only be activated by C0 in the ladder diagram; Feed Hold can only be activated by C1 in the
ladder diagram.
In Auto or MDI mode, C0 can start the machining process with rising edge-triggered. S0 will be activated
after the machining process is started.
C1 can also pause the machining process with rising edge-triggered. S1 will be activated after the process
is paused and S0 will be suspended.

Operation Panel Application Example – 27


机床产品/Machine Tool Products

Ladder Programming and Development.

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG
Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

In HOME mode, the controller will move towards the origin with the parameter setups when pressing JOG
button of each axis.
When touching a Home Dog(origin switch), the corresponding C Bit in the table below should be
activated.
After the home searching is done, the controller will activate the corresponding home searching complete
flag.

X Axis Y Axis Z Axis

Operation Panel Application Example – 28


机床产品/Machine Tool Products

Ladder Programming and Development.

Home Dog Signal C79 C80 C81

Home Searching Complete Flag S16 S17 S18

Ladder Diagram Example:

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG
Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

The table below shows the corresponding C Bit of +/- hardware stroke limit for each axis.
When the C Bit is activated, the controller will send alarms and stop the machine automatically.
The controller then can only receive reverse direction commands to bring the machine out of the limit
position.

X+ limit X- limit Y+ limit Y- limit Z+ limit Z- lmit

C Bit C50 C51 C52 C53 C54 C55

Operation Panel Application Example – 29


机床产品/Machine Tool Products

Ladder Programming and Development.

Ladder Diagram Example:

PS:Sometimes the hardware limit switch is malfunctioning so the system can't free the alarm.
For situation like this, there should be a way to free the alarm manually, such as I-92 in the picture above.

Mode Selection Spindle Override MPG/ INJOG/ G00 Override G01/ JOG Override MPG Simulation
Program Dry Run Optional Stop Optional Skip Single Block Emergency Stop JOG
Cycle Start/Feed Hold Home Searching Hardware Stroke Limit Spindle CW/CCW/Stop

Spindle CW/CCW rotation correspond to C64/C65 respectively, there are some notifications for general
operations:
1. C64, C65 must be cut off when pressing the Reset button or the program is running M05, M02 or
M30.
2. The spindle shouldn't be rotating if the gripper is not clamping for lathe machine or the tool is
loosen for milling machine.
3. Do not stop the spindle manually during the machining(S0 on), stop the spindle with M05.

Ladder Diagram Example:


I-69 is the spindle stop button on the panel; S32 is the reset signal.

Operation Panel Application Example – 30


机床产品/Machine Tool Products

Ladder Programming and Development.

A103 is M03 spindle CW rotation; A105 is M05 spindle stop; A7 is the state spindle rotation is banned(like
tool loosen, oil cooler alarm).

Operation Panel Application Example – 31


机床产品/Machine Tool Products

Ladder Programming and Development.

4 Application Example of Carousel Tool Magazine in Milling


Machine
M Code T Code S Code

4.1 M Code

M Code Definition Table


M code below should be provided in ladder diagram of standard milling machine:

M code Function

M03 Spindle CW Rotation

M04 Spindle CCW Rotation

M05 Spindle Stop

M07 solenoid valve of air blow ON

M08 cutting fluid motor ON

M09 solenoid valve of air blow & cutting fluid motor OFF

M19 Spindle Orientation

M30 solenoid valve of air blow, cutting fluid motor OFF, Spindle Stop

M37 Chip Conveyor CW Rotation

M38 Chip Conveyor CCW Rotation

M50 Tool Unclamp

M51 Tool Clamp

Application Example of Carousel Tool Magazine in Milling Machine – 32


机床产品/Machine Tool Products

Ladder Programming and Development.

M52 Tool Magazine Out

M53 Tool Magazine In

PS:M01(Optional Stop), M02(Program Finish), M98(Call Subprogram), M99(Program Return).


These four M code are provided by the controller kernel, so they're not listed above.

M Code Operation Specification


1. M03(Spindle CW Rotation):This M code is used to make the spindle do CW rotation, apply with
S code to set rotation speed. Specification as follows:
a. When executing M03, proceed the NC program when the spindle speed(R36) reaches 80%
target speed(R871~).
b. During spindle CW rotation signal(C64 On) output, keep checking if the spindle speed is
higher than 70% target speed, if not, the machining process will be paused immediately and
the alarm will be sent.
2. M04(Spindle CCW Rotation):This M code is used to make the spindle do CWW rotation, apply
with S code to set rotation speed. Specification as follows:
a. When executing M04, proceed the NC program when the spindle speed(R36) reaches 80%
target speed(R871~).
b. During spindle CCW rotation signal(C65 On) output, keep checking if the spindle speed is
higher than 70% target speed, if not, the machining process will be paused immediately and
the alarm will be sent.
3. M05(Spindle Stop):This M code is used to stop the spindle rotation, also able to cancel the
spindle orientation. Specification as follows:
a. When executing M05, turn off C64, C65 to stop the spindle.
b. When the spindle speed(R36) is lower than 10 RPM, the spindle control will be turned off.
(applicable for pulse spindle)
4. M19(Spindle Orientation):This M code is used to make the spindle process the
orientation. Specification as follows:
a. When executing M19, turn on the spindle orientation signal(C61).
b. Proceed the NC program after the controller receive spindle orientation complete signal
(S61).
5. M50(Tool Unclamp):This M code is used to unclamp the tool. Specification as follows:
a. When executing M50, output tool unclamp signal.
b. Proceed the NC program after the controller receive tool unclamp complete signal.
6. M51(Tool Clamp):This M code is used to clamp the tool. Specification as follows:
a. When executing M51, turn off the tool unclamp signal.
b. Proceed the NC program after the controller receive tool clamp complete signal.
7. M52(Tool Magazine Out):This M code is used to push the tool magazine out. Specification as
follows:
a. When executing M52, output push out signal.
b. Proceed the NC program after the controller receive tool magazine out signal.
8. M53(Tool Magazine In):This M code is used to pull the tool magazine in. Specification as
follows:
a. When executing M53, turn off the push out signal.
b. Proceed the NC program after the controller receive tool magazine in signal.

Application Example of Carousel Tool Magazine in Milling Machine – 33


机床产品/Machine Tool Products

Ladder Programming and Development.

M Code Technical Specification


1. M03(Spindle CW Rotation):
a. M03 can only be executed when the tool is clamped.
b. If the spindle speed(R36) couldn't reach 80% target speed(R871~) within 10 seconds,
"Spindle CW Rotation Speed Error" alarm will be sent and the machining process will be
paused. Press "Reset" button to cancel the alarm.
c. Keep checking the spindle speed when the spindle is rotating, if the spindle speed is lower
than 70% target speed, "Spindle Speed too Low" Alarm will be sent and the machining
process will be paused. Press "Reset" button to cancel the alarm.
2. M04(Spindle CCW Rotation):
a. M04 can only be executed when the tool is clamped.
b. If the spindle speed(R36) couldn't reach 80% target speed(R871~) within 10 seconds,
"Spindle CCW Rotation Speed Error" alarm will be sent and the machining process will be
paused. Press "Reset" button to cancel the alarm.
c. Keep checking the spindle speed when the spindle is rotating, if the spindle speed is lower
than 70% target speed, "Spindle Speed too Low" Alarm will be sent and the machining
process will be paused. Press "Reset" button to cancel the alarm.
3. M05(Spindle Stop):
a. No need to wait when executing M05, which means C38 should stay triggered.
b. Turn off the external spindle execution(RUN) signal when the spindle speed is lower than
10 RPM.(Applicable for pulse spindle)
4. M19(Spindle Orientation):
a. M19 can only be executed when the tool is clamped.
b. If the spindle orientation complete signal is not sent back to the controller within 3 seconds,
"Spindle Orientation Failure" alarm will be sent and the machining process will be paused.
Press "Reset" button to cancel the alarm.
c. During the spindle orientation, if the orientation complete signal sent from the inverter is
interrupted abnormally, "Spindle Orientation Abnormal Interruption" alarm will be sent and
the machining process will be paused. Press "Reset" button to cancel the alarm.
d. During the spindle orientation, it could be cancelled by M03, M04, M05 and start the next
action directly.
5. M50(Tool Unclamp):
a. Do not unclamp the tool when spindle is rotating.
b. Only unclamp the tool when the spindle speed(R36) is lower than 10 RPM.
c. If the tool unclamp signal is not sent back to the controller within 3 seconds, "Tool Unclamp
Failure" alarm will be sent and the machining process will be paused. Press "Reset" button
to cancel the alarm.
d. The tool unclamp action is completed only if the tool unclamp signal lasts over 0.1 second.
6. M51(Tool Clamp):
a. Do not clamp the tool when spindle is rotating.
b. Only clamp the tool when the spindle speed(R36) is lower than 10 RPM.
c. If the tool clamp signal is not sent back to the controller within 3 seconds, "Tool Clamp
Failure" alarm will be sent and the machining process will be paused. Press "Reset" button
to cancel the alarm.
d. The tool clamp action is completed only if the tool clamp signal lasts over 0.1 second.
7. M52(Tool Magazine Out):
a. Do not push the tool magazine out when spindle is rotating.
b. Only push the tool magazine out when the spindle speed(R36) is lower than 10 RPM.

Application Example of Carousel Tool Magazine in Milling Machine – 34


机床产品/Machine Tool Products

Ladder Programming and Development.

c. If the "tool magazine out" signal is not sent back to the controller within 10 seconds, "Tool
Magazine Push Out Failure" alarm will be sent and the machining process will be paused.
Press "Reset" button to cancel the alarm.
d. The pushing out action is completed only if the "tool magazine out" signal lasts over 0.1
second.
8. M53(Tool Magazine In):
a. Do not pull the tool magazine in when spindle is rotating.
b. Only pull the tool magazine in when the spindle speed(R36) is lower than 10 RPM.
c. If the "tool magazine in" signal is not sent back to the controller within 10 seconds, "Tool
Magazine Pull In Failure" alarm will be sent and the machining process will be paused. Press
"Reset" button to cancel the alarm.
d. The pulling in action is completed only if the "tool magazine in" signal lasts over 0.1 second.
9. Others:
a. Can't control spindle manually by operation panel during the machining process.
b. If a G code and M05 are in the same block, M05 can only be executed after G code is
completed(S30 activated).
10. Notification:
a. After dealing with the tool changing failure alarm, please make sure if the magazine tool
number and spindle tool number recorded by the controller is the same as the actual tool
number. If not, please correct the tool number table then reboot the controller.

M Code T Code S Code

4.2 T Code

T Code Operation Specification


When executing T code in NC program, the tool will be changed according to the process below:
1. Spindle stop(M05)
2. Tool magazine rotates to current tool number
3. Spindle Orientation(M19)
4. Z axis moves to 2nd reference point by G00(Pr2803)
5. Tool magazine push out(M52)
6. Tool unclamp(M50)
7. Z axis moves to mechanical origin by G00
8. Tool magazine rotates to target tool number
9. Z axis moves to 2nd reference point by G00(Pr2803)
10. Tool Clamp(M51)
11. Tool Magazine pull in(M53)
12. Cancel Spindle Orientation(M05)
13. Modify Spindle Tool Number
14. Continue to execute NC Program

Application Example of Carousel Tool Magazine in Milling Machine – 35


机床产品/Machine Tool Products

Ladder Programming and Development.

T Code Technical Specification


1. When the tool magazine is out, the spindle and the tool magazine are not allowed to rotate.
2. If the tool count signal is not sent to the controller within 3 seconds after activate tool magazine
rotation, "Tool Count Error" alarm will be sent and the machining process will be paused.
3. During tool changing process, if "Spindle Orientation Failure", "Tool Magazine Push Out Failure",
"Tool Unclamp Failure", "Tool Clamp Failure", "Tool Magazine Pull In Failure" or "Tool Count Error"
alarm happens, "Tool Change Failure" alarm will be sent and the machining process will be paused.
Please wait till the tool clamp signal and "tool magazine in" signal appear then press "Reset"
button to cancel the tool changing process.

T Code Macro Calling Function


Tool changing is composed of several actions, it would be better to execute it as a T code macro.
After finishing the setups below, it will enter T0000 macro first when executing T code, then triggers the
related PLC actions according to T0000.
1. Set Pr3215 to 1.
2. Get the T code macro ready and save it in the controller. The file name of the macro should be
T0000(no extension).

MSD of T code

Example of T0000 Macro


%@MACRO

Application Example of Carousel Tool Magazine in Milling Machine – 36


机床产品/Machine Tool Products

Ladder Programming and Development.

// @481=R81_total tool number


//@502=R102_current spindle tool number
// #1004_G90/G91 mode;#1036_target tool number;#26023=Pr2803_tool changing point of Z axis
IF ( @502 = #1036 OR #1036 = 0 OR @481 < #1036 ) THEN
M99; //If target tool number = current tool number or tool No.0 or larger than total tool number, leave
T0000
END_IF;
@102:=#1036; // save target tool number
@103:=#1004; // save G90/G91 state
M3S0; // stop the spindle by S0, then use M05
M05;
WAIT();
T@502; // tool magazine rotates to current tool number
M19; // spindle orientation
G90 G53 Z#26023; // Z axis moves to tool changing point(Pr2803)
G4X0.5;
WAIT();
M52; // tool magazine push out
M50; // tool unclamp
G90 G53 Z0; // Z axis moves to mechanical origin
WAIT();
T@102; // tool magazine rotates to target tool number
G90 G53 Z#26023; // Z xis moves to tool changing point(Pr2803)
G4X0.5;
WAIT();
M51; // tool clamp
M53; // tool magazine pull in
M05; // cancel spindle orientation
WAIT();
@502:=@102; // modify current tool number
G@103; // restore G90/G91 state
M99;

M Code T Code S Code

Application Example of Carousel Tool Magazine in Milling Machine – 37


机床产品/Machine Tool Products

Ladder Programming and Development.

4.3 S Code

S Code Operation Specification


1. Executing S code while the spindle is rotating will change the spindle speed.
2. Proceed the NC program if the spindle speed(R36) is higher than 80% target speed(R871~)
and lower than 110% target speed.

S Code Technical Specification


1. If the spindle speed(R36) couldn't reach 80% ~ 110% target speed within 10 seconds, "Spindle
Speed Change Failure" alarm will be sent and the machining process will be paused.
2. The spindle speed changing is completed only if the spindle speed stays between 80% ~ 110%
target speed over than 0.1 second.

MSD of S Code

Application Example of Carousel Tool Magazine in Milling Machine – 38


机床产品/Machine Tool Products

Ladder Programming and Development.

5 Common C/S/R

5.1 Axial Related

Func Item Typ Explanation 1 2 3 4 5 6 7 8


tion e
9 10 11 12 13 14 15 16

Axis 1 C Axis JOG(+) C6 C8 C10 C17 C17 C12 C174 C176


Flag 0 2
&
Regi
C178 C180 C182 C18 C18 C188 C190 C192
ster
4 6

2 C Axis JOG(-) C7 C9 C11 C17 C17 C13 C175 C177


1 3

C179 C181 C183 C18 C18 C189 C191 C193


5 7

3 C MPG axis C16 C17 C18 C21 C21 C19 C217 C218
selection 5 6

C219 C220 C221 C22 C22 C224 C225 C226


2 3

4 C Setup machine C25 C26 C27 C23 C23 C28 C232 C233
coordinate 0 1

C234 C235 C236 C23 C23 C239 C240 C241


7 8

5 C Manual control C31 C32 C33 C24 C24 C34 C247 C248
(Monitor Mode) 5 6

C249 C250 C251 C25 C25 C254 C255 C256


2 3

Common C/S/R – 39
机床产品/Machine Tool Products

Ladder Programming and Development.

6 C Positive C50 C52 C54 C14 C14 C56 C144 C146


hardware stroke 0 2
Limit
C148 C150 C152 C15 C15 C158 C160 C162
4 6

7 C Negative C51 C53 C55 C14 C14 C57 C145 C147


hardware stroke 1 3
limit
C149 C151 C153 C15 C15 C159 C161 C163
5 7

8 C PLC axis control C66 C67 C68 C26 C26 C69 C262 C263
flag 0 1

C264 C265 C266 C26 C26 C269 C270 C271


7 8

9 C Home dog C79 C80 C81 C20 C20 C82 C202 C203
signal Flag 0 1

C204 C205 C206 C20 C20 C209 C210 C211


7 8

10 S Axis busy flag S6 S7 S8 S15 S15 S9 S157 S158


5 6

S159 S160 S161 S16 S16 S164 S165 S166


2 3

Func Item Typ Explanation 1 2 3 4 5 6 7 8


tion e
9 10 11 12 13 14 15 16

Axis 11 S Axis home S16 S17 S18 S14 S14 S19 S142 S143
Flag searching finish 0 1
& flag
Regi
(Home OK) S144 S145 S146 S14 S14 S149 S150 S151
ster
7 8

12 S Servo alarm flag S171 S172 S173 S17 S17 S176 S177 S178
4 5

Common C/S/R – 40
机床产品/Machine Tool Products

Ladder Programming and Development.

S179 S180 S181 S18 S18 S184 S185 S186


2 3

13 R Axis program R721 R722 R723 R72 R72 R726 R727 R728
coordinate 4 5
( ( ( (
R26 R27 R28 R29
) ) ) )

R729 R730 R731 R73 R73 R734 R735 R736


2 3

14 R Axis machine R741 R742 R743 R74 R74 R746 R747 R748
coordinate 4 5
( ( ( (
R31 R32 R33 R34
) ) ) )

R749 R750 R751 R75 R75 R754 R755 R756


2 3

15 C Machine lock for R600. R600. R600. R60 R60 R600. R600 R600
single axis 1 2 3 0.4 0.5 6 .7 .8

R600. R600. R600. R60 R60 R600. R600 R600


9 10 11 0.12 0.13 14 .15 .16

16 C MPG simulation R601. R601. R601. R60 R60 R601. R601 R601
for single axis 1 2 3 1.4 1.5 6 .7 .8
(PLC Axis)
R601. R601. R601. R60 R60 R601. R601 R601
9 10 11 1.12 1.13 14 .15 .16

17 S G31 skip R610. R610. R610. R61 R61 R610. R610 R610
position latched 1 2 3 0.4 0.5 6 .7 .8

R610. R610. R610. R61 R61 R610. R610 R610


9 10 11 0.12 0.13 14 .15 .15

18 S Axis moving flag R611. R611. R611. R61 R61 R611. R611 R611
1 2 3 1.4 1.5 6 .7 .8

R611. R611. R611. R61 R61 R611. R611 R611


9 10 11 1.12 1.13 14 .15 .16

Common C/S/R – 41
机床产品/Machine Tool Products

Ladder Programming and Development.

19 C Positive R612. R612. R612. R61 R61 R612. R612 R612


machine lock 1 2 3 2.4 2.5 6 .7 .8

R612. R612. R612. R61 R61 R612. R612 R612


9 10 11 2.12 2.13 14 .15 .16

20 C Negative R613. R613. R613. R61 R61 R613. R613 R613


machine lock 1 2 3 3.4 3.5 6 .7 .8

R613. R613. R613. R61 R61 R613. R613 R613


9 10 11 3.12 3.13 14 .15 .16

21 S M code read flag R629. R629. R629. R62 X X X X


for PLC axis 1 2 3 9.4

X X X X X X X X

Func Item Type Explanation 1 2 3 4 5 6 7 8


tion
9 10 11 12 13 14 15 16

Axis 22 C M code finish R630 R630 R630 R630 X X X X


Flag flag for PLC axis .1 .2 .3 .4
&
Regi
X X X X X X X X
ster

23 R M code content R681 R682 R683 R684 R685 R686 R687 R688
for PLC axis
R689 R690 R691 R692 R693 R694 R695 R696

24 R G00/G01 R661 R662 R663 R664 R665 R666 R667 R668


override for PLC
axis
R669 R670 R671 R672 R673 R674 R675 R676

25 R MPG command R641 R642 R643 R644 R645 R646 R647 R648
multiplier ratio
of each axis
R649 R650 R651 R652 R653 R654 R655 R656

26 R Axis speed of R701 R702 R703 R704 R705 R706 R707 R708
each axis

Common C/S/R – 42
机床产品/Machine Tool Products

Ladder Programming and Development.

R709 R710 R711 R712 R713 R714 R715 R716

27 R Machine R861 R862 R863 R864 R865 R866 R867 R868


coordinate of
break point
R869 R870 X X X X X X

28 R Temperature R901 R902 R903 R904 R905 R906 R907 R908


compensation
of each axis
R909 R910 R911 R912 R913 R914 R915 R916

29 R Home dog shift R961 R962 R963 R964 R965 R966 R967 R968

R969 R970 R971 R972 R973 R974 R975 R976

30 R Absolute R981 R982 R983 R984 R985 R986 R987 R988


counter of each
axis
R989 R990 R991 R992 R993 R994 R995 R996

31 R Following error R500 R500 R500 R500 R500 R500 R500 R500
of each axis 1 2 3 4 5 6 7 8

R500 R501 R501 R501 R501 R501 R501 R501


9 0 1 2 3 4 5 6

5.2 MST Channel and Multi Axis Group

Functio Item Type Explanation Channe Channel Channel Channel


n l1 2 3 4

MST 1 C M.S.T code finish C38 R615.0 R619.0 R623.0


Chann
el &
2 S Finish signal of G code in same S30 R615.1 R619.1 R623.1
Multi
block (Distribution End)
Axis
Group

Common C/S/R – 43
机床产品/Machine Tool Products

Ladder Programming and Development.

3 S M code read (Multiple M code S29 R615.2 R619.2 R623.2


1)
( ( (
R615.24 R619.24 R623.24
) ) )

4 S M code read (Multiple M code S11 R615.25 R619.25 R623.25


2)

5 S M code read (Multiple M code S12 R615.26 R619.26 R623.26


3)

6 S M code read (Multiple M code S13 R615.27 R619.27 R623.27


4)

7 S M code read (Multiple M code S14 R615.28 R619.28 R623.28


5)

8 S S code Read S54 R615.3 R619.3 R623.3

9 S T code Read S69 R615.4 R619.4 R623.4

10 S MST flag sent from 1st axis R589.1 R615.8 R619.8 R623.8
group

11 S MST flag sent from 2nd axis R589.2 R615.9 R619.9 R623.9
group

12 S MST flag sent from 3rd axis R589.3 R615.10 R619.10 R623.10
group

13 S MST flag sent from 4th axis R589.4 R615.11 R619.11 R623.11
group

14 S MST related information of R589.1 R615.16 R619.16 R623.16


multi axis group for 1st 1
spindle

15 S MST related information of R589.1 R615.17 R619.17 R623.17


multi axis group for 2nd 2
spindle

Common C/S/R – 44
机床产品/Machine Tool Products

Ladder Programming and Development.

16 S MST related information of R589.1 R615.18 R619.18 R623.18


multi axis group for 3rd 3
spindle

17 S MST related information of R589.1 R615.19 R619.19 R623.19


multi axis group for 4th 4
spindle

18 R M code content (Multiple M R1 R616 R620 R624


code 1)
( ( ( (
R2050 R2060) R2070) R2080)

19 R M code content (Multiple M R2051 R2061 R2071 R2081


code 2)

20 R M code content (Multiple M R2052 R2062 R2072 R2082


code 3)

21 R M code content (Multiple M R2053 R2063 R2073 R2083


code 4)

22 R M code content (Multiple M R2054 R2064 R2074 R2084


code 5)

Functio Item Type Explanation Channe Channel Channel Channel


n l1 2 3 4

MST 23 R S Code Content R2 R617 R621 R625


Chann
el &
24 R T Code Content R3 R618 R622 R626
Multi
Axis
Group 25 R Spindle selection for multi R791 R792 R793 R794
axis group

26 R Cause of block stop R841 R842 R843 R844

27 R Maximum spindle cutting R5021 R5022 R5023 R5024


speed

28 R Active session ID R21 R21 R21 R21

Common C/S/R – 45
机床产品/Machine Tool Products

Ladder Programming and Development.

29 R B Code Content R5 Not Not Not


Supporti Supporti Supporti
ng ng ng

30 S B Code Read S53 Not Not Not


Supporti Supporti Supporti
ng ng ng

Common C/S/R – 46

You might also like