Ladder Programming and Development.
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
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.
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.
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.
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:
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/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).
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.
M/S/T Code – 9
机床产品/Machine Tool Products
–
Ladder Programming and Development.
• 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.
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.
When R40 ~ R43 are outputted in the ladder diagram, alarm windows pop-up on the controller screen
according to the table below.
Alarm triggering
As the picture below, the external signal I-10 triggers R40.0, and R40.0 corresponds to PLC Alarm No.01.
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.
R45.0 ~ R45.15 81 ~ 96
R591.0 ~ R591.31 32 ~ 63
R592.0 ~ R592.31 64 ~ 95
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.
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"
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
Input Output
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
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
Input Output
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%
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
Input Output
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.
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
Input Output
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%
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%
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
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.
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
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
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
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
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
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-
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.
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.
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.
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.
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).
4.1 M Code
M code Function
M09 solenoid valve of air blow & cutting fluid motor OFF
M30 solenoid valve of air blow, cutting fluid motor OFF, Spindle Stop
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.
4.2 T Code
MSD of T code
4.3 S Code
MSD of S Code
5 Common C/S/R
3 C MPG axis C16 C17 C18 C21 C21 C19 C217 C218
selection 5 6
4 C Setup machine C25 C26 C27 C23 C23 C28 C232 C233
coordinate 0 1
5 C Manual control C31 C32 C33 C24 C24 C34 C247 C248
(Monitor Mode) 5 6
Common C/S/R – 39
机床产品/Machine Tool Products
–
Ladder Programming and Development.
8 C PLC axis control C66 C67 C68 C26 C26 C69 C262 C263
flag 0 1
9 C Home dog C79 C80 C81 C20 C20 C82 C202 C203
signal Flag 0 1
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.
13 R Axis program R721 R722 R723 R72 R72 R726 R727 R728
coordinate 4 5
( ( ( (
R26 R27 R28 R29
) ) ) )
14 R Axis machine R741 R742 R743 R74 R74 R746 R747 R748
coordinate 4 5
( ( ( (
R31 R32 R33 R34
) ) ) )
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
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
18 S Axis moving flag R611. R611. R611. R61 R61 R611. R611 R611
1 2 3 1.4 1.5 6 .7 .8
Common C/S/R – 41
机床产品/Machine Tool Products
–
Ladder Programming and Development.
X X X X X X X X
23 R M code content R681 R682 R683 R684 R685 R686 R687 R688
for PLC axis
R689 R690 R691 R692 R693 R694 R695 R696
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.
29 R Home dog shift R961 R962 R963 R964 R965 R966 R967 R968
31 R Following error R500 R500 R500 R500 R500 R500 R500 R500
of each axis 1 2 3 4 5 6 7 8
Common C/S/R – 43
机床产品/Machine Tool Products
–
Ladder Programming and Development.
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
Common C/S/R – 44
机床产品/Machine Tool Products
–
Ladder Programming and Development.
Common C/S/R – 45
机床产品/Machine Tool Products
–
Ladder Programming and Development.
Common C/S/R – 46