Author Topic: simple analog function generator design  (Read 36984 times)

0 Members and 1 Guest are viewing this topic.

Offline buck converterTopic starter

  • Regular Contributor
  • *
  • Posts: 165
  • Country: us
simple analog function generator design
« on: March 30, 2017, 10:04:50 pm »
This is my very first post!
I am Teen hobbyist and can't justify buy signal generator, so thought i could learn something by building one (crappy Chinese kit does do not count). I want it to be analog. I was thinking of something like this, But want to add adjustable amplitude and offset.

How much bandwidth can I expect from this if I use a good enough op amp.
For amplitude adjustment,  can use a classic inverting amplifier? Or is there any reason it should be non-inverting?
for the offset adjustment, Which op amp has necessary bandwidth and a null adjustment?
Just me and my scope.
 
The following users thanked this post: ali6x944

Offline TimFox

  • Super Contributor
  • ***
  • Posts: 8693
  • Country: us
  • Retired, now restoring antique test equipment
Re: simple analog function generator design
« Reply #1 on: March 30, 2017, 10:10:22 pm »
In your circuit, the square wave will have a constant amplitude with frequency, but the triangle wave amplitude will fall off as 1/(freq) and the filtered triangle wave will not look very sinusoidal at low frequencies.
A normal function generator starts off with an integrator for the triangle generator, with the current into the integrator reversing when the triangle reaches positive and negative thresholds for a Schmitt-trigger comparator, which also gives the square wave.  The sine-wave output requires a non-linear circuit (resistors, diodes, etc.) after the triangle wave that does not vary with frequency.
 
The following users thanked this post: ali6x944

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20080
  • Country: gb
  • 0999
Re: simple analog function generator design
« Reply #2 on: March 30, 2017, 10:15:18 pm »
The problem with that circuit is the frequency cannot be adjusted, without also altering the amplitude of the signal. Increasing the frequency will also reduce the amplitude. A triangle wave oscillator and waveshaping circuit can be used to provide adjustable frequency with very little change in amplitude.

Another op-amp based amplifier can be used to alter the amplitude and offset.
 
The following users thanked this post: ali6x944

Offline buck converterTopic starter

  • Regular Contributor
  • *
  • Posts: 165
  • Country: us
Re: simple analog function generator design
« Reply #3 on: March 30, 2017, 10:20:48 pm »
How much bandwidth can I expect from this circuit if i used a faster op amp and another to amplify the output ?


Another op-amp based amplifier can be used to alter the amplitude and offset.

Which op amp has a null pin and can handle the bandwidth?
Just me and my scope.
 
The following users thanked this post: ali6x944

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: simple analog function generator design
« Reply #4 on: March 31, 2017, 12:07:00 am »
A lousy old LM324 was the first quad opamp designed to use low supply current. Therefore it has crossover distortion, hiss and a problem at high levels with frequencies above only 2kHz as shown in its datasheet.
Every single opamp has offset null pins. Every audio opamp has low distortion, low hiss and good response to at least 100kHz. Look at the OPA134 single, OPA2134 dual and OPA4134 quad audio opamps.
 
The following users thanked this post: ali6x944

Online MrAl

  • Super Contributor
  • ***
  • Posts: 1618
Re: simple analog function generator design
« Reply #5 on: March 31, 2017, 01:17:28 am »
Hello,

First, there is a circuit on the web that does the square and triangle and doesnt need amplitude adjustment.

Second, the output is not a sine wave.  It is close but it is more like an x^2 wave over the short period.  Also, the output of that second integrator will always need adjustment as the frequency is adjusted.

So it will work as is but needs three different adjustments.  With the circuit on the web you need two adjustments.
 
The following users thanked this post: ali6x944

Offline cncjerry

  • Supporter
  • ****
  • Posts: 1317
Re: simple analog function generator design
« Reply #6 on: March 31, 2017, 03:06:28 am »
At one time there was an analog generator on a chip, it was made by XR, like an XR2210?? and didn't cost much at all.  I used to have one and if I can find it, it would be yours and I'll even cover the postage.  I think you just needed a couple of switches, pots and extraneous parts for a decent little generator to maybe 100K.

