Towards Industry 4.0 — #9 Field Devices, Motion Control: Driving an Actuator, Stepper Motor

Andi Sama
8 min readJul 17, 2023

--

The Digital Transformation Journey to Industry 4.0 starts by understanding Industry 3.0

Andi Sama CIO, Sinergi Wahana Gemilang with Cahyati Sj. Sangaji

In Summary
- Implementation of Driving a Stepper Motor, through a Stepper Motor Driver.
- PLC Hardware: Siemens S7-1200 DC/DC/DC.
- Stepper Motor: A NEMA-34 with 4.5NM, 6A, 18-80VAC (with micro-step driver).
- Software tools: Siemens TIA Portal on Windows.
- Language: Ladder Logic Diagram.
- This article's supporting files (Siemens S7-1200) are available on Github.
1. Motion Control - Commissioning test with Siemens TIA Portal
2. Motion Control with Siemens' MC Technology Object
Driving a stepper motor (stepper motor front view): A 4.5NM, 6A Stepper Motor, an 18–80VAC (Volt AC) stepper motor driver at 5.4A 400 micro-steps supplied with 48VAC, and a step-down 220VAC to 48VAC transformer. PLC’s 24VDC PTO %Q0.2 and direction setting %Q0.3 controller outputs are connected to 5VDC PUL and DIR connectors at the stepper motor driver through a 2K Ohm resistor in series.

In our first series of “Towards Industry 4.0” (October 2022 — February 2023), we discussed various things covering some of the technological developments on the journey towards Industry 4.0, the convergence of Information Technology (IT), and Operational Technology (OT).

Those five articles (six, including the summary article) discussed the industrial automation technology driven primarily by Programmable Logic Controller (PLC) along with its surrounding technologies. Field devices such as various sensors and actuators like motors, pneumatic, and hydraulic are examples of that surrounding technologies.

A few working examples were also presented, such as the typical “Hello World” program in PLC, including the mixer, traffic light, and box sorting using conveyor use cases. It covered PLC programming with a ladder logic diagram and SFC (Sequential Function Chart), as well as visualizing PLC data by SCADA (Supervisory Control and Data Acquisition) using Open PLC Simulator software, ScadaBR software, Siemens PLC Simulator software, Siemens TIA (Total Integrated Automation) software, and the actual hardware of Siemens PLC S7–1200.

Motion Control

As industrial motors require high current and voltage, PLC does not directly drive a motor from its standard output. Typically, a PLC drives motors through a motor driver.

Industrial motors can be DC (direct current) or AC (alternating current)-powered and mostly use 3-phases instead of just 1-phase like commonly found in households.

Motor drivers have many names, such as inverter, VFD (Variable Frequency Drive), VSD (Variable Speed Drive), and IGBT (Insulated Gated Bipolar Transistor). In general, they are called drives.

In Siemens PLC, we can drive motors in three ways: digitally with Program Train Output (PTO), Analog, and Profinet. With Siemens PLC S7–1200 1214C DC/DC/DC, we demonstrate driving the stepper motor with PTO.

We are driving a stepper motor through a stepper motor driver. The Stepper motor is a brushless DC motor. Brushless means that there is no brush to the rotor. The mechanical energy is generated by applying electrical energy to the motor stator to move the rotor.

Hardware and Connectivity

A Siemens S7–1200 DC/DC/DC PLC controls an AC-powered stepper motor drive which controls a NEMA Stepper Motor.

Siemens PLC’s S7–1200 %Q0.1, %Q0.2, and %Q0.3 digital outputs. These PLC’s digital outputs are connected to stepper motor driver inputs: ENA, PUL, and DIR.
Driving a stepper motor (micro-step driver view): A 4.5NM, 6A Stepper Motor, an 18–80VAC (Volt AC) stepper motor driver at 5.4A 400 micro-steps supplied with 48VAC, and a step-down 220VAC to 48VAC transformer. PLC’s 24VDC PTO %Q0.2 and direction setting %Q0.3 controller outputs are connected to 5VDC PUL and DIR connectors at the stepper motor driver through a 2K Ohm resistor in series.

The NEMA-34 stepper motor has 4.5NM (Newton Meter) and 6A (Ampere)j with a 1.8-degree step angle configuration. Stepper motor driver is an 18–80VAC (Volt AC ), set at 5.4A (can be selected at 6A max), 400 micro-steps, and supplied with 48VAC from the step-down transformer.

The step-down transformer is a 220VAC to 48VAC transformer with 500VA and 50Hz.

PLC’s 24VDC PTO (Pulse Train Output) %Q0.2 and Direction setting %Q0.3 controller outputs are connected to and driving 5VDC PUL (pulse) and DIR (direction) connectors in stepper motor driver, wired through a 2K Ohm (2 Watts, tolerance: 1%) resistor each, in series (to convert the PLC’s 24VDC pulses to 5VDC pulses as expected by the stepper motor driver). Optionally, the ENA (Enable) input in the stepper motor driver can also be wired, e.g., through %Q0.1 PLC output.

Commissioning Test with Siemens TIA Portal

Without running any program in “Main OB1” (Organization Block 1), we can test the functionalities of the connected stepper motor with the commissioning test function available within the Siemens TIA Portal.

First, we need to configure how the PLC controls the stepper motor through the stepper motor driver by assigning %Q0.2 output as the PTO signal to the PUL input at the stepper motor and %Q0.3 output as the direction signal (Clock Wise — CW or Counter Clock Wise — CCW) to the DIR input at the stepper motor.

We also set the pulse per motor revolution to 400 (this setting must match the stepper motor DIP switch setting). Minimum/maximum velocity is set at 10 and 200 mm/s (millimeter per second), respectively.

Stepper motor configuration in TIA Portal. %Q0.2 is the pulse (PUL), while %Q0.3 controls the direction of the motor (CW or CCW).

Once the configuration is done, we can start the commissioning test, in which we can do various motor movements such as jog, velocity, positioning, and homing. The motor movements can be in either CW or CCW. We stop the motor first before changing direction.

Commissioning Test — Axis’ Velocity Movement at 25 mm/s in a Forward Direction

Here we illustrate PLC’s PTO output to the stepper motor driver’s PUL input. The oscilloscope shows the generated pulses when the axis moves at 25 mm/s in the forward direction.

Commissioning test in TIA Portal. The axis is moving at 25 mm/s in the forward direction.

Vpp (Voltage peak-to-peak) is 24.8VDC with a frequency of 1.00KHz (duty cycle at 50%), while Vavg (Voltage average) is at 12.4VDC.

PLC’s PTO output to Stepper motor driver’s PUL input. The oscilloscope shows the generated pulses when the axis moves at 25 mm/s in the forward direction.

Commissioning Test — Axis’ Velocity Movement at 100 mm/s in a Forward Direction

Here we illustrate PLC’s PTO output to the stepper motor driver’s PUL input. The oscilloscope shows the generated pulses when the axis moves at 100 mm/s in the forward direction.

Commissioning test in TIA Portal. The axis is moving at 100 mm/s in the forward direction.

Vpp (Voltage peak-to-peak) is 24.6VDC with a frequency of 4.00KHz (duty cycle at 50%), while Vavg (Voltage average) is at 12.7VDC.

PLC’s PTO output to Stepper motor driver’s PUL input. The oscilloscope shows the generated pulses when the axis moves at 100 mm/s in the forward direction.

Details on the configuration and commissioning test (jog and velocity movements) are in the recorded video below. Velocity movements are tested at 25mm/s, 100mm/s, and 200mm/s.

Driving a stepper Motor with a PLC — Configuration and commissioning test in TIA Portal (jog and velocity movements).

Motion Control with Siemens Technology Object Function Blocks

In contrast with the commissioning test that can run without any program in “Main OB1” (Organization Block 1), we can write a program in OB1 to control the motor programmatically within the Siemens TIA Portal.

Let’s illustrate this with MC_Power and MC_Velocity — some function blocks available within the motion control’s technology object. MC stands for Motion Control.

We use MC_Power to power the motor ON and MC_Halt to stop the motor. Following that, we can do additional functions such as MC_MoveJog and MC_MoveVelocity.

Powered ON — Idle State

We have five networks with the following states when PLC is first powered ON.

Network 1: Start-Stop

If “Start PB” (Start Push Button) attached to PLC input %I0.1 is pressed, then the “Power Enabled” memory bit at %M2.1 is energized (set). The “Start PB” is latched with the “Power Enabled” memory bit, so when the “Start PB” is released, the “Power Enabled” memory bit keeps the “Power Enabled” memory bit set.

The “Power Enabled” memory bit will be de-energized if the “Stop PB” (Stop Push Button) is pressed. The “Stop PB” is NC (Normally Closed) in the wiring configuration.

Controlling Start and Stop from the push buttons.

Network 2: Motor POWER ON

The Siemens motion control starts with the MC_POWER function block. When MC_POWER is enabled, the rest of the MC function blocks are active.

MC_Power function block.

Network 3: Setting Motor Parameters

First, we set two parameters to run our stepper motor, direction and velocity. The direction can be set clockwise or counterclockwise. The velocity can be set from minimum to maximum as defined in the motor configuration technology object “Stepper_Motor_01”. In this case, our setting for velocity movement is in mm/s (millimeters per second).

Setting the motor parameters.

Network 4: Run the MC_MoveVelocity Function Block

MC_MoveVelocity function block runs the stepper motor by sending PTO signals as defined in the motor configuration technology object.

MV_MoveVelocity function block.

Network 5: Run the MC_Halt Function Block

When “Motor Halt PB” is pressed, the transition signal from 0 to 1 activates this function block, which stops the motor.

MC_Halt function block.

Running — “Start PB” is Pressed

When “Start PB” is pressed, the network runs.

The “Power Enabled” memory bit is set and latched until “Stop PB” is pressed later.

The “Power Enabled” memory bit is set and latched.

MC_POWER is enabled with the “Stepper_Motor_01” motor configuration technology object.

MC_Power enables the MC function blocks.

Motor parameters are set.

Setting motor parameters.

The motor is at a standstill as the “Motor Execute PB” is not yet activated.

MC_MoveVelocity still needs to be activated.
The current state of the MC_Halt function block. It is not activated.

Running — “Motor Execute PB” is Pressed

When “Motor Execute PB” is pressed, the motor runs according to the defined velocity and direction.

Finally, the motor runs (InVelocity = TRUE) as the MC_MoveVelocity function block runs and moves the motor axis according to the “Stepper_Motor_01” motor configuration technology object. In this case, in the forward direction with 50mm/s velocity.

Running — “Motor Halt PB” is Pressed

When “Motor Halt PB” is pressed and released, the signal transition from FALSE to TRUE, causing the motor to stop. The final state for the “Done” memory bit is FALSE.

The transition from FALSE to TRUE at the “Motor Halt PB” activated the MC_Halt function block, causing the “Done” bit to be set (TRUE), then back to FALSE.

--

--

No responses yet