ADC little question

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Hi All!

I have Never used an ADC of a microcontroller but looks like this time around i will have to use it...

I'll have to process some analog signal after filtering...and guess the analog voltage will be weak so i will have to amplify it in order for the ADC module of the PIC microcontroller to recognise it and then do the conversion...

so I want to know what voltage range (minimum and maximum) can be recognised by the ADC module??? so i know how i need to amplify this signal that I will have at the input...

Thanks for all your comments!!
 

joeyd999

Joined Jun 6, 2011
5,237
Hi All!

I have Never used an ADC of a microcontroller but looks like this time around i will have to use it...

I'll have to process some analog signal after filtering...and guess the analog voltage will be weak so i will have to amplify it in order for the ADC module of the PIC microcontroller to recognise it and then do the conversion...

so I want to know what voltage range (minimum and maximum) can be recognised by the ADC module??? so i know how i need to amplify this signal that I will have at the input...

Thanks for all your comments!!
If you're still using the PIC, the A/D input voltage can range from Vss to Vdd.
If you use Vdd/Vss as your Vref+/Vref- (which is software selectable), then the entire input range will be digitized.

You can configure some of the analog input pins to be external Vref+/Vref- if you want to use a stable reference. Then, any input voltage below Vref- will read as 0 counts, and above Vref+ as 2^10-1 counts.

Remember that the analog input voltage on any pin (including Vrefs) cannot exceed Vdd, or go below Vss. If there is a chance of this happening, it is best to put a resistor (do not exceed 10K total) in series with the signal source and the pin. You will need to adjust your signal acquisition time to compensate for the limited current available to the analog input (details are in the datasheet).
 

thatoneguy

Joined Feb 19, 2009
6,359
If your input is very low, I'd suggest a low noise Single Supply, Rail to Rail precision op-amp set up for adjustable gain to bring the signal up to the PIC supply rail voltage, that way, the 1024 "steps" will represent more detail of what you are sampling.
 

joeyd999

Joined Jun 6, 2011
5,237
If your input is very low, I'd suggest a low noise Single Supply, Rail to Rail precision op-amp set up for adjustable gain to bring the signal up to the PIC supply rail voltage, that way, the 1024 "steps" will represent more detail of what you are sampling.
Actually, if he is digitizing a slowly changing signal, a small input cap and oversampling can eliminate the need for a low noise front end. I always try to keep the expense and complexity of the analog front end to a minimum, and using (not so) clever DSP techniques go a long way in that direction.

Eric, just remember that the S/N (signal-to-noise) increases by the square-root of the number of samples you take (assuming summing the readings in an accumulator). This holds true for asynchronous noise (but not synchronous noise!). So, my recommendation is to run the A/D fast and often, and sum a lot of readings. 256 sums gives you an 8:1 improvement in S/N.

Synchronous noise can be effectively eliminated by timing your A/D conversions to coincide with the timing of the offending noise source.


EDIT: Correction -- 256 sums give a 16:1 improvement in S/N, not 8:1. Obviously, SQRT(256)=16. Also, this technique will not work for sampling AC signals. Only slowly varying DC. So, in retrospect, and with respect to the posts below, none of this is applicable to Eric's problem. Sorry.
 
Last edited:

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Humm guess I have to do lots of reading...I still have lots to learn but I'm so grateful that I'm in this forum surrounding with great n clever people...

Thanks thatoneguy and joeyd999
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Da thang is I'm still working on my voice recognition thang... I did some researchs and I found a way of doing that...it kinda complicated but I'm willing to take the pain and try....

That's why I'm breaking it into smaller parts and later ima put everything together and bingo!!

According to my reading, humain voice is on the order of 100Hz to 2000Hz...
So what I'm tryna do now is : as I have a mic ima do some soldering so I can breadboard my little mic (will attach pic later) then will connect output to a high pass filter (with R= 1KOhm and C=1uF) giving a cutoff frequency of ~159 Hz (will attach a little schmatic tomorrow) then I will measure the output voltage after filtering using an oscillator...

And based on the reading, i will amplify this signal for the ADC to work with it...
I'm planning to use LM358 for the amplification circuit...

Will fill you guyz with what next later...I want to achieve this first plus got lots of reading on ADC as like I said I never use this before...

Thanks!
 

debjit625

Joined Apr 17, 2010
790
You are trying to sample a very weak anolag signal,now a mcu can measure voltage between a range like 0V to 5V but its not so important in this case,whats important to look is what's the resolution of the ADC i.e.. what is the small steps of voltage it could sample ,for example your mcu have a valid ADC input range from 0V to 5V and it's a 10 bits ADC so its max state could be 1023 i.e.. total 1024 steps so the smallest voltage it could sample is 5/1024 = 0.0048828125 Volts or 4.8828125 milli Volts.So if your signal is greater than 4.88 mV then its safe to sample it ,otherwise its not.If you are amplifying it and then sampling it using ADC then its not a problem.
You could read this for ADC
http://ww1.microchip.com/downloads/en/devicedoc/adc.pdf

If you are trying to make any voice/speech recognition stuff then I dont think like that way it will work,sampling audio is different than sampling other frequencies as audio is a mixed frequency,normally using simple ADC module of general PIC we sample fundamental frequencies or constant voltage and for mixed frequencies their are separate range of PICs device known as dsPIC for digital signal processing.

You can have a look on it ,its a speech recognition library which can do the job,but its not free
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023596
Evaluation Copy is only $5 not too much

Good Luck
 
Last edited:

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Thanks debjit624...what you guyz saying becoming a bit clear in my mind...
Guess by the time I'm done reading the data sheet my ada stuff, ur links I'll be definately ohk...

Amplyfying might not be important...thx again
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Remember that the analog input voltage on any pin (including Vrefs) cannot exceed Vdd, or go below Vss. If there is a chance of this happening, it is best to put a resistor (do not exceed 10K total) in series with the signal source and the pin. You will need to adjust your signal acquisition time to compensate for the limited current available to the analog input (details are in the datasheet).
Talking about acquisition time...I read the datasheet (PIC16F690, section 9.2) and i got the picture but then still a bit confusing to me...

Assuming you doing a ADC conversion for some application...so how do you tell that you need 'X' microsecond for minimum acquisition time for the ADC to meet its specified accuracy?

Hope I expressed my concern well...

Thx!
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
here's another problem I'm trying to figure out...

I haven't done any harware yet but it is not a problem...I'm first trying to really have a good picture in my mind how this thing should function...

Assume you have the following:

Mic ---> High Pass Filter ---> Amplifier (if necessary) ---> ADC ---> Processing...

Now when you say word (one, off, whatever) , the mic will convert this speech signal into an electrical signal (voltage) which will be filtered and amplified (if necessary) before being sent to ADC...

My question is: Before doing the required conversion, the ADC must sense that there's a voltage signal at its input! So how does the ADC tell/know there is one???

I think there should be some kind of voltage comparison to some fixed predefined voltage...but I'm not too sure...

Please clarify thid to me! Hope my concern is clear...

Thx!
 

joeyd999

Joined Jun 6, 2011
5,237
Talking about acquisition time...I read the datasheet (PIC16F690, section 9.2) and i got the picture but then still a bit confusing to me...

Assuming you doing a ADC conversion for some application...so how do you tell that you need 'X' microsecond for minimum acquisition time for the ADC to meet its specified accuracy?

Hope I expressed my concern well...

Thx!
You only need to worry about this if you are multiplexing multiple a/d input channels. If you are only using one channel, remember this:

If the A/D is not converting (ADGO bit = 0), then it is in acquisition mode. If ADGO=1, it is in convert mode.

Again, if you are using only one channel, then you may safely set your acquisition time to 0*. For your application, minimizing timing jitter will be most important. If available, use a high-priority timer interrupt to initiate the A/D conversion, or, even better, use the CCP special event trigger. This will reduce your jitter to that of your crystal (or other) oscillator.

*This is not always true. If you are trying to synchronize the A/D with a step input, you need to spend some time acquiring the new analog voltage level prior to starting the conversion.
 

joeyd999

Joined Jun 6, 2011
5,237
here's another problem I'm trying to figure out...

I haven't done any harware yet but it is not a problem...I'm first trying to really have a good picture in my mind how this thing should function...

Assume you have the following:

Mic ---> High Pass Filter ---> Amplifier (if necessary) ---> ADC ---> Processing...

Now when you say word (one, off, whatever) , the mic will convert this speech signal into an electrical signal (voltage) which will be filtered and amplified (if necessary) before being sent to ADC...

My question is: Before doing the required conversion, the ADC must sense that there's a voltage signal at its input! So how does the ADC tell/know there is one???

I think there should be some kind of voltage comparison to some fixed predefined voltage...but I'm not too sure...

Please clarify thid to me! Hope my concern is clear...

Thx!
There is always voltage on the input! It could be some DC level (perhaps 0v) or some AC signal (on a DC offset). You could spend a bunch of hardware trying to work it out.

Are you trying to run at exceptionally low power or something? Otherwise, just convert continuously, as fast as you can. Use your DSP code to determine if a vaiid analog signal is present.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
There is always voltage on the input! It could be some DC level (perhaps 0v) or some AC signal (on a DC offset). You could spend a bunch of hardware trying to work it out.

Are you trying to run at exceptionally low power or something? Otherwise, just convert continuously, as fast as you can. Use your DSP code to determine if a vaiid analog signal is present.
Ok but what I'm tryna figure out is how do I make the ADC tell/recognise whether or not a word has been spoken (valid analog signal)?
 

joeyd999

Joined Jun 6, 2011
5,237
Ok but what I'm tryna figure out is how do I make the ADC tell/recognise whether or not a word has been spoken (valid analog signal)?
How do *you* tell when a word is spoken? Remember, when you hear someone speak, your brain picks out the nature of the spoken word amongst a bunch of background noise and interference. Your speech recognition system will need to do something similar, just to a far more limited extent. How you do that is *your* problem. Sorry...can't help you there.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
How do *you* tell when a word is spoken? Remember, when you hear someone speak, your brain picks out the nature of the spoken word amongst a bunch of background noise and interference. Your speech recognition system will need to do something similar, just to a far more limited extent. How you do that is *your* problem. Sorry...can't help you there.
Yeah you got my problem...but it ok I'm doing some reseach on it...I'll be fine!!
ThanKs anyway!

BTW, what's a threshold value? How is it related to ADC?
 

joeyd999

Joined Jun 6, 2011
5,237
Yeah you got my problem...but it ok I'm doing some reseach on it...I'll be fine!!
ThanKs anyway!

BTW, what's a threshold value? How is it related to ADC?
Threshold value? AFAIK, nothing to do with ADC. Is this a term you picked up in your research? What is the context? A little help, please...
 

kubeek

Joined Sep 20, 2005
5,794
Mic ---> High Pass Filter ---> Amplifier (if necessary) ---> ADC ---> Processing...
The high pass filter is optional but you should still use it, but for a reliable ADC you must have a low pass filter, preferably pretty steep, cutting anything above Fs/2.

My question is: Before doing the required conversion, the ADC must sense that there's a voltage signal at its input! So how does the ADC tell/know there is one???
You still didn´t say what method of recognition youre using.

Either your method will be so good that it can keep running all the time and take care of this problem by itself in a way that it doesn´t produce false positives, or you will have to set up a thing known as Noise gate.
This monitors the input signal and when it reaches some level the gate opens and passes the signal to the next stage. When the signal drops below the threshold, the gate waits for some time and if the signal didn´t get above the threshold again, it closes and stops passing the signal. Offcourse it is easier to do this in software rather than in hardware.
(by level I mean absolute voltage wrt the resting level)
 
Last edited:
Top