Amplifying the signal before ADC

Started by Ridaros, March 16, 2017, 02:25:40 PM

Previous topic - Next topic

Ridaros



Quote from: anotherjim on March 20, 2017, 05:44:06 AM
I can't get this to show either!
[img]http://imgur.com/a/9WO1e[/img]

However,
http://i.imgur.com/pdSsmWH.png
This does. Go to the link to your image. Right click on the image and take "copy image location". Paste that between the image code tags.

I made it show smaller with this...
[img height=400]http://i.imgur.com/pdSsmWH.png[/img]


Have you selected a single supply op-amp type that can output to ground?

Connect R1 to 3.3v instead of 5v and your bias will be 1.65v.

The op-amp output voltage cannot go negative below 0v, so D2 will never act - it isn't needed.

D1 won't start to act until the output exceeds 5.5V. It cannot do this either.
If D1 connects to 3.3v instead of 5v, it will act when the output exceeds  3.8v. Not ideal, but better than 5.5v.

Actually, I would be surprised if the input pin to the PIC ADC does not already have the 2 diodes internally across 3.3v to 0v anyway, but I would keep D1 on the op-amp output connecting cathode to 3.3V and fit a 10k resistor between there and the ADC input. The resistor will limit current in the event of the internal diode on the ADC input conducting and let D1, being before the resistor, carry it safely away from the chip.

In the event you want some input filtering, the 10k resistor will have another use. Add a capacitor from the ADC pin to 0v and it acts with the 10k to form a low pass filter.

Thanks, Jim.

I raised the voltage from 3.3v to 5v because I was told that 3.3v op amps aren't great for this application.  Should I still lower the supply back to 3.3V?

OK, so remove D2, and add a 10k resistor to the anode of the diode and the ADC line?

What value cutoff frequency should I aim for?

anotherjim

No, don't lower the op-amp supply back to 3.3v. Only the bias resistor feed to R1 changes to 3.3v.

Really, we need to know what op-amp it is. Can it's output go to ground? How close can it's output go to the + supply?

Running on 5v, the commonly available (and cheap) LM358 can swing it's output from 0v to maybe +3.5v.  Close enough to not need any clamping diodes (they would not act anyway). It is a dual op-amp, so you may have a use for the other op-amp in it elsewhere - such as the DAC output. Actually the 358 can run off 3.3V, but the output won't reach close enough to 3.3v and you would lose the most positive range of the ADC.

However, Microchip have thought about this and supply the MCP6002. Also a dual amp, this one CAN run from 3.3v supply AND the output can reach 0v and 3.3v (less a few millivolts).
If you use this chip or a similar type, you can go back to running everything off the 3.3v supply.

Ridaros

Ok, would you recommend using the MCP6002 in that case?

anotherjim

I'm pretty sure the MCP6002 is made for the job. I personally have never used it, only noticed it after searching for a low voltage amp. So if you have to buy the part, I'd pick that one. Simplifies a lot of things.




[In_Joke] I'd use a CD4007UB myself   :icon_twisted: [/In_Joke]

Ridaros

Thanks once again, Jim :) I'll give that op amp a go then.

Just a couple of questions though, with the 10k Resistor from Anode to ADC Line, how does this form a low pass filter? My understanding was the signal need to have the resistor in series with a cap to ground.

While on the subject of LPF, is 20k a normal value you'd expect for cut off frequency?

anotherjim

The 10k will only form a low pass with a capacitor IF you want one. I suggested the 10k to limit any fault current with an amplifier that can go higher than 3.3v of the ADC. The resistor won't be needed with the 3.3v amplifier, but won't do any harm. It could be useful to form a filter if you need one. Capacitor value depends on what cut-off frequency you need.

If you are only planning to input a guitar, there is no need to go as high as 20kHz. Guitar signal does not exceed 5kHz. Your sampling rate needs to be at least 2.5 times higher than the signal to avoid aliasing distortion - but you might want that to happen for all I know.


Ridaros



Quote from: anotherjim on March 21, 2017, 02:30:13 PM
The 10k will only form a low pass with a capacitor IF you want one. I suggested the 10k to limit any fault current with an amplifier that can go higher than 3.3v of the ADC. The resistor won't be needed with the 3.3v amplifier, but won't do any harm. It could be useful to form a filter if you need one. Capacitor value depends on what cut-off frequency you need.

If you are only planning to input a guitar, there is no need to go as high as 20kHz. Guitar signal does not exceed 5kHz. Your sampling rate needs to be at least 2.5 times higher than the signal to avoid aliasing distortion - but you might want that to happen for all I know.

OK so if I sample at 2.5 x the highest guitar frequency would that mean I need a frequency cutoff that would also need to be 2.5 x the highest too?

The idea I was going for was to sample the clean guitar signal as perfectly as possible and then do the bit work for 8 bit sounds entirely through software.

anotherjim

No, the filter isn't 2.5 times higher. It should just pass the highest frequency you can sample. That will be about 5Khz for guitar.

antonis

#28
@ Ridaros: As Jim said, linear circuits DO NOT alter signal frequency..!!
(they may do some nasty things with amplitude & phase but they wholly respect the frequency of a sine-wave signal..)

Just have in mind that setting the cut-off point (-3dbfbreak) of an arbitrary frequency doesn't mean that you'll result in a "completely" attenuated signal just right after (or before, in case of LPF) this point..

You'll have to mess a little with 50% attenuated output (6db/octave or 20db/decade) as a trailhead and set it according to your taste..  :icon_wink:
"I'm getting older while being taught all the time" Solon the Athenian..
"I don't mind  being taught all the time but I do mind a lot getting old" Antonis the Thessalonian..

anotherjim

You have to see this the right way around. I asked before what sampling rate you have, because that is the main factor.
Call the sample rate  Fs (kHz).
Maximum input frequency is Fs/2.5. The 2.5 factor is an ideal, it MUST be more than 2. Trying for 2.5 gives a margin.

If Fs is only 10kHz, you can't really sample up to 5Khz with this without hearing some aliasing, but it might be ok if you actually want "digital artefacts" to come out. If Fs is 44.1kHz, happy days, you can sample any audio cleanly. With many controller chips, you can usually easily obtain 30Khz Fs, which means a limit of around 12kHz for audio, but still more than enough for guitar.

So, if you want a suggestion for your filter, we have to know that sampling rate!

If you add a capacitor after the 10k, it's only a single pole low-pass filter, not a "brick wall". That filter calculator I linked to earlier will draw the response curve as well as tell you at what frequency it cuts by -3dB is. You'll see there is signal still passing above the cut-off, but increasingly less with increasing frequency. Single pole filters like this are often used in guitar distortions to tame the harshness caused by all the extra harmonics - and to be effective actually have -3dB points as low as 700Hz (some lower still). The aim was probably to cut high frequencies above the 1 or 2 kHz region. Using the simple filter means it's -3dB point has to be a lower frequency to be effective at the higher frequencies.

Actually, I was thinking that your sampling rate might easily be 12Khz or more, so if only a guitar is feeding it, a filter is not strictly necessary. The only danger is higher frequency noise above 5Khz getting in.

If the aim is to analyse and resynthesise the guitar signal, do you really need the full clean signal? Highest fundamental guitar pitch is around 1.2Khz and everything above that is harmonics.

Ridaros

Quote from: anotherjim on March 22, 2017, 12:40:02 PM
You have to see this the right way around. I asked before what sampling rate you have, because that is the main factor.
Call the sample rate  Fs (kHz).
Maximum input frequency is Fs/2.5. The 2.5 factor is an ideal, it MUST be more than 2. Trying for 2.5 gives a margin.

If Fs is only 10kHz, you can't really sample up to 5Khz with this without hearing some aliasing, but it might be ok if you actually want "digital artefacts" to come out. If Fs is 44.1kHz, happy days, you can sample any audio cleanly. With many controller chips, you can usually easily obtain 30Khz Fs, which means a limit of around 12kHz for audio, but still more than enough for guitar.

So, if you want a suggestion for your filter, we have to know that sampling rate!

If you add a capacitor after the 10k, it's only a single pole low-pass filter, not a "brick wall". That filter calculator I linked to earlier will draw the response curve as well as tell you at what frequency it cuts by -3dB is. You'll see there is signal still passing above the cut-off, but increasingly less with increasing frequency. Single pole filters like this are often used in guitar distortions to tame the harshness caused by all the extra harmonics - and to be effective actually have -3dB points as low as 700Hz (some lower still). The aim was probably to cut high frequencies above the 1 or 2 kHz region. Using the simple filter means it's -3dB point has to be a lower frequency to be effective at the higher frequencies.

Actually, I was thinking that your sampling rate might easily be 12Khz or more, so if only a guitar is feeding it, a filter is not strictly necessary. The only danger is higher frequency noise above 5Khz getting in.

If the aim is to analyse and resynthesise the guitar signal, do you really need the full clean signal? Highest fundamental guitar pitch is around 1.2Khz and everything above that is harmonics.
I'll be using a Dspic of some sorts to begin with, I imagine. I may later use external ADC'S / DAC'S.

So for a starting point, if I say I'm going to use a dspic33fj128gp802. That should give me a 12bit reading sampled at 500ksps.