help interfacing an external quadrature encoder/counter chip - Avago HTCL-2022

todo:

check speed and repeatability
add index functionality
double check the inputs aren't inverted either in code or circuit and causing any errors
produce a stable clock pulse from the Mega, so extra Nano is not needed

working circuit: