Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 29th September 2007, 09:22 AM   (permalink)
Default High ADC sampling rate PIC, 18F needed?

Hi,
I'm using PIC to digitize/sample the audio signal, then send to another PIC and a D/A converter to get back the audio.
Currently I'm testing with only a single PIC, sample and D/A. I've just tested with PIC16F88, I found that the quality of the D/Aed output is not that good at 2 kHz and above, around 10 kHz and above, aliasing happened.
Then I found from Microchip site that the maximum sampling rate of 16F is only 30 ksps, while a few 18F PIC can be up to 200 ksps.
As a first time user of 18F PIC, I write my first 18F program in MPLAB. There are so many configuration settings!! And the format of the configuration is different from 16F as well.
The datasheet of the 18F PIC is really complicated, the opcode is also more :'(.

Is there any solution for using 16F PIC? Or I should start using 18F?

Thanks
__________________
Superman returns..
bananasiong is offline   Reply With Quote
Old 29th September 2007, 09:58 AM   (permalink)
Default

If the 18F series has the faster analogue conversion time you may as well move to that. However, if you're getting anti-aliasing problems, it's because you're not bandwidth limiting the input (and the output?) correctly.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 29th September 2007, 10:15 AM   (permalink)
Default

hi,
Are you aware of the 18F templates in the Microchip/Templates files??

They will assist with the CONFIG.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now   Reply With Quote
Old 29th September 2007, 11:25 AM   (permalink)
Default

Quote:
Originally Posted by bananasiong
Hi,
I'm using PIC to digitize/sample the audio signal, then send to another PIC and a D/A converter to get back the audio.
Currently I'm testing with only a single PIC, sample and D/A. I've just tested with PIC16F88, I found that the quality of the D/Aed output is not that good at 2 kHz and above, around 10 kHz and above, aliasing happened.
Then I found from Microchip site that the maximum sampling rate of 16F is only 30 ksps, while a few 18F PIC can be up to 200 ksps.
As a first time user of 18F PIC, I write my first 18F program in MPLAB. There are so many configuration settings!! And the format of the configuration is different from 16F as well.
The datasheet of the 18F PIC is really complicated, the opcode is also more :'(.

Is there any solution for using 16F PIC? Or I should start using 18F?

Thanks
You're not likely to produce much in the way of pleasing audio results with ROTM* components. High end audio equipment is expensive for a reason. Do the initial experiments with the PIC and then switch to a 56000 series, or a Blackfin, or a TMS320. A PIC just doesn't have the schtuts for audio processing.

*ROTM - run of the mill
Papabravo is offline   Reply With Quote
Old 29th September 2007, 12:07 PM   (permalink)
Default

I agree with Nigel, you need to filter your input signal. When I programmed SNES games we sampled most instruments at 8kHz and filtered anything above half the sample frequency. The only thing we ever had problems with was hihats and snare drums. If we were doing speech then we sampled at 1kHz. If you filter your input signal at half your sampling frequency then the noise should disappear. Please note that the filtering has to be done analogue wise unless you have very good software and can sample at 30kHz before digitally filtering and re-sampling at the lower frequency.

Mike.
Pommie is online now   Reply With Quote
Old 29th September 2007, 02:41 PM   (permalink)
Default

The ADC's on micro controllers are really more for analog control use not high quality high speed sampling for audio or precision applications. If you want higher quality you should probably use an external ADC, then you can use a cheap PIC and a decent inexpensive dedicated ADC to get great results.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline   Reply With Quote
Old 29th September 2007, 05:12 PM   (permalink)
Default

Hi all,
Thanks for all the responses, I appreciate that
This is still the beginning plan, I have not decided which method to be used yet. But I know, experiments have to be done.
If I want to sample the audio signal as high as 20 kHz, then the sampling rate should at least be 40 kHz. But I'm not sure why the low pass is needed, because the input is coming from the audio source (20 Hz to 20 kHz). The filter is needed at the DAC output because of the "staircase smoothening".

Thanks eric for the info, but there is only one example in the templates. It seems _CONFIG1 type is no longer being used. How if I want to set the configuration setting by hexadecimal instead of setting one feature followed by another?

Thanks
__________________
Superman returns..
bananasiong is offline   Reply With Quote
Old 29th September 2007, 05:24 PM   (permalink)
Default

Quote:
Originally Posted by bananasiong
Thanks eric for the info, but there is only one example in the templates. It seems _CONFIG1 type is no longer being used. How if I want to set the configuration setting by hexadecimal instead of setting one feature followed by another?

Thanks
hi,

Which 18F series PIC are you planning to use?
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now   Reply With Quote
Old 29th September 2007, 05:27 PM   (permalink)
Default

