Author Topic: Two op-amp VCO  (Read 12034 times)

0 Members and 1 Guest are viewing this topic.

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Two op-amp VCO
« on: March 19, 2020, 10:55:27 pm »
Hello! Please help me to understand if I got that circuit theorically right. I'm looking for your feedback.
I assume for now some simplifying conditions: drain-source voltage null when mosfet is ON,  R7=R6 and R2=R1=R4=2*R5 (will explain that later) and both opamps
powered by V+ = -(V-).

It is important for me to have a symmetrical triangular wave. (by this I mean equal semiperiods for positive and negative slopes)

I've never found some formula explanation online so I tried to figure out by my own how it exactly works.
OUTPUT1 is a triangular wave while OUTPUT2 square wave. As it happens for the simple triangle-square wave generator, capacitor charges with direct current so its voltage rises linearly, giving birth to the triangular wave.
From my conditions I find that half of Vin is always on positive input of first opamp. When the mosfet is off (output2 low level) current on R1 (Vin / 2R1) discharges the capacitor with negative voltage till it brings output1 to the half of negative output2 low level. If I can manage to have my triangular wave symmetrical I can find frequency directly by considering this semiperiod when mosfet is off.
If I'm not wrong we get (Vin*Toff)/(2*C*R1)=V+   (because it charges between the two thresholds of the second opamp at output1, V+/2 - V-/2 so it gives V+)

My biggest doubt is when dealing with mosfet ON. What I think is if we impose a current on the mosfet that is double of Vin / 2R1, and therefore we choose 2*R5=R1, for the ampere law on the node we have also a current coming from the capacitor equal to (Vin / 2R1)
but this time it has the opposite sign of the previous one so my capacitor charges in theory with the same slope but a different sign, for an equal duration of the semiperiod. 

Am I right? I want to go on dealing with real mosfet but I want to be sure I got it. It's been many years since last time I dealt with similar circuits.
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1135
  • Country: us
Re: Two op-amp VCO
« Reply #1 on: March 20, 2020, 01:10:23 am »
Is it a MOSFET or a JFET.  You drew JFET and said MOSFET.  Please clarify.

With the MOSFET on, you use the Thevenin eq of R1, R5 and Vin giving the Thevenin voltage of Vin (R5/(R1+R5)) and a Thevenin resistor of R1R5/(R1+R5).
The charging current is the difference in the Thevenin voltage and Vin/2 divided by the Thevenin resistance.
« Last Edit: March 20, 2020, 02:13:53 am by Wimberleytech »
 
The following users thanked this post: bonzer

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 18725
  • Country: us
  • DavidH
Re: Two op-amp VCO
« Reply #2 on: March 20, 2020, 06:02:22 am »
I have used that circuit several times and it provides moderate performance up to several kHz or 10s of kHz if a comparator is used.  The resistor in series with the drain/collector of the transistor is usually selected to make the transistor's series resistance insignificant.
 
The following users thanked this post: bonzer

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 21844
  • Country: gb
  • 0999
Re: Two op-amp VCO
« Reply #3 on: March 20, 2020, 11:29:12 am »
Yes, ideally a comparator should be used for the Schmitt trigger. Preferably one with a rail-to-rail output to ensure the hysteresis is symmetrical.

The schematic originally posted would require a bipolar supply to work properly, as a J-FET requires a negative gate voltage to turn off. The traditional circuit uses a MOSFET or BJT.

No resistor values are on the schematic. I prefer to use lower value input resistors, than the ones suggested on the schematics in the LM358 data sheets, otherwise to get the full frequency range out of this circuit the input voltage needs to nearly double the supply voltage.
 
The following users thanked this post: bonzer

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 18725
  • Country: us
  • DavidH
Re: Two op-amp VCO
« Reply #4 on: March 20, 2020, 03:00:19 pm »
I have some other comments about this circuit:

