# voltage to frequency converter

Discussion in 'The Projects Forum' started by moorea21, Aug 23, 2012.

1. ### moorea21 Thread Starter Member

Sep 5, 2010
30
0
Hi,

I'm building a synthesizer based on a violin, which uses resistive strips on the fingerboard to set voltage values which will be converted into audible frequencies. For this I'm using LM331N's, and intend building a circuit like that in the datasheet, as attached.

This gives a nice linear response proportional to voltage input, which in my case will be between approximately 5 and 10 volts input, outputting frequencies on (for example) the G string of 196 to 293.9Hz, at 5.07V and 9.4V respectively.

The problem is this:

If I were to plot a graph of my input voltages (as I currently get from the resistive strip) on a graph against the output frequencies I want, it is a straight line, BUT it does not pass through (0,0). The circuit in question is described as 'full scale', and judging from the equation linking voltage and frequency, unavoidably produces 0Hz from a 0V input (as I understand it). And also, of course, if it has component values set to produce 196Hz from an input of 5.07V, then an input voltage of 9.4V will produce 9.4/5.07 x 196Hz output, which is rather higher than the 293.7Hz I need at this point.

I'm unable to think of a way of matching up my needed frequencies to the existing voltages; I don't even know how to define this problem beyond what I've written here, and I would welcome any input that could either clarify what needs to be done in theoretical terms, or even suggestions on exactly what circuit/ sub-circuit I could use.

I googled this , both on and off this forum, but I suspect that my lack of the right technical terms held me back from finding anything.

Thanks anyone!

Rich B

File size:
27.1 KB
Views:
161
2. ### wayneh Expert

Sep 9, 2010
15,875
5,960
Can you please better specify what the relationship is between voltage and intended frequency, ie. the slope and intercept of your line describing the violin?

As I understand your problem, you want to maintain the slope ∆ƒ/∆V but gain control over the intercept - offset voltage - of the LM331 circuit. Does that sound right?

I see the datasheet and the figure you posted both address the issue of an optional offset. I think that's all you need. I'd use a precision pot for that, so you can tune it precisely. You may want to use two pots for a coarse and fine arrangement.

Last edited: Aug 23, 2012
3. ### moorea21 Thread Starter Member

Sep 5, 2010
30
0
Ideally I would be able to control both the slope (∆/∆V) and the intercept, as these will be different for each of the 4 strings. I did wonder about the operation of the offset mentioned in the datasheet; I had hoped it would refer to something I could use to change the intercept, but was not sure. If this is the case, then the slope could be altered by changing the gain, and the intercept by changing offset. Job done...

I may resort to using a spice simulation to test whether this is the case, although that would mean giving up on trying to understand the circuits operation in theoretical terms, which would be a shame!

I've attached a graph relating frequency to Voltage, in case that clarifies things.

RB

File size:
70.2 KB
Views:
71
4. ### wayneh Expert

Sep 9, 2010
15,875
5,960
Since that extrapolates back to a negative Y-intercept voltage, I believe you merely need to apply an offset of that much as "described" in the datasheet. (It would be nice if it covered this in a little more detail.)

IMHO, the simulation exercise will just delay you getting your feet wet. I'd go straight to a breadboard and see if it behaves as predicted.

5. ### #12 Expert

Nov 30, 2010
18,076
9,678
Have you thought of using resistors so that each strip on the fretboard only has the voltages available that correspond to the notes you want?

6. ### moorea21 Thread Starter Member

Sep 5, 2010
30
0
Thanks Waynh, and yes, you're right, I would be wimping out of just building the circuit and testing it if I end up fiddling with LTSpice again... except that I don't own or have access to an oscilloscope, which is something I can use within LTSpice.

When it comes to testing the actual circuit, I'll need to amplify the square wave, and send it to a speaker near a microphone in my pc, where a program called 'Intonia' should be able to show me the pitch, waveform, and duration.

I haven't designed an amplifier in years, I think I still have a few op amps hanging around. The whole business of impedence matching seems to have dropped out of my brain over the last 20 years... I need a refresher course.

#12;

