DCC-EX / EX-Turntable

Turntable-EX is a new feature to control a stepper motor based turntable from DCC++ EX
GNU General Public License v3.0
6 stars 5 forks source link

Enable uni-directional rotation #47

Closed peteGSX closed 8 months ago

peteGSX commented 2 years ago

Some stepper and turntable configurations end up being less accurate when turning in one direction vs. the other, or when alternating direction of travel, likely due to sloppiness in the internal stepper setup or the mating between the turntable components and stepper shaft.

We can enable a workaround for this by turning in the specified direction only (clockwise or counter clockwise).

energiebrand commented 1 year ago

Hi Pete, I'm running exactly in that problem. Could that be implemented in the upcoming(?) first official version? Hardy

peteGSX commented 1 year ago

Also from @energiebrand :

I found a workaround by modifying the EX-Turntable SW (comment line 375 - 379 + 381). Now it's turning always CW from lower to higher values and back, no calculation which way is the shortest. Not elegant but working at the moment.

twr140 commented 11 months ago

I modified the moveToPosition function in TurntableFunctions.cpp to allow for a new define in config.h to deal with this:

If

#define SINGLE_ROTATION_DIRECTION

is added to config.h, and the following lines are INSERTED into TurntableFunctions.cpp as lines 177 - 183 inclusive:

#if defined(SINGLE_ROTATION_DIRECTION)
    if (steps > lastStep) {
      moveSteps = steps - lastStep;
    } else {
      moveSteps = fullTurnSteps - lastStep + steps;
    }
#else

And the following line is inserted as a new line 191 in TurntableFunctions.cpp:

#endif

Then the turntable will only operate in the direction defined by the STEPPER_DRIVER in config.h (e.g. ULN2003_HALF_CW will only then turn the motor Clockwise)

Note that I only have a ULN2003/28BYJ-48 stepper to test with though.

It works for both CW and CCW rotation, with both Full ans HALF steps.