M, S, T code Ladder logic in SYNTEC CNC provides the interface between NC program execution and the PLC Ladder when the CNC encounters an M, S, or T command. The CNC transfers the command information through the register interface, activates the corresponding code-read signal, and waits for the Ladder to complete the required sequence. After completion, the Ladder returns the M.S.T. Finish signal C38, allowing the CNC to continue execution of the NC program.
This article explains the basic M/S/T handshake, the purpose of S29, S54, S69, R01, R02, R03 and C38, and a recommended state-based method for organizing the corresponding Ladder logic.
M/S/T Processing Principle
When the CNC executes an NC program and encounters an M, S, or T command, the command must be communicated to the Ladder logic. The SYNTEC interface uses dedicated S bits to inform the Ladder that a new command has been read and dedicated R registers to transfer the command contents.
NC PROGRAM
│ M / S / T command
▼
CNC CONTROLLER
│
├── R01 ← M-code contents
├── R02 ← S-code value
└── R03 ← T-code contents
│
├── S29 = M-code Read
├── S54 = S-code Read
└── S69 = T-code Read
▼
PLC LADDER
│
├── recognize command
├── execute corresponding Ladder sequence
└── complete M/S/T processing
▼
C38 = M.S.T. Finish
▼
CNC CONTINUES NC PROGRAM
The essential principle is that the CNC and PLC do not operate independently during this sequence. The CNC presents the M/S/T request to the Ladder, the Ladder performs the required logic, and C38 is used to indicate completion.
M/S/T Interface Signals and Registers
| Interface | Name | Direction | Purpose |
|---|---|---|---|
| R01 | M-code contents | CNC → Ladder | Contains the M-code information transferred to the Ladder. |
| R02 | S-code contents | CNC → Ladder | Contains the value specified by the S command. |
| R03 | T-code contents | CNC → Ladder | Contains the T-code information transferred to the Ladder. |
| S29 | M-code Read | CNC → PLC | Indicates that the CNC has encountered an M code and requests M-code processing. |
| S54 | S-code Read | CNC → PLC | Indicates that the CNC has encountered an S code and requests S-code processing. |
| S69 | T-code Read | CNC → PLC | Indicates that the CNC has encountered a T code and requests T-code processing. |
| C38 | M.S.T. Finish | PLC → CNC | Reports completion of the M/S/T processing sequence to the CNC. |
M-Code Processing
When the NC program reaches an M code, the CNC places the M-code contents into R01 and turns ON S29 — M-code Read. The Ladder then executes the related M-code sequence.
NC program reaches M code
↓
R01 ← M-code contents
↓
S29 = ON
↓
Ladder detects M-code request
↓
Ladder performs corresponding M-code logic
↓
M processing completed
↓
C38 = M.S.T. Finish
↓
CNC continues NC program
The Ladder therefore uses two pieces of information: S29 indicates that an M-code request is active, while R01 provides the M-code contents that the Ladder can use to select the corresponding logic.
S-Code Processing
When the NC program reaches an S code, the CNC places the value specified by the S command into R02 and turns ON S54 — S-code Read. The Ladder then executes the related S-code sequence.
NC program reaches S code
↓
R02 ← S-code value
↓
S54 = ON
↓
Ladder detects S-code request
↓
Ladder performs corresponding S-code logic
↓
S processing completed
↓
C38 = M.S.T. Finish
↓
CNC continues NC program
According to the supplied SYNTEC description, the command sent to the frequency converter is handled inside the CNC, but it is performed after the Ladder returns the M.S.T. Finish signal C38.
This distinction is important: R02 makes the requested S value available to the Ladder, while the supplied documentation describes the frequency-converter command itself as being handled internally by the CNC.
T-Code Processing
When the NC program reaches an T code, the CNC places the T-code contents into R03 and turns ON S69 — T-code Read. The Ladder then executes the related T-code sequence.
NC program reaches T code
↓
R03 ← T-code contents
↓
S69 = ON
↓
Ladder detects T-code request
↓
Ladder performs corresponding T-code logic
↓
T processing completed
↓
C38 = M.S.T. Finish
↓
CNC continues NC program
The exact machine action associated with a T code depends on the Ladder implementation and machine configuration. The interface described here establishes how the command reaches the Ladder and how completion is returned to the CNC; it does not by itself define the physical tool-change sequence of a particular machine.
M.S.T. Finish — C38
C38 — M.S.T. Finish is the completion signal returned from the PLC Ladder to the CNC.
Its role in the handshake is fundamental. The CNC sends an M/S/T request to the Ladder, the Ladder executes the required logic, and when processing has been completed, the Ladder returns the finish condition through C38. The CNC can then complete the M/S/T processing and continue with the following NC program block.
CNC PLC LADDER
M/S/T command
├──────────────► S29 / S54 / S69
├──────────────► R01 / R02 / R03
│ ↓
│ execute logic
│ ↓
│◄────────────────── C38
│ M.S.T. Finish
▼
continue NC program
M, S and T in the Same NC Block
The supplied SYNTEC description specifically notes that when the user writes M, S and T codes in the same NC program line, the CNC sends the corresponding read flags S29, S54 and S69 to the Ladder at the same time.
For example:
N100 Mxx Sxxxx Txx
The interface can therefore present the three requests together:
R01 ← M-code contents
R02 ← S-code value
R03 ← T-code contents
S29 = ON
S54 = ON
S69 = ON
The Ladder implementation must therefore be designed so that the individual M, S and T processing states can be managed correctly when more than one request is present.
Recommended Ladder Structure
The supplied Ladder programming recommendation proposes using an MSD graph concept to organize the M/S/T logic. Instead of implementing an entire sequence as one large Ladder condition, each command type is divided into three logical states:
M_START → M_EXECUTE → M_FIN
S_START → S_EXECUTE → S_FIN
T_START → T_EXECUTE → T_FIN
The recommendation is to assign these states to internal A bits. The specific A-bit addresses are not defined in the supplied material and therefore must be assigned according to the Ladder design of the actual machine.
START → EXECUTE → FIN State Sequence
1. START State
When the corresponding M, S or T code-read signal arrives, the appropriate START state is activated immediately.
S29 ON → M_START ON
S54 ON → S_START ON
S69 ON → T_START ON
This state records that a new command has been received and that its processing sequence must begin.
2. EXECUTE State
The sequence then enters its EXECUTE state. According to the recommended structure, the corresponding START state is turned OFF when the EXECUTE state becomes active.
M_START
↓
M_EXECUTE
└── M_START OFF
S_START
↓
S_EXECUTE
└── S_START OFF
T_START
↓
T_EXECUTE
└── T_START OFF
The actual machine sequence associated with the command is performed while the corresponding EXECUTE state is active.
3. FIN State
After the required operation has been completed, the sequence enters the FIN state. At this transition, the corresponding EXECUTE state is turned OFF.
M_EXECUTE → M_FIN
└── M_EXECUTE OFF
S_EXECUTE → S_FIN
└── S_EXECUTE OFF
T_EXECUTE → T_FIN
└── T_EXECUTE OFF
This separates command reception, execution and completion into distinct states and makes the Ladder sequence easier to follow during diagnostics.
Recommended M/S/T State Model
| Command | Read signal | START | EXECUTE | FIN |
|---|---|---|---|---|
| M | S29 | M_START | M_EXECUTE | M_FIN |
| S | S54 | S_START | S_EXECUTE | S_FIN |
| T | S69 | T_START | T_EXECUTE | T_FIN |
Generating C38 from the FIN States
The supplied programming recommendation describes a common completion condition in which the M, S and T sequences each have their own FIN state and C38 is generated when the required completion conditions have been satisfied.
The supplied example expresses the condition as:
C38 =
M_FIN
AND S_FIN
AND T_FIN
Conceptually:
M_FIN ──┐
S_FIN ──┼──► completion condition ──► C38
T_FIN ──┘
This is a recommended Ladder organization from the supplied material, not a universal statement that every SYNTEC machine must implement C38 using exactly these three internal A-bit contacts. The actual internal A-bit assignments and machine sequence must be verified in the specific CNC.LAD.
Commands absent from a block: a plain AND of M_FIN, S_FIN and T_FIN can complete only if all three states have appropriate values. The machine-specific logic must account for command types that were not requested, reset stale completion states, and prevent a request that remains active from restarting the same sequence. Verify request acceptance and C38 reset timing in the controller documentation and actual CNC.LAD.
Complete Action Sequence
The complete interaction can be summarized in five stages.
1. CNC reads the M/S/T command
When NC program execution reaches an M, S or T command, the CNC places the corresponding command contents into the register interface:
M → R01
S → R02
T → R03
2. CNC sends the code-read request to the Ladder
M request → S29
S request → S54
T request → S69
These signals inform the Ladder that the corresponding command is ready for processing.
3. Ladder executes the corresponding logic
The Ladder detects the code-read signal, reads the corresponding register contents and starts the machine-specific sequence associated with that command.
4. Ladder returns M.S.T. Finish
After the required M/S/T processing has been completed, the Ladder returns C38 — M.S.T. Finish to the CNC.
5. CNC continues program execution
After receiving C38, the CNC completes the M/S/T handshake and continues execution of the following NC program.
1. NC program reaches M / S / T
↓
2. CNC writes R01 / R02 / R03
↓
3. CNC activates S29 / S54 / S69
↓
4. Ladder executes corresponding sequence
↓
5. Ladder completes the sequence
↓
6. PLC → CNC : C38 M.S.T. Finish
↓
7. CNC continues the NC program
Using the M/S/T Interface for Diagnostics
The same handshake used to design the Ladder is useful when diagnosing a machine that stops during an M, S or T command.
Instead of immediately assuming that the CNC program itself is faulty, the technician can follow the command through the interface step by step.
NC COMMAND
↓
R01 / R02 / R03
↓
S29 / S54 / S69
↓
LADDER START state
↓
LADDER EXECUTE state
↓
machine-specific conditions / sequence
↓
FIN state
↓
C38
↓
CNC continues
Example: CNC Stops at an M Code
If the NC program reaches an M code and does not proceed to the following block, the diagnostic path can begin with the M-code handshake:
M code in NC program
↓
Is the expected M-code value present in R01?
↓
Is S29 (M-code Read) ON?
↓
Does the Ladder enter the M-code sequence?
↓
Does M_START transition to M_EXECUTE?
↓
What condition prevents completion?
↓
Does M_FIN become active?
↓
Does C38 become active?
↓
Does CNC continue to the next NC block?
This makes it possible to determine whether the sequence has stopped at the CNC → PLC interface, inside the Ladder sequence, or at the final PLC → CNC completion handshake.
If the Ladder sequence depends on physical equipment, diagnosis must then continue beyond the internal PLC state and into the actual machine hardware.
M / S / T command
↓
CNC interface
↓
PLC Ladder
↓
interlocks
↓
PLC output
↓
physical I/O
↓
relay / electrical control
↓
actuator / drive / solenoid
↓
machine mechanism
↓
sensor / feedback
↓
PLC input
↓
Ladder completion condition
↓
C38
↓
CNC
The exact physical chain depends on the machine and must be determined from its CNC.LAD, electrical schematics, I/O documentation and machine configuration.
Important Implementation Notes
1. M, S and T may be requested simultaneously.
If M, S and T commands are written in the same NC block, the supplied description states that S29, S54 and S69 can be sent to the Ladder at the same time. The Ladder design must therefore account for simultaneous requests.
2. R01, R02 and R03 carry different command information.
R01 is associated with the M-code contents, R02 with the S-code value, and R03 with the T-code contents.
3. S29, S54 and S69 are request/read signals.
They indicate that the corresponding M, S or T command has been read by the CNC and is being presented to the Ladder for processing.
4. C38 is the return handshake.
C38 is the M.S.T. Finish signal from the PLC side to the CNC side. It tells the CNC that the required M/S/T processing has been completed.
5. Internal A-bit addresses are machine-program dependent.
The START, EXECUTE and FIN state names describe the recommended programming structure. The supplied material does not specify fixed A-bit addresses for these states. They must therefore be identified or assigned in the actual Ladder program.
6. Do not assume the physical action from the interface signal alone.
S29 indicates an M-code request, but it does not by itself identify the machine hardware that will operate. The actual M-code action must be traced through the machine's Ladder. The same principle applies to T-code processing and other machine-specific sequences.
7. The S-code path has a specific distinction.
According to the supplied description, the S value is placed in R02 and S54 informs the Ladder about the S-code request, while the command to the frequency converter is handled inside the CNC after the Ladder returns C38.
Diagnostic Summary
The M/S/T interface can be understood as a controlled handshake between the CNC kernel and PLC Ladder:
CNC → PLC
M code : R01 + S29
S code : R02 + S54
T code : R03 + S69
↓
PLC LADDER
START → EXECUTE → FIN
↓
PLC → CNC
C38 = M.S.T. Finish
↓
CNC continues program
For diagnostics, this creates a clear sequence to follow: command → register contents → code-read signal → Ladder state → machine sequence → completion state → C38 → continuation of the NC program.
This interface should be treated as the boundary between NC program execution and machine-specific PLC logic. The SYNTEC interface defines how the request and completion signals are exchanged, while the actual behavior of each M or T function — and any interlocks, outputs, actuators and feedback signals involved — is determined by the Ladder and hardware configuration of the individual machine.
← All materials in PLC and Ladder