added speed encoder reading code