Author Topic: Automatic Gain Control or (AGC) Circuit Help  (Read 14886 times)

0 Members and 1 Guest are viewing this topic.

Offline Williamscullen818Topic starter

  • Contributor
  • Posts: 23
Automatic Gain Control or (AGC) Circuit Help
« on: August 09, 2013, 10:38:08 pm »
Hello Everyone. I'm newby to the forum, but I've been watching the EEVBLOG videos on YouTube for a while now. Been doing a little research into AGC or AVC circuits, so I figured it was about time for me to try the EEVBLOG.

I'm currently in the process of developing a sonar location system for a project that I'm involved with at school right now. I need an Auto Gain Amplifier between my piezo crystal in the water and my uC. I'm trying to find a circuit that will give me the frequency coming from the piezo at a constant Voltage. The amplitude of the signal will not always be the same depending on the distance of the AUV to the sonar buoy, So I need a circuit that will always give me the signal at a constant Voltage no matter what the amplitude of the signal is. There will also be a band-pass filter inline, but we already have that part squared away.

I'm almost sure its not that difficult, but not sure what circuit would be best for my application. If anyone knows of an IC that is capable of this that would work too.
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4706
  • Country: au
  • Question Everything... Except This Statement
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #1 on: August 09, 2013, 11:09:52 pm »
Most places term it automatic level control, with this circuit popping up in a number of places on the subject

http://www.electroschematics.com/wp-content/uploads/2009/12/automatic-volume-control-schematic.gif
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #2 on: August 09, 2013, 11:17:21 pm »
Can you just use a comparator hooked up as a Schmitt trigger?
 

Offline Williamscullen818Topic starter

  • Contributor
  • Posts: 23
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #3 on: August 10, 2013, 12:18:19 am »
Jack,
You mean convert the sin wave from the piezo into a square wave and then measure the frequency? I'm not sure how that would work. Can you post a schematic?

What do you think about this circuit,
https://www.circuitlab.com/editor/#?id=tz64uk
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7527
  • Country: nl
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #4 on: August 10, 2013, 12:20:42 am »
Can't you just use a 24 bit ADC? Don't even need to sample above Nyquist as far as I can see, even with undersampling you will have all the data you need.

AGC throws away the reflectance information you can use to determine the material ... if you really don't care about that I'd say the Schmitt trigger approach, it's simpler.
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #5 on: August 10, 2013, 02:25:43 am »
Jack,
You mean convert the sin wave from the piezo into a square wave and then measure the frequency? I'm not sure how that would work. Can you post a schematic?

What do you think about this circuit,
https://www.circuitlab.com/editor/#?id=tz64uk

See the attached for an example of what I'm thinking. 

Some of the values would change depending on the nature of the input signal.  R5 is controlling the hysteresis.  As you can see from the output it is about +/-100mV.  Also, you might have to buffer the sensor's output with a voltage follower.
 

Offline Williamscullen818Topic starter

  • Contributor
  • Posts: 23
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #6 on: August 10, 2013, 05:39:50 am »
Thanks, I like the simplicity, I think I'll breadboard that one and do a little testing. I'm still not sure what the output of the Crystal will be at min and max, I'm guessing anywhere between 100mV and maybe over 2V, but that kinda depends on what kind of wattage is going into the transmitting crystal. From what I've been told so far, we need to hit the transmitter with a rather high voltage to see anything useful a couple hundred meters away.
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #7 on: August 10, 2013, 05:47:37 am »
Just so you know, you can probably use pretty much any comparator.  The LMV339 that I used in my example has an open collector output.  This is why R6 is there.  You can get rid of R6 if you use a comparator with a push/pull output.
 

Offline ElectroIrradiator

  • Frequent Contributor
  • **
  • Posts: 614
  • Country: dk
  • More analog than digital.
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #8 on: August 10, 2013, 06:30:51 am »
Here is a different solution, which may or may not be easier to build and work with.

The idea here is to build a whole amplifier for the signal from the piezo transducer, and then just brutally clipping/limiting the signal amplitude at critical points in the signal path. This way you can build an amp, which has more than adequate gain, and you will get a fairly reasonable and constant amplitude square wave/PWM signal out, regardless of input signal strength.

*) You may need more gain stages than I could be bothered to draw, probably one and maybe even two additional stages. Copy everything in the schematic below from and including C4 and back to the input, and attaching as many duplicates as needed.

*) The voltage gain of each stage is about 12. The gain of for instance U1a has a set gain of (1 + R3/R2) ~ 13, but this is reduced by the voltage divider made up by R4/R5. So for 3 gain stages the total voltage gain would be ~ 1700.

*) Now imagine you have 3 or 4 gain stages and the input signal is very strong. Maybe the output signal at pin 1 of U1a would then be, say, +/- 5V. What happens now is that D1 and D2 starts to conduct as soon as the voltage across the pair is above/below roughly 0.65V. R4 limits the current through the diodes to something reasonable U1a can cope with. The +/- 5V signal has now been 'cut down' to a fairly nice +/- 0.65V square wave (1.3V peak-to-peak amplitude). This signal is amplified once again by U1b, boosting it to +/- 8.5V, which now appear at pin 7.

R8 plus D3 now clips the signal again, making an asymmetric -0.65 / +4.7 V square wave-ish signal. The Signal to the A/D or digital input pin goes slightly negative, but R9 protects the MCU from damage here. If you use a MCU running on 3.3V, then use a 2.7V zener diode for D3.

*) Most small(?) ultrasound transducers operate around 40 KHz, so a gain of 13 (12) per stage is about as much as one can hope for from an inexpensive opamp like the TL082. This if you want something resembling a square wave on the output. Don't use a stone age opamp like the 741, it won't have enough gain to work here.

*) C4 and R5 forms a high pass filter, which limits low frequency gain below about 1.5 KHz. This helps reduce noise picked up from the mains, along with coping with other potential problems, as you string more gain stages together.

*) C5 and C6 are kind of optional but recommended, and again they are there to reduce the chance of running into problems as you add more gain. You may not get a perfect square wave on the output when using them, though that is probably not a problem for the MCU.

*) The total bandwidth for the whole amplifier would end up being about 2 to 100 KHz, more or less.

*) Depending on how you might build this, then I would recommend using a pair of TL082 chips, instead of using for instance a single TL084. This would allow you to put a bit of distance between the gain blocks, further reducing the risk of instability problems. Each chip should of course have its own pair of 0.1 uF decoupling caps right next to it.

*) I would start building one stage at a time, starting from the output and working my way back, and test each stage before proceeding. Would require some form of signal generator plus a scope to check, though.

*) You only wish to build this, if you truly don't care about the amplitude of the input signal, as there is no way of recovering that information from this circuit.
« Last Edit: August 10, 2013, 06:32:55 am by ElectroIrradiator »
 

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #9 on: August 10, 2013, 07:39:42 am »
Clipping the signal and excessive amplification gives the same output as the comparator with hysteresis (i.e. the schmitt trigger), except that it allows more low-level noise to pass...
 

Offline ElectroIrradiator

  • Frequent Contributor
  • **
  • Posts: 614
  • Country: dk
  • More analog than digital.
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #10 on: August 10, 2013, 07:49:08 am »
Clipping the signal and excessive amplification gives the same output as the comparator with hysteresis (i.e. the schmitt trigger), except that it allows more low-level noise to pass...

Yes, good point. I doubt you'd get away with not having any amplification ahead of the comparator, though. 100mV to 2V signal level from the piezo transducer seems a bit optimistic.
 

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #11 on: August 10, 2013, 07:52:56 am »
Yes, good point. I doubt you'd get away with not having any amplification ahead of the comparator, though. 100mV to 2V signal level from the piezo transducer seems a bit optimistic.
Yes, you're probably right. I believe that incorporating hysteresis is a worthwhile exercise though.
 

Offline Williamscullen818Topic starter

  • Contributor
  • Posts: 23
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #12 on: August 10, 2013, 08:13:59 am »
Jack,
I built your circuit up in circuit lab with a TL081 and it worked well at higher amplitudes. The square wave was off a bit when below 150mV, but anything above that was working great. I have a few other lm339 at school, so Monday I'll put it together and test it on the scope, as I don't have a scope or a function gen at home. I was thinking I could put together an Arduino sketch with my MCP4922 DAC to make a 12 bit sine wave and voltage divide it to test different amplitudes from home with my frequency counting multimeter, but that is not worth it.


Irradiator,
Thanks for the Advice, have you built that circuit before? Or do you c have experience with similar circuits?  I'll for sure build that one up also, as I have all those parts as well. I don't care much about the input amplitude of the signal, I'm only using this circuit in the buoy to ping back to the sub. I don't have a way to transmit that info to the sub even if I could get the input signal strength from the circuit. Now from the sub we might have a interest retaining that info, but I believe we are planning on using the time in which a response took to determine where we are. We will have 2 buoys with known positions and of course one sub. So in theory we can triangulate.
 

Offline Williamscullen818Topic starter

  • Contributor
  • Posts: 23
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #13 on: August 10, 2013, 08:24:42 am »
Quote
100mV to 2V signal level from the piezo transducer seems a bit optimistic

