Rotary incremental encoder

Hello guys,
I’m using an incremental rotary encoder HN38-06-N you can find it’s datasheet here (http://www.ekt2.com/pdf/96_ROTARY_ENCODER_HN38-06-N.pdf) it’s 400 ppr etc…
So I’m using this encoder to control 3 servo motors depending on the encoder’s angular position.
The encoder is attached to a shaft which is constantly rotating.
I’m using the arduino UNO ATMEGA328p.
In my code the number of pulses are transformed from 400 to 360 by mutilpying by a factor of 0.9, which gives me 360 degrees per rotation of shaft.
I noticed a a problem where the zero-position of the shaft is being shifted to another zero-position(the zero position of the shaft is unstable). What I’m guessing is that the encoder is too fast for the ATmega328p and that I might be missing some rising edges. What if I Use an arduino mega with ATmega2560 which has a bigger and faster processor. Will that do the trick?
You can find the code attached to this topic.
Thank you for taking your time to read my topic.
God bless

FSD13QBIM3QGLHR.ino (1.66 KB)

Sorry, the data sheet you linked to shows an encoder with NO zero position.

Paul

Yes I have mentioned that i'm using an incremental encoder which doesn't have a zero position. I will be using another home positioning sensor which will be a hall effect sensor to calibrate my zero position.

Seroujig:
Yes I have mentioned that i'm using an incremental encoder which doesn't have a zero position. I will be using another home positioning sensor which will be a hall effect sensor to calibrate my zero position.

A quote from wikipedia "A Hall effect sensor is a device that is used to measure the magnitude of a magnetic field. Its output voltage is directly proportional to the magnetic field strength through it. Hall effect sensors are used for proximity sensing, positioning, speed detection, and current sensing applications.

My question is: over how many steps of the encoder, can you still get signal from the Hall sensor?

Paul

Are you missing steps or are you getting extra steps? Is it consistently one way or the other?