PLEASE HELP! Rotary encoder absolute position

Hi! I have a problem reading the absolute position of my encoder. Im using the HEDS 5500.
It worked before perfectly but I had to replace my arduino and the code got lost, now I can't manage to figure out how to get it to work again and after searching the whole night I still didn't find any usable code online. All what I found where for incremental readings.

The encoder does 1024 pulses per revolution and I simply want that it starts again to count from 1 when it completed a full turn (counter reached 1024) and other way around to go up to 1024 when the counter reaches 1.

I tried a lot with if conditions but these seem not to work for encoders.
I would be very thankful for any kind of help!

How do you know which pulse is pulse 1?

After that it's a simple matter of counting.

The HEDS5500 is an incremental encoder, not absolute. The HEDS5540 has an extra index channel that allows you to reset the count at a defined axial orientation.

Datasheet

wernj91:
It worked before perfectly...

That's interesting. Did the encoder actually give the absolute position? How did that happen, when power went on on the Arduino?

You need HEDS 5540 or 5640 for ABZ encoding - this is still not absolute, you have to spin till you find the
index pulse on the Z channel and then you are zeroed and ready.