0

This is as simple and less vague as I can make it, so please and try to help me out.

By this, meaning I want to:

1) Input an audio track (Anaglod)

2) Using the micro controllers ADC convert it to a digital output

3) Then Have the microcontollers/boards timer sample the data at selected intervuls.

4) Tell the board to take the "Sampled audio track" and now sample it at a rate of 2B, ( B meaning the highest frequency.

F= Frequency

F(Hz=1/s) E.x. 100Hz = 1000 (Cyc/sec) F(s)= 1/(2f)

Example problem: 1000 hz = Highest frequency 1/2(1000hz) = 1/2000 = 5x10(-3) sec/cyc or a sampling rate of 5ms

5) Spit it back at the boards ADC and convert it back to analog, thus the out-put is a perfect reconstruction of the initial audio track.

Using Fourier Analysis i will determine the highest frequency at which I will sample the track at.

However in theory it sounds easy enough and straight forward, but what I need is to program this in C and utilize my msp430 chip/Experimenters board to sample the track.

Im going to be using Texas Instruments CCS and Octave for my programming and debugging. This is my board that I will be using.

Questions:

Is C the right language for this? Can I get any examples of how to sample the tack at nyquist frequency using C? What code in C will tell the board to utilize the ADC component? And any recommended information that is similar or that will help me on this project.

knbk
  • 52,111
  • 9
  • 124
  • 122
Andrew
  • 111
  • 1
  • 2
  • 10
  • The step of using Fourier analysis to determine the sampling frequency doesn't make a lot of sense. Please elaborate. – Jim Brissom Dec 25 '10 at 15:56
  • Just using it to determain the highest frequency then going to sample at nyquist which is 2(f). So i just want to determain F with Fourier analysis. – Andrew Dec 25 '10 at 16:10
  • You have a "chicken and egg" problem - you need to sample before you can do an FFT, and if your sample rate is too low then you will have aliassing, so the FFT will be invalid. I suspect this is never goign to fly anyway, since you probably don't have suitable low pass filters for audio on your ADC and DAC. Better to use an actual DSP evaluation board with suitable ADCs, DACs and anti-aliassing filters. – Paul R Dec 25 '10 at 16:21
  • Ive asked around and the current boards ADC is suitable for dsp. An and sampling rate cannot be too low since if its at or higher then nyquist frequency it will yield a perfect reconstruction. Just what would your recommended actions be, for creating the c code for sampling at nyquist frequency? – Andrew Dec 25 '10 at 16:25
  • and Richard Baraniuk was the person who suggested this board for simple dsp processes – Andrew Dec 25 '10 at 16:37
  • @Andrew: for typical audio you'll need a sample rate of say 44.1 kHz and anti-aliassing (low pass) filters with a cut off at 20 kHz. Are you sure your microcontroller can handle sampling (and processing) at this rate, and that you have a suitable low pass filter ? – Paul R Dec 25 '10 at 17:34
  • From my conversations with Richard the board does have suitable capeabilities. Thats why i chose this one, and aswell as the fact it can do many other operations, so it would be ok for a "simple" dsp reconstruction process. – Andrew Dec 25 '10 at 18:00
  • @Andrew: you can probably do simple DSP at a relatively low sample rate, but whether you can do *audio* DSP is another matter. Does the board have anti-aliassing filters ? What's the max sample rate for the ADC ? How are you going to do audio out (PWM ?) ? – Paul R Dec 25 '10 at 19:06
  • I dont know if this will help, The MSP430F5438A generates a high-frequency PWM signal to emulate the functionality of a DAC. The duty cycle of the PWM is derived from the ratio between the emulated voltage and the rail of 3.3 V. This PWM output signal is filtered heavily to emulate a constant voltage value. This output is then connected to a Texas Instruments TPA301 audio amplifier. The audio output circuit utilizes the audio amplifier to amplify the filtered output signal from the PWM and feed the amplified signal into the audio output jack. – Andrew Dec 25 '10 at 19:21
  • You need to get the simplest possible audio pass through program implemented and working first. Init the ADC, init the PWM output, set up a timer interrupt at your chosen sample rate, then on every timer interrupt read a sample from the ADC and write it to the PWM output. – Paul R Dec 26 '10 at 08:53

3 Answers3

0

I don't fully understand what you want to do, but I'll answer your specific questions.

Yes, C is the right language for this.

You should probably look at application code on the Texas Instruments website to see how to interact with the ADC. You can start with the example code listed at the bottom of the page you linked to. It has C code that shows how to use the ADC.

Incidentally, an ADC only converts analog to digital. To go digital to analog, you need a DAC, which this board does not appear to have.

Kyle Heironimus
  • 7,741
  • 7
  • 39
  • 51
0

5) ADC doesnt do Digital-to-Analog Conversion, 'cause it's ADC, not DAC. But you may use PWM with Low-pass filter to output analog signal.

It is often a bad idea to sample signal at Nyquist frequency. This will cause lots of aliasing at high frequencies. For example signal with frequency F-deltaF, where deltaF as small, will look like F amplitude modulated by 2deltaF.

That's why CD sampling rate is 44.1 kSPS, not 30 kSPS (as twice 15 kHz -- higher frequency limit).

Vovanium
  • 3,798
  • 17
  • 23
0

You have to sample the signal with a frequency that is twice as high as the highest frequency in your signal. Otherwise you get aliasing effects (distortion of the original signal). It is not possible to determine the highest frequency in your signal with fourier analysis because to perform an fft you have to convert your analog signal to digital values - with a conversion frequency (that you want to determine with the fft).

The highest frequency in your input signal is defined by the analog input filter that the signal must pass before analog to digital conversion.

chrmue
  • 1,552
  • 2
  • 18
  • 35