Saving stepper current position as a constant

Hi guys,

I have a problem with my accelstepper library. Is it possible, when I call the currentPosition, to save the number of steps, as a constant? I need this to use it as backslash for the motor.

Thanks

Serial.print("Backslash: ");
      Serial.print (stepper2.currentPosition());

Kasty: Hi guys,

I have a problem with my accelstepper library. Is it possible, when I call the currentPosition, to save the number of steps, as a constant? I need this to use it as backslash for the motor.

Thanks

Serial.print("Backslash: ");
      Serial.print (stepper2.currentPosition());

It cannot be saved as a 'constant'. The value of a 'constant' is set at compile-time and can't be changed at runtime. It can be saved in a 'variable':-

long currentPosition = stepper2.currentPosition();

Made store it in EEPROM.

Invest in a backslash nut.

LarryD: Made store it in EEPROM. Invest in a backslash nut.

I thought he was just confusing 'constant' with 'variable'. If a 'constant' is really needed, to persist between power-ups, you're right - EEPROM. (No idea what a "backslash" is, in terms of motors.)

(No idea what a “backslash” is, in terms of motors.)

This usually refers to the lead screw and its traveler going from forward to reverse.

.

Backlash nut: |500x342

.

LarryD: This usually refers to the lead screw and its traveler going from forward to reverse.

That's "backlash". I'm familiar with that, but the usage of the word "back*s*lash, plus the context, had me wondering.

... need this to use it as backslash for the motor

perhaps should have been "need to use this for backlash compensation." or similar.

Just saw your pic - I've used that exact method myself. I just didn't connect it with the name "back~~s~~lash nut".

backslash OOPS :(

I have a Python program sending data to an Arduino to control a small lathe. I measured the number of steps needed to take up the backlash on each axis and I have used them as constants in the Python program. It seems to work very well. When there is a change of direction the extra steps are added to the required move.

...R

Robin2: I have a Python program sending data to an Arduino to control a small lathe. I measured the number of steps needed to take up the backlash on each axis and I have used them as constants in the Python program. It seems to work very well. When there is a change of direction the extra steps are added to the required move. ...R

That's a better option - hard-coding the values as constants, once you've worked out the exact amount of free-play during testing.

If that's what Kasty is planning, he only needs a 'variable' for current position and then fixed constants to hold the amount of play. In that case, my first reply is still valid. ;)