Set the target position. The run() function will try to move the motor (at most one step per call) from the current position to the target position set by the most recent call to this function. Caution: moveTo() also recalculates the speed for the next step. If you are trying to use constant speed movements, you should call setSpeed() after calling moveTo().
moveto
@/moveto
Set the target position. The run() function will try to move the motor (at most one step per call) from the current position to the target position set by the most recent call to this function. Caution: moveTo() also recalculates the speed for the next step. If you are trying to use constant speed movements, you should call setSpeed() after calling moveTo().
DEV@/accelstepper-device
positionnumber
The desired absolute position. Negative is anticlockwise from the 0 position.
Dirboolean
clockwise = TRUE
anticlockwise = False
UPDpulse
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->moveTo(position);
else stepper->moveTo(-position);
emitValue<output_DONE>(ctx, 1);
}