Control or error compensation of scanning position or velocity