hjd1964 / OnStepX

GNU General Public License v3.0
87 stars 63 forks source link

Step dir servo #18

Closed claudioarena closed 2 years ago

claudioarena commented 2 years ago

The addition of the servo class in OnStepX is deeply appreciated and useful. However, I am now using an external board to control a servo motor, using dir/step command.

I think some other people might want this functionality, to allow flexibility. As such, I've re-added a generic motor controller, that uses DIR STEP commands, and can do mode switching using a single pin.

Of course, care must be taken to consider the slewing and goto micro-steps settings. The original OnStep changed the logic of micro-stepping when slewing if a servo was selected, such that (for servo), you could use a larger microstepping value when slewing (compared to small movements), and obtain larger movements per step.

But I think leaving it as is should be ok...and then care must be taken by the person using this to correctly set microstep values.

hjd1964 commented 2 years ago

I changed this feature so the control line doing the switching is M2 instead of M0.

M2 is a unique pin on all OnStep hardware, even hardware that only supports TMC SPI stepper drivers. In the case of M0 that pin is used for SPI MOSI and is often connected to both Axis1 and Axis2, and sometimes Axis3 and Axis4 also. In the case of M2 that pin is used for SPI CS and is unique for each socket.

This is different than OnStep but worth changing, the modification for existing hardware is minimal and it avoids a whole lot of hassle for users.

hjd1964 commented 2 years ago

While working on this it also occurs to me that GENERIC vs. GENERIC2 aren't really needed. If the user doesn't want mode switching that is specified in Config.h so lets just have GENERIC.

And I added the ability to specify the ON state (HIGH or LOW) for the M2 pin so in this special case if the user wants that signal inverted they can have it.

claudioarena commented 2 years ago

Sounds good to me, thanks! Will try it out