MAX038 Function Generator Design

RichardO

Joined May 4, 2013
2,270
Yesterday I made a SOIC to DIP adapter to test the THS4222 with the circuit I have in the breadboard. Apart from measuring the effect on the power supply and check the op-amp's resistors, I also wanted to make sure I was able to draw such a small footprint and solder it by hand.
Good work!

In regards to the power supply: there's just a small increase in current consumption on both rails (about 10mA more on each) and the variation with different loads and settings is fairly small (no more than 5mA on any rail); which is more or less what I got before with the AD822; so I guess the current power supply will also be able to cope with it as before with a minor tunning.
It is apparent that you are _not_ testing with a real load. A 50 ohm load at 2.5 volts out will be 50 mA. All of this current _must_ come from the power supply -- if your power supply could supply it, which it can't.

I also tested the new opamp at high frequencies, and got up to 2.5Mhz at 10 Vpp without any issue (as it is, without changing anything else in the breadboard circuit; except adding the 50Ω output resistor, which didn't influence the results). From there onwards I get the same drop in amplitude discussed previously; which is is not that bad, considering the limitations of my oscilloscope and the use I'm going to give the device
2.5 MHz is not a high frequency unless it is a square wave. ;) What is the rise time of a square wave at this frequency?

I looked through the pages of the THS4222 datasheet you recommended, and noticed that I'll need 3 decoupling capacitors per rail -which is going to be quite difficult to fit right next to the opamp in the design as it is-. I don't understand this (I only studied decoupling calculations for designing power supplies): why are 3 different capacitors needed; doesn't the biggest one get the job done? I mean, I always thought that you just use the smallest capacitor you could get away with, and that this capacitor would be good for all frequencies. I even did a few tests in a simulator, and always got the same result, no matter the frequency: the highest the capacitance, the best it works. So, why 3 capacitors for this opamp?
You may be able to "share" the largest value bypass caps with the MAX038 if they are close together. You may want to consider using surface resistors and capacitors around the THS4222. This would allow the shortest lead lengths possible. Either 0805 or 0603 package sizes would work although the 0805 may be a bit big.

At high frequencies, a capacitor is not perfect because it has a series inductance. The bigger the capacitor value, the bigger the inductance. So, the solution is to put large capacitors in parallel with small capacitors give a than the inductance of a single capacitor (inductances in parallel are like resisitors in parallel). By the way, this applies to ceramic capacitors as well as electrolytic capacitors. However, electrolytic capacitors have a HUGE inductance because they are made by winding a coil of aluminum foil to make a high amount of capacitance in a small package. Ceramic capacitors are not wound, instead, they are a bunch of parallel layers separated by a high dialectic ceramic, therefore, the inductance of a ceramic cap is much, much lower than an electrolytic cap.

If you don't have a low enough bypass impedance on a high frequency amplifier it can oscillate. Even if the amp does not oscillate, it will not be able to drive a load with fast changing signals because the power leads to the amp has inductance whose impedance will divide with the load impedance.

Also about the THS4222 datasheet: if I change the opamp's feedback resistor to 2k, I assume the input resistor also needs to be changed. I calculated 400Ω, or 390Ω in standard values; is this correct?
You need a gain of about 5 to go from 2 volts p-p to 10 volts p-p. In an non-inverting op-amp circuit the gain is Rout/Rin +1. So, with a feedback resistance of 2000 ohms, you need an input resistor of about 510 ohms.

