Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Audio recording/playback using PIC

Status
Not open for further replies.
Well here you need a even cleaner supply. You proabobly have noticed the AVdd and AVss pins on the pic. This is a separate supply for the analog part of the chip. What you would do is put a LC filter between those analog supply pin and the supply that the rest of he chip is running off. The PIC will generate noise on the line it self so we use the filter to make the supply even cleaner for the analog part of the circuit.

You should have no problems with C in that case.Since its pretty much the same. As for interfacing hardware in it its the same as in assembler, its writing and reading to registers (unless you use a library to do that for you). But i suggest you start with the easy things to get to know the dsPICs. Things like blinking a LED , making beeps, send stuff trough a UART etc
 
Well here you need a even cleaner supply. You proabobly have noticed the AVdd and AVss pins on the pic. This is a separate supply for the analog part of the chip. What you would do is put a LC filter between those analog supply pin and the supply that the rest of he chip is running off. The PIC will generate noise on the line it self so we use the filter to make the supply even cleaner for the analog part of the circuit.

You should have no problems with C in that case.Since its pretty much the same. As for interfacing hardware in it its the same as in assembler, its writing and reading to registers (unless you use a library to do that for you). But i suggest you start with the easy things to get to know the dsPICs. Things like blinking a LED , making beeps, send stuff trough a UART etc


Thanks electro, I am reading up on the cleaner supply requirement for analog portions of the chip here (in case anyone else is interested).

https://www.electro-tech-online.com/custompdfs/2008/08/power.pdf

One question for you however: Why LC Filter? This is to block out everything but dc (or close to dc) values right? Would a capacitor to ground be ok? I looked up different examples of LC filters and i'm trying to wrap my head around why you'd need the inductor.
 
Its simple. A inductors conducts at most with DC trough it, but its tougher for high frequency interference to get trough it, so it helps make it cleaner.

All this mombo jobmo is not a must, the whole thing will still work fine, but since your after great sound quality doing these stuff helps a lot with it.


Oh and also keep in mind you also need a programmer for loading your program in to the dsPIC. For this its probably best to buy the official pickit 2 programmer from microchip. Its a small and cheap programer that offten debugging support (That means you can step trough the program line by line, look at variables, jump trough the program etc)
 
I present to you a far better option.

Drop the PIC's ADC in favor of an external codec chip. Look up "stereo codec". Look up Maxim-IC's stuff.

There's speech codecs but also a lot of 16-bit/stereo/full audible range with major work already done behind preserving the audio quality. Max 9861/9853/9856 even have headphone drivers and negative-rail charge pumps so it can provide AC outputs without DC blocking caps. One's also got bridged speaker drivers for a pretty respectable output off of a 3.3v rail!

The codecs generally do not require antialiasing filters. They're buffered and can deal with signals with high output impedance. They can handle microphone levels, often have internal mike bias generators for condensor mikes, OR handle line levels, and the gain is adjustable. Adjustable gain is surprisingly important, it's easy to have a mike signal be high enough to exceed the input range or be so faint the electrical noise becomes significant or it's just making lousing use of 16-bit space by only peaking at 12 bits out of it (1/16th the maximum level the recorder could handle, consequently this might as well been a 12-bit ADC).

The codec's spec sheet also has real clear & concise info on how to do the job- how to handle the Analog Vdd-Vss power.

Downside, you may be able to find the 33F in a DIP or at least its SMD sizes will be work with readily available sizes of SMD prototyping boards. Some of these codec chips suck the 9856 is a QFN20 and no SMD prototyping boards exist from anyone, I checked! You will not find any codec chip as a DIP. Well, get the free student edition of Eagle, make sure you get it right and send the board off to Sparkfun or whoever. Takes like a month so plan ahead.

Best to get a 3.3V codec device, otherwise you need another reg and have to deal with 5v compatibility issues (33F has 5v compatibility features though). Also be sure the codec has a simple 16-bit mode because the 33F DCI module and DMA controller may choke on handling larger words.