1. If you are expecting accuracy, forget it.  There are much better circuit to use for voltage to frequency conversion when accuracy and linearity are desired.
2. I always had problems with the collector/drain capacitance of the transistor limiting performance at high frequencies so sacrifice on-resistance for lower capacitance if necessary; the common 2N7000 TO-92 MOSFET was particularly bad about this.  I think in the last one of these I made, I used a 4053 analog switch for lower capacitance and got excellent results.  A CMOS 74125 tri-state buffer or even better, any open drain output should work well.
3. The lag in a slow comparator causes the triangle wave to overshoot at high frequencies and contributes considerably to the transfer function nonlinearity.  This can be improved by placing a resistive divider between the operational amplifier and comparator, which also increases the amplitude of the triangle wave, and then adding a low value adjustable capacitor in parallel with the input resistor of the divider to add phase lead.  Then as frequency increases, the increasing phase lead causes the comparator to trip earlier making up for its delay.
 
The following users thanked this post: bonzer

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Re: Two op-amp VCO
« Reply #5 on: March 20, 2020, 05:09:41 pm »
Thank you everybody for your answers. I'm sorry about the poor details. I want my transistor to be MOSFET and this is what I originally thought it was in the schematic.

Thanks for making me notice that applying Thevenin really helps here.

I'm afraid about two practical problems:

To avoid problems for higher frequencies I can use comparators LM311 or LM393 but from what David said it's still not guaranteed. But is this really a problem for frequencies under 20kHz? LM311 is fast - takes 165ns of response time. Would also mosfet drain's capacitance give problems in that frequency range? It surprises me I thought these frequencies are low enough. Anyway these problems are solvable because I can try to do what David suggested.

I have another problem: to be honest I've never used comparators so from what I see they give 0/5V of output despite their power source.  It's not compatible because I want my triangle wave to be alternating so equal and opposed threshold voltages would simplify this. Supposing that I use LM311.  I can try to work on finding these resistance values but I'm not sure I'll be able to get both negative and positive thresholds voltages.  I did the circuit below so it might be wrong, I'm gonna try to understand it better later.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 21844
  • Country: gb
  • 0999
Re: Two op-amp VCO
« Reply #6 on: March 20, 2020, 10:25:15 pm »
No, a comparator's output voltage will depend on the voltage its output pull-up resistor is connected to.

I think the LM311 will be fast enough for 20kHz.

The drain capacitance of a MOSFET might be too high though. Another option is a BJT, with a small capacitor, aroung 10pF, in parallel with the base resistor to speed up the turn-off time.
 
The following users thanked this post: bonzer

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 21844
  • Country: gb
  • 0999
Re: Two op-amp VCO
« Reply #7 on: March 21, 2020, 12:53:27 pm »
I think using the LM393 with one of the comparators used to directly switch the resistor, would be better than a discrete transistor and the faster LM311.


Another possibility is using the LM339 quad comparator, with one of the sections used as an op-amp integrator. I've not tried simulating it, because I don't trust model's accuracy in the linear region.

http://www.ti.com/lit/ds/symlink/lm339-n.pdf
« Last Edit: March 21, 2020, 05:12:21 pm by Zero999 »
 
The following users thanked this post: bonzer

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2152
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: Two op-amp VCO
« Reply #8 on: March 21, 2020, 01:07:17 pm »
If you need identical ramps up/down then you can start with a simple sawtooth generator and use the retriggering mechanism (comparator?) to toggle a flip-flip.

This flip-flop can then select an output (either inverted or non-inverted).  As we don't know your application or just how identical identical needs to be it's difficult to know if this is overkill.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 
The following users thanked this post: bonzer

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 18725
  • Country: us
  • DavidH
Re: Two op-amp VCO
« Reply #9 on: March 22, 2020, 04:01:45 am »
To avoid problems for higher frequencies I can use comparators LM311 or LM393 but from what David said it's still not guaranteed. But is this really a problem for frequencies under 20kHz? LM311 is fast - takes 165ns of response time. Would also mosfet drain's capacitance give problems in that frequency range? It surprises me I thought these frequencies are low enough. Anyway these problems are solvable because I can try to do what David suggested.

It is only a problem if you are expecting better linearity and a constant amplitude triangle wave.  Up to a few kHz, an LM393 is fine as shown below where I used an LT1013 (improved precision LM358) for the operational amplifier, an LM393 for the comparator, and a 4053 analog switch.  The other half of the LT1013 is an instrumentation amplifier which drives the VCO and I think I used the other half of the LM393 to drive the speaker.  Since I was only going to a couple kHz, I did not bother with the phase lead linear correction.