About the Iin pots: I only use one plus a limiting resistor. What happens is that I've been trying different values -from 1MΩ to the recommended 20kΩ in the datasheet-. 200kΩ is what works best for the frequency range capacitors I'm using, but had to go with 100kΩ as I couldn't get a matching 200kΩ pot.
Are you using the pot on the Fadj pin for a fine adjust of frequency? I personally don't think that there is much to be gained by doing that. If the range of frequency setting is correct for the pot on the Iin pin then the fine tuning is not really needed. To get the desired setting range of the single Iin pot you will most likely have to change your timing capacitors to 33 pF, 330 pF, 3.3 nF etc. See the OUTPUT FREQUENCY vs. IIN CURRENT graph on page 4 of the MAX038 data sheet. Note that the ratio of the pot to the resistor in series with it has to be more than 10:1 to get overlap in the frequencies from range to range. I would shoot for a ratio of somewhere between 100:1 and 500:1.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
It is apparent that you are _not_ testing with a real load. A 50 ohm load at 2.5 volts out will be 50 mA. All of this current _must_ come from the power supply -- if your power supply could supply it, which it can't.
I did the test with a proper regulated dual power supply, not with the shunt regulator and the virtual ground; but even then you are right, it can't keep the output amplitude with a 100Ω load. What I meant in my previous post is that I can't see any change in consumption on either rail whether I have a 100Ω load or no load at all; the only thing that changes is the output amplitude, which begins to drop with a 700Ω at 10Vpp.

So, I'm seeing it this way: if the amps consumed by the whole device are practically the same, no matter what load or setting, then the simple shunt power supply will be good enough.

2.5 MHz is not a high frequency unless it is a square wave. ;) What is the rise time of a square wave at this frequency?
Sorry, I consider anything over 1Mhz high frequency. :D

I'm getting 120ns rise time from 10% to 90% at 10Vpp.

You may be able to "share" the largest value bypass caps with the MAX038 if they are close together. You may want to consider using surface resistors and capacitors around the THS4222. This would allow the shortest lead lengths possible. Either 0805 or 0603 package sizes would work although the 0805 may be a bit big.
I nearly got all the parts to build the exposition box for making PCBs with the photo-resistent method. In fact I'm just waiting for the special ink jet transparencies to arrive -all the parts for the box are already here-. If get it all working before I finish the design for this project, I probably do as you said and change those components for SMDs.

At high frequencies, a capacitor is not perfect because it has a series inductance. The bigger the capacitor value, the bigger the inductance. So, the solution is to put large capacitors in parallel with small capacitors give a than the inductance of a single capacitor (inductances in parallel are like resisitors in parallel). By the way, this applies to ceramic capacitors as well as electrolytic capacitors. However, electrolytic capacitors have a HUGE inductance because they are made by winding a coil of aluminum foil to make a high amount of capacitance in a small package. Ceramic capacitors are not wound, instead, they are a bunch of parallel layers separated by a high dialectic ceramic, therefore, the inductance of a ceramic cap is much, much lower than an electrolytic cap.

If you don't have a low enough bypass impedance on a high frequency amplifier it can oscillate. Even if the amp does not oscillate, it will not be able to drive a load with fast changing signals because the power leads to the amp has inductance whose impedance will divide with the load impedance.
Do you, or anyone else, know of a good place where I can read the basics and calculations needed for all this?

You need a gain of about 5 to go from 2 volts p-p to 10 volts p-p. In an non-inverting op-amp circuit the gain is Rout/Rin +1. So, with a feedback resistance of 2000 ohms, you need an input resistor of about 510 ohms.
I already tried 2.2k for the feedback resistor and 560Ω for the input resistor this afternoon. It worked well, and they are also close enough to the recommended values.

Tomorrow I'll try to combined the 2 op-amps on the THS4222; as you recommended yesterday.

Are you using the pot on the Fadj pin for a fine adjust of frequency? I personally don't think that there is much to be gained by doing that. If the range of frequency setting is correct for the pot on the Iin pin then the fine tuning is not really needed. To get the desired setting range of the single Iin pot you will most likely have to change your timing capacitors to 33 pF, 330 pF, 3.3 nF etc. See the OUTPUT FREQUENCY vs. IIN CURRENT graph on page 4 of the MAX038 data sheet. Note that the ratio of the pot to the resistor in series with it has to be more than 10:1 to get overlap in the frequencies from range to range. I would shoot for a ratio of somewhere between 100:1 and 500:1.
Not really. I added the FADJ pot, but it's meant to be tuned once and then only use the Iin for normal usage. It's just there in case I need it for any reason, but it should always be set around the 12k recommended in the datasheet.

For the Iin, I chose the limiting resistor in series by manually testing the smallest value that I could get away with; which turned out to be 10k. Anything under 10k, and the MAX stops working, and anything over 10k and I don't reach the maximum possible frequency. For the Iin pot itself I chose one that would allow me to reach all frequencies in between ranges. At the moment, for the breadboard tests, I'm using 100nF, 10nF, 1nF, 47pF and 20pF capacitors; but I will change these once I know the final stray capacitance of all the parts mounted on the PCB (specially those from the final switching transistors).
 
Last edited:

RichardO

Joined May 4, 2013
2,270
I did the test with a proper regulated dual power supply, not with the shunt regulator and the virtual ground; but even then you are right, it can't keep the output amplitude with a 100Ω load.
The output amplitude should not change with a 700 ohm load if the THS4222 and power supply are working. (You can not do this test with 10 volts p-p as your starting amplitude since the THS4222 can not drive a full load all the way to the power supply voltages).

What I meant in my previous post is that I can't see any change in consumption on either rail whether I have a 100Ω load or no load at all; the only thing that changes is the output amplitude, which begins to drop with a 700Ω at 10Vpp.
The power supply current must change when you apply a load because the load current must come from somewhere and that is the power supply.

So, I'm seeing it this way: if the amps consumed by the whole device are practically the same, no matter what load or setting, then the simple shunt power supply will be good enough.
Since the power supply current _must_ change with load... I will say again... The shunt regulator will _not_ work.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Then there's something wrong, or I'm not doing the right test... or the test right.

This is how I'm doing it:

amperage_mesurement.jpg

I'm connecting an amperimeter between the dual power supply, which should be good for 7.5 A on the +5V rail and 300mA on the -5V rail, and the power input to the +5V. At the output of the opamp I'm connecting a limiting 100Ω resistor in series with a 10k potentiometer, which will simulate the load. And I'm also connecting the oscilloscope's probe at the point between the opamp and the load to monitor the output.

I begin with a square wave at 100Khz and 5Vpp -more or less with everything set in the mid point- and with the load at minimum (10K plus the 100Ω limiting resistor). With this settings I'm reading around 127mA in the amperimeter.

Now I set the load in the mid point (around 5k + 100Ω), and there's no change in the output or the amperimeter, which still marks 127mA.

Then I set the load pot to maximum, leaving only the 100Ω resistor as load. The amperimeter now reads 136mA; which just adds around 10mA more. With these settings I'm not seeing any drop in amplitude; maybe it only happens at the high frequency range, or at 10Vpp.

See what I mean: that's only around 5% increase in the amperage needed; which is fine for the shunt regulator... or not? I tried all possible settings these past weeks and there's never more than 10mA change on any rail.
 
Last edited:

RichardO

Joined May 4, 2013
2,270
OK. Now things are getting clearer.

You are not loading the THS4222 to the maximum you will see when using the generator in real life.

There are basically 3 kinds of loads you will see. The obvious one is no load or a very small amount of loading such as the input of an audio amplifier.

A much heavier load will be seen when driving a terminated coax cable. In this case, the cable is driven from the TS4222 through the internal 50 ohm resistor. This is "series termination". At the far end of the cable is the parallel termination using another 50 ohm resistor to ground. This is a total 100 ohms.

The worst case load is a short on the output of the generator. This will, of course, be equal to the 50 ohm internal resistor. When I use my function generators, I commonly short the leads both intentionally and accidentally. An intentional short is when using the internal 50 ohms to measure the reactance of a large inductor or driving a speaker.

Any of these loads can be applied while the output amplitude is set for the maximum of 10 volts p-p.

So, with the generator trying to supply 5 volts (peak) into a shorted output there will be 100 mA through the internal 50 ohm resistor. (The THSD4222 only guarantees 88 ma but in you have to expect the part will deliver more than that).

Now here is the subtle part. If you do your power supply current measurement with and without a 50 ohm load on the output of the THS4222 you then you will only measure a 50 ma change!

Why? This is because the signal on the output of the THS4222 is ac, not DC. Because of this, the power supply -- either positive or negative -- is only seeing the load current half of the time. But, the peak current is 100 mA and this is what the power supply must deliver. At high frequencies, this peak current can be supplied by the bypass capacitors. However, at low frequencies, the power supply must be able to deliver a nearly constant 100 mA for one half of the ac cycle going into the load.

Let's say that the output frequency is 20 Hz into a 4 ohm speaker. The peak current will be about 90 mA for 25 ms. The bypass capacitors would have to be thousands of microfarads to keep the 20 Hz signal from showing up on the power supply. this is not practical.

So, the bottom line is that the power supplies must be capable of delivering the full 100 mA to the load. Even though it is not always needed, that amount of current must be available. If it isn't then sometimes weird things will come out of the generator. I prefer a piece of test equipment that does not do unexpected stuff.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Sorry for the delay in my answer; I was finishing the UV exposure box and doing dozens of tests until I got it right.

You've convinced me... finally! :p... that the current needed is going to vary a lot for the shunt regulator to handle it. So, I guess the next best thing -without making the whole power supply- is, as you suggested in a previous post, to add a transistor to the zeners. I was about to design it, but I still have the same problem as before; how will I know for sure how much current I would need? I mean, I need this to calculate it.

I know for sure that I will need 7mA for the PIC and 77mA for the LCD; I guess these will not change with any setting or frequency. But how can I measure the current needed for the MAX and the opamp, if I can't measure it directly?
 

bance

Joined Aug 11, 2012
315
Doesn't this answer your question?
Any of these loads can be applied while the output amplitude is set for the maximum of 10 volts p-p.

So, with the generator trying to supply 5 volts (peak) into a shorted output there will be 100 mA through the internal 50 ohm resistor. (The THSD4222 only guarantees 88 ma but in you have to expect the part will deliver more than that).
HTH Steve.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Only partially. That's the maximum current through the load; but then there's also the current that the opamp itself needs, plus the current for the MAX038; which I also measured a slight variance with different settings, and I guess the readings are also not reliable since I'm not measuring the peaks, only the average...

... or is it as easy as adding those 100mA per rail to what I got before?
 
Last edited:

RichardO

Joined May 4, 2013
2,270
So, I guess the next best thing -without making the whole power supply- is, as you suggested in a previous post, to add a transistor to the zeners.
You forgot what I really said: "You might be able to limp along by putting emitter followers on the Zener diodes but that is not what I would do."


I was about to design it, but I still have the same problem as before; how will I know for sure how much current I would need? I mean, I need this to calculate it.
I don't follow you. What currents are you talking about?

But how can I measure the current needed for the MAX and the opamp, if I can't measure it directly?
If I understand you correctly, you need to read the data sheets for the MAX038 and THS4222 to get the quiescent operating currents. To be sure that you can supply the needed currents, you need to use the maximum currents specified. Then you need to add in the maximum currents that are drawn by any other components/circuits.

Measuring the currents will only get you one example of how much current you will need. The manufacturer of the IC's knows what the _range_ of currents are and they tell you in the specifications.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
You forgot what I really said: "You might be able to limp along by putting emitter followers on the Zener diodes but that is not what I would do."
I know, and I agree with you I would avoid all these problems by making an external dual power supply; but before that I want to try all other possibilities. I prefer to compact it all in the main device, and then use any common 12v source, even if it has some small performance issues.

Also look at it this way: I'm also trying to learn about all these types of power supplies, and what they can and can't do. if I hadn't run into all these problems, and went for the same power supply I did last year for the other function generator, I wouldn't have learn any of this stuff.

If I understand you correctly, you need to read the data sheets for the MAX038 and THS4222 to get the quiescent operating currents. To be sure that you can supply the needed currents, you need to use the maximum currents specified. Then you need to add in the maximum currents that are drawn by any other components/circuits.

Measuring the currents will only get you one example of how much current you will need. The manufacturer of the IC's knows what the _range_ of currents are and they tell you in the specifications.
Thanks, that's exactly what I was looking for; I didn't know that was the right way of doing it.
 
Last edited:

RichardO

Joined May 4, 2013
2,270
I was doing a bit of thinking about what regulator configuration would work for you...

This caused me to realize that a artificial ground (also known as a rail splitter) is a shunt regulator! If anyone is interested in my reasoning, let me know.:)
 

Thread Starter

adam555

Joined Aug 17, 2013
858
This caused me to realize that a artificial ground (also known as a rail splitter) is a shunt regulator! If anyone is interested in my reasoning, let me know.:)
The electronics course I did ended with single supply regulation, and we didn't have time to go through much. So, I'm quite interested in as much as you can share about this subject.

I was doing a bit of thinking about what regulator configuration would work for you...
I didn't have much luck with the transistor regulators. I added the maximum current I would need for all the components and their maximum outputs by looking at their datasheets, and I came up with 350mA for the positive rail and 200mA for the negative. I can make the individual transistor regulators for each rail, but as soon as I try to combine them -adding the virtual ground- they stop working properly.
 
Last edited:

RichardO

Joined May 4, 2013
2,270
I didn't have much luck with the transistor regulators. I added the maximum current I would need for all the components and their maximum outputs by looking at their datasheets, and I came up with 350mA for the positive rail and 200mA for the negative. I can make the individual transistor regulators for each rail, but as soon as I try to combine them -adding the virtual ground- they stop working properly.
The 350 mA and 200 mA agree well with my estimates. :)
Can you post your circuit(s) that do not work? I am a firm believer that you only learn from things that _don't_ work.
 

crutschow

Joined Mar 14, 2008
34,428
If you still want to use a single supply to generate plus and minus regulated voltages with a virtual ground that can handle significant current unbalances, here's a circuit that should work. But it does require a specific series regulator to work (one that can both sink and source output current).
 

Thread Starter

adam555

Joined Aug 17, 2013
858
The 350 mA and 200 mA agree well with my estimates. :)
While calculating the current I ran into a doubt: if the maximum output current of the MAX or opamp is X, do I need to divide it into 2 -for each rail-?

For example: the MAX states 40mA maximum output current (short current), and it's meant to have a 50Ω output resistor. Since its output voltage is 2Vpp (1V peak per rail), then it comes down to 20mA per rail, or 40mA adding both.

In the same way, with the THS4222, it's meant to work with a load up to 100Ω at a maximum output voltage of 10Vpp (5V peak per rail); which comes down to 50mA per rail, or 100mA adding both.

I added 40mA per rail for the MAX, and 100mA per rail for the THS, instead of 20mA and 50mA per rail respectively, as this would account for the worst case scenario; but wasn't sure.

And by the way, do I also need to add that 50Ω output resistor at the output of the MAX, going into the amplitude pot before the opamp? The way it is, without it, when the amplitude pot is at minimum, the MAX output shorts directly to ground without any resistor.

Can you post your circuit(s) that do not work? I am a firm believer that you only learn from things that _don't_ work.
I came up with this circuit for the positive rail:

positive_rail.jpg

and this circuit for the negative:

negative_rail.jpg
But when I combine them like this -I'm obviously not doing it right- I get this result (look at the voltages and currents in the yellow boxes):

both_rails.jpg
If you still want to use a single supply to generate plus and minus regulated voltages with a virtual ground that can handle significant current unbalances, here's a circuit that should work. But it does require a specific series regulator to work (one that can both sink and source output current).
Thanks! Something like that would be ideal. My only concern is fitting it in the small space I have left. If I can't get away with something smaller I'll surely go for it.
 
Last edited:

Thread Starter

adam555

Joined Aug 17, 2013
858
Today I finished the UV exposure box -it's inside an old PC case-. Looks cheap, but for less than a dollar I spent on it, I can't really complain; and it also works. :)

I can now print dual layer PCBs with small tracks and precision...

WP_20141212_004.jpg WP_20141212_003.jpg

... just need to decide which power supply I'm going to use on the function generator.
 

RichardO

Joined May 4, 2013
2,270
In the first 2 power supply circuits your input voltage is 12 volts. In the third circuit the input for each half of the circuit is about 6 volts.
It is subtle but with the 2 power supplies connected as you have them it is like having 2 current sources in series. This is why you get about 200 mA in the "350" mA circuit.

It is going to be hard to get 2 5-volt power supplies out of a single 12 volt power supply. Both of the 5-volt supplies will have to use low dropout regulators such as the LT1118-5 parts in crutschow's circuit.

The best idea I have come up with so far is to supply your circuit with a regulated positive 5 volts at about 600 mA and use an inverting switching power supply to get the negative 5 volts. The Linear Technology LT1931 is an example of a part that can do this using a couple of small inductors and a few R's and C's. TI's TPS6735 also looks interesting since it only needs one inductor.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Thanks Richard; I'm going for this last option. I don't think I'll have problems fitting it if I get the SMD version.

I prefer the LT1931 as the other one provides just 200mA, which is a bit tight. They are not cheap though: $8.50 from China and £6 from the UK on ebay.

While it arrives I'll be making another circuit to test it (hooking the dual power supply I have to the design as it is) so I can begin testing everything else. I already did the PCB today, and it turn out to be a great idea to do this one first; as a lot of things went wrong. I'll let you know how it went and post a picture.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
I finished assambing the test PCB without power supply. It seems to be working quite well, except for 2 issues...

MAX_test_PCB.jpg

The first is the small discontinuity in the middle that you see in the picture. It comes directly out of the MAX's output -though the opamp amplifies it to the size you see- but I think I'll get rid of it once I buy the 1uF ceramic capacitors. At first I tried with only 100nF ceramics on both rails of the MAX, and it was a bit bigger; and then changed them for 1uF electrolitic and 1nF ceramic recommended in the datasheet. I hope I'll get rid of it with the 1uF ceramic; otherwise I guess I can deal with it adding bigger caps.

Also, I'm having some problems with the PIC reading the right frequency. In the picture, the oscilloscope is set at 0.2mS per division -which makes that square wave 500Hz- but the PIC is detecting more than 8KHz. With the PIC connected to the MAX's SYNC output I always had problems reading frequencies under 100KHz. The alternative is changing it to the PDO output, with which I would get the right frequency; but that one only works with frequencies under 1MHz. I always had this problem, and completely forgot to tackle it before finishing the design.

Apart from that, everything else seems to be working well; besides the frequency pot, which is the other way around.

Also just checked that the power supply you recommended (the one with the LT1931) fits in the design; I just need to order the chip, the coupled inductor and the Schottky diode specified in the datasheet and I'm finally done with this project, my very first design. :)
 

RichardO

Joined May 4, 2013
2,270
Congratulations! You now have the first 90% of the project done. You only have 90% to go. :D

The first is the small discontinuity in the middle that you see in the picture.
I think this glitch is from the sync signal. (As I remember, the sync signal is 90 degrees out of phase with the square wave).
Hopefully, better power supply bypassing will get rid of the glitch. If not, you may have the sync signal coupling into the input of the output amp, a poor ground for the bypass capacitors or a ground loop that the sync signal is drawing current through.

Also, I'm having some problems with the PIC reading the right frequency. In the picture, the oscilloscope is set at 0.2mS per division -which makes that square wave 500Hz- but the PIC is detecting more than 8KHz. With the PIC connected to the MAX's SYNC output I always had problems reading frequencies under 100KHz. The alternative is changing it to the PDO output, with which I would get the right frequency; but that one only works with frequencies under 1MHz. I always had this problem, and completely forgot to tackle it before finishing the design.
This one could be either hardware or software... You need to make sure that the sync signal at the PIC input pin is clean without any wiggles or oscillations. If the sync signal is clean then I would vote for a software problem. Posting your code would be needed to help with that.
 
Top