runtonewposition

ivanmason/accelstepper/runtonewposition

Moves the motor (with acceleration/deceleration) to the new target position and blocks until it is at position. Dont use this in event loops, since it blocks.
runtonewposition
@/runtonewposition
Moves the motor (with acceleration/deceleration) to the new target position and blocks until it is at position. Dont use this in event loops, since it blocks.
DEV@/accelstepper-device
Positionnumber
The new target position.
DIRboolean
clockwise = TRUE anticlockwise = False
UPDpulse
runtonewposition
DEV
Position
DIR
UPD
DONE
DONEpulse
To use the node in your project you should have the ivanmason/accelstepper library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
   if (!isInputDirty<input_UPD>(ctx))
        return;

    auto stepper = getValue<input_DEV>(ctx);
    long position = getValue<input_Position>(ctx);
    if(getValue<input_Dir>(ctx))
        stepper->runToNewPosition(position);
    else stepper->runToNewPosition(-position);

    emitValue<output_DONE>(ctx, 1);
}