The other way to make one is to use a switched capacitor LP filter that runs right at the frequency of the incoming square wave.  You don't get a triangle wave but square and sine. The switched cap filter takes the harmonics out of the square wave to make the sine.  You would use a PLL chip to do fractional N divide of the clock.  I built one with all discrete components years ago and thought it was pretty interesting design because the amplitude was pretty constant and clean.  Not my design, one of the engineers at IBM designed it. I can't remember how the filter worked but it was easy to interface.

If you look up the schematics for the FG modules that go into the TM500 frames you can see how they did the sine, triangle and square, but not in that order.

These days on eBay you can pickup a signal generator for the cost of a slice of pizza.  I'll look for that XR chip and let you know if I find it.

Years ago I spent a lot of time on these circuits and I can't remember why.  It might have been before PCs had sound cards
 
The following users thanked this post: ali6x944, buck converter

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20080
  • Country: gb
  • 0999
Re: simple analog function generator design
« Reply #7 on: March 31, 2017, 08:12:29 am »
How much bandwidth can I expect from this circuit if i used a faster op amp and another to amplify the output ?
You haven't even stated your requirements yet, so it's a bit premature to look at different op-amps.

The first thing you'll notice bandwidth wise, with that circuit, is the slew rate limitation of the op-amp, which is around 0.5V/µs or 2µs/V, so if your square wave has an amplitude of 20V peak-to-peak, then the rise and fall times will be 40µs. As the frequency is increased, the square wave will start to look more like a triangle wave and when the period becomes 80µs or less (a frequency of >12.5kHz) it will be a triangle wave. Of course, the maximum usable frequency will be much less than 12.5kHz, as by then it's no longer a square wave.
http://www.ti.com/product/LM324

A faster op-amp will give much faster rise and fall times. For example the TL072 has a slew rate of 13V/µs or 77ns/V. With a 20Vp-p square wave the rise and fall times will be 1.54µs.
http://www.ti.com/product/TL072?keyMatch=TL072&tisearch=Search-EN-Everything

Ideally the squarewave section should use a comparator IC, such as the LM393 or LM311, which is designed for this, so the squarewave section will no longer be the limiting factor. The op-amp's slew rate will then limit the maximum slope of the triangle wave and thus the frequency, as calculated above.

Quote
Another op-amp based amplifier can be used to alter the amplitude and offset.

Which op amp has a null pin and can handle the bandwidth?
There is no need for a null pin. An inverting amplifier with the non-inverting pin connected to the offset voltage will introduce the offset you require.
« Last Edit: March 31, 2017, 08:14:40 am by Hero999 »
 
The following users thanked this post: ali6x944

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14915
  • Country: de
Re: simple analog function generator design
« Reply #8 on: March 31, 2017, 09:34:01 am »
Like already written: It is much better to start with a combined triangle / square oscillator with just one frequency setting capacitor, and nonlinear sine shaping.

With a suitable choice of OPs / comparator a upper frequency in the 1 MHz range is reasonable. HP got it considerably faster ( >20 MHz) this way, this usually included special chips for the sine shaping. For a beginner I would stick to about 100 kHz, maybe 1 MHz with less perfect waveform.

The offset adjustment pins at OPs are there to compensate the OPs internal offset, thus maybe +-10 mV. If used for more or other offsets the drift performance of the OP can deteriorate - so it is generally not a good idea to use it for another purpose.
 
The following users thanked this post: ali6x944

Offline SingedFingers

  • Frequent Contributor
  • **
  • Posts: 599
  • Country: gb
Re: simple analog function generator design
« Reply #9 on: March 31, 2017, 10:04:04 am »
Cheapest decent solution:

1. Buy one of these http://www.taydaelectronics.com/xr-2206-xr2206cp-xr2206-monolithic-function-generator-ic.html
2. Download this: https://archive.org/download/ExarFunctionGeneratorDataBook/ExarFunctionGeneratorDataBook.pdf
3. Refer to page 42.

Building a usable function generator from opamps needs:

1. One current source and sink, driven via a control circuit to ensure linearity.
2. Diode switch
3. Switchable bank of capacitors
4. Two comparators and a bistable.
5. Various offset and amplitude controls and opamps.
6. Sine shaper
7. Various switching for the above signals.
8. power amplifier.

It all starts with a couple of ramp generators. One that fills up a capacitor and one that drains it and the comparators switch between charge/drain. This gives constant amplitude and frequency dependent on the charge current and you just use a few stacked diode limiters to approximate a sine wave.

XR2206 has a big chunk of that in one IC. You can add a potentiometer on the output to control level, then a summing amplifier for offset, then a pair of driving transistors (bd139/140 or 2n2219/2n2905 are a good bet) as a power amplifier with a couple of 50R resistors in parallel to give a reasonable approximation of 50 ohms.

If you want an audio generator any old opamp with a 28v bulb in the feedback loop makes a pretty good low distortion sine oscillator.
« Last Edit: March 31, 2017, 10:07:43 am by SingedFingers »
 
The following users thanked this post: ali6x944, buck converter

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20080
  • Country: gb
  • 0999
Re: simple analog function generator design
« Reply #10 on: March 31, 2017, 10:39:43 am »
There are plenty of triangle wave generator circuits on the Internet. The trouble is, many of them aren't very good. They normally use an op-amp as a comparator (like the circuit posted by the OP here) or a comparator IC with a pull-up resistor which results in an asymmetrical waveform.

Attached is a circuit for a triangle wave generator, which gives a fairly symmetrical wave shape (providing the power supply rails are balanced) and should work up to around 100kHz. Higher frequencies will  require a faster comparator and op-amp.



U1b forms a Schmitt trigger with the upper and lower thresholds equal to 2/3 of the power supply rails = 10V. U1a has its inputs connected to the opposing inputs of U1b and drives Q1 which pulls the output of U1b very close to +V when U1b is high. The result is a Schmitt trigger circuit with a near rail-to-rail output.

U2a is an integrator with a time constant determined by C1 and R1.

Changing the values of C1 & R1 alter the frequency but the amplitude remains a constant +/-10V.

The operation of the circuit is described in the site linked below:
http://www.falstad.com/circuit/e-triangle.html


As far as the sine wave is concerned, you need a wave shaping circuit for that. I found this circuit on the Internet awhile ago but can't remember the source.

It's designed for a +/-4V signal source but will work with my circuit if R1 is increased to 2k5. In fact, I'd make R1 a 2k2 resistor and a 500R trimmer, as it will probably need some adjustment to get a clean sine wave.


https://www.eevblog.com/forum/projects/function-generator-ics/msg66399/#msg66399

There are other ways to do this. See the following links:
http://www.kelm.ftn.uns.ac.rs/literatura/mi/pdf/Wave-Shaping.pdf
http://www.intersil.com/content/dam/Intersil/documents/ca31/ca3140-a.pdf
http://www-personal.engin.umd.umich.edu/~fmeral/ELECTRONICS%20II/03%25c3-Diodes/02a-Diode%20Waveshape%20Illus.pdf
« Last Edit: March 31, 2017, 11:07:01 am by Hero999 »
 
The following users thanked this post: dentaku

Offline SingedFingers

  • Frequent Contributor
  • **
  • Posts: 599
  • Country: gb
Re: simple analog function generator design
« Reply #11 on: March 31, 2017, 11:20:21 am »
Another shaper, from "Art of Electronic Student Manual" pp 203. Built one of these back in the day and it worked pretty well:



Basically symmetric diode clamps. Each pair clamps at a portion of the wave. Think the above was adapted from a Krohn Hite function generator schematic. Needs a very low impedance drive that can sink and source well (pair BJTs/opamp) and a high impedance on the next stage (JFET follower/opamp)

Some of the cheaper Tek function generators use a similar arrangement albeit slightly obfuscated.

