Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

implementation of sampling on ADC

Status
Not open for further replies.

PlayaSlaya69

Junior Member level 1
Joined
Aug 17, 2011
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,455
Hi there, i'm in need of some expert advice. I need to perform sampling of an audio signal at a around 40 kHz on my dsPIC. The way i thought of achieving this is by setting up a timer interrupt at the set frequency and on every interrupt read the ADC and store the result. I plan on setting up the PIC's ADC for automatic sampling and manual conversion. On each interrupt i'll set the SAMP bit so that ADC conversion occurs, poll to check when the conversion is done, and when done store the result. After the conversion the ADC module should automatically start sampling.

Is my thinking correct? Another one of my concerns is would all this be achieved quick enough so that the next interrupt is called while the first is still executing. I plan to run the PIC at 30 MHz. I'm very new to PIC and maybe its just me, but i find the information on how their ADC's work very confusing. So if anyone could tell me if my solution would achieve the sampling i want or if there's a better way of doing it.

I'd appreciate any suggestions you guys have. Thanks
 

So far I had used PIC ADC at very low speed sampling rates such as 10 samples taken over 200 msec....for sensing application as i need to do the averaging to get accurate results.....It had given me good results sofar....but you are planning to use PIC adc for sampling of 40Khz .....I am doubt full there as ADC conversion time and stable sampling period that i used was approximatly 5ms....If I reduce that further then I was getting wrong results in my averaging....How ever I was using PIC16F877a with 10 bit adc resolution....in your case please explore the PIC DSP may be helpful to you.....

Good Luck
 

So far I had used PIC ADC at very low speed
He using dsPIC!

The good way is to use 2 interrupts. First by timer every 25us start ADC conversion and second by ADC result ready, where you will fill your data array with adc value. You can't use pooling method in interrupt. Shall I must to explain why?
 

Hi easyrider, thanks for your input. Although would you mind explaining your method of two interrupts in more detail, and also why polling can't be used in interrupts, i wasn't aware of that. I also plan to implement two channels such that i read the ADC value on both channels at different sampling frequencies. Any ideas how this can be done?
 

It is not my method. Interrupt should not take more than 10-15 cycles of cpu. So, you can't use delays or while cycles inside interrupt routine. This is a basically.
If you have only one ADC module, you will have to use twice more faster sampling. So, your timer interrupt must occurs every 12us. The timer interrupt routine must clear interrupt flag and start adc conversion by set the corresponding bit (ADC_GO/DONE).
ADC interrupt routine clears their interrupt flag and gets adc result value from adcresl and adcresh registers. This data should fill some array or buffer and, possible, set some ready flag that will be used later in main program. I don't know how your algorithm works.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top