Overview
Positioning a servo drive from a Siemens SIMATIC S7-1200 controller requires three things: a wired pulse/direction (PTO) or analog interface to the drive, a configured technology object "TO_Axis_PTO" in TIA Portal, and the correct PLCopen motion function block (FB) in the user program. The most common commissioning mistake is selecting the wrong motion FB: engineers load MC_MoveRelative when they actually need MC_MoveAbsolute, or vice versa. Both FBs accept a Position and Velocity input, but their semantic meaning is fundamentally different.
This reference covers the correct function-block selection for absolute and incremental moves, the wiring of a S7-1200 PTO channel to a servo drive pulse/direction input, the parameter set of each MC FB, and the verification steps required after download.
Prerequisites
- SIMATIC S7-1200 CPU with firmware 4.2 or higher (CPU 1211C, 1212C, 1214C, 1215C, or 1217C). Motion control was substantially expanded in V4.x; refer to the S7-1200 Motion Control V4.0 Function Manual.
- TIA Portal V15.1 or higher (V17/V18 recommended for current S7-1200 firmware V4.5+).
- A servo drive that accepts step/direction (pulse train) input, or analog ±10 V with digital enable. Common S7-1200-compatible families include Siemens SINAMICS V90 (with pulse/direction variant), Festo EMMS-AS, Yaskawa Sigma-7 in pulse-train mode, and Delta ASDA-A2.
- Encoder feedback wired back to the drive (the S7-1200 PTO is open-loop from the PLC's perspective; closed-loop control happens inside the drive).
- Axis mechanics: leadscrew pitch, gearbox ratio, and load inertia should be known so that user units (mm, deg, or revolutions) can be derived.
MC_Power: Enabling the Drive
Before any motion FB can issue setpoints, the axis must be enabled. MC_Power is the mandatory first block in every motion sequence. It energizes the drive's power stage and clears the controller's enable interlock.
| Port | Direction | Type | Meaning |
|---|---|---|---|
| Axis | IN | TO_Axis | Reference to the technology object created in TIA Portal |
| Enable | IN | BOOL | Rising edge energizes the drive; falling edge disables |
| StopMode | IN | INT | 0 = Immediate stop, 1 = Emergency stop, 2 = Controlled stop with current ramp |
| Status | OUT | BOOL | TRUE = drive is enabled and ready to accept setpoints |
| Busy | OUT | BOOL | TRUE while the FB is actively controlling the axis |
| Error | OUT | BOOL | TRUE if the FB raised an error |
| ErrorID | OUT | WORD | 16#8001 .. 16#800F range for MC_Power-specific errors |
Standard usage pattern in ladder or structured text:
// Enable axis continuously while bEnable is true
MC_Power_Instance(Axis := MyAxis, Enable := bEnable, StopMode := 0,
Status => bDriveReady, Busy => , Error => bErr,
ErrorID => wErrID);
Status = TRUE before calling any MC_MoveAbsolute or MC_MoveRelative. Issuing motion commands to a non-enabled axis raises ErrorID 16#8001 (axis not enabled) or 16#8002 (axis disabled by MC_Power).MC_MoveAbsolute vs MC_MoveRelative: The Core Difference
Both FBs accept a target Position in the technology object's configured user units, and both accept a Velocity in user units per second. The difference is the coordinate reference:
| Aspect | MC_MoveAbsolute | MC_MoveRelative |
|---|---|---|
| Position argument means | Target position in the axis coordinate system (referenced to home/zero) | Incremental distance from the current commanded position |
| Coordinate reference | Absolute machine zero (after MC_Home) | Current axis position at the moment of execution |
| Typical use | Pick-and-place targets, indexed stations, tool change positions | Inching/jog moves, incremental step routines, indexing by fixed step |
| Behavior on power cycle | Re-homing required (drive loses position reference) | Re-homing required before the next absolute move, but incremental moves still produce predictable step distance |
| Direction logic | Controller computes shortest or directional path to target | Sign of Position sets direction (negative = reverse) |
Worked Example: Selecting the Right FB
Assume the axis is currently sitting at user-unit position 1000 (e.g., 1000 mm on a linear slide) and the technology object "MyAxis" has been homed.
| Call | Resulting Axis Position | Use Case |
|---|---|---|
| MC_MoveAbsolute(Position := 500, Velocity := 5000) | 500 (backward move to absolute target) | Go to fixed station 500 mm from home |
| MC_MoveRelative(Position := 500, Velocity := 5000) | 1500 (1000 + 500 incremental) | Step forward 500 mm from wherever the axis is now |
| MC_MoveRelative(Position := -200, Velocity := 3000) | 800 (1000 - 200 incremental reverse) | Jog back 200 mm without changing absolute target |
If your application requires the drive to go to a fixed station number regardless of the axis's current position, use MC_MoveAbsolute. If the application only ever needs to move a fixed step in one direction (e.g., a feeder advancing a part), MC_MoveRelative is appropriate.
MC_MoveAbsolute Parameter Reference
| Port | Dir | Type | Description |
|---|---|---|---|
| Axis | IN | TO_Axis | Technology object reference |
| Execute | IN | BOOL | Rising edge starts the motion |
| Position | IN | LREAL | Target position in user units (mm, deg, revs) |
| Velocity | IN | LREAL | Target velocity in user units / second |
| Acceleration | IN | LREAL | Acceleration in user units / s² (optional; default = axis config) |
| Deceleration | IN | LREAL | Deceleration in user units / s² (optional) |
| Jerk | IN | LREAL | Jerk limit for S-curve ramp (optional, V4+) |
| Direction | IN | INT | 1 = positive only, -1 = negative only, 0 = shortest path (default 1) |
| Done | OUT | BOOL | TRUE when target is reached within positioning window |
| Busy | OUT | BOOL | TRUE while the FB is commanding motion |
| CommandAborted | OUT | BOOL | TRUE if a higher-priority FB interrupted this one |
| Error | OUT | BOOL | TRUE on error |
| ErrorID | OUT | WORD | 16#8001 invalid mode, 16#8002 axis not enabled, 16#8003 axis disabled, 16#8004 direction invalid, 16#8005 velocity ≤ 0, 16#8006 acceleration ≤ 0, 16#8007 jerk ≤ 0, 16#8008 position out of SW-limit range |
MC_MoveRelative Parameter Reference
| Port | Dir | Type | Description |
|---|---|---|---|
| Axis | IN | TO_Axis | Technology object reference |
| Execute | IN | BOOL | Rising edge starts the move |
| Distance | IN | LREAL | Signed travel distance from current position (user units) |
| Velocity | IN | LREAL | Target velocity in user units / second |
| Acceleration | IN | LREAL | Optional override |
| Deceleration | IN | LREAL | Optional override |
| Jerk | IN | LREAL | Optional S-curve override (V4+) |
| Done / Busy / CommandAborted / Error / ErrorID | OUT | BOOL/WORD | Same semantic as MC_MoveAbsolute |
Note that the parameter is named Distance on MC_MoveRelative, not Position. A common TIA Portal edit error is to wire a tag called Position to a Distance input; the compiler will accept it but the semantic is wrong. Always rename the tag to Distance for clarity.
Pulse/Direction (PTO) Wiring Reference
On a CPU 1214C, the first PTO channel is on output Q0.0 (pulse) and Q0.1 (direction). On CPU 1215C and 1217C, the second channel is Q0.2/Q0.3, and the third is Q0.4/Q0.5. The fourth PTO (only on 1217C from V4.4) is Q0.6/Q0.7. These outputs are differential 5 V TTL or 24 V push-pull depending on the wiring module used.
| Channel | Pulse Output | Direction Output | Max Frequency |
|---|---|---|---|
| PTO1 | Q0.0 | Q0.1 | 100 kHz (1 MHz on 1217C with signal board) |
| PTO2 | Q0.2 | Q0.3 | 100 kHz |
| PTO3 | Q0.4 | Q0.5 | 100 kHz |
| PTO4 (1217C) | Q0.6 | Q0.7 | 100 kHz |
For high-frequency servo drives, use a Siemens signal board (SB 1222 DQ 200 kHz, 6ES7 222-1AD30-0XB0) or the SB 1223 high-speed counter board. Wire the differential outputs through a 24 V line-driver adapter (e.g., Siemens Sirius 3TX7002) if the drive expects 24 V open-collector or 5 V differential.
Configuring the Technology Object
- In TIA Portal, expand the S7-1200 station in the project tree and right-click Technology Objects → Add new object → TO_Axis_PTO.
- Select the pulse generator (PTO) channel that matches the wired output pair (Q0.0/Q0.1 for PTO1).
- Set the drive type to "Servo" (vs. stepper) so the technology object exposes a closed-loop-ready error window.
- Configure user units: choose mm, inches, degrees, or revolutions, then enter the load distance per motor revolution (e.g., 10 mm/rev for a 10 mm-pitch ballscrew).
- Set the maximum velocity, acceleration, and jerk to values supported by the mechanics. A safe commissioning starting point is 20% of the drive's rated speed.
- Define software limit switches (positive and negative) in the configuration to protect the mechanics.
- Configure the homing mode: active homing with the home-switch input (DI of the drive or DI of the S7-1200) is the standard.
- Download the project. The technology object is now accessible as
<TO_name>in the user program.
Sample Program in Structured Text
The following ST snippet implements the typical sequence: enable the drive, home, then move to absolute position 500 mm at 5 000 mm/s. This is the corrected version of the typical "MC_Power + MC_MoveRelative" pattern that operators new to PLCopen motion often attempt.
// FB instances (declare as STATIC in FB or in global DB)
InstMC_Power : MC_Power;
InstMC_Home : MC_Home;
InstMC_MoveAbs : MC_MoveAbsolute;
InstMC_MoveRel : MC_MoveRelative;
InstMC_Reset : MC_Reset;
// Tag declarations
bEnable : BOOL; // Start enable
bStartHome : BOOL; // Start homing
bStartMoveAbs : BOOL; // Start absolute move
bStartMoveRel : BOOL; // Start relative move
lrAbsTarget : LREAL := 500.0; // mm
lrRelDist : LREAL := 50.0; // mm
lrVelocity : LREAL := 5000.0; // mm/s
bMoveDone : BOOL;
bDriveReady : BOOL;
bErr : BOOL;
wErrID : WORD;
// 1) Enable the drive continuously
InstMC_Power(Axis := MyAxis,
Enable := bEnable,
StopMode := 0,
Status => bDriveReady,
Busy => , Error => bErr, ErrorID => wErrID);
// 2) Run homing (call once, on first start, or after power cycle)
InstMC_Home(Axis := MyAxis,
Execute := bStartHome AND bDriveReady,
Position := 0.0,
Mode := 0, // 0 = passive, 1 = active
Done => , Busy => ,
Error => bErr, ErrorID => wErrID);
// 3) Absolute move - correct FB for "go to position X"
InstMC_MoveAbs(Axis := MyAxis,
Execute := bStartMoveAbs AND bDriveReady,
Position := lrAbsTarget,
Velocity := lrVelocity,
Acceleration := 10000.0,
Deceleration := 10000.0,
Direction := 0, // shortest path
Done => bMoveDone,
Busy => ,
CommandAborted => ,
Error => bErr, ErrorID => wErrID);
// 4) Optional relative move - correct FB for "step N units from current pos"
InstMC_MoveRel(Axis := MyAxis,
Execute := bStartMoveRel AND bDriveReady,
Distance := lrRelDist,
Velocity := lrVelocity,
Done => ,
Error => bErr, ErrorID => wErrID);
// 5) Error reset on rising edge
InstMC_Reset(Axis := MyAxis, Execute := bReset, Error => , ErrorID => );
Common Error Codes and Root Causes
| ErrorID | Meaning | Likely Cause | Corrective Action |
|---|---|---|---|
| 16#8001 | Invalid mode/state | Axis not configured; TO not downloaded | Re-download technology object; verify Axis reference |
| 16#8002 | Axis not enabled | MC_Power Status = FALSE | Check Enable input, drive 24 V, enable wire, no drive fault |
| 16#8005 | Velocity ≤ 0 | User wired 0 or negative velocity | Check lrVelocity tag; ensure positive value or signed direction |
| 16#8008 | Position out of SW-limit | Target outside configured limits | Adjust software limit switches or move to safer target |
| 16#800B | Homig required | Absolute move called before MC_Home | Run MC_Home first, then verify Done before absolute move |
| 16#800C | Axis currently in error | Drive fault, stall, following error | Clear drive fault, call MC_Reset, then MC_Power |
| 16#8011 | Acceleration/Deceleration ≤ 0 | Invalid ramp tag | Set acceleration/deceleration > 0 in user units/s² |
| 16#8020 | Axis not configured for this FB | Wrong TO type (e.g., MC_TouchProbe on linear axis) | Verify technology object class matches FB |
| 16#8023 | Command not allowed in current state | Axis is stopping or aborting | Wait for Busy=FALSE before issuing new command |
The complete list is published in the S7-1200 Motion Control V4.0 function manual. For firmware-specific additions (V4.4 and V4.5), refer to the release notes in the same Knowledge Base entry.
Verification Procedure
- After download, open the S7-1200 online view in TIA Portal and navigate to Commissioning → Axis control panel.
- Click Enable in the axis control panel. The
MC_PowerStatus output must turn TRUE within 2 seconds. - Click Home. The drive must travel to the home position and stop.
MC_Home.Done must rise TRUE. - Use the Jog buttons to verify direction matches the physical axis movement. If positive jog moves the axis in the negative direction, invert the direction in the technology object configuration (Basic parameters → Direction).
- Trigger the Position to position test from the axis control panel with a small target (e.g., 10 mm) and low velocity (50 mm/s) to confirm the wiring, direction, and limits are correct.
- Switch to the user program and trigger the
MC_MoveAbsoluteblock. Monitor the axis's actual position on the HMI or in the watch table; it must reach the target within the configured positioning window. - Test
MC_MoveRelativeby issuing a +10 mm incremental move, then a -10 mm move. The axis must return to its previous position.
Troubleshooting Matrix
| Symptom | Likely Root Cause | Corrective Action |
|---|---|---|
| MC_Power Status stays FALSE | Drive fault, missing 24 V on enable input, MC_Power StopMode mismatch | Read drive display / LED; clear drive fault; verify drive enable input is 24 V; try StopMode 2 |
| Move command issued but axis does not move | Velocity = 0, or axis not yet homed, or MC_Power not energized | Verify MC_Power Status, MC_Home Done, Velocity tag |
| Axis moves in the wrong direction | Pulse/Direction outputs inverted, or sign of target reversed | Swap A+/A- (pulse) or B+/B- (direction); or invert Direction in technology object |
| Axis overshoots and oscillates | Drive's internal position loop gains too low for the load inertia | Tune servo drive (PI or PIFF) gains per the drive manual; do not increase S7-1200 ramp jerk as a workaround |
| Following-error alarm on drive | Mechanical binding, low drive torque, friction too high | Decouple the load; verify torque limit; check couplings and bearings |
| MC_MoveAbsolute Done = FALSE indefinitely | Position outside SW-limit, or window tolerance too tight | Loosen the positioning window in the TO configuration; check software limits |
| ErrorID 16#800B on every absolute move | MC_Home never called or was aborted | Run MC_Home and check Done before issuing MC_MoveAbsolute |
| Drive runs at very low speed when jog is commanded from the control panel | Unit conversion error: user units do not match load distance per rev | Recompute load distance per revolution and re-enter in the technology object |
Notes on the Pulse/Direction (CE-X7) Profile
The S7-1200 PTO emits a step/direction signal, which is the most common interface on small-format servo drives. The CE-X7 profile referenced in older Festo / Siemens documentation describes a 5 V differential (RS-422) pulse output with 24 V opto-isolated direction. Most current drives (Siemens V90 pulse variant, Yaskawa Sigma-7, Delta ASDA-A2, Mitsubishi MR-J4 in pulse-train mode) accept this directly. Always wire the drive's PULS+ / PULS- and SIGN+ / SIGN- to the S7-1200 differential outputs through a shielded twisted pair; ground the shield on the drive end only.
Field-Proven Best Practices
- Always call
MC_Powerin a cyclic task, not in a startup OB. Cyclic invocation lets the axis re-enable automatically after MC_Reset. - Interlock
MC_MoveAbsolute.ExecutewithMC_Power.Status AND MC_Home.Done. Issuing motion before homing is the single most common cause of ErrorID 16#800B. - Use
MC_Resetto clear a drive-side error and motion-side error in one operation; a rising edge on its Execute input performs the reset and re-arms the axis. - For pick-and-place routines with multiple stations, store each target as a constant in a global DB and call
MC_MoveAbsolutewith the constant. Avoid dynamic distance calculations; they invite logic errors. - Limit
Jerkto 80-100 % of maximum during commissioning. Allowable jerk protects the mechanics; a jerk-limited (S-curve) profile is dramatically smoother than a trapezoidal one. - For applications that must survive a power cycle without re-homing (vertical axes, large rotary tables), use a multi-turn absolute encoder and switch to a closed-loop position interface such as PROFINET IRT with a Siemens V90 PN or a Festo CMMT-AS. Pulse/direction is inherently incremental.
FAQ
What is the difference between MC_MoveAbsolute and MC_MoveRelative on an S7-1200?
MC_MoveAbsolute moves the axis to a fixed position referenced to the home coordinate (e.g., position 500 means 500 mm from home). MC_MoveRelative moves the axis by a signed distance from wherever it is right now (e.g., distance +50 means 50 mm further from current). Use MC_MoveAbsolute for fixed stations and MC_MoveRelative for jog or step moves.
Do I need MC_Home before MC_MoveAbsolute?
Yes. The S7-1200 technology object requires a known home reference before it will accept an absolute target. If MC_Home is not done, MC_MoveAbsolute raises ErrorID 16#800B (homing required). Call MC_Home after every power cycle or after MC_Reset.
How many PTO channels does an S7-1200 have and which outputs do they use?
CPU 1211C/1212C/1214C/1215C support 2 PTO channels (Q0.0/Q0.1 and Q0.2/Q0.3). The CPU 1217C supports 4 channels (adds Q0.4/Q0.5 and Q0.6/Q0.7). Maximum pulse frequency is 100 kHz, extended to 200 kHz on the 1217C with a signal board.
Why does my servo run in the wrong direction?
Either the pulse-direction wiring is reversed (swap A+/A- or B+/B- on the drive) or the technology object direction is set incorrectly. Open TIA Portal → Technology Object → Configuration → Basic parameters and invert the direction; recompile and download.
Can I use MC_MoveVelocity together with MC_MoveAbsolute?
Yes. MC_MoveVelocity commands a constant speed with no fixed end position. Calling it while MC_MoveAbsolute is busy will cause the absolute move to be aborted (CommandAborted = TRUE on MC_MoveAbsolute). Use MC_Stop or MC_Halt to stop the axis before switching modes, or use a sequential task with priority logic to ensure only one motion FB is active at a time.