You'd be surprised, we have some extreme crystals. It's not a flat disk type, it's cylindrical, and we are planning on hitting it with alot of voltage, apparently some 1500v.  But I still don't expect it go above 1 maybe 2V if we are lucky.
 

Offline ElectroIrradiator

  • Frequent Contributor
  • **
  • Posts: 614
  • Country: dk
  • More analog than digital.
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #14 on: August 10, 2013, 08:53:58 am »
Irradiator,
Thanks for the Advice, have you built that circuit before? Or do you c have experience with similar circuits?  I'll for sure build that one up also, as I have all those parts as well. I don't care much about the input amplitude of the signal, I'm only using this circuit in the buoy to ping back to the sub. I don't have a way to transmit that info to the sub even if I could get the input signal strength from the circuit. Now from the sub we might have a interest retaining that info, but I believe we are planning on using the time in which a response took to determine where we are. We will have 2 buoys with known positions and of course one sub. So in theory we can triangulate.

I have built something similar several times, for various applications, though this particular schematic was just jotted down in a hurry. Signal limiting is a common technique used in many applications.

When I read your original post, I was somehow reading your question relating to a small and simple student project, using relatively small transducers. No mentioning of subs or lakes.  ;)

The schematic can be improved or simplified in various ways, depending on which components are available, and how it is to be used. The original intent was to provide something, which had a fair chance of working well with a variety of components and construction techniques. I won't claim it is anywhere near optimal or world class for the application, because it certainly isn't.

From your description in your latest post I'm not even sure I understand how you intend to use it, as I was thinking of the *receiver* end when cooking this up, not the transmitter.

If you are making some form of monitor for the transmitted signal, and your test point has sufficient amplitude, then I'd have to say the original suggestion with the comparator is likely to be the best solution for your problem.


Quote
100mV to 2V signal level from the piezo transducer seems a bit optimistic
You'd be surprised, we have some extreme crystals. It's not a flat disk type, it's cylindrical, and we are planning on hitting it with alot of voltage, apparently some 1500v.  But I still don't expect it go above 1 maybe 2V if we are lucky.

Yeah, I'm probably not on top of exactly what you are trying to do here. :D
 

Offline Williamscullen818Topic starter

  • Contributor
  • Posts: 23
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #15 on: August 10, 2013, 10:00:32 am »
Thanks for the help, it it's a school project, but it definitely is not small. we are building an AUV platform (Autonomous Underwater Vehicle) that is capable of search a grid and reporting back what is found.we need to find metallic objects laying and some buried under the sand. So we are trying to put together a simple sonar location system. This particular part of the project is not that complex (in terms of just the buoy), but implementing it into the rest of the project is a bit more difficult.

For the sonar system, we need a way to output a constant voltage that was coming from the  Crystal which looks like is taken care of now. But basically we have a piezo crystal that will be used to transmit and receive. So the crystal will pick up vibration in the water, take out whatever frequency we are looking for and pass it to the uC at a set voltage always, no matter the signal quality. Then the uC will recognize the frequency as the correct one, wait a little bit, and send a high voltage/current to the crystal so that the sub can hear it and determine location by length of time of reply. This will be the same from the 2buoys but on different frequency. Honestly this was not my original part of the project, right now I'm doing power distribution,  but I've been doing research on the sonar anyways because I like the subject. I'll present the options to the team on Monday, I think they well like the comparator option as it is already a nice clean square wave for the uC.
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7527
  • Country: nl
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #16 on: August 10, 2013, 10:24:29 am »
Thanks for the help, it it's a school project, but it definitely is not small. we are building an AUV platform (Autonomous Underwater Vehicle) that is capable of search a grid and reporting back what is found.we need to find metallic objects laying and some buried under the sand.
Wouldn't you want to know the reflectivity of the objects if you want to find metal?
 

Offline Williamscullen818Topic starter

  • Contributor
  • Posts: 23
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #17 on: August 10, 2013, 11:38:18 am »
Yes I do, but that's not what this particular circuit is for. We are trying to use a off the shelf fish finder for that, and possibly a metal detector. But I really don't know much about the complexity of that type of circuit, would it be difficult to do that? Would we just send out a ping to the bottom at a constant altitude and see if we get a high amplitude back?
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7527
  • Country: nl
Re: Automatic Gain Control or (AGC) Circuit Help
« Reply #18 on: August 10, 2013, 01:09:12 pm »
I assumed you were using a sidescan sonar type setup, with a narrow fan beam.

With that setup the delay will tell you the position of the object along the fan and the amplitude of the response is a function of distance (attenuation, which can be corrected for) and the reflectivity of the object.

With a 24 bit ADC all that information can be digitized without an AGC at all.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf