I have a linear encoder on a shaft that is driven by a stepper using the AccelStepperEncoder library. The goal is that when the motor is off you can manually push and pull the shaft to program the move sequences then run and repeat the sequence.
I have tried evaluating the increment/decrement using the following code however noticed that the encoder can jitter a little.
The hope is to be able to set the moves into memory at the peak of each move to im wondering if doing some kind of compare of the last 4 readings and selecting the highest of lowest would be a better idea.
unless anyone has any better ideas as to how to deal with this.
if(cmd == 4){
int encmove = stepper1.readEnc();
int lastmove;
int encdir;
if(lastmove < stepper1.readEnc()){
encdir = 1;
lastmove = stepper1.readEnc();
}
if(lastmove > stepper1.readEnc()){
encdir = 0;
lastmove = stepper1.readEnc();
}
}