One of the characteristics of a violin is that you can hit any pitch on the string, rather than just set notes, which is why I chose a graduated resistive strip rather than resistors. This would be a great solution for a guitar, though.

I may at some point insulate the areas of resistive strip where 'non notes' are to be found, so that when I'm practicing, I either get the correct note, or no note at all. Probably just a bit of insulation tape should acheive that. This should sharpen up my intonation a lot.

7. ### wayneh Expert

Sep 9, 2010
15,875
5,960
Don't worry too much about that, impedance matching and all. There are a lot of options that take care of that for you.

I think a LM386 audio amplifier would come in handy for you. Just look up the datasheet. You could accomplish a similar result with many op-amps also, since you don't need much power.

BTW, you can also go directly into the sound card just like it's an oscilloscope, without the speaker-mic coupling. I use a high-ohms resistor in line to help protect the audio input, maybe 100k. I'll take a look at the exact value if you're interested. Anyway, it allows me to probe circuits directly and get fine results in the range of 1Hz to maybe 5kHz.

8. ### moorea21 Thread Starter Member

Sep 5, 2010
30
0
I like the idea of directly connecting to the soundcard. Is there some software you use to represent the signals in an 'oscilloscope' type way? For audio frequencies, I'd plug straight into the 'Intonia' software I mentioned before, but some way to capture and graphically represent higher frequency signals would be good to have, too.

Do you think it might be possible to plug the output from the LM331 straight into the soundcard, using a protective resistor, as you suggested, and a 3.5mm jackplug? Or would the signal to noise ratio be to low? Not sure what amplitudes are involved, but listed under 'LOGIC OUTPUT (Pin 3)' on the datasheet's page 17 are figures such as 0.15V and 0.10V for VSAT. Are these typical output amplitudes, or am I misreading the datasheet?

The LM386's seem ideal, Farnell stock them, and I can order a whole load of other components at the same time, to cut delivery costs per item. Looking forward to putting this all together and testing it soon. Thanks!

9. ### #12 Expert

Nov 30, 2010
18,076
9,678
I didn't mean a resistor for every note, just 2 resistors, one at each end of the resistive strip. If the notes for that strip are between 2.8 volts and 5.3 volts, set up the resistors so the strip has from 2.8 to 5.3 volts on it.

