Speed Encoder First Draft

not tested code for speed encoder