I'd like to add a structure to manage stepper motors as seen in the 28bjy-48 sample.
There are a couple of trade-offs to be made between ease of use and flexibility though, so I'd like to get some feedback before moving forward. Different stepper motors have different stator configurations; different number of electromagnets, different alignments etc. This leads to a different number of pins needed and different sequence profiles.
Even for a single motor, different sequences can be used. For example, with the motor used in the sample, you can choose between powering one em (electromagnet) at a time (1, 2, 3, 4), or stair stepping across them (1, 1/2, 2, 2/3, 3, 3/4, 4, 4/1) for a slightly slower but more precise step. Or you can power two adjacent ems at a time for more torque (1/2, 2/3, 3/4, 4/1).
My inclination is to recommend building a Stepper that is configured with a factory (NewStepper) which accepts a slice of gpio pins and the step sequence to use (a slice of slices). This struct would implement all step-motor functionality.
Specific factories could then be developed for the most likely usage of a given stepper motor model. e.g. New28bjy48Stepper could accept 4 ints representing gpio pins and return a Stepper configured to use the more precise 8 step sequence.
I will take a crack at building this out as described, but I wanted to make sure first that the trade-offs involved were understood.
I'd like to add a structure to manage stepper motors as seen in the 28bjy-48 sample.
There are a couple of trade-offs to be made between ease of use and flexibility though, so I'd like to get some feedback before moving forward. Different stepper motors have different stator configurations; different number of electromagnets, different alignments etc. This leads to a different number of pins needed and different sequence profiles.
Even for a single motor, different sequences can be used. For example, with the motor used in the sample, you can choose between powering one em (electromagnet) at a time (1, 2, 3, 4), or stair stepping across them (1, 1/2, 2, 2/3, 3, 3/4, 4, 4/1) for a slightly slower but more precise step. Or you can power two adjacent ems at a time for more torque (1/2, 2/3, 3/4, 4/1).
My inclination is to recommend building a
Stepper
that is configured with a factory (NewStepper
) which accepts a slice of gpio pins and the step sequence to use (a slice of slices). This struct would implement all step-motor functionality.Specific factories could then be developed for the most likely usage of a given stepper motor model. e.g.
New28bjy48Stepper
could accept 4 ints representing gpio pins and return aStepper
configured to use the more precise 8 step sequence.I will take a crack at building this out as described, but I wanted to make sure first that the trade-offs involved were understood.