Path: EDN Asia >> Design Ideas >> Test & Measurement >> Low-cost way to measure motor speed
Test & Measurement Share print

Low-cost way to measure motor speed

29 Apr 2016  | R Garcia

Share this page with your friends

This design idea employs a microcontroller, a 16x2-key LCD, and a rotary encoder to measure and visualise the speed of a motor (figure). You measure the rotor speed of the motor using an incremental encoder coupled to the motor shaft, which provides quadrature pulses with a frequency proportional to the rotor speed. The 1024-pulse rotary encoder is the RS-32-0/1024ER.11KB from Hengstler. You can calculate the rotational speed of the motor, ωR, by counting the number of revolutions that the encoder axis, nV, makes during a certain time period, tP. You calculate nV by counting the number of pulses, nP, that the encoder generates during this fixed period, tP: nV=nP/1024 for this encoder. And the rotational speed is

where δ=60/(tP×1024) rpm represents the resolution of the measured speed. To obtain a resolution of 1 rpm for this application, the fixed period you use as a timebase is 60/1024=58.59 msec. In this Design Idea, a low-cost microcontroller, the PIC16F873, IC1, from Microchip performs these operations. This microcontroller also drives the LCD, IC2, which shows the rotational speed in rotations per minute.

Figure: This circuit for measuring a motor's speed includes a PIC microcontroller and an LCD. It also provides an analogue-to-digital conversion without an ADC.

In a similar fashion to the circuit in Reference 1, you apply the quadrature pulses of the encoder to IC1's RB0/INT input, which generates a high-priority interrupt at the rising edge of the pulse. These interruptions allow you to compute nP by increasing a counter, which initializes after it reaches fixed period tP. Moreover, the microcontroller's internal 8bit timer, Timer 0, registers tP, which generates a tM (timer interruption) each 286µsec for a clock frequency, fCLK, of 14.3MHz: tM=4×28/fCLK/4=286µsec. This calculation means that fixing the timebase, tP, requires 205 timer interruptions (tP/tM). When the counter reaches this time, the count, nP, determines the rotational speed, according to the equation. Finally, this value appears on the screen of the LCD.

In addition, a digital-to-analogue conversion is necessary if the control system must measure the rotational speed. You can do this conversion without adding an expensive DAC by applying a PWM (pulse-width-modulation) output of the microcontroller to a lowpass filter comprising R2, R3, C4, C6, and IC3. The frequency of the PWM signal is 20kHz, and the cut-off frequency of the lowpass filter is 160Hz, which is much lower than the PWM frequency. In this design, the maximum duty cycle of the PWM signal corresponds to a rotational speed of 1500 rpm.

You can download the source code for IC1's program and assemble the software with MPLab from Microchip. You can alter constants within the software according to the encoder you use and your required resolution from the equation.

Jain, Abhishek, "Versatile digital speedometer uses few components,"EDN, May 12, 2005, pg 95.

About the author
R Garcia contributed this article.

This article is a Design Idea selected for re-publication by the editors. It was first published on November 22, 2007 in

Want to more of this to be delivered to you for FREE?

Subscribe to EDN Asia alerts and receive the latest design ideas and product news in your inbox.

Got to make sure you're not a robot. Please enter the code displayed on the right.

Time to activate your subscription - it's easy!

We have sent an activate request to your registerd e-email. Simply click on the link to activate your subscription.

We're doing this to protect your privacy and ensure you successfully receive your e-mail alerts.

Add New Comment
Visitor (To avoid code verification, simply login or register with us. It is fast and free!)
*Verify code:
Tech Impact

Regional Roundup
Control this smart glass with the blink of an eye
K-Glass 2 detects users' eye movements to point the cursor to recognise computer icons or objects in the Internet, and uses winks for commands. The researchers call this interface the "i-Mouse."

GlobalFoundries extends grants to Singapore students
ARM, Tencent Games team up to improve mobile gaming

News | Products | Design Features | Regional Roundup | Tech Impact