09/17/2025
How-to

Control of Stepper Motor on Linear Axes from PLC

This article is about the ISS042 (NEMA17), ISS057 (NEMA23) or ISS086 (NEMA34) stepper motors. They are equipped with an incremental encoder (magnetic, 4096 PPR) and a pre-parameterized integrated drive controller. You will learn how to connect the motors to the ctrlX CORE via EtherCAT and control the axis movement from the PLC using the CoE statusword and controlword. This means the Motion app is not used. A function block will handle the homing routine of the axis after start up and afterwards you can use it for positioning tasks.

Requirements

Step by Step

1. EtherCAT Configuration

First download the ESI File (xml) for the stepper motor from the Rexroth website.

Download ESI file

Connect the EtherCAT port on the motor to port XF50 on the ctrlX CORE. Then open your browser and login to the OS of the control. Go to EtherCAT Master and click "Add EtherCAT Master".

Add EtherCAT Master

Leave the settings as they are proposed and click "Add". Afterwards you can open ctrlX IO Engineering by clicking the button in the upper right corner to continue with the EtherCAT configuration.

Open IO Engineering

Inside ctrlX IO Engineering go to Tools -> Device Repository. Then click "Install..." and select the xml file you downloaded previously.

Afterwards right click on "ethercatmaster", then select "Scan for Devices".

Scan for devices

There you will see the stepper motor on the right side. Click the button at the top, rename the device, if you want to, and then confirm with "Apply" and "OK".

Scan for Devices

Before you can download the new configuration to the control, you need to edit the start up parameters of the motor. Therefore you need to check the technical data of your motor and your linear axes, namely the limits for velocity and acceleration for your combination of motor and linear axis and the length and the spindle pitch of the linear axis. For example the linear axis "SMS-030-P8-100" has a spindle pitch of 8 mm/rotation and a usable length of 100 mm.

Open the tab "Startup Parameters" of the stepper motor, add the parameters according to the image below and set the values depending on your application. The units of the parameters are in micrometers. In this example the following values are set:

  • Max_Software_Position_Limit according to the length of the linear axis: 100.000 μm (you could also set min: -50.000 and max: +50.000)

  • Feed constant feed: 8.000 μm/rotation

  • Profile acceleration and deceleration: 1.500.000 μm/s^2

  • Profile velocity: 200.000 μm/s

  • Homing method: -13

Startup parameter

The parameters "Profile acceleration", "Profile deceleration" and "Profile velocity" define the dynamic values of the operation mode "Profile Position Mode", that will be used for the positioning movements.

The correct value for the parameter "Homing method" should be evaluated from the table below:

Homing method

Once you're done, you can download the configuration to the control.

Download EtherCAT configuration

2. Realtime parameters in PLC project

Open ctrlX PLC Engineering and create a new project or edit your existing project.

Add the following variables for the cyclic real time data of the stepper motor to your program. If you have more than one stepper motor add these variables for each motor and rename to _Stepper02, _Stepper03, etc.

VAR

	// EtherCAT variables of Stepper Motor
	
	// Input
	wStatusWord_Stepper01		: WORD;
	siOpModeDisplay_Stepper01	: SINT;
	diActualPosition_Stepper01	: DINT;
	
	// Output
	wControlWord_Stepper01		: WORD;
	siOpMode_Stepper01			: SINT;
	diTargetPosition_Stepper01	: DINT;

END_VAR

Then go to "DataLayer_Realtime" in the device tree, then "Select realtime data" and click "Selectively from ctrlX CORE".

Realtime data in ctrlX PLC Engineering

In the pop up window under "Source: Control" on the right side, select "ethercat_master..." (1). Then navigate to the stepper motor and select the parameters (2) according to the image below. If you have several stepper motors, select these parameters for all of them. Then add the parameters to your project with the button in the middle (3) and close the window (4).

Realtime parameter selection

Then map the EtherCAT parameters to the variables in your GVL. Therefore open the stepper motor in the device tree and for each of the six parameters double-click on the empty field in the variable column and then click the tree dots, that will appear. There you can select the variables, until your screen looks like the image below. Repeat this for the other stepper motors, if you have more than one.

Realtime parameter mapping

3. Function block for motor control in PLC project

Download the file attached in the end of this article. It contains a prepared function block (FB) for the control of stepper motor and linear axis in your PLC program. Import the FB into your PLC project through the menu "Project" -> "Import".

Import menu

Select the downloaded file "FB_Stepper.export". Then make sure to choose a target for the import in the device tree (1), then confirm with OK (2).

Import dialogue

In your program add an instance of the FB for each stepper motor you have and call it like this:

PROGRAM AxisMotion      // call program every cycle

VAR
	fbStepper01 : FB_StepperControl;
END_VAR

fbStepper01(	Enable 				:= TRUE,
				bHomingPossible		:= TRUE,
				bMoveDown	 		:= , 
				bMoveUp 			:= , 
				diPosUp				:= 10000, 
				diPosDown			:= 90000,
				wStatusWord			:= wStatusWord_Stepper01, 
				siOpModeDisplay		:= siOpModeDisplay_Stepper01, 
				diActualPosition	:= diActualPosition_Stepper01, 
				wControlWord		=> wControlWord_Stepper01, 
				siOpMode			=> siOpMode_Stepper01,
				diTargetPosition	=> diTargetPosition_Stepper01, 
				bIsDown				=> ,
				bIsUp				=> ); 

Download the PLC program to your control and run it.

Some comments about the FB

  • In my case the axis is mounted vertically so the position variables I use are called "diPosUp" and "diPosDown".

  • Once the FB is enabled (input variable "Enable") and the boolean input variable "bHomingPossible" is TRUE, the stepper will perform a homing routine to the hard stop of the linear axis. You must only trigger this, if the movement is possible without a crash in your machine.

  • After a successful homing routine, the movement to the UP and DOWN positions will be triggered by a rising edge of the control variable "bMoveDown" or "bMoveUp".

  • Inside the FB the relevant bits of the control- and statusword are mapped to boolean variables like this:

// Read cyclic realtime data: Statusword
bStat_ReadySwitchOn		:= wStatusWord.0;
bStat_SwitchedOn		:= wStatusWord.1;
bStat_OpEnabled			:= wStatusWord.2;
bStat_Fault				:= wStatusWord.3;
bStat_QuickStop			:= wStatusWord.5;
bStat_SwitchOnDisabled	:= wStatusWord.6;
bStat_TargetReached		:= wStatusWord.10;
bStat_Homed				:= wStatusWord.15;

// Set cyclic realtime data: Controlword (Homing Mode)
wControlWord.0 	:= bCon_SwitchOn;
wControlWord.1 	:= bCon_EnableVoltage; 
wControlWord.2 	:= bCon_QuickStop; 
wControlWord.3 	:= bCon_EnableOp; 
wControlWord.4 	:= bCon_StartHoming; 

Happy positioning ;)

FB_Stepper.zip
5.58KB
Types
How-to
Products
Drives
Controls
Motors
PLC
Motion
Markets
Assembly Lines
Logistic
Manufacturing
Packaging
Printing
Production Machines
Robotics
Semicon & Electronics

Latest published/updated articles