# A Simple Frequency-to-Voltage Converter

Quote of the Day

We are what we repeatedly do. Excellence, then, is not an act, but a habit.

— Aristotle

## Introduction

Figure 1: Explanation for Why I Need a Voltage-to-Frequency Converter.

I often build small electronics projects for use around my home. I recently put together a small sensor interface that generates an output sine wave with a frequency proportional to the sensor's inductance.  At my receiver, I want to convert that frequency to a voltage that is proportional to the sensor's inductance. I want to send out a text message when the value of the sensor's inductance passes through a threshold level – I am detecting the presence of a car (Figure 1).

Since this is a home project, I want to keep it simple and cheap. This blog post documents how I designed this circuit.

## Background

The circuit I used is very slight variation on a charge pump circuit I saw years ago in the great little book called "Electronic Designer's Handbook" by Thomas Hemingway (Figure 13.5). This little gem can be viewed online here. The only change I made to this circuit was to shift the voltage levels so that my input signal can be positive.

I will derive an expression for the input frequency-to-output voltage transfer function that is a bit more accurate than what Hemingway derives. However, this is his circuit and his book is still worth reading for those interested in transistor-level design. As you can see, this book was first published in 1966 and I still use it nearly fifty years later.

## Analysis

I will focus on my simulation results in this blog post section. Appendix A contains measured data from a working circuit in the field.

### Schematic

Figure 2 shows an LTSpice schematic of the circuit I put together.

Figure 2: Simple Frequency-to-Voltage Converter.

### Theory of Operation

#### Qualitative Description

The circuit operation is fairly straightforward.

• When the input signal goes low, C1 charges through D1. It is critical that C1 charge quickly relative to the period. This circuit depends on the transfer a fixed quantity of charge at the same rate as the input signal. This means that the charge transfer rate (i.e. current) is directly proportional to the input frequency.
• When the input signal goes high, C1 discharges through Q1 into C2. C2 will have enough capacitance to ensure that it changes little when C1 discharges into it. This will provide the filtering we need to for a smooth output voltage.
• The RC filter composed of R1 and C2. R is critical in determining the gain (i.e. slope) of the output voltage versus frequency curve. At equilibrium, the charge lost through R1 for each input cycle exactly equals the charge on C1.

I included my simulation results below that clearly shows each of these operations occurring.

If you seek a more detailed narrative description of how this circuit work, see the discussion comments below.  A reader put together an excellent theory of operation on the circuit.

#### Mathematical Details

Figure 3 shows my derivation of a formula for the frequency-to-voltage conversion process.

Figure 3: Derivation of Frequency-to-Voltage Conversion.

### Simulation Results

#### Single Simulation Result

Figure 4 shows my simulation results. To see these results clearly, you need to click on the image. The circuit operates exactly as described above.

Figure 4: Simulation Results.

#### Linearity Measurements

Figure 5 shows the linearity that I measured on the simulator. I predicted the slope of my voltage conversion to be 1.08 in Figure 2. My simulation shows 1.095, which means an error of ~1.4%. Not too bad.

Figure 5: Plot of the Linearity of the Frequency-to-Voltage Conversion.

## Conclusion

This circuit is a critical part of a small home sensor system that I have put together. Here is a quick description of my sensor system.

• I built a metal sensor that is composed of a coil of wire (i.e. inductor) whose inductance decreases when a metal object comes near -- the inductance decreases because of how currents are induced in the metal object.
• I built an oscillator which puts out a digital signal with a frequency that is proportional to the inductance of my wire coil.
• The circuit described here converts the digital signal's frequency to a voltage level.
• I use a Schmitt trigger to generate an alarm when the voltage from my frequency-to-voltage converter exceeds a value that I have set.

## Appendix A: Some Empirical Data from a Circuit I Built

Figure 6 shows 3 data points from a version of this circuit that I am using for a home project. This particular application had C1 = 0.001 µF and R1 = 4 kΩ. You can see that the response is quite linear, the measured and predicted slopes were within experimental error, and it is working well in my application.

Figure 6: Three Data Points from a Quick Lab Test I Did.

Save

Save

Save

Save

This entry was posted in Electronics. Bookmark the permalink.

### 28 Responses to A Simple Frequency-to-Voltage Converter

1. xxx says:

I don't really understand why you are doing -VD1-VBE1 in figure 2, those voltages are in a closed loop.

• mathscinotes says:

This is not a closed-loop feedback system. While there is a transistor in the circuit, it is really used as a current switch. This circuit is really a form of diode switching network, so the voltage drops (diode and base-emitter junction) must be accounted for.

mathscinotes

• xxx says:

Thanks for replying, I ended up understanding that part, here is a more detailed explanation (just in case someone is looking for one):

When V2 is low C1 will charge through D1. Assuming that V2 remains low for a longer time than what it takes C1 to fully charge, then the final voltage drop across C1 will be of V1-0.7V (due to the diode biasing), after that the diode stops conducting and we have to "wait" for V2 to go high. During this time Q2 is not conducting since Vb = V1 > Ve = V1 - 0.7 V.

When V2 goes high then Vb is still V1, but Ve is now Ve = V1 - 0.7 V + V2 (but V1 and V2 are equal (12 V) when V2 is high). So now we have: (Ve)initial=2 V1 - 0.7 V > Vb= V1. So Q2 will conduct and C1 will begin to discharge through R1 while charging C2. Assuming that Q2 is saturated then Vce is approximately 0 V (not really). So Q2 will conduct until Ve-Vb reaches the forward biasing requirement of the transistor, which I assume is 0.7 V. So we have: (Ve - Vb)final = V1 + Vc1 - Vb = Vc1= 0.7 V .
Since (Vc1)initial = V1 - 0.7 V, and (Vc1)final = 0.7 V then the total charge that must go through the output is (V1 - 1.4 V)*C1. But initially C2 and R1 behave as a short circuit, so the whole charge is quickly stored in C2. If all that charge went to C2 then it would translate in (V1 - 1.4 V)*C1/C2 = 0.1 V. Since the time constant of R1, C2 is 1 second and the input period is smaller then the output voltage will being to increase in time and we have to wait.

To see why the charge stored in C1 will quickly be transferred to C2, even as the voltage increases consider the following:

Once the transistor opens almost 12 V (V2 + Vc1) must fall through C2 and R1, but initially the voltage across C2 and R1 is less than that (at least for this range of frequencies). The only way to satisfy that is if C2 is suddenly charged to 12 V, but that won't happen since the transistor will close first, remember from before that the maximum change in voltage that each pulse can make in C2 is 0.1 V.

That explains why the opening and closing of the transistor must be fast (like a shortcircuit). But to understand why almost the whole charge will also be stored in C2 and not lost through R1 you have to take into account the values of them:

let's say the charge in C2 increases by q during a time t, then the necessary charge q1 through R1 needed for that will be:

R1 * q1 / t = q / C2

From before we know t will be very short, and C2*R1 = 1 s which is much higher than time t. So q1 has to be very small compared with q.

Finally equilibrium will be reached once the voltage given to C2 is such that the same voltage will be lost during the time the transistor is off (which is almost T, remember that the charging is very fast, as soon as V2 goes high). That means:

[ (V1 - 1.4 V)*C1/C2 ] = Vout*(T/(R1*C2))

where Vout is the equilibrium voltage through C2 (and R1), and T/(R1*C2) is the off time relative to the discharge time (the real solution is proportional to exp(-t/(R1*C2)) and this is what you get after expanding in series around t=0).

C2 cancels because the voltage through it goes up as C2 goes down, but as C2 goes down the discharge time constant goes down.

• mathscinotes says:

Excellent description.

mathscinotes

• Charles Reyes says:

How did you come up with the valeus of c1, c2 and r1? could you pls show me the formulas you use. thank you in advance.

• mathscinotes says:

Hi Charles,

I will include a modified version of my post here that will focus more on the tradeoffs associated with component selection.

• Charles Reyes says:

Thank You very much for this. I will be using your circuit in order to sense a capacitance in the range of femto F. This would really help me a lot.

2. Ishtiaq says:

Thanks dear... it was really helpful.

3. Antiath says:

I just ordered som ICs to perform just that but I was still seaching for a more simple solution with discrete components. So thanks for this elegant solution.
In my testing, I used a 555 timer to get the frequency ( 1-3 kHz at 5V) and hooked it to your circuit. I immediatly noticed a linearity issue when changing the frequency. A change by a factor 3 in frequency only resulted in a drop of 1 V. I tuned the circuit to ouput approx. 5V at max so I should have obtained less than 2V after the change. I solved that by putting a 1K resistor in series before C1. It causes a drop of 1 V on the input of the converter circuit but it also restores the linearity.

On a side note : the final goal is to convert the output of a capacitive sensor ( rain detector) into a voltage signal. The sensor controls the frequency of a 555 timer in astable mode and the square wave is converted to a voltage that is linearly changing with the capacitance of the sensor. This works quite well.

On a side note bis: I also noticed on the scope a high frequency noise content on the output of the 555 timer when it was hooked to the converter circuit. Not sure why it does that.

• Antiath says:

Just a follow up : this is what happens when you go in a forum/comment section explaining an weird issue before considering every possible trap. You look like a complete idiot. So in the end, nothing was wrong with the F to V converter, it was a decoupling cap wrongly connected on the 555. Once set right, no more noise and no linearity issue.

• mathscinotes says:

I'm glad it worked for you. I like what you were doing with your rain gauge sensor and I plan to build one once the water here unfreezes.

mathscinotes

4. Willy says:

Hi, when V2 goes high then we have Ve=2V1-0.7 and Vb=V1, that makes Veb=V1-0.7 , because Veb can't go that high, then there is a quick discharge from C1 to get aprox. Veb=0.7, so C1 have to discharge instantly V1 volts (with a time constant depending of the internal resistance of V2 and the transistor's emitter base diode )

I . n . g . e . n . i . o . u . s . !

6. It's surprising to find on mathscinotes.com a resource so precious about equations.

We will note your page as a benchmark for A Simple Frequency-to-Voltage Converter .

We also invite you to link and other web resources for
equations like http://equation-solver.org/ or https://en.wikipedia.org/wiki/Equation.
Thank you ang good luck!

7. Ripper says:

hi, I have a question that puzzles me for several days. How can I know the time to arrive at the point of equilibrium of Vout. Because when I simulate the circuit shown in the fig.2, there always takes a period of time before the Vout arrives at the point of equilibrium. And can the time be controlled?

8. Leon Sutliffe says:

if anyone can anyone give me links or just a list off the parts needed it would be much appreciated thanks 🙂

• Oliver says:

And/Or a photo of a completet circuit would be soo nice. I'm not realy getting this just from the schematics. Sorry :/

9. Thor Nilsson says:

Hi, I don´t have the technical knowledge to build this on my own so my question is if there are any cheap alternatives online with a similar output? Preferably with a little bit higher output voltage and a dial to adjust the output.

10. R says:

Before I say anything please understand I am new into the field of electronics. I just want to clarify that the input frequency should be the "Sensor Interface Output" and the "Supply Voltage" is just an outside voltage source. Also is the Vout located on the top wire? Probably being stupid but I just want to make sure I have the right idea of how this works.

• markoh says:

what a moron

11. Navid says:

Thanks for 'Simple Frequency-to-Voltage Converter'.

12. igrowing says:
• Betabiker says:

I think the link is broken. Could you fix it?

• mathscinotes says:

Which link is broken? I tried all I could see and they worked.

mark

• mathscinotes says:

Got it! I will try to fix it.

biegert

• igrowing says:

As alternative, you can go http://www.falstad.com/circuit/
And paste the circuit text via File -> Import from text...

\$ 1 0.000005 5.934295036739208 56 5 50
R 176 176 64 176 0 2 10000 3.3 0 0 0.7000000000000001
c 176 176 240 176 0 1e-8 0.1299108276163885
c 400 288 400 352 0 0.00001 3.7354801206917565
r 464 288 464 352 0 1000
d 272 256 272 176 2 default
t 352 192 400 192 0 -1 -0.4354801206917567 0.1299108276163885 100
g 336 352 336 384 0
v 208 352 208 256 0 0 40 3.3 0 0 0.5
w 400 208 400 288 0
w 272 256 208 256 0
w 208 352 336 352 0
w 336 352 400 352 0
w 400 352 464 352 0
w 464 288 400 288 0
w 352 192 352 256 0
w 352 256 272 256 0
w 400 176 272 176 0
w 272 176 240 176 0
o 0 2 0 4614 5 0.1 0 2 0 3
o 3 128 0 4610 10 0.1 1 2 3 3

13. Pedro Agune says:

Hi, I am trying to make this cuircuit for a college work and I would like to know what are the components of this project, especially the "Sensor Interface Output" and any good advice on building this.