Tachometer for downhole drilling motor