General > General Technical Chat
Single GPIO/PWM controlled Stepper Motor?
leestrong:
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?
tom66:
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.
Ian.M:
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 PCA9629 [Mouser] which 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.
Bradlez:
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 ;D.
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).
Siwastaja:
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 a lot of 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.
Navigation
[0] Message Index
[#] Next page
Go to full version