Overview: Stepper Motor Position Control with an Analog Setpoint
A Siemens S7-1500 PLC can position a stepper motor proportionally to an analog potentiometer by combining the TO_Axis_PTO technology object, the PLCopen motion command MC_MoveAbsolute, and a scaled analog input. The PLC generates step and direction pulses on a Pulse Train Output (PTO) channel, which a separate stepper amplifier converts into phase currents. A 0-10 V potentiometer is read on an SM 531 analog input, normalized to the configured travel range, and written to the axis as the position setpoint. The entire motion controller lives in TIA Portal V17 or later, so no external indexer or microcontroller is required. The reference design below is consistent with the S7-1500 Motion Control Function Manual available on the Siemens Industry Online Support portal.
System Architecture and Hardware Prerequisites
The minimum hardware stack consists of the items listed below. Each component must be ordered with the correct firmware version to interoperate with TIA Portal V17 or V18.
| Function | Component | Article Number | Firmware / Notes |
|---|---|---|---|
| Controller | SIMATIC S7-1500 CPU 1515-2 PN | 6ES7515-2AM02-0AB0 | Firmware V2.9 or later |
| Analog input (8-ch) | SM 531 AI 8xU/I/RTD/TC ST | 6ES7531-7KF00-0AB0 | Firmware V1.0 or later |
| Digital input for limit / homing | SM 521 DI 16x24VDC HF | 6ES7521-1BH00-0AB0 | Firmware V1.0 or later |
| Stepper amplifier | Third-party microstepping drive (e.g., Oriental Motor AZ Series, Festo EMCS-ST, Leadshine DM series) | vendor-specific | Step/Dir interface required |
| Stepper motor | 2-phase NEMA 23 or NEMA 34 bipolar | vendor-specific | Rated current ≤ drive current |
| Potentiometer | 10 kΩ linear, 0.5 W or 1 W | vendor-specific | 3-terminal voltage divider |
| Reference sensor | Inductive proximity, PNP NO, 24 V | vendor-specific | Rising-edge home signal |
The PLC drives the stepper amplifier through the PTO channel (Pulse + Direction). The amplifier powers the motor windings. The PLC reads the potentiometer wiper voltage through the SM 531 and the home sensor through the SM 521. Per the S7-1500 Motion Control Function Manual, a stepper drive requires two separate functions: a pulse-reference indexer (the PLC) and an amplifier that switches the motor currents (the external drive).
Wiring the Potentiometer and Stepper Drive
The potentiometer forms a three-wire voltage divider: 24 V on one end, 0 V on the other, and the wiper routed to the SM 531 channel. A 10 kΩ potentiometer is recommended because the SM 531 input impedance exceeds 100 kΩ on the voltage range, so loading errors stay below 0.1 percent.
Potentiometer connection
- Connect terminal
24Vof the potentiometer to the SM 531 terminalM+on channel 0. - Connect terminal
GNDof the potentiometer to the SM 531 terminalM-. - Connect the wiper to SM 531 input
AI0+(terminal 2 on the 6ES7531-7KF00-0AB0). - Configure the channel for voltage measurement 0-10 V in TIA Portal under Properties > AI configuration > Channel 0 > Measurement type.
- Bridge unused inputs to
M-to suppress noise pickup.
Stepper drive connection (PTO Pulse + Direction)
- Route
PTO.PULSE(CPU onboard output, e.g., Q0.0 on a CPU 1515-2 PN) to the drive’sSTEP+/PUL+input. - Route
PTO.DIR(Q0.1) to the drive’sDIR+input. - Connect
PULSE-andDIR-to the 24 V ground reference of the drive’s optocoupler common (typically0VorCOM). - Enable the drive’s Step/Dir interface in its configuration software. Set microstep resolution (1/8 or 1/16) and motor current to match the motor nameplate.
Configuring TO_Axis Technology Object in TIA Portal
The technology object encapsulates the mechanical model, drive interface, limits, and homing behavior. Insert the object from the project tree: Add new object > Technology objects > Motion Control > TO_Axis_PTO. Use the PTO variant, not TO_SynchronousAxis, because PTO does not receive an actual position from the drive. Detailed procedure is documented in the S7-1500 Motion Control Function Manual.
Configuration wizard settings
- Drive selection: "Pulse Train Output (PTO)".
- PTO output assignment: Select the CPU onboard output channel. For the CPU 1515-2 PN this is typically channel 1 (Q0.0/Q0.1).
- Signal type: "Pulse and direction" for unidirectional step signals.
- Output frequency range: Set the maximum to 100 kHz or 200 kHz depending on the CPU variant; the S7-1500 PTO supports up to 1 MHz on high-end CPUs such as the CPU 1518-4 PN/DP.
- Measuring system: "Incremental" - the stepper is open-loop, so the PLC commands moves without feedback. If the application is critical, use a closed-loop stepper drive such as the Oriental Motor AZ Series (closed-loop) and wire the encoder to the drive only.
Mechanical Configuration: Leadscrew, Gear Ratio, and User Units
The mechanical conversion from motor revolutions to load displacement must be entered exactly. The PLC uses these values to convert user units (e.g., millimeters) to motor steps.
| Parameter | Example Value | Description |
|---|---|---|
| Unit of measure | mm | User unit for all position values |
| Pulses per motor revolution | 1600 | 200 native steps × 1/8 microstepping |
| Leadscrew pitch | 5 mm/rev | Linear travel per motor revolution |
| Gearbox transfer ratio (load/motor) | 1.0 | Ratio between load shaft and motor shaft |
| Maximum velocity | 200 mm/s | Software limit on velocity setpoint |
| Maximum acceleration | 1000 mm/s² | Software limit on acceleration |
| Jerk limit | 50000 mm/s³ | Set to 0 to disable jerk-limited profile |
| Software limit switch (positive) | +150 mm | Upper travel limit in user units |
| Software limit switch (negative) | -150 mm | Lower travel limit in user units |
| Position tolerance | 0.1 mm | Window for the in-position flag |
1600 / 5 = 320 pulses. At a maximum velocity of 200 mm/s, the PTO must generate 200 × 320 = 64000 pulses per second, well within the PTO’s 100 kHz capability. Three-phase apparent power note: this calculation applies to the pulse rate only; motor current sizing follows the drive’s datasheet, not the step rate.Active Homing with MC_Home and Reference Sensor
Open-loop steppers lose absolute position on power-down. The axis must be homed to a known mechanical reference before absolute moves. Use active homing with a PNP proximity sensor wired to a digital input.
- Assign the home sensor to a digital input, e.g., I0.0 on the SM 521.
- In TO_Axis configuration, navigate to Homing > Homing mode and select Active homing with reference mark and reversing to clear signal.
- Set approach velocity to 50 mm/s and homing velocity (creep speed after sensor contact) to 10 mm/s.
- Define the home position offset: the user-unit position the axis should report when the reference sensor is reached (commonly 0 mm).
- Call
MC_Homein the user program withMode = 3(active homing) on power-up or after an E-stop reset.
During homing, the axis accelerates to approach velocity, traverses until the sensor closes, then reverses at creep velocity to find the exact transition edge. The technology object latches the mechanical reference, writes the home position offset into the actual position, and sets AxisStatus.HomingDone.
MC_Home to complete but leave the actual position shifted by the deceleration distance.Scaling the Potentiometer Analog Input to Position
The raw AI value (0-27648 for unipolar 0-10 V on the SM 531) must be scaled to the travel range, e.g., 0-100 mm. The S7-1500 standard function SCALE performs linear conversion when the input type matches. For full control, use the NORM_X and SCALE_X instructions from the basic instructions library.
For a travel range of 0-100 mm:
- Minimum raw value: 0 (0 V at wiper)
- Maximum raw value: 27648 (10 V at wiper)
- Minimum scaled value: 0 mm
- Maximum scaled value: 100 mm
Equivalent SCL code:
// Read scaled potentiometer position
#RawAI := %IW64; // SM 531 channel 0
#NormVal := NORM_X(MIN := 0,
VALUE := #RawAI,
MAX := 27648); // 0.0 - 1.0
#SetPos := SCALE_X(MIN := 0.0,
VALUE := #NormVal,
MAX := 100.0); // 0.0 - 100.0 mm
PLCopen Motion Commands: MC_MoveAbsolute
The PLCopen standard defines the motion command set implemented in the LBC (Library of Basic Controls) blocks provided with TIA Portal. After successful homing, MC_MoveAbsolute drives the axis to a commanded position regardless of its current actual position.
| Input | Type | Description |
|---|---|---|
| Axis | TO_Axis | Technology object reference |
| Execute | BOOL | Rising edge starts the move |
| Position | LREAL | Target position in user units (mm) |
| Velocity | LREAL | Maximum velocity (mm/s); must be ≤ TO maximum |
| Acceleration | LREAL | Acceleration (mm/s²) |
| Deceleration | LREAL | Deceleration (mm/s²) |
| Jerk | LREAL | Jerk limit (mm/s³); 0 = trapezoidal |
| Direction | INT | 0 = shortest, 1 = positive, 2 = negative, 3 = current |
Typical wiring: MC_Power enables the axis, MC_Home defines zero, and a continuous MC_MoveAbsolute with the scaled potentiometer value is called on a slow timer (e.g., every 100 ms) so the axis tracks the wiper smoothly. To avoid busy polling, hold the last MC_MoveAbsolute.Execute true and only re-trigger when the new setpoint differs by more than the position tolerance.
Complete Program Structure in SCL
The following SCL snippet integrates the scaling, the homing trigger, and the continuous absolute move. The MC_Power call enables the PTO and the MC_Home call runs once on the first program cycle or on operator command.
// FB_AxisControl
IF "iFirstRun" THEN
"MC_Home_Instance"(Axis := "TO_Axis_1",
Execute := TRUE,
Mode := 3,
Position := 0.0);
"iFirstRun" := FALSE;
END_IF;
#RawAI := "SM531_AI0";
#NormVal := NORM_X(MIN := 0, VALUE := #RawAI, MAX := 27648);
#SetPos := SCALE_X(MIN := 0.0, VALUE := #NormVal, MAX := 100.0);
IF "bPower" THEN
"MC_Power_Instance"(Axis := "TO_Axis_1",
Enable := TRUE);
END_IF;
IF "TO_Axis_1".StatusWord.HomingDone AND "bAutoRun" THEN
"MC_MoveAbsolute_Instance"(Axis := "TO_Axis_1",
Execute := TRUE,
Position := #SetPos,
Velocity := 50.0,
Acceleration := 200.0,
Deceleration := 200.0);
END_IF;
For ladder logic users, the same structure is built with the LBC motion control blocks from the “Motion Control” task card in TIA Portal. Wire MC_Home.Execute to a first-cycle flag, MC_Power.Enable to a permanent operator enable, and MC_MoveAbsolute.Execute to a comparator output that detects setpoint changes exceeding the position tolerance.
Commissioning and Verification Procedure
- Download the hardware configuration and user program to the CPU.
- Open Online > Commissioning > Axis control panel in TIA Portal.
- Enable the axis with Operating mode > Manual control. The StatusWord should report
Standstill. - Use the jog buttons to verify that the motor rotates in the expected direction. If it reverses, swap the
PULSEandDIRECTIONpolarity in the drive or invert the direction flag in TO_Axis (Mechanics > Direction reversal). - Trigger Home in the axis control panel. Verify that the actual position resets to 0 mm at the reference sensor.
- Toggle the potentiometer by hand. Verify that the actual position tracks within the configured position tolerance.
- Disconnect from the programming PC and run the system standalone for 24 hours to validate thermal drift and wiper noise.
- Capture an S7-1500 trace recording of the PTO pulse train and the AI channel to confirm electrical integrity.
Troubleshooting Matrix
| Symptom | Likely Root Cause | Corrective Action |
|---|---|---|
| Motor does not move at all | PTO output not enabled; drive not powered; enable input on drive missing | Check MC_Power.Status = TRUE; verify drive enable; check 24 V supply |
| Motor vibrates but does not rotate | Pulse frequency too high for mechanical resonance; microstep mis-configured | Reduce velocity; check microstep setting matches driver |
| Motor rotates but position drifts | Mechanical slip; backlash not compensated; lost steps at high acceleration | Reduce acceleration; add gearbox anti-backlash nut; reduce load |
| Position setpoint stuck at one extreme | Potentiometer wiper open; AI channel misconfigured | Measure voltage at AI0+ with multimeter; verify channel mode = 0-10 V |
| Axis faults on homing start | Homing mode selected before MC_Power enabled |
Enable axis first, then issue MC_Home
|
| Software limit switch trips unexpectedly | Travel range miscalculated; leadscrew pitch wrong | Re-measure pitch; verify pulses/rev and gearbox ratio |
| Position oscillates around setpoint | Potentiometer noise; no deadband in move command | Add moving-average filter; ignore setpoint changes < tolerance |
| Homing completes but actual position is offset | Home position offset mis-configured; sensor polarity reversed | Set home offset to 0 mm; flip sensor polarity in TO_Axis |
| Axis reports "configuration error" at download | CPU firmware older than TO_Axis_PTO version; missing technology object license | Upgrade CPU firmware; confirm TIA Portal version matches |
Extended Diagnostics and Edge Cases
Open-loop lost steps
Stepper motors stall when load torque exceeds the motor’s torque at the commanded speed. The PLC has no feedback to detect this, so the actual position silently drifts. For closed-loop behavior, use a stepper drive with integrated encoder feedback such as the Oriental Motor AZ Series or a Leadshine CS series closed-loop stepper. These drives close the loop internally and report a position-error alarm that the S7-1500 can read over PROFINET using the PROFIdrive profile.
Potentiometer wiper noise
Mechanical wear generates transient contact resistance spikes that appear as voltage noise on the wiper. A first-order software filter with a time constant of 100 ms smooths the noise without introducing noticeable lag for typical operator inputs. Apply the filter before the NORM_X call.
Direction inversion at the application
If rotating the motor CCW should increase position but the actual position decreases, set Invert direction in the TO_Axis configuration under Mechanics > Direction. Do not rewire the pulse and direction signals: inversion in software keeps the wiring identical and reduces commissioning errors.
Alternate CPU platforms
The same procedure applies to the S7-1200 with firmware V4.4 or later, but PTO frequency is limited to 100 kHz and the technology object is named TO_PositioningAxis rather than TO_Axis_PTO. The ET 200SP CPU 1510SP-1 PN and CPU 1512SP-1 PN behave identically to the S7-1500 for stepper control. The S7-300 does not support TO_Axis_PTO in the same manner; legacy FM 353 / FM 354 positioning modules are required.
Safety integration
When the stepper drives a load that can cause injury, route the E-stop chain through a SIMATIC F-CPU or a Sirius 3SK safety relay to disable the drive’s enable input. The S7-1500 PTO channel must be configured to stop on PROFIsafe or hard-wired E-stop, and the technology object must enter Error state via MC_Reset after the safety chain closes.
FAQ
Can the S7-1500 control a stepper motor without a dedicated stepper drive?
No. The PLC’s PTO generates only logic-level step and direction signals. A stepper amplifier (also called stepper drive or power module) is required to switch the motor phase currents at the rated voltage and current. The PLC acts as the indexer only.
What is the maximum PTO frequency on the S7-1500?
The S7-1500 PTO supports up to 1 MHz on high-end CPUs such as the CPU 1518-4 PN/DP and 100 kHz to 200 kHz on mid-range CPUs (CPU 1511, 1513, 1515). Verify the specific limit in the CPU data sheet before sizing the maximum linear velocity.
Which TIA Portal version is required?
TIA Portal V17 or later is recommended for S7-1500 motion control. V16 supports TO_Axis_PTO but lacks newer jerk-limited profile options. The CPU firmware must be V2.6 or later to match the TIA Portal version’s technology objects.
How is the potentiometer reading converted to the axis position?
The 0-10 V analog value is normalized to 0.0-1.0 with NORM_X and scaled to the configured travel range with SCALE_X. The resulting LREAL value becomes the input to MC_MoveAbsolute.Position in user units (mm).
What happens if homing is skipped after a power cycle?
The PLC has no absolute reference, so the axis actual position starts at the last saved value (or 0 if never homed). Issuing MC_MoveAbsolute without homing can drive the load into a mechanical end stop. Always call MC_Home on startup or after E-stop reset.