I'm using the FlexyStepper library.Unfortunately there's no way to write an issue to the author so I'm going to ask my question here.

The documentation says about the setCurrentPosition*() functions:

set current position of the motor in millimeter, this does not move the motor

But I see a different behavior. Looking at the code, it seems it just update the current position, leaving unchanged the target position. This leads to an expected movement of the motor. Example:

  1. set the target position to, say: 1000
  2. the motor reach that position
  3. set the current position to, say: 1500
  4. now the motor come back to 1000

Instead, I want the current position from now is 1500, but because it has already reached the target, it shouldn't move further.

Of course a workaround is to set both current position and target to the same value.

I wonder if I'm wrong about the documentation or this might be considered a bug.


The point of setCurrentPosition() is to calibrate the stepper. It would normally be used in association with a limit switch of some form.

If you set the motor to go to 1000 and then tell it that the motor is actually at 1500 then of course it will then try and go back to 1000 - you have told it that is where you want it, but you also told it that's not where it is.

The normal usage would be:

  1. Step the motor constantly in one direction until it hits a limit switch or similar
  2. Set the current position to whatever that actual position is
  3. Start going to actual positions that are relative to that reference point.

For example

  • Move the motor anti-clockwise
  • Motor triggers limit switch
  • Stop moving the motor
  • Set the current position to 0
  • Start using the motor normally
  • Thanks, but not all projects use motors in such a "normal" way. I need, sometimes, to set a different current position rather than the actual one. I've ended to set both target and current positions. It seems to work. The misleading sentence here is "does not move the motor" until a target was defined before. – Mark Jan 15 '20 at 7:44
  • What exactly are you trying to achieve by changing what the system thinks the position is all the time? – Majenko Jan 15 '20 at 10:30
  • where did you read all the time? I said sometimes :-) I want to achieve exactly what it literally means: I need the system changes the references on-the-fly. It's a set up for theatrical effects that moves balloons and other stuff. There are no homing switchs, etc... – Mark Jan 15 '20 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.