Detection, control or error compensation of scanning velocity or position