If I did that circuit today, I would use a different kind of voltage-to-frequency converter since it only needed to drive a speaker and I had no need of the triangle wave.

Quote
I have another problem: to be honest I've never used comparators so from what I see they give 0/5V of output despite their power source.

Most comparators, including the LM393 and LM311, have an open collector/drain output so they require a pullup resistor which sets the output high voltage for whatever logic family they are driving.  Some CMOS comparators however have a rail-to-rail output which is ideal if you want precise output levels.  If you use an LM393 or LM311, then you have to take the pull-up resistance into account or make other provisions to control the output voltage levels.
« Last Edit: March 22, 2020, 04:04:25 am by David Hess »
 
The following users thanked this post: bonzer

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 21844
  • Country: gb
  • 0999
Re: Two op-amp VCO
« Reply #10 on: March 22, 2020, 01:15:40 pm »
If it's non-critical and you just want to control the tone of a speaker, just use the classic two transistor astable. Here's an example of a wailing siren I make awhile go. It has a timer, so it doesn't go on forever.
 
The following users thanked this post: bonzer

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Re: Two op-amp VCO
« Reply #11 on: March 22, 2020, 03:17:27 pm »
Sorry for the delay, I was doing simulations and different calculations. Thanks for your answers they are very important for me.

It's a university work, just a little project: after I get the VCO and triangle wave at the output I should use it for a triangle-sinusoidal shaper. I'll be going to work on this second block later.

In this 2Hz-20kHz I think it's not essential to have a very accurate 1V/kHz relation as the main task is the shaper. I want my triangle wave to have 0 mean value (alternating). I've added some things to adapt the schematic if two comparators to my needs but I'm gonna share it later.
I want to ask you for help with another problem. This is the original schematic I'm talking about
I think using the LM393 with one of the comparators used to directly switch the resistor, would be better than a discrete transistor and the faster LM311.
(Attachment Link)

I tried to simulate it in LTSpice (I added LM393 and NE5532 models to LTSpice) in transient mode.

My problem is that when it starts running, I has some "too many steps error" . Sometimes I get it istantly other times later but anyway it looks like it's going like overclock: starts showing picoseconds in the graph and keeps on adding them slowly.
I looked for a solution google but I find that it's circuit related. I also tried changing operational amplifier (for something like OP77 or LT.. which are already inside) and it doesn't help, instead when I completely remove the opamp and adjust a bit the circuit of the comparator for a test it works.
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1135
  • Country: us
Re: Two op-amp VCO
« Reply #12 on: March 22, 2020, 03:39:08 pm »


I tried to simulate it in LTSpice (I added LM393 and NE5532 models to LTSpice) in transient mode.

My problem is that when it starts running, I has some "too many steps error" . Sometimes I get it istantly other times later but anyway it looks like it's going like overclock: starts showing picoseconds in the graph and keeps on adding them slowly.
I looked for a solution google but I find that it's circuit related. I also tried changing operational amplifier (for something like OP77 or LT.. which are already inside) and it doesn't help, instead when I completely remove the opamp and adjust a bit the circuit of the comparator for a test it works.

I ran the asc file without modification and it worked fine.  What did you change?
 
The following users thanked this post: bonzer

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Re: Two op-amp VCO
« Reply #13 on: March 22, 2020, 04:38:25 pm »
Thanks for your answer! I didn't actually notice there was the asc file.

I did some mistakes I noticed them now. I kinda copied it but I put 7V of Vin and -Vcc, a negative power source for NE5532. So it gives this problem.

I've just downloaded the asc file and actually it gives a good triangular wave, it's even symmetrical.
The reason why I want to hold dual power supply for my operational is because I'm trying to get a triangual wave with 0 mean value. I could do a subtraction later but anyway I would have to use the second ne5532 of the DIP which would be powered with ground again for negative VEE. I'm trying to figure out a way to solve this by using some pull up resistors and dividers and combinations

 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 21844
  • Country: gb
  • 0999
Re: Two op-amp VCO
« Reply #14 on: March 22, 2020, 04:46:02 pm »
Sorry for the delay, I was doing simulations and different calculations. Thanks for your answers they are very important for me.

It's a university work, just a little project: after I get the VCO and triangle wave at the output I should use it for a triangle-sinusoidal shaper. I'll be going to work on this second block later.

In this 2Hz-20kHz I think it's not essential to have a very accurate 1V/kHz relation as the main task is the shaper. I want my triangle wave to have 0 mean value (alternating). I've added some things to adapt the schematic if two comparators to my needs but I'm gonna share it later.
I want to ask you for help with another problem. This is the original schematic I'm talking about
The most important things are equal rise and fall times and amplitude, across the frequency range, otherwise distortion increases with the frequency, as the delay in the comparator starts to become significant.

Even at 20kHz, glitches can be seen at the top of the triangle wave, when zoomed in.

Thanks for your answer! I didn't actually notice there was the asc file.

I did some mistakes I noticed them now. I kinda copied it but I put 7V of Vin and -Vcc, a negative power source for NE5532. So it gives this problem.

I've just downloaded the asc file and actually it gives a good triangular wave, it's even symmetrical.
The reason why I want to hold dual power supply for my operational is because I'm trying to get a triangual wave with 0 mean value. I could do a subtraction later but anyway I would have to use the second ne5532 of the DIP which would be powered with ground again for negative VEE. I'm trying to figure out a way to solve this by using some pull up resistors and dividers and combinations


Don't worry if the triangle wave isn't biased around 0V, as long as the rise and fall times are matched, it can be biased to 0V with an AC coupling capacitor.
« Last Edit: March 22, 2020, 05:55:12 pm by Zero999 »
 
The following users thanked this post: bonzer

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Re: Two op-amp VCO
« Reply #15 on: March 22, 2020, 06:52:06 pm »
Thanks for your answer. I've just  found another mistake that I did previously so now I'm ok even with the dual supply inside simulator.
I was moving on with the voltage divider and I did it but now after your words I've just realised it's useless  :palm:

Using a capacitor would put all things right. My previous solution works but it's worse than yours because I also use a diode at the output of the second comparator, this way I thought I would simplify my calculations for the resistors at left, but the problem is that it introduces some assimetry in my triangular wave so I will keep on working on your solution. Now I'm doing some calculations on resistors to find the desired voltage-frequency relation.
« Last Edit: March 22, 2020, 06:54:02 pm by bonzer »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 21844
  • Country: gb
  • 0999
Re: Two op-amp VCO
« Reply #16 on: March 22, 2020, 09:15:14 pm »
Thanks for your answer. I've just  found another mistake that I did previously so now I'm ok even with the dual supply inside simulator.
I was moving on with the voltage divider and I did it but now after your words I've just realised it's useless  :palm:

Using a capacitor would put all things right. My previous solution works but it's worse than yours because I also use a diode at the output of the second comparator, this way I thought I would simplify my calculations for the resistors at left, but the problem is that it introduces some assimetry in my triangular wave so I will keep on working on your solution. Now I'm doing some calculations on resistors to find the desired voltage-frequency relation.
What sort of shaping circuit are you intending to use?

Here's one I've made earlier. It isn't my design. Unfortunately I can't remember where I got it from. I've tried searing the Internet again but can't find it. Hopefully someone will recognise it.

Sine shaper.asc

In real life part of R1 was a potentiometer to trim the amplitude of the input.

Here's another thread:
https://www.eevblog.com/forum/beginners/simple-analog-function-generator-design/msg1175040/#msg1175040
 
The following users thanked this post: bonzer

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Re: Two op-amp VCO
« Reply #17 on: March 22, 2020, 11:08:31 pm »
Actually I'm not alone working on this so this second block for shaping is done by my collegue, but I will also take part so anyway thanks for this solution. I've only seen once the initial circuit and it was something like the attached image.

But I'm personally more interested in your solution.

About VCO: I see your solution is good when applied to the simulator. I also tried the first solution with transistor, using BJT (BC337) and it gives a peak that is a bit smooth, it's worse than your solution but I understand it better because I can chose easily resistors for frequency dependence etc...

I would like to know how you decided the values on the resistors at left in your solution? It seems like you just put that big resistors to get the input voltage closer to the capacitor so the output voltage depends more on the input rather than presence of for example +V from the second comparator. Anyway I'm not sure about understanding the point, first time I saw it I was afraid about +V influence from the second comparator.

« Last Edit: March 23, 2020, 08:35:32 am by bonzer »
 

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Re: Two op-amp VCO
« Reply #18 on: March 23, 2020, 05:31:35 pm »
I want to share a little improvement I've just done. For the comparator: to avoid unrealiable high voltage at the output, which is lower than the power source and depends on other things (it's usually open collector), I added a 10V zenner diode with some resistors. It works in the simulator but I don't know if it can give problems in reality.
« Last Edit: March 23, 2020, 07:24:00 pm by bonzer »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 18725
  • Country: us
  • DavidH
Re: Two op-amp VCO
« Reply #19 on: March 23, 2020, 10:27:03 pm »
It's a university work, just a little project: after I get the VCO and triangle wave at the output I should use it for a triangle-sinusoidal shaper. I'll be going to work on this second block later.

That brings up another problem; sine shapers require an accurate level of triangle wave.  So if you use this VCO design, you should use the phase lead compensation circuit that I suggested because it also helps control the level of the triangle wave.  It just means adding 2 resistors and a trimmer capacitor.
 
The following users thanked this post: bonzer

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Re: Two op-amp VCO
« Reply #20 on: March 24, 2020, 10:17:04 am »
Thanks a lot David! I'm gonna learn about it right now, seems easy.

Thank you everybody for your answers. I decided to definitely use Zero999 advice! I hope it works in practice (not only inside simulator). It's way faster using that second comparator replacing a transistor. Also after I added that zener at the output I see that relation 1V/kHz is respected well, increasing precision.

I want to share with you the whole diagram.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 21844
  • Country: gb
  • 0999
Re: Two op-amp VCO
« Reply #21 on: March 24, 2020, 11:13:07 am »
Don't purely go on simulation results. David's suggestion is a good one and might be better than mine in real life. Another thing you could try is a BJT with a capacitor in parallel with the base resistor to speed up the turn off time. The RH111 model, used in the simulation attached, is similar to the LM311.
 
The following users thanked this post: bonzer

Offline bonzerTopic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: it
Re: Two op-amp VCO
« Reply #22 on: March 25, 2020, 11:58:48 am »
Is it necessary in your opinion to do a stability analysis? Here we have a frequency that depends on the input voltage, and to me it seems open loop. I would leave it f=kV where k is the constant that we desire and impose in the electrical calculations. Though in the end it doesn't introduce any significant constant error in the voltage to frequency conversion and k value seems to be respected. Here I have a screen of the simulation. I'm not interested in building a control loop for frequency control but only to have any idea about its behavior.

 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 21844
  • Country: gb
  • 0999
Re: Two op-amp VCO
« Reply #23 on: March 25, 2020, 07:59:15 pm »
Is it necessary in your opinion to do a stability analysis? Here we have a frequency that depends on the input voltage, and to me it seems open loop. I would leave it f=kV where k is the constant that we desire and impose in the electrical calculations. Though in the end it doesn't introduce any significant constant error in the voltage to frequency conversion and k value seems to be respected. Here I have a screen of the simulation. I'm not interested in building a control loop for frequency control but only to have any idea about its behavior.
I'm not sure what you mean by stability analysis?

As long as the loading on the comparator is the same and its propagation delay is negligible, the V/F characteristic won't change.

How sensitive do you want it to be? The original schematic on the data sheet needs the control voltage to exceed the supply voltage to get the full range of the circuit, because the input resistors (R11 and R7) on your schematic attenuate the input voltage by half. If you want a wider range of frequencies, for a smaller input voltage range, then I recommend using lower values. The resistor values in my schematic give a larger value of k and the voltage required for the maximum frequency is a bit under the supply voltage.
 
The following users thanked this post: bonzer

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 18725
  • Country: us
  • DavidH
Re: Two op-amp VCO
« Reply #24 on: March 26, 2020, 04:12:46 am »
Another thing you could try is a BJT with a capacitor in parallel with the base resistor to speed up the turn off time.

The bypass capacitor should always be used no matter what else is going on.  It considerably improves the switching time of the transistor for a given amount of base series resistance.
 
The following users thanked this post: bonzer


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf