Author Topic: function generator  (Read 830 times)

0 Members and 1 Guest are viewing this topic.

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
function generator
« on: February 28, 2024, 05:50:48 pm »
Hi, I'm new to the forum so I hope I'm not doing anything wrong, in case please let me know; i wanted to ask if ther's any amplifier that brings the peak value of a signal to a desired level indipendently from the input, i already found a solution to the problem with the diagram attached but i was told not to use log and antilog amplifiers becouse they need high quality components and still are not suitable for presicion.I need this becouse i'm tryng to make a simple function generator project, i generate a sine wave from a wien oscillator an then pass it trough a comparator to obtain a square wave an then integrate the square wave to get a triangular wave, the problem is that the whole thing is variable in frequency and voltage( for this part i'll just use an attenuator to the end) so the gain of the integrator will change with the change of frequency, to bring the voltage back to the peak value i want even with the frequency change should i use an amplifier as said or something else (for example i don't know if it's better working with 1 oscillator an then transform the signal or just use 3 separate oscillators)?
« Last Edit: February 28, 2024, 07:44:00 pm by GIGGINO94 »
 

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1327
  • Country: ca
Re: function generator
« Reply #1 on: February 28, 2024, 07:44:24 pm »
You could use a modern chip like the AD9837.

How much of a frequency range do you need? Triangle and squarewaves are pretty easy to generate with two op-amps as long as you don't need a huge frequency range. Low distortion sinewaves are more difficult.

 
The following users thanked this post: GIGGINO94

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #2 on: February 28, 2024, 08:08:47 pm »
it's just a simple project i want the frequency range like 100hz-5khz or something like that but it should all be done in analog electronics if possible (it's a school project)
 

Online antenna

  • Frequent Contributor
  • **
  • Posts: 364
  • Country: us
Re: function generator
« Reply #3 on: February 28, 2024, 08:14:36 pm »
Yes, there are amplifiers that can do that, with the help of an automatic gain control loop.  My first stop would be the wikipedia page on Root Mean Square.  There, you will find the relationship between the peak voltage of various waveforms and their respective RMS values.  Once you know that for sine, square, sawtooth, triangle etc, you could add a sensitive peak detector and level shifter for each different waveform to get a DC value representing the RMS value of the waveform and use that to run the AGC loop. After the AGC control loop establishes a consistent RMS output voltage for each of the oscillator modes, you can add a buffer with voltage gain and then use a linear pot to select the desired signal level and pass that through a unity gain buffer or a negative resistance circuit at the output.
 
The following users thanked this post: GIGGINO94

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #4 on: February 28, 2024, 08:30:26 pm »
i searched a few agc circuits but there's a lot culd you please suggest me one?
 

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1327
  • Country: ca
Re: function generator
« Reply #5 on: February 28, 2024, 08:34:41 pm »
Here's a very basic sim circuit (Not 100% realistic sim). Adjust the "resistance" slider on the right to see the frequency change. For a wider frequency range you'll have to switch in different capacitors.
 
The following users thanked this post: GIGGINO94

Online antenna

  • Frequent Contributor
  • **
  • Posts: 364
  • Country: us
Re: function generator
« Reply #6 on: February 28, 2024, 09:16:43 pm »
AGC loops are unique to the circuit, so without knowing what circuit you go with, I cannot suggest one.  To do so would require designing the whole thing or handing you someone else's completed schematic, which I don't have on hand.   Is this school project graded or is it just something to aid in the classroom activities?   There are phone apps that do this if the latter is the case and would be much easier.

There are many ways to implement automatic gain control.  Lets say no matter what mode you are in, you want 1v RMS.  A decoupled sawtooth wave centered on 0v (no DC offset) with an RMS voltage of 1v will have a peak voltage of 1.7v.  A detector takes this peak voltage and uses it to control either the gain of the amplifier or the attenuation of the signal going to the amplifier.  If what comes out of the peak detector is less than 1.7v, the circuit sends more signal through to the amp input or raises the amp's gain, if it is higher than 1.7v, it cuts down the signal at the input or lowers amp gain.

There are many ways to change the gain of an amplifier and there are many ways to attenuate a signal at the input.  Amplifier gain can be controlled (to a certain degree) by changing the bias point, but it is far better to use something like a JFET to control the amount of resistance in series with an emitter bypass capacitor.  The small signal can also be attenuated before it gets to the input of the amp by either series or shunt control. 

If you want a great example of a JFET being used to control amplifier gain, check this out, it is one example of many:
https://youtu.be/N7htFfiQl3w?si=pHUoWa1Pk9jh1fyu
 
The following users thanked this post: GIGGINO94

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #7 on: February 28, 2024, 09:56:40 pm »
thanks a lot, this is a perfect base, i'll study the circuits and jfets more, also the channel of the linked video is full of cool circuits . btw this is a project for my final highscool exam.
(do i need to end the conversation somehow or i just leave it as it is?)
 

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #8 on: February 28, 2024, 09:59:40 pm »
Thanks, it will definitely be useful and the online simulator seems also to be well done, thanks again.
 

Online antenna

  • Frequent Contributor
  • **
  • Posts: 364
  • Country: us
Re: function generator
« Reply #9 on: February 28, 2024, 11:01:32 pm »
why end the conversation? you might have more questions as you go forward.  I was just curious about it being homework, that doesn't mean all help stops.   If anything, I'm sure plenty others will still chime in, so unless you got what you needed and don't plan to check back, just leave it open and see what happens.
 
The following users thanked this post: GIGGINO94

Online antenna

  • Frequent Contributor
  • **
  • Posts: 364
  • Country: us
Re: function generator
« Reply #10 on: February 28, 2024, 11:03:45 pm »
If I may ask, what high school is cool enough to have an electronics course?  I WISH one of the schools I went to had one.  I had to ruin all my toys to get my start in the hobby.
 

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #11 on: February 29, 2024, 11:08:53 am »
It is an electronics course highschool in italy, we build small circuits in lab, we don't really study the hard parts but we have very good teachers to ask something (off-path) but unfortunately a lot of student don't care about what they're studying so the whole class can't go deeper into the topics
« Last Edit: February 29, 2024, 01:50:22 pm by GIGGINO94 »
 
The following users thanked this post: antenna

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16622
  • Country: us
  • DavidH
Re: function generator
« Reply #12 on: February 29, 2024, 03:36:09 pm »
Function generators usually start with a triangle wave and then produce square and sine waves from that.

Integrating a square wave to produce a triangle wave has its own problems because gain at DC must be controlled, because otherwise the offset of the triangle wave will drift.
 
The following users thanked this post: Ian.M, GIGGINO94

Offline Terry Bites

  • Super Contributor
  • ***
  • Posts: 2397
  • Country: gb
  • Recovering Electrical Engineer
Re: function generator
« Reply #13 on: February 29, 2024, 04:12:11 pm »
All sine to triangle conversion schemes are doomed to expense, complexity and failure.
I think you've made a trap for yourself. Stay out of the rabbit hole!\aq

Filter+AGC could work but it will be complex to implement. Log amps are monopolar and have horrible temperature coefficients that are hard to compensate.
Analog multipliers are a lot less bother and relatively inexpensive, eg AD835. There are voltage and digitally controlled amplifiers: VCA's PGA's an VGA's, that perform two quadrant multiplication. The "loop filter" in an AGC circuit impacts the response time and the AGC will struggle to operate at low frequencies.

I suppose you could use a PLL to multiply the squarewave frequency by a binary value 'n' and then clock the output of an n -bit an up/down counter. Connect the output to an ADC? Possible. An arduino could possibly be forced to perform the frequency multiplication and output a 10 bit resolution triangle wave. https://bb7.com/e-unum-pluribus-using-arduino-as-a-frequency-multiplier/

Mr Hess is right. Creating a very good quality sine from a triangle is far easier. Many classic precision lab function generators did just that. https://till.com/articles/sineshaper/index.html See also https://lookmumnocomputer.discourse.group/t/vco-3340-sine-wave/1337.

A classic analog Voltage Controlled Oscillator (VCO) makes this simple. Example attached.
The integrator section can produce both negative and positive slopes from the control voltage.
The sign of integration is switched by the MOSFET. When the integrator output trips the comparator the slope is reversed and a new cycle starts.
This circuit has an output frequency that is linearly proportional to the control voltage. About 1kHz per volt with the values shown. Regulated power supplies are needed for frequency stability.Its easy to rescale the frequency by changing the comparator resistors and the capacitor. R1=R3=R4, R2=2R1. Note that not all opamp types can be used as comparators.

Add gain/ Attenuation, summing amps etc to set output levels.
Instrumentation amplifiers are ideal for these tasks as they give you sum/ difference and slope. (mx+c operations)

For a total solution DDS is the low cost and simple way to go. eg AD9837


 
The following users thanked this post: GIGGINO94

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14214
  • Country: de
Re: function generator
« Reply #14 on: February 29, 2024, 05:16:32 pm »
Adjusting the amplitude of the triangel wave is tricky. It would be easier to adjust the amplitude of the square wave to get send to the integrator and this way regulate the amplitude of the tringle wave.
This way not analog multiplier is needed, just a switch (e.g. CMOS chip like 4053) to convert the voltage to a square wave amplitude.

Another similar way would be to make a triangle wave VCO and use a PLL to lock the frequency to the sine wave. The difference here is that there is no peak detector circuit but comparators keep a reasonable stable amplitude for the triangle wave. The +- switching is part of the VCO.
A triangle to sine generator is old classic way for function generators. At the low end often the XR2206 chip. At the higher grades with a PLL loop to stabilize the frequency.

The DDS chips are quite good with the sine wave, but the triangle part is somewhat limited. Otherwise a DDS is the modern way to build a function generator.
 
The following users thanked this post: GIGGINO94

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19520
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: function generator
« Reply #15 on: February 29, 2024, 05:35:24 pm »
It is an electronics course highschool in italy, we build small circuits in lab, we don't really study the hard parts but we have very good teachers to ask something (off-path) but unfortunately a lot of student don't care about what they're studying so the whole class can't go deeper into the topics

When it comes to applying for a job (in any field), an interviewer will be pleased to see you are doing more than strictly necessary. It demonstrates interest in a topic and an enquiring mind. Both are very useful to an employer.

In addition, try to do a home project, i.e. set realistic stretch goals, do it as far as possible, work out what you would do better in the next project. Those are all things you will be doing in an interesting job :) (My project was to design and build an 8-bit computer with a 6800 and 128bytes (not kB, not MB!) of RAM)

All of that gives an interviewer something to talk about during an interview; you would be unpleasantly surprised to find how difficult that can be sometimes!

Have fun, safely.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: GIGGINO94

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #16 on: February 29, 2024, 10:17:00 pm »
All sine to triangle conversion schemes are doomed to expense, complexity and failure.
I think you've made a trap for yourself. Stay out of the rabbit hole!\aq

Filter+AGC could work but it will be complex to implement. Log amps are monopolar and have horrible temperature coefficients that are hard to compensate.
Analog multipliers are a lot less bother and relatively inexpensive, eg AD835. There are voltage and digitally controlled amplifiers: VCA's PGA's an VGA's, that perform two quadrant multiplication. The "loop filter" in an AGC circuit impacts the response time and the AGC will struggle to operate at low frequencies.

I suppose you could use a PLL to multiply the squarewave frequency by a binary value 'n' and then clock the output of an n -bit an up/down counter. Connect the output to an ADC? Possible. An arduino could possibly be forced to perform the frequency multiplication and output a 10 bit resolution triangle wave. https://bb7.com/e-unum-pluribus-using-arduino-as-a-frequency-multiplier/

Mr Hess is right. Creating a very good quality sine from a triangle is far easier. Many classic precision lab function generators did just that. https://till.com/articles/sineshaper/index.html See also https://lookmumnocomputer.discourse.group/t/vco-3340-sine-wave/1337.

A classic analog Voltage Controlled Oscillator (VCO) makes this simple. Example attached.
The integrator section can produce both negative and positive slopes from the control voltage.
The sign of integration is switched by the MOSFET. When the integrator output trips the comparator the slope is reversed and a new cycle starts.
This circuit has an output frequency that is linearly proportional to the control voltage. About 1kHz per volt with the values shown. Regulated power supplies are needed for frequency stability.Its easy to rescale the frequency by changing the comparator resistors and the capacitor. R1=R3=R4, R2=2R1. Note that not all opamp types can be used as comparators.

Add gain/ Attenuation, summing amps etc to set output levels.
Instrumentation amplifiers are ideal for these tasks as they give you sum/ difference and slope. (mx+c operations)

For a total solution DDS is the low cost and simple way to go. eg AD9837
Thanks, I still find it a little complicated because I haven't studied the digital electronics part yet, but, having this guideline I will definitely study it and I'm sure it will be useful even in many other projects , so thanks again
 

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #17 on: February 29, 2024, 10:19:43 pm »
It is an electronics course highschool in italy, we build small circuits in lab, we don't really study the hard parts but we have very good teachers to ask something (off-path) but unfortunately a lot of student don't care about what they're studying so the whole class can't go deeper into the topics

When it comes to applying for a job (in any field), an interviewer will be pleased to see you are doing more than strictly necessary. It demonstrates interest in a topic and an enquiring mind. Both are very useful to an employer.

In addition, try to do a home project, i.e. set realistic stretch goals, do it as far as possible, work out what you would do better in the next project. Those are all things you will be doing in an interesting job :) (My project was to design and build an 8-bit computer with a 6800 and 128bytes (not kB, not MB!) of RAM)

All of that gives an interviewer something to talk about during an interview; you would be unpleasantly surprised to find how difficult that can be sometimes!

Have fun, safely.
thanks for the advice, I'm happy to be doing something useful for my future as well as studying.btw about your project i don't know mutch about this branch of electronics (I don't want to say something stupid but I also think computer science ) but it seems like a very hard project , so congratulations on your achievement!
« Last Edit: February 29, 2024, 10:26:27 pm by GIGGINO94 »
 

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #18 on: February 29, 2024, 10:35:48 pm »
Adjusting the amplitude of the triangel wave is tricky. It would be easier to adjust the amplitude of the square wave to get send to the integrator and this way regulate the amplitude of the tringle wave.
This way not analog multiplier is needed, just a switch (e.g. CMOS chip like 4053) to convert the voltage to a square wave amplitude.

Another similar way would be to make a triangle wave VCO and use a PLL to lock the frequency to the sine wave. The difference here is that there is no peak detector circuit but comparators keep a reasonable stable amplitude for the triangle wave. The +- switching is part of the VCO.
A triangle to sine generator is old classic way for function generators. At the low end often the XR2206 chip. At the higher grades with a PLL loop to stabilize the frequency.

The DDS chips are quite good with the sine wave, but the triangle part is somewhat limited. Otherwise a DDS is the modern way to build a function generator.
I didn't know that integrated circuits like this existed, however I will also try to apply the idea of changing the input of the integrator instead of the outpu, thanks for the reply.
 

Offline GIGGINO94Topic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: function generator
« Reply #19 on: February 29, 2024, 10:37:41 pm »
Function generators usually start with a triangle wave and then produce square and sine waves from that.

Integrating a square wave to produce a triangle wave has its own problems because gain at DC must be controlled, because otherwise the offset of the triangle wave will drift.
Thank you, i'll keep that in mind.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf