Single GPIO/PWM controlled Stepper Motor? - Page 1
Forum section: electronics / general

author: leestrong
author_rank: Newbie
timestamp: June 28, 2021, 08:41:36 am
content: Typical stepper motor driver takes 4 gpios to control, which I feel is a waste of precious ports. Are there any drivers that require only 1 port, perhaps via PWM like a servo motor?

author: tom66
author_rank: Super Contributor
timestamp: June 28, 2021, 08:55:54 am
content: There are I2C based motor controllers, like DRV8847S, which can implement basic stepper motor controls.Only two GPIOs required and you can address multiple ones by using the nFAULT lines of the devices so one additional IO required per stepper controller.

author: Ian.M
author_rank: Super Contributor
timestamp: June 28, 2021, 08:58:57 am
content: How do you plan to encode step and direction on a single pin without introducing an often unacceptable lag between issuing a step command and decoding its direction so it can be actioned, and without making it excessively sensitive to glitches and noise? GPIO interface stepper controllers use two pins for step and direction for a reason, and often use a third pin to signal status back to the MCU.If you don't care (much) about latency, as Tom noted, there are I2C interface smart stepper drivers available. Consider NXP's PCA9629which allow you to drive up to 16 motors from only two I/O pins on your MCU, which can still be used for other I2C devices.

author: Bradlez
author_rank: Contributor
timestamp: June 29, 2021, 02:09:35 pm
content: Well if you're considering price, you could use the DAC of your microcontroller to connect to the ADC of a second 8 pin microcontroller where the second drives the stepper via some transistors. This is because you'd have 3 states: clockwise, stop, anticlockwise, which you can assign to Vcc, Vcc/2, GND respectively. If you only need to rotate one way, then it's even easier and just use a normal digital output.If you don't want to use a microcontroller and only go one way, you can probably use a decoded counter IC like the 4022 or 4017 with the fifth output connected to the reset pin so it will only ever count through the first 4 outputs. The digital output of the microcontroller will go to the enable pin and the outputs of the counter IC will drive the stepper via transistors. If you want to go both ways, I don't think there is an IC with a counter, decoder, and bidirectionality all in one so you would need to convert the analog output from your microcontroller into two digital lines through some weird circuit design, pass that into your bidirectional binary counter, connect the output to a binary decoder, to the stepper motor via transistors and voila, you have the definition of unnecessary.And lastly, if you care about variable speed, I'm sure some 1 wire asynchronous transmission solution exists you can communicate to your second microcontroller (like Maxim's "1-wire"). If you're good at assembly, you can bit bang at a given transmission rate and make the second micro sync up with it based on the first pulse. Transmissions shouldn't be too long however as they will go out of sync. You can even make it two way by adding circuitry so both sides will only be pulling the line low to prevent a short circuit (like I2C but asynchronous). Add CRC verification in the transmission to make sure there is no miscommunication and the second micro can signal if the transmission has to be sent again. As this is done through software, both micros must have interrupts for other things off and they will be busy waiting focused on performing the transmission before they can run other code.Or if you're really into analog, add to what I said in the second paragraph but make the source oscillator of the stepper motor a VCO with your analog output from your microcontroller basically be mathematically |out - Vref/2| * 2 into the VCO but done through analog circuitry. There will probably be linearity issues.If you have to use PWM instead of analog output, well I hope you like 4th order sallen key low pass filters. Because the other solution is not pretty (I think it involves PLLs).

author: Siwastaja
author_rank: Super Contributor
timestamp: June 29, 2021, 05:37:50 pm
content: Likely you need to roll your own 1-wire stepper controller, I think it's unlikely anything exist off-the-shelf because this isn't a very common use case. Any small MCU would do the trick of acting as a bridge to a driver IC, or a complete driver, and you'd have the luxury of defining your own 1-wire protocol as you'd like (contrary to previous suggestion, I'd go digital; UART would be obvious!), but this is alotof work and flashing the separate microcontroller is pain in the ass.I'd look at all the possibilities to change the main microcontroller to a larger one so you can afford the pins required for the stepper.

author: langwadt
author_rank: Super Contributor
timestamp: June 29, 2021, 05:56:28 pm
content: Quote from: Ian.M on June 28, 2021, 08:58:57 amsteppers are quite slow, GRBL on an AVR tops out at about 30kHz steprate, you could do step/direction serially at that speedsome TMC stepper drivers can run the internal motion controller with a single pin uart

author: leestrong
author_rank: Newbie
timestamp: June 30, 2021, 08:42:22 am
content: Thank you guys, really appreciate your ideas. I think I am going with I2C based drivers, it essentially costs no pins since I am already using I2C. Decade counter and UART drivers are also great for if the MCU doesn't support I2C.

author: ajb
author_rank: Super Contributor
timestamp: July 01, 2021, 04:56:19 pm
content: Trinamic have some stepper drivers with built-in motion control that can be controlled via SPI or UART. Through either interface you can configure acceleration, current curves, etc, and also tell the driver to move to a given position and it will do the required accel/decel automatically, or you can tell it to accelerate to a certain velocity. There are both integrated drivers as well as motion controllers that can control external drivers. Here's one example:https://www.trinamic.com/products/integrated-circuits/details/tmc5031-la/

author: Doctorandus_P
author_rank: Super Contributor
timestamp: July 03, 2021, 03:23:44 pm
content: Stepper motors usually run on more voltage and current then a uC can deliver, so you will need some kind of interface.Most stepper motor controllers take step and direction inputs from a uC, and if your motor only has to turn in one direction, then you can get away with tying the direction signal to either GND or Vcc.Apart from that, uC pins are cheap. Jumping though hoops to control 1000 gadgets at once with your 8 pin microcontroller is pretty silly.