(and yes, I'm a guitar player.)

10. ### Audioguru Expert

Dec 20, 2007
10,902
1,245
A square-wave has strong harmonics that might upset the circuit trying to hear the pitch. A sine-wave has no harmonics and is better.

A square-wave sounds harsh like an old mechanical buzzer. A sine-wave sounds smooth like a flute.

A modern amplifier does not match the speaker impedance. Instead the amplifier has an extremely low output impedance (0.04 ohms or less) as a voltage source so it can damp resonances of the speaker.
Usually a simple inexpensive audio amplifier IC is used today.

11. ### wayneh Expert

Sep 9, 2010
15,875
5,960
Here's the arrangement I use for lab bench range voltages (ie., 12v or less, usually 5V or less). I have no problem working in the 100mV range with this setup. Input impedance of the sound port is over 50kΩ anyway, so the 10k resistors aren't really doing much.

I use the tin to make it easier to switch out the resistors or use resistor dividers if I need to probe higher voltages. There's an adapter at the computer to convert the RCA jacks to the 1/8" mini jack.

Just google for "free oscilloscope software" to find software for your PC and operating system. Maybe other folks here can make recommendations. I use an ancient, repurposed Mac and I doubt that's what you have.

• ###### Picture 6.jpg
File size:
52.1 KB
Views:
232
Last edited: Aug 24, 2012
12. ### moorea21 Thread Starter Member

Sep 5, 2010
30
0
Hi #12,

I see what you mean. I was going to run one LM331 per string, but if I did it your way, I could run all 4 strings through one IC, with each string occupying its own range of voltages. Good thinking. I wonder whether accuracy would suffer;- at the moment, each string will have a voltage range of 5V, but using your method (if I understand correctly) would mean each string having 1/4 of that spread of voltages. It may not make any real difference accuracy wise, and I'd have 3 spare Ics hanging about. I imagine that playing 'double stopped' notes might be a problem, though, as the 2 voltage signals would add to each other, maybe producing one composite output frequency?

Guitars are so much more sensible than fiddles... maybe one day I'll try one.

Audioguru:-

The software I use to check my intonation (Intonia) works best with signals that contain a lot of overtones, and in fact doesn't work well with sine waves, apparently. Square waves will sound 'buzzy' however, so once I know that the basic idea is viable, I'll smooth the signal in the direction of being a sine wave, if that makes any sense.

I shall ignore impedence issues, I think! Thanks.

Wayneh:-

Thanks for that, I'll build something similar that works with the jackplug socket on my PC. By the look of it yours can run 2 probe channels simultaneously? Soundcards probably don't want DC voltages, but as far as I can tell there should be no DC bias in the LM331's outputs. I'll get the software at http://www.sillanumsoft.org, it looks impressive. It'll be a few days before I can get all this together, I'll post back hopefully with some results...

13. ### wayneh Expert

Sep 9, 2010
15,875
5,960
Don't be so sure! A guitarist bends notes, can apply variable pressure on a string behind a fret, might use a slide, use a tremolo bar, and on and on. Frets help, but there's a lot more to it. Try it!
Yup, the input supports stereo.
What you'll see at lower Hz is a RC decay at the top of a square wave. That's the coupling capacitor slowly draining into the sound card impedance. So you can't use it as a DC voltmeter. On the upside, a DC bias has no effect, no worries.

There IS one concern though - ground. Your PC has one ground at the sound card and your circuit will have another ground. If it's isolated from the mains by a transformer, no worries. But if your circuit ground is from another computer PSU (a handy lab bench power supply), there COULD be a voltage difference between them and current could flow when you connect them. Use a meter and proceed with care. Connect grounds via a 200Ω resistor first, and see if there's any ∆V.
I know you're not looking for a Mac app, but just for reference, here are some good examples:
Mac the Scope
Signal Scope
iSpectrum

14. ### Audioguru Expert

Dec 20, 2007
10,902
1,245
During my many years studying and listening to music (I studied and played music when I was in my high school band) I have developed "perfect pitch" which is where I can "sense" the exact frequency of a tone something like a frequency counter in my brain. Sound frequencies to me are something like colours to ordinary people.

Some recordings have artists singing perfectly (they probably rehearsed it many times or use a machine to get the pitch correct) but when they sing live their pitch is completely wrong.

Some people don't have a clue about the pitch of a tone. Then they are not interested in music.

15. ### #12 Expert

Nov 30, 2010
18,076
9,678
I don't think you're going to wind up with 3 unused chips. Each chip can only output a single frequency at a time. One resistance strip, one note.

16. ### moorea21 Thread Starter Member

Sep 5, 2010
30
0
That's the coupling capacitor slowly draining into the sound card impedance.

I take it you mean the sound card's coupling cap?

My power supply for the resistive strips and circuitry is a 9V battery, so there shouldn't be any problem with that side of things, I think...

I'd be happy with good relative pitch skills, and yes, I was kidding about guitars being easy!

17. ### moorea21 Thread Starter Member

Sep 5, 2010
30
0
I'm a bit confused by the voltages for 'offset' adjustment as depicted in the circuit I posted originally. It specifies '+Vs' and '-Vs' across what I guess must be a pair of potentiometers in reality. Looking through the datasheet suggests max. offset voltages of +-10mV.

Am I supposed apply a +-10V supply, and tweak the offset voltage between +10mV and -10mV? In which case I'll need to use a DC to DC voltage converter to get my -10V?

18. ### wayneh Expert

Sep 9, 2010
15,875
5,960
No, I think that 10mV spec is for an internal error maximum within the chip itself. Your applied offset will be in the volts range, and I suspect equal to the offset you need, within that 10mV error range.

They show the offset being created by a resistor voltage divider. You'll want to choose the fixed resistors to get you to the middle of the pot's range at the anticipated setpoint, so that you have the most control. Their setpoint in the schematic is probably zero volts = no offset.

Some experimentation will be necessary and I suggest you do this before going forward with a build. You need to be sure you understand that offset function. What I've described is my hunch, but it's only that.