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.

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 1: Simple Frequency-to-Voltage Converter.

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 2: Derivation of Frequency-to-Voltage Conversion.

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 3: Simulation Results.

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 4: Plot of the Linearity of the Frequency-to-Voltage Conversion.

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. This complex electrical process involved the use of specialist electronic tools such as wire strippers (wirestriper).
  • 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 5: Three Data Points from a Quick Lab Test I Did.

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.

41 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.

      • 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 )

  5. kwiadnyana says:

    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?

    • Tom Austin says:

      I experienced the same when I modeled the circuit exactly in LTSpice. Using the inventors original values it takes three seconds before the output reaches equilibrium.

      Although the linearity is very good when I graphed the output, the output voltages are not the same as what the inventor's showed.

  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.

  11. Navid says:

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

  12. 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.

  13. blake says:

    I am very new to electrical work and was wondering if there were to be a tutorial in setting up this circuit, any help will be appreciated

  14. Pingback: DIY LED Music Visualizer | Real-Time Animations (Arduino) – Miftah Steven Code

  15. Loke says:

    Is there a good way to use this for a soundwave and output it with 5v max so it can be used with an arduino?

    • SeaDog says:

      I would also like to know this if Mathscinotes could come to the rescue!

      I've been trying to build the circuit to read in an audio signal. For a 5V Arduino I'm assuming the signal would have to to be amplified but would it need to oscillate around +2.5V as well rather than 0V so that there's no negative voltage? Then I'm guessing the output of the amplified & offset audio signal would simply connect to C1?

      Any help would be much appreciated as my electrical engineering has faded quiet a bit since college.

  16. mohamad haiyfa haiyfa says:

    It's a work of art, what are the component values ​​you used

  17. Tony says:

    What would be the frequency range of such a circuit? I want to build an audio to control voltage interface to convert audio output from a keyboard into a control voltage for an analog synth. I realize that non-linearities may sound out of tune, but not to worry for now. My concern is the range of the conversion. I would need something like 100hz-4khz to get a few octaves. Can you suggest capacitances that would support this in your circuit?
    Thanks for a great design by the way.
    Tony

  18. Charles says:

    Does this circuit also work for sine waves?

  19. Charles says:

    How do you change this circuit to accept frequencies between 0 to 100kHz?

  20. That's why maths is known as the mother of science

  21. Balveer Singh says:

    Hi,
    Came here from Devon Crawford's video.

  22. MrCat says:

    Hi, thank you for sharing. Do you know where to get LTspice models?

Comments are closed.