I would like to measure the speed of a DC motor using a phototransistor and get as an output a voltage which varies linearly with frequency.

The motor speed can vary from 0 to say 3000 RPM. Using the phototransistor I can easily get a signal whose frequency varies from 0 (DC) to 50 Hz. I would like to convert this signal to a voltage which varies from 0 (or close to zero) to 5 V linearly with the speed of the motor (and therefore with the frequency of the signal obtained from the phototransistor).

I know that a simple solution would be to use a microcontroller to calculate the period of the signal from the phototransistor and then output the corresponding PWM voltage, but I'd like to keep things analog and not use a microcontroller, if possible. What circuit can I use to achieve this?

  • 2
    \$\begingroup\$ low pass filter it \$\endgroup\$
    – PlasmaHH
    Commented Sep 10, 2018 at 10:32
  • \$\begingroup\$ That's what I had in the back of my mind, could you suggest a circuit for this purpose? Can I use a basic RC network? \$\endgroup\$
    – mickkk
    Commented Sep 10, 2018 at 10:44
  • 1
    \$\begingroup\$ Its called a frequency to voltage converter circuit. I believe there is also dedicated ICs for it. There is a lot of examples on google that should get you started \$\endgroup\$
    – Linkyyy
    Commented Sep 10, 2018 at 11:04
  • 1
    \$\begingroup\$ @PlasmaHH that would certainly work, but it might pay to one-shot first, so that the relationship between duty cycle and frequency is more linear. \$\endgroup\$ Commented Sep 10, 2018 at 13:45
  • \$\begingroup\$ You can take a one-shot, switch a reference voltage with it (or just power a CMOS one-shot from the reference), then low-pass filter, but you need to think about how slow the response can be and how much ripple you can tolerate. Think about something like a 10ms pulse. At 5% full scale (2.5Hz) you'll have a lot of ripple or a rather slow response, or both. Maybe you can get 10 pulses per revolution rather than 1. \$\endgroup\$ Commented Sep 10, 2018 at 14:37

2 Answers 2


I made a circuit for this (different application).

Use a 555 in a one-shot configuration, circuit diagrams abound for this on the net.

Make the output pulse "relatively" short, that is short for your expected input frequency. For example, if you expect 100Hz input then your output pulse MUST be shorter than 10ms because, if triggered 100 times per second the output would be ON all the time. If too short, you lose sensitivity to frequency change. Figure out your maximum frequency and make your pulse width shorter than 1/maxfrequency.

Connect your optical circuit to trigger your 555 pulse. Every time you get an optical pulse, the 555 will generate a shaped output of fixed duration.

Couple the output of that pulse to a "smoother" (a low pass filter).

To build the LP, put a resistor in series with your pulse lead. Beyond the resistor, tie a capacitor between it and ground.

The sizing of both the capacitor and resistor are governed by several factors:

1) The 555 output current limit. Just use a 1K or larger resistor.

2) Response. The filtered DC output voltage of this will always track the frequency meaning that the motor frequency will change but the DC voltage will lag. The response is determined by multiplying R*C. Bigger is slower but also smoother.

3) #2 above should be designed by the input frequency, the higher the input frequency, the smaller The R*C. Don't worry too much about this, just build it and play with the values until you get what you like. Good starting values might be 10K resistor and 100uF capacitor.

BTW, I tested this circuit with expensive equipment (equiv to $1000ish equipment in today's dollars) and it was within about 5% linear and accurate. The trick is the shaped output pulse.


There are several chips designed as precision frequency to voltage converters. The LMx31x series are an old design but if they worked then they'll work now.

Check the datasheet. It will run on a 5 V supply but scanning through it I can't see whether the output voltage can reach 5 V full scale.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.