mattjlewis / diozero

Java Device I/O library that is portable across Single Board Computers and microcontrollers. Tested with Raspberry Pi, Odroid C2, BeagleBone Black, Next Thing CHIP, Asus Tinker Board and Arduinos / Pico. Supports GPIO, I2C, SPI as well as Serial communication. Also known to work with Udoo Quad.
https://www.diozero.com
MIT License
261 stars 59 forks source link

Enhancement: Adding stepper motors to devices #125

Closed EAGrahamJr closed 1 year ago

EAGrahamJr commented 1 year ago

Stepper motors would be a good enhancement for the set of available devices.

The defined interface would probably contain concepts and functions for:

I think this would allow for most use cases.

(This has personal historical reasons :grin: ). There many other implementations for references and the above covers most actions in an OO way.

Preliminary thoughts are at https://github.com/EAGrahamJr/diozero/tree/add-stepper

mattjlewis commented 1 year ago

Definitely. Someone has previously contributed a draft class for a "Watterott SilentStepStick", however, I've not been able to test. Have just committed into the com.diozero.devices.sandpit package in diozero-core. I've held off to date as these are slightly more expensive devices.

EAGrahamJr commented 1 year ago

Interesting - that implementation seems to drive in a single direction until disabled, which I guess makes sense in a 3D-printer, but doesn't seem "right" to me. I'm basing my implementations more on the current state of various drivers for things like the ubiquitous 28BYJ-48.

EAGrahamJr commented 1 year ago

I wouldn't hold up 1.3.5 for this - it's going to take a bit and I have a new I2C board coming next week that I'll want to add to the mix.

mattjlewis commented 1 year ago

Agreed. I've ordered a couple of those 28BYJ-48 stepper motors. 1.3.5 seems good to go, as mentioned in another issue I'm just doing the last few changes to documentation.

EAGrahamJr commented 1 year ago

Yikes - I'm not sure what stepper "flavor" I've got - they apparently come with two different gear-boxes (16:1 or 64:1), with some that aren't quite exactly either. I'm pretty sure I've got the 64:1 one - I need to set up some protractors and a more accurate "dial indicator" than my LEGO pieces :grinning:

EAGrahamJr commented 1 year ago

TIL - steppers is complex:

It appears there's two distinct driver types:

Then there's the different motor types. The 28BYJ-48 is a unipolar 5-wire type.

But... I've got a different "pin-direct" driver (I2C) arriving soonish, along with a bi-polor motor, and I went ahead and popped for a TMC2225 (one type of SSS) while I was at it.

mattjlewis commented 1 year ago

I’m still tidying up some internal refactoring, basically simplifying the way boards are automatically detected and making it easy to add support for new boards (have an OrangePi 5 on the way which should be interesting). My 28BYJ-48 stepper motors have arrived, not had a chance to look into them yet. Any progress on your side? The next version will be 1.4.0 as I plan to do some further refactoring but shouldn’t affect any APIs - would be great to include some of this.