4
\$\begingroup\$

I bought a contraption from aliexpress which included a stepper motor, and I can't figure out how to control it. The documentation is very poor (and chinese) so this is a puzzle question, maybe some of you will have an idea.

The motor has 6 pins, which are shown in this image from the docs (where it is connected to some unknown and ungoogable STM32 board):

motor connected to some STM32 board

The pins, top to bottom in the picture, and right to left in the table google translate to the following:

wire color english STM32 pin
violet Motor line + 3.3V
black Encoder GND GND
blue Encoder B B7
green Encoder A B6
orange Encoder 5V 5V
white Motor line - GND

My guess was that the Motor line + and Motor line - are for the power, and the remaining four are for the control. I connected Motor line + and Motor line - to a 3V source and the motor spins continuosly.

I then tried to connect Encoder GND, 5V, B, A to a microcontroller ground, voltage, and two GPIO pins and change the B & A values to 0 or 1. Nothing happens, the motor still spins continously to the same direction.

I hope that this "encoder A & B" is some kind of standard interface that some of you will know. Otherwise, I would appreciate hints on how to further interrogate the device.

\$\endgroup\$
1

1 Answer 1

6
\$\begingroup\$

Encoder is a sensor that you use to determine position and speed of the motor.

In this case, it's a Quadrature Encoder, which outputs 2 square wave signals form the A & B channels. These two signals has 90 degrees phase difference and it allows you to determine the direction of the rotation.

You connect A & B signals coming from the encoder into the input pins of your uC. If you have supplied signals from your output pins, you may have damaged them.

Most of the times A & B pins are open-drain outputs and need pull-up resistors to work.

BTW, it's not a stepper motor. It's just a permanent magnet brushed DC motor with a quadrature encoder.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you! Obviously a noob question, but how do I control it then? By changing the voltage direction and magnitude to the motor + and motor - pins? Like using L293D motor driver controller? \$\endgroup\$
    – psarka
    May 29, 2021 at 9:51
  • 2
    \$\begingroup\$ Yes, you can just use + & - pins with a H bridge (like L293D). You don't need encoders for open-loop control. If you need to read the encoder, STM32 timers can be configured to count encoder pulses automatically. For other uCs with no encoder reading hardware, you will probably need 1 or 2 external interrupt pins and some logic in software to determine the direction. \$\endgroup\$
    – Tagli
    May 29, 2021 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.