MAX038 Function Generator Design

tindel

Joined Sep 16, 2012
936
A few things that jump out... though I haven't critiqued heavily.
  • It appears that you have 6 or 7 traces that have not been routed.
  • The output of function generators typically have a 50 ohm resistor - 2W inside that protect the device from shorting and to help with 50 ohm transmission lines (50 ohm coax). You could get away with a 1W resistor if you're still using a 5V supply, but I wouldn't go any smaller. This will create 100mA short current... and 50mA operating currents... this can cause voltage dips on the power rails if too small of a trace is used... because of this - I offer up the next two suggestions:
  • You do not have a high-side power plane... typically you will see a plane on the top and bottom... usually one will be power and the other will be ground... I suggest doing a power fill on the top layer once all your routing is complete.
  • 1uF seems like pretty large decoupling capacitance for high-speed design... you probably want more on the order of 0.01uF ceramic as close to the part as possible (really, making the smallest loop possible), 0.1uF ceramic right next to those, and then some bulk caps on the order of one or two 4.7uF tantalum spread out on the card. I have taken this approach on my high speed designs and I have never had a problem. I usually leave out the 0.01uF capacitors if there is nothing over 1MHz going on with the chip I'm trying to decouple.
  • I'd also design my output stage amplifier traces properly for a 50 ohm transmission line or add the 50 ohm resistor and keep it as close to the BNC as possible... possibly doing a little bit of both.
With that said... with the exception of the first bullet, your design will probably be 'Good?... Enough!', as my boss likes to say, if you proceeded with the current design... and would make a good functioning function generator. These are just the other suggestions that us anal types like to make sure are designed correctly.
 

bance

Joined Aug 11, 2012
315
Pretty sure you can simplify somewhat by swapping some pin numbers around on the MCU. Pins 1&2 for example...
HTH Steve.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Thanks Tindel. I'll check all those issues with more time and get back to you later today.

Well if you want please send me the files and I can try printing them out for you and if you like them I can send them to you....
Yes, sure; thanks a lot! But I'm having a lot of problems doing toner transfers. I tried it 3 times in my cyber-cafe's laser printer, and these where the results:

In the first one, the only one I etched, the toner transfer wasn't strong enough so there's no continuity in most tracks...

WP_20141128_010.jpg WP_20141128_006.jpg

In the second and third trials, which I didn't etch, I tried to solve the problem by doing 2 transfers per side, and on some parts I still got a weak transfer...

WP_20141128_004.jpg

... while in other parts the toner went over the spaces. Also, in one of the second transfers it moved a bit, as it is quite difficult to match them with precision; so that was another trial that I had to re-do.

WP_20141128_005.jpg

I'll attach the files anyway, but don't send them yet; I think I can manage with the marker -even though those thin tracks on the op-amp are going to be really though.

In any case, if I have problems, I already ordered all the parts and products to do photo-tranfers. I just need to wait a month for them to arrive; which is fine, as I'm not in any hurry.

Hola Adam

Could you please change the black background to white? I do not know why actually, but reading that schematic as is, is very hard for me. Age counts, maybe...:(

Gracias.
Yeah, sure. I attached another one with the background in white. Might still not be good enough -as I captured those images- so you might like to see it through the files I uploaded to Dr. Killjoy.

Pretty sure you can simplify somewhat by swapping some pin numbers around on the MCU. Pins 1&2 for example...
HTH Steve.
Yes, I already thought about that; but then dropped the idea because it would involve reprogramming the PIC and I wasn't absolutely sure about the final position of the PIC. It wont be too difficult, but it will take additional subroutines to reorder the bits of the data sent out to the LCD.

I also wasn't bother too much with those 4 pins, and gave preference to other tracks, because those carry digital data, and I supposed they still would work well even through an external wire. The one what worries me is the SYNC, which carries the high frequency signal for the PIC to read.
 

Attachments

Last edited:

Thread Starter

adam555

Joined Aug 17, 2013
858
A few things that jump out... though I haven't critiqued heavily.
Thanks, and sorry for the delay; I needed to check some things first.

It appears that you have 6 or 7 traces that have not been routed.
I now routed pins 1 and 2 of the PIC by re-routing another track, but I still have 5 left. I can't get those, so I will connect them with a wire outside the PCB. Four of them carry digital data to the LCD, so don't worry me much, but the last one carries a high frequency square wave (up to 20Mhz).

The output of function generators typically have a 50 ohm resistor - 2W inside that protect the device from shorting and to help with 50 ohm transmission lines (50 ohm coax). You could get away with a 1W resistor if you're still using a 5V supply, but I wouldn't go any smaller. This will create 100mA short current... and 50mA operating currents... this can cause voltage dips on the power rails if too small of a trace is used... because of this - I offer up the next two suggestions:
I had a 50Ω resistor at the output of the MAX, as the datasheet's schematics suggest, but took it off when I added the op-amp; which also has a 1k potentiometer between them, but it's output is directly connected to the BNC connector.

You do not have a high-side power plane... typically you will see a plane on the top and bottom... usually one will be power and the other will be ground... I suggest doing a power fill on the top layer once all your routing is complete.
I'm not sure what "high-side power plane" and "power fill" mean. Do you want me to make the +5V and the -5V wider or make them fill the empty spaces on the bottom side?

1uF seems like pretty large decoupling capacitance for high-speed design... you probably want more on the order of 0.01uF ceramic as close to the part as possible (really, making the smallest loop possible), 0.1uF ceramic right next to those, and then some bulk caps on the order of one or two 4.7uF tantalum spread out on the card. I have taken this approach on my high speed designs and I have never had a problem. I usually leave out the 0.01uF capacitors if there is nothing over 1MHz going on with the chip I'm trying to decouple.
I used 1uF caps for the MAX038 because it's what its datasheet recommends for all configurations. I just noticed that if I use electrolytic caps I also need to use a 1nF ceramic; as the datasheet states: "bypass capacitors are 1μF ceramic or 1μF electrolytic in parallel with 1nF ceramic".

I'd also design my output stage amplifier traces properly for a 50 ohm transmission line or add the 50 ohm resistor and keep it as close to the BNC as possible... possibly doing a little bit of both.
I just added the 50Ω resistor next to the BNC connector; but not sure what you mean by "design output traces properly for 50 Ω"; you mean wider?

With that said... with the exception of the first bullet, your design will probably be 'Good?... Enough!', as my boss likes to say, if you proceeded with the current design... and would make a good functioning function generator. These are just the other suggestions that us anal types like to make sure are designed correctly.
'Good?... Enough!' for you is a compliment for me. :)

Please post any other suggestion you might have. Apart from doing it right I also want to learn from it.
 

tindel

Joined Sep 16, 2012
936
I'd personally get those last few traces on the board... much easier to do it once than every single time... don't be afraid to put a few short traces on the back of the board - but do it smart too... electrons are lazy... they always take the path of least resistance... and high frequency electrons are even more lazy... high frequency electrons tend to want to go thru large copper planes in the exact same path as they went to the load (I.E. a mirror of the traced path, see: https://www.sigcon.com/Pubs/news/8_08.htm for more info). I would get that 20MHz square wave placed with a good return path... you need that placed... even though it's a 20MHz square wave, it will have harmonics up to 200MHz pretty easily...

For the 50 ohm impedance... use something like this: http://www.eeweb.com/toolbox/microstrip-impedance to determine the impedance of your transmission line on the card try to make it close to 50 ohms. Most function generators have 50ohms on the output... mainly to limit the current during short circuit events. This has the negative effect that DC voltages will be half of the drive voltage by the time you terminate your transmission line, but usually this is an acceptable trade because you can make the signal drive twice the voltage. More info: http://www.allaboutcircuits.com/vol_2/chpt_14/4.html

In regards to the copper fills... I forgot you were using +/- 5V as your rails - it's a tad bit hidden in the schematic... In that case (the case of having 3 power rails +5 / -5 / GND, I'd put a GND copper fill on both sides once you're done with your layout and bulk up your power traces a bit... this just helps reduce the impedance of your power rails and gound plane and never will not hurt you...

Nice work on your pwb print outs... you're almost there... It looks like your first run was almost perfect... you just need a sharpie marker to fill in the poor toner areas.
 

atferrari

Joined Jan 6, 2004
4,769
I'd personally get those last few traces on the board... much easier to do it once than every single time... don't be afraid to put a few short traces on the back of the board - but do it smart too... electrons are lazy... they always take the path of least resistance... and high frequency electrons are even more lazy... high frequency electrons tend to want to go thru large copper planes in the exact same path as they went to the load (I.E. a mirror of the traced path, see: https://www.sigcon.com/Pubs/news/8_08.htm for more info). I would get that 20MHz square wave placed with a good return path... you need that placed... even though it's a 20MHz square wave, it will have harmonics up to 200MHz pretty easily...
Good tindel! Short and to the point. Thanks for sharing.

This sentence got me thinking: At high speeds, the inductance of a given return current path is far more significant than its resistance. High-speed return currents follow the path of least inductance, not the path of least resistance.

Wow!:eek: :eek:
 

tindel

Joined Sep 16, 2012
936
That is a powerful sentence... I would change the sentence to read: At high speeds, the inductance of a given return current path is far more significant than its resistance. All currents follow the path of least impedance (Z), not the path of least resistance (R). That's splitting hairs though. Dr. Howard Johnson really knows his stuff... he literally wrote the book on high speed design. I got a chance to meet Dr. Johnson one time during a conference he was doing. I learned so much during that conference. That website is FULL of information for folks that are serious about high speed design - analog or digital.

Anyway - I'm getting a bit off-topic.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
The main problem with getting those tracks on the board through the top plane is that I will have to do a dual layer by hand with a marker; which will be extremely difficult. The way it is, with the top plane entirely as ground, I just need to cover it all when etching, and then drill the copper off where the components go (as RichardO suggested); but I don't think I'll be able to draw tracks on the top plane and make them match with the bottom precisely by hand. That's the main reason I didn't go with a dual layer from the beginning; I wasn't even going to use a ground plane -that's why I was going for a predrilled PCB-, until RichardO suggested it.

About the 20Mhz digital signal: will it not work with a shielded wire instead; e.g. one of those small shielded cables used in audio?

Regarding the return path, and sorry for asking such a basic question -I didn't even know what a return path was before reading that the document you linked-, if I understood correctly, the main point is making sure that there is a return path on the ground plane following the same route under the path of every high frequency line; is that it?

I couldn't use the Microstrip Impedance calculator because I don't know the Trace Thickness and the Substrate Dielectric. I bought these boards by the dozen from China and came without any type of specifications. Thanks for posting it anyway; I also didn't know anything about that subject, but I'm sure it will be useful for future projects.

I added a ground fill on the bottom plane, as you suggested; connected 2 of the 7 unconnected ratlines, and got another 4 closer for the jumper wires to be as short as possible; made more space around the opamp; increase the width of power lines wherever possible (using 0.05" for power, and 0.032" for the rest), which I guess it doesn't matter much, since I'm doing it by hand; added additional 1nF ceramic caps to the MAX's 1uF electrolytic caps, as suggested in the datasheet; and rearranged the layout a bit.

If you see the attachments you might notice that the opamp is now on the same space as resistor R21 -I couldn't find any other way-. I hope this is fine, since the opamp goes on the bottom plane with the tracks, while R21 goes on the top.
 

Attachments

Last edited:

bance

Joined Aug 11, 2012
315
Maybe try turning the PIC 90 deg clockwise and the other IC 90 degrees counterclockwise....
layout is an iterative process don't be afraid to just start over.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Maybe try turning the PIC 90 deg clockwise and the other IC 90 degrees counterclockwise....
layout is an iterative process don't be afraid to just start over.
Thank you for the suggestion; I think I just got the 20Mhz line connected through the bottom plane. Been trying all configurations for more than a week; starting from the beginning over and over again dozens of times. I got the best results with the PIC just under the LCD's row of pins; but if I do it that way I would need a bigger board to place all the controls and the power supply in an accessible place, while leaving the central area under the display practically empty.
 
Last edited:

bance

Joined Aug 11, 2012
315
It looks to me that there are all sorts of islands in there, there does not appear to be a plane at all.....
I think you have the ground plane on the top layer?
 
Last edited:

tindel

Joined Sep 16, 2012
936
You'll have to figure out how to line-up the top and bottom layer... because of the copper voids in your planes... there are some youtubes that show how to do this.

Like I said - it's probably 'Good?... Enough!' if you want to build it and get something working... go for it! I was just offering suggestions for improvements and further learning, really.

Regarding the return path, and sorry for asking such a basic question -I didn't even know what a return path was before reading that the document you linked-, if I understood correctly, the main point is making sure that there is a return path on the ground plane following the same route under the path of every high frequency line; is that it?
Yes, I think you understand the concept. You want a return path for all of your currents... usually at DC through ~1MHz this is simply the ground plane... for higher currents, the return path is usually the closest plane to the source path... think of all of your currents in loops... every time current moves it has to go back to the same place it came. The higher the frequency becomes the more likely it is to return via the same route that it came because it is the lowest impedance path because it is also the lowest inductance path.

I couldn't use the Microstrip Impedance calculator because I don't know the Trace Thickness and the Substrate Dielectric. I bought these boards by the dozen from China and came without any type of specifications. Thanks for posting it anyway; I also didn't know anything about that subject, but I'm sure it will be useful for future projects.
It looks like you put a 50 ohm resistor as close to the output as you reasonably could, so you will probably be okay. Do note that this will reduce your output voltage by half if you properly terminate your 50 ohm transmission line. If you want to get rid of the 50 ohm resistor, I'd suggest using the calculator to calculate the trace width so that you can use proper 50 ohm impedance transmission lines. This will have the benefit of getting the entire voltage on the output, but have the downside that a short may take out your op-amp - or more. You can calculate your trace width by using calipers to figure out your board thickness, subtract out your copper thickness (usually 1oz copper (o.0014")). FR4 relative permeability Er is 4.8, so that will get you in the ballpark... it doesn't have to be perfect, just close. Assuming your board thickness is about 64 mil - this would make the trace about 120 mil wide - pretty thick. usually you want to keep voids around the trace, just as thick as the trace itself... so this will get you around 120mil * 3, about 3/8" wide.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Just finished re-arranging the design to connect that 20Mhz digital line with a track through the bottom plane; for which I needed to add an additional row at the top.

I think you have the ground plane on the top layer?
Yes, the top is the ground plane; all the tracks go on the bottom plane, to which I also added a ground fill as suggested by tindel.

You'll have to figure out how to line-up the top and bottom layer... because of the copper voids in your planes... there are some youtubes that show how to do this.
Now that I connected that 20Mhz line, and with the exception of those 4 jumper wires that I need to connect the PIC to the LCD data, I don't need to use tracks on both layer; so I just need to cover the ground plane completely while etching, and draw the tracks only on the bottom plane. I also won't need to align them, as I can first drill the pad's holes, and use those as a guide to use a wider drill bit for the space between each pin and the ground on the top plane; which makes is far easier.

Like I said - it's probably 'Good?... Enough!' if you want to build it and get something working... go for it! I was just offering suggestions for improvements and further learning, really.
I was just saying that I took that 'Good?... Enough!' as a compliment. You have definitely touch a lot of subjects that I never even heard about before; so please continue.

Yes, I think you understand the concept. You want a return path for all of your currents... usually at DC through ~1MHz this is simply the ground plane... for higher currents, the return path is usually the closest plane to the source path... think of all of your currents in loops... every time current moves it has to go back to the same place it came. The higher the frequency becomes the more likely it is to return via the same route that it came because it is the lowest impedance path because it is also the lowest inductance path.
Since I'm leaving the top plane entire as ground, I'm pretty sure there will be a good return path under every high frequency line. I checked it anyway; just in case.

It looks like you put a 50 ohm resistor as close to the output as you reasonably could, so you will probably be okay. Do note that this will reduce your output voltage by half if you properly terminate your 50 ohm transmission line. If you want to get rid of the 50 ohm resistor, I'd suggest using the calculator to calculate the trace width so that you can use proper 50 ohm impedance transmission lines. This will have the benefit of getting the entire voltage on the output, but have the downside that a short may take out your op-amp - or more. You can calculate your trace width by using calipers to figure out your board thickness, subtract out your copper thickness (usually 1oz copper (o.0014")). FR4 relative permeability Er is 4.8, so that will get you in the ballpark... it doesn't have to be perfect, just close. Assuming your board thickness is about 64 mil - this would make the trace about 120 mil wide - pretty thick. usually you want to keep voids around the trace, just as thick as the trace itself... so this will get you around 120mil * 3, about 3/8" wide.
I'll leave the 50 Ω resistor -since it's already well placed- and make that track as wide as possible.
 
Last edited:

RichardO

Joined May 4, 2013
2,270
Wow. A lot has happened while I wasn't looking.

Some things I noticed:
You need to connect the unused pins of the THS4222. Connect pins 6 and 7 together and ground pin 5.

The gain of the THS4222 seems a bit high and the feedback resistor is the wrong value. You must use a 2 K ohm feedb ack resistor -- any other value will cause either a reduction in bandwidth or peaking in the frequency response.
The input resistor (R21) should be more like 510 ohms.

The traces going to and from the THS4222 look way to long to me.

Your shunt regulated power supply will not work well when the output is driving an external 50 ohm termination resistor.

All bypass caps other than the 10 uF bulk bypass capacitors should be ceramic types.

You want the ceramic bypass capacitors on both the MAX038 and THS4222 power pins.

The values on the Fadj and Iin pins of the MAX038 don't look quite right to me.


... My laptop battery is dieing so more later...
 

Thread Starter

adam555

Joined Aug 17, 2013
858
Wow. A lot has happened while I wasn't looking.
Glad you're back. :)

Some things I noticed:
You need to connect the unused pins of the THS4222. Connect pins 6 and 7 together and ground pin 5.

...

All bypass caps other than the 10 uF bulk bypass capacitors should be ceramic types.

...

You want the ceramic bypass capacitors on both the MAX038 and THS4222 power pins.
I just connected the unused pins of the THS4222 and added 100nF bypass ceramic capacitors to it. Also changed all other bypass capacitors of ICs to ceramic.

The gain of the THS4222 seems a bit high and the feedback resistor is the wrong value. You must use a 2 K ohm feedb ack resistor -- any other value will cause either a reduction in bandwidth or peaking in the frequency response.
The input resistor (R21) should be more like 510 ohms.
It's quite confusing in that area: the feedback resistor is R22, which is 4.7k; and the input resistor is R21, which is 1k. Those where the values I've been using in the breadboard with the AD822AN opamp. Should I use different values for the THS4222?

The traces going to and from the THS4222 look way to long to me.
I had to use long tracks for both supply rails -there was no other way- but I think the opamp input and output are fairly short; just marked them in this image for clarity:

opamp_in-out.jpg

Your shunt regulated power supply will not work well when the output is driving an external 50 ohm termination resistor.
How can I fix that issue without changing much the power supply; should I take the 50Ω resistor off, recalculate the regulator to account for the resistor, or maybe add transistors for better regulation?

The values on the Fadj and Iin pins of the MAX038 don't look quite right to me.
I have a 20k pot plus a 1k limiting resistor on the FADJ; which will allow me to select the recommended 12k on the datasheet. It's what I've been using in the breadboard, and worked fine up to now.

The datasheet recommends a 20k pot for the Iin, but I got better results using 1M and 100k pots with a 10k limiting resistor in the breadboard. Both worked well, but the 1M gives me too much range and little precision, while the 100k is a tiny bit short for the range caps I've used. The ideal would be a 200k pot, but I couldn't get that value, so I went for the 100k.

... My laptop battery is dieing so more later...
Thanks for all your help.
 

RichardO

Joined May 4, 2013
2,270
It's quite confusing in that area: the feedback resistor is R22, which is 4.7k; and the input resistor is R21, which is 1k. Those where the values I've been using in the breadboard with the AD822AN opamp. Should I use different values for the THS4222?
Yes. The AD822 is a low frequency op-amp. The THS4222 is a very high frequency op-amp. The THS4222 data sheet shows a 2 K Ohm resistor for a gain of 5. that is what I would use. The value is not as critical as I was thinking in my earlier post since the THS4222 is a voltage, not current, feedback amplifier. Even with the 2K feedback resistor, just a few pF of capacitance will effect the bandwidth of the amplifier. Note that at a gain of 5, your amplifier only has a bandwidth of about 25 MHz. This is because the gain bandwidth product of the part is only 120 MHz. You may want to consider using both amplifiers of the part each with a voltage gain of about 2.2.

Re-read pages 14 through 19 of the THS4222 data sheet for resistor values and bypassing recommendations.

I have a 20k pot plus a 1k limiting resistor on the FADJ; which will allow me to select the recommended 12k on the datasheet. It's what I've been using in the breadboard, and worked fine up to now.

The datasheet recommends a 20k pot for the Iin, but I got better results using 1M and 100k pots with a 10k limiting resistor in the breadboard. Both worked well, but the 1M gives me too much range and little precision, while the 100k is a tiny bit short for the range caps I've used. The ideal would be a 200k pot, but I couldn't get that value, so I went for the 100k.
I am not sure why you have 2 frequency setting pots...

How can I fix that issue without changing much the power supply; should I take the 50Ω resistor off, recalculate the regulator to account for the resistor, or maybe add transistors for better regulation?
The right way of doing it is to supply positive and negative unregulated input voltages to positive and negative 5-volt regulators. As I have said, making an artificial ground will not work very well. The problem is not the 50 ohm resistor. Instead, the problem is the current into your external circuit under test. This load current can cause large current mismatches (as much as 100 mA) on the plus and minus power supplies. You might be able to limp along by putting emitter followers on the Zener diodes but that is not what I would do.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
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.

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.

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.

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?

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?

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.
 
Last edited:
Top