Original logic mixed up parameters and calibrated for 20000 ticks per second rather than 50.
Passes the test program INSTRUCTION-B.