However all of these look like shit if you stick them through a relatively ideal differentiator though. If you need a pure sine, then a wein oscillator is the way to go.
« Last Edit: March 31, 2017, 11:23:37 am by SingedFingers »
 
The following users thanked this post: buck converter


Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20080
  • Country: gb
  • 0999
Re: simple analog function generator design
« Reply #13 on: March 31, 2017, 12:11:24 pm »
I've simulated the sine wave shaper in my previous post and it works quite well. I didn't bother connecting it to the triangle wave generator circuit because it would have taken ages to simulate. I used a +/-10V triangle wave voltage source to simulate it.



I used a sinewave voltage source for comparison and it's quite good. It might not work as well in real life with the not so perfect triangle wave, slight differences in +/-V and mismatches in D1 to D6.
 
The following users thanked this post: ali6x944, buck converter

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: simple analog function generator design
« Reply #14 on: March 31, 2017, 08:29:20 pm »
Those XR2206 ICs work pretty well, they do pretty much exactly what you're trying to do, and do it better and at a lower cost.

If you really want to build something with op-amps, I've always been fond of the classic HP-invented incandescent lamp stabilized audio oscillator. It only makes a sine wave but it does it really well.

From that you could derive a square wave if you wanted, using a 74ALC14 will give you very fast rise and fall times although the output will be TTL levels rather than a full range.
 
The following users thanked this post: ali6x944

Offline buck converterTopic starter

  • Regular Contributor
  • *
  • Posts: 165
  • Country: us
Re: simple analog function generator design
« Reply #15 on: March 31, 2017, 09:57:03 pm »
Thank you Hero999 for your schematics and simulations. I will your design when the parts come. For a split power supply, would this work?http://www.ebay.com/itm/3W-DC-DC-Boost-Converter-3-3V-12V-to-15V-Output-Step-up-Power-Supply-Module-/141755085768?hash=item210142f3c8:g:kb4AAOSwgQ9V2bvM
Just me and my scope.
 

Online MrAl

  • Super Contributor
  • ***
  • Posts: 1618
Re: simple analog function generator design
« Reply #16 on: March 31, 2017, 10:34:17 pm »
Hi,

Funny story...
I clicked on this thread to read what replies might have come in and i saw the name "buck converter" and so for a second or two i thought i clicked on the wrong thread :-)

Just a note, but if you wanted to you could simulate all of the circuits shown in this thread so far using LT's simulator and look at the Fourier components.  That would tell you the distortion present in the pseudo sine.  You could then play around with the resistor values to see if you could improve it.  I have a feeling they may be optimized already, but you never know.  If you cant get it better then the circuit is probably optimized already for the resistor values and any other parameters.

There's also a wave shaper circuit that uses transistors instead of diodes.  That is used in at least one of the BK function generators i know of.  I believe that is what is used in the 8038 chips as well as the XR chips for shaping.  They may have chosen transistors over diodes because of the impedance benefits.
There was also a chip that went up to 20MHz that used shaping (the others usually only go up to 1MHz).  That chip was discontinued though and if you find one today i think it is quite expensive. 
The DSP chips and modules are pretty cheap so you can generate sines, and they go from something like 0.01Hz to 40MHz under 32 bit word control of the frequency.

My experience with the wave shaper circuits is that they usually have a somewhat pointed top but it's not really really bad.  It would be unsuitable for some tests and suitable for other less demanding tests.  For example if you wanted to use it to stimulate an audio amplifier and then check the THD out of the output, it would be quite unsuitable, but if you just want to test some inductors or capacitors with a sine wave input it should work good enough.  I used one years and years ago (8038 chip) for just general amplitude gain testing, but never for THD analysis.
« Last Edit: March 31, 2017, 10:45:34 pm by MrAl »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9941
  • Country: us
Re: simple analog function generator design
« Reply #17 on: March 31, 2017, 11:12:13 pm »
Thank you Hero999 for your schematics and simulations. I will your design when the parts come. For a split power supply, would this work?http://www.ebay.com/itm/3W-DC-DC-Boost-Converter-3-3V-12V-to-15V-Output-Step-up-Power-Supply-Module-/141755085768?hash=item210142f3c8:g:kb4AAOSwgQ9V2bvM

Characterized as 120 mV of ripple - that's kind of noisy.  Maybe a couple of 100 ufd electrolytic capacitors will help.  Plus the usual 0.1 ufd ceramic capacitors, of course.

Switching regulators are always more noisy than linear regulators but they are often cheaper to build.  Look around and see if you can find a dual (or triple) output supply with far less than 100 mV of noise.

Sometimes those links with 'hash=...' are problematic.
http://www.ebay.com/itm/3W-DC-DC-Boost-Converter-3-3V-12V-to-15V-Output-Step-up-Power-Supply-Module-/141755085768
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: simple analog function generator design
« Reply #18 on: March 31, 2017, 11:41:40 pm »
Are we talking a power supply for the function generator, or a bench power supply? If the former then building one out of a 78xx and 79xx linear regulator is likely a better choice as it will be much cleaner without much effort.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20080
  • Country: gb
  • 0999
Re: simple analog function generator design
« Reply #19 on: March 31, 2017, 11:43:33 pm »
I've just simulated the triangle wave generator at a higher frequency, by changing R1 and C1 to 10k and 330pF respectively. The amplitude increases and the bottom of the waveform becomes distorted.





It seems to be a problem with Q1 not switching fast enough and the increased amplitude due to the LM393's propagation delay. Adding an extra pull-up resistor and speed-up capacitor has helped to speed up the switching of Q1 and reduce the distortion (I was able to increase the frequency further) but the increase in amplitude is still there and can probably only be avoided by using a faster comparator.


« Last Edit: March 31, 2017, 11:56:09 pm by Hero999 »
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: simple analog function generator design
« Reply #20 on: April 01, 2017, 12:36:49 am »
Several approaches tri to sine conversion, like using
JFET square law behavior -


http://www.timstinchcombe.co.uk/index.php?pge=trisin


In your original post if you replace integrator input R's with R2R DAC ladders
you can control frequency digitally.


https://www.ksp-electronics.com/product_files/859555c74e9afd45ab771c615c1e49a6



Regards, Dana.
« Last Edit: April 01, 2017, 10:50:36 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Online MrAl

  • Super Contributor
  • ***
  • Posts: 1618
Re: simple analog function generator design
« Reply #21 on: April 01, 2017, 06:29:11 am »
Hi,

Yes and the integration of a triangle also results in a square law, but it depends on time so it has to be adjusted with a change in operating frequency.
 

Online Neganur

  • Supporter
  • ****
  • Posts: 1163
  • Country: fi
Re: simple analog function generator design
« Reply #22 on: April 01, 2017, 10:01:38 am »
how about the old Intersil/Maxim 8038, less than 7 USD incl pcb:
http://www.ebay.com/itm/DC-12V-ICL8038-Function-Signal-Generator-Module-Square-Triangle-Sine-Wave-Output-/181877555017

Actually what the hell, 2.42 USD incl. shipping eBay auction: #191904291275
« Last Edit: April 01, 2017, 10:05:47 am by Neganur »
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2133
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: simple analog function generator design
« Reply #23 on: April 01, 2017, 10:19:21 am »
I'd definitely start by building a triangle generator, square/PWM/sine can be easily created from a good triangle core.

If you don't want to start from first principles then use an LM13700 (http://www.ti.com/lit/ds/symlink/lm13700.pdf) - there's many tonnes of data of VCO's built from these.  Some have quite a frequency span too.

As others have said the 8038 is a no-brainer if you want to be up & running quickly - but you won't learn as much.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: simple analog function generator design
« Reply #24 on: April 01, 2017, 10:54:57 am »
Integration of sine does produce square law, and issue here (apart
from level of distortion) is amplitude change with freq. I used a
differentiator to create effectively an AGC loop so I could sweep
the design with DACs and yield constant amplitude.


Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf