Controlling a stepper motor with a PLC


Thread Starter

Roman Rusconi

I'm trying to generate the pulses to control a stepper motor with a PLC.

The motor has a driver that converts the pulse/direction signals to the proper A and B phase signals for the motor. I programmed the PLC to give in one output pin a series of pulses to move the motor. The problem is that when the motor moves a step it makes loud noises, like it is shaking roughly. Also, the motor turns a few steps in one direction and then it either misses one or two steps or it turns a couple steps in the opposite direction. I maintained the DIR signal unchanged.

I read about acceleration and deceleration ramps to make the motor run smooth and I initially thought this may be the problem, although this same thing happening even if I send only one pulse every one or two seconds to the driver. So for a one step movement there's no possible accel/decel ramp (right??).

I tested the same stepper motor and driver with a PC controlled system (Using Mach3 software) and it runs smooth and one step movements don't make the noise and shaking I'm getting.

Any help???

Gabriele Corrieri

Hello Roman

a quickly answer: your pulse generator that you've made by software reach too slow frequencies, compared to the LPT port (I assume that you have used LPT port with Mach3 Linux CNC), another some (stupid) tips: the output of your plc have discrete output? Or relay one? I assume that's you have PNP open collector output, you can try to reach (little) more stability and noiseless by put a resistor from output to gnd commond of output, right value could be around 5-10 KOhm, you need that the signal isn't floating when the output transistor is open: the right solution could be a push-pull outputs ...

Could you post the motor driver, and the plc model?

I'm assuming your Pulse and direction input is TTL, but you want to verify this. Make sure your PLC has a transistor output, preferably NPN (sinking) as you can use a 5V pull-up resistor to make it TTL compatible. If it is a PNP type output (sourcing) you will have to make your PNP common 5V and verify with the PLC datasheet that this is acceptable.

IF it is a relay output, forget it, get a new PLC or output module that is transistor based. Relays have bounce and chatter that your step and direction driver will interpret as multiple steps in very fast succession. This could make even one step per second appear as a grumbly thing that looses position.

Do you have an oscilloscope to look at the signals output to the board?


Roman Rusconi


Thanks for the tips!

It seems they point in the right direction.

I tried a smaller pulse, with about 5ms ON time and it works MUCH better now!!

I´ll keep playing around a little bit, although it looks much more promising now.


curt wuollet

No sweat, if you want some real fun try driving one directly and getting it smooth and fast.


Roman Rusconi

I know about the bouncing contacts in a relay.
I´m using a PLC with transistor output and now it´s working neat :)

Thanks for your great help!!!!!