It will either be 18F4331 or 2331.
__________________
Superman returns..
bananasiong is offline   Reply With Quote
Old 29th September 2007, 05:49 PM   (permalink)
Default

Quote:
Originally Posted by bananasiong
It will either be 18F4331 or 2331.
hi,
Attached the two 18F... templates. In case you dont have them?
Attached Files
File Type: asm 2331temp.asm (6.1 KB, 11 views)
File Type: asm 4331temp.asm (6.1 KB, 4 views)
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 7th July 2008 at 11:21 AM.
ericgibbs is online now   Reply With Quote
Old 29th September 2007, 08:12 PM   (permalink)
Default

Noise comes from a plethora of sources, not just the signal source. For the ADC on a PIC I'm sure it's not listed on the white paper but the digital components near the ADC unit have a cross talk to the ADC, above it's maximum sampling rate and then some. Any frequency above the Nyquist rate inverts itself after cutoff at half the power unless its filtered, beyond that the harmonics continue to compound. Filtering is a must.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline   Reply With Quote
Old 29th September 2007, 08:49 PM   (permalink)
Default

Quote:
Originally Posted by bananasiong
Hi all,
Thanks for all the responses, I appreciate that
This is still the beginning plan, I have not decided which method to be used yet. But I know, experiments have to be done.
If I want to sample the audio signal as high as 20 kHz, then the sampling rate should at least be 40 kHz. But I'm not sure why the low pass is needed,
The input filter is probably even more important?, otherwise you can end up with a completely different sound being recorded. It's not just 'important' it's absolutely 'essential' that you don't provide any frequencies higher than double the sampling frequency, and preferably less than that.

The sampling frequency of CD is 44.1KHz to give 20KHz bandwidth, and recordings are bandwidth limited to 20KHz to prevent aliasing problems.

If you sample a 20KHz sinewave at 44.1KHz, it comes out looking something like a sinewave (due to the output filtering), if you sample a 20KHz sinewave at only 30KHz it will come out looking nothing like 20KHz, more likely a MUCH, MUCH lower frequency. Try it with a piece of graph paper, draw a sinewave, then draw sample points at only 1.5 times the frequency - then joint the points together and see what you get.

Doing 40KHz sampling and processing with a PIC seems to be pushing thinks rather?, you've only got 25uS to read the sample, and process it however you're wanting to do it.

Perhaps you might like to tell us EXACTLY what you're trying to do, and what you're hoping to achieve?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 30th September 2007, 12:22 AM   (permalink)
Default

Quote:
Originally Posted by ericgibbs
hi,
Attached the two 18F... templates. In case you dont have them?
What I have is different to yours :O
Code:
;Configuration bits
;Microchip has changed the format for defining the configuration bits, please 
;see the .inc file for futher details on notation.  Below are a few examples.



;   Oscillator Selection:
    CONFIG	OSC = LP             ;LP
Attached Files
File Type: asm 4331temp.asm (5.4 KB, 2 views)
__________________
Superman returns..
bananasiong is offline   Reply With Quote
Old 30th September 2007, 12:51 AM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin
Doing 40KHz sampling and processing with a PIC seems to be pushing thinks rather?, you've only got 25uS to read the sample, and process it however you're wanting to do it.
That is for 16F devices, isn't that?
I see the datasheet of 18F4331, only 0.62 us is needed for the acquisition time, and the process of sampling takes only 5 us. That should be enough for 25 us?
Quote:
Perhaps you might like to tell us EXACTLY what you're trying to do, and what you're hoping to achieve?.
I'm trying to digitize the audio signal, either A/D from PIC or from other A/D conversion IC. Then the data is sent to another PIC serially and there is another D/A converter at the receiver PIC to get back the audio signal.

Thanks
__________________
Superman returns..
bananasiong is offline   Reply With Quote
Old 30th September 2007, 09:37 AM   (permalink)
Default

It doesn't matter what device it is, you've only got 25uS between samples, and you've got to send the data out before the next one is due - so you're talking about some pretty speedy serial!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Speedometer Kiko Micro Controllers 131 29th November 2007 05:33 PM
help needed for ADC circuit konzen General Electronics Chat 25 9th October 2007 02:55 PM
Need some help with a code provided by ATMEL ikalogic Micro Controllers 1 23rd January 2007 02:45 PM
ADC Converter Ic with high bit rate dineshbabumm Electronic Projects Design/Ideas/Reviews 12 23rd June 2006 08:53 PM
Having problems with pic16f872 cjgalway1000 Micro Controllers 0 7th April 2004 02:39 PM



All times are GMT. The time now is 02:44 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.