The 33F has a codec interface (DCI), Framed SPI ports can often do the same job.
The 33F has another important feature: DMA transfer. That allows you to fill up buffers going to the SPI module, and coming from the codec, with 16-bit data and not have to deal with interrupt response times every time the SPI buf needs data, and far less processor intensive. DMA's brilliantly simple- you config one of 9 DMA channels to transfer data from the DMA space to SPIxBUF and advance the DMA memory pointer when a SPIxTX interrupt occurs instead of using an ISR. Well there's buffer length and all there too to configure but you get the idea.

The 33F's also 16-bit. The codec and SPI hardware modules and the DMA controller are 16-bit. You wanna be able to handle this data as 16-bit for sure or processing can get crazy inefficient. 24F and 30F series are 16-bit too but 30F doesn't have DMA and is a bit slower and crazy high on power consumption and heat if you try to crank it up to full speed. 24F, IIRC it does have DMA but doesn't have the DSP core. Now technically you don't need the DSP core for buffering the audio data from codec to SD card, but it's "good to have around" because sooner or later you may expand the project to include a digital filter. In fact if you didn't include some sort of filter I think a prof would be "disappointed". The 33F are barely more expensive anyways and you're probably gonna be sampling them out for free so get the 33F for sure.

It's almost cheating. But it IS the "smart" way to do it, in fact most modern circuit designers would take the same route, it's vastly smaller, cheaper, and better performance. I'd do it quick and then add a bunch onto the project for extra credit. Yeah I mean you've got easy access to the audio stream so build some digital filters for neat guitar effects.
 
Last edited:
I present to you a far better option.

Drop the PIC's ADC in favor of an external codec chip. Look up "stereo codec". Look up Maxim-IC's stuff.
....

Woah, information overload! haha just kidding. I'm gonna have to read up on that tomorrow when I have some time to kill at work. Thank you for all of your insightful help.

This project will be done using Eagle, although i'd be worried about prototyping (breadboarding) a circuit with SMD components. Maybe I'll just spend a few bucks and design a prototyping board for the chip.

I saw another blog from you Oznog and from what I remember, it was a very similar project.

Thanks for the tips.
 
Guitar Audio Frequency

Guitar audio range is not 400Hz-20kHz:

If you use a Dropped B/Standar B tuning you will go down to 61.74 Hz on 6th string. With Standard E tuning your fundamental frequency on 6th string will be 82.41 Hz.

From experience I have never seen any tuning schemes higher than Standard E. With this scheme, if you have a 24 fret guitar, plucking the 1st string open will give you 329.63 Hz fundamental, on 24th fret(2 octaves higher) the highest fundamental frequency you can achieve is going to be 329.63× 2× 2 = 1318.52 Hz.

Considering that you have Floyd Rose tremolo, without breaking the 1st string you can go maybe 3 octaves higher (I believe this impossible on 24th fret but we are calculating extremes here) giving you a fundamental frequency of 1318.52×2³=10548.16 Hz. This will produce almost no amplitude by the way.

To achieve a natural guitar sound recording you will not need more than the 3rd harmonic of the sound in my opinion.

Standard E tuning:
Fundamental Range(open): 82.41 Hz - 329.63 Hz
3rd Harmonic Range(open): 659.28 Hz - 2637.04 Hz
24th Fundamental Range : 329.64 Hz - 1318.52 Hz
24th Fret Harmonic Range: 2637.12 Hz - 10548.16 Hz
Floyd Rose Screamer : - 80kHz (Inaudible)
Recording Filter Theoretic: 82.41 Hz - 20kHz (Highest Audible)
Recording Filter Practical : 82.41 Hz - 11kHz

Pick-ups will not be able to capture audible amplitude of 2nd/3rd order harmonics on 18-24th frets of the guitar on first string. This is why you will hear "cleaner" sounds on very high notes.

With alternate tuning schemes included down to Standard B your filter should setup should be:
Low-pass @ 11kHz (you might not even need a low-pass for this project imo)
High-pass @ 60Hz

I advise you to use 8th order butterworth filter for the high pass to eliminate 50Hz noise, if you are living in the states make sure to use shielded cables and shield the hell out of your project box to get rid of the 60 Hz noise.

To save space try using switched capacitor low pass filters @ ~8$ a piece from digikey. They are kinda expensive but are worth it.

Conclusion:
Filter Range: 60 Hz - 11kHz

frequency reference
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top