Speed sensor for hydraulic motors