DC motor with 3(or more) programmed limits

I forget to tell You, that the incremental encoder was NPN type.

I try with some new founded logics and its working with encoder.h library only.

A