This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to get sounds from four different analog pins synchronously in TM4C129?

Other Parts Discussed in Thread: TIDM-TM4C129POEAUDIO

Hello everyone,

ı just bought tiva-c, and ı want to recieve sounds from 4 different microphones synchronously to find the direction of the source. The main problem is that taking sounds synchronously. where should ı start? what can u advice?

Thanks for your help.

  • Hello Mehmet,

    There is a lot more to capture Audio than just configuring the pins to be analog. TIDM-TM4C129POEAUDIO does audio capture with a single Analog Pin and a single ADC.

    Using 2 ADC controllers can give you simultaneous capture. But not anymore. 4 channels simultaneous capture is not possible. There would be a 1us delay when capturing two analog channel data due to the structure of the ADC controller.
  • Mehmet,

    As Amit has already pointed out, TM4C129 has two ADCs. Each has a number of sample sequencers, which allow multiple inputs to be sampled in succession, but not at the same time.

    If you absolutely MUST sample all four signals at the same time then you need to look at an external sample / hold buffer. This would allow you to "freeze" all 4 signals simultaneously and then sample them at your leisure.

    The 1us delay may however be acceptable anyway. Given these are microphones, then we are most likely dealing with sound in air. Sound travels in the region of 340 metres per second in air. So that would be 340 millionths of a metre in one millionth of a second, which is the delay between samples. If you think about this - the error created by the delay associated with the sample sequencer is the same as if you were to get the positioning of your microphone wrong by 0.34 millimetres. If you have a precision fixture that will hold the microphones more accurately than that, you have the option of the sample / hold buffer, or you can compensate in the maths. If, as I suspect, your microphones are not quite that precisely spaced, you may be able to ignore the delay.

    It is likely that you don't want to sample continuously at 1Msps - with two channels per ADC that would be 500ksps per channel, giving a Nyquist frequency of 250kHz, which is almost certainly well above the microphones' capability. You could use a timer to trigger ADC conversions at a more sensible rate.

    Hope this helps,

    Pat.
  • Hello Patrick,

    A small addition. The human voice range is mostly between 200Hz-3KHz. A very narrow band which can easily be sufficed by a 48KHz sampling rate.
  • All,

    48kHz is more than adequate for speech. Indeed, Compact Disc Digital Audio is "only" 44.1kHz. And LP DAT could run at 32kHz sampling rate. These were/are all considered High Fidelity recordings, so 48kHz will be plenty for recording voice. The fact that the ADC has only 12 bits resolution would be a bigger problem than the sampling rate, but of course that can be mitigated by injecting a little noise, oversampling and running a decimation filter to increase the effective quantisation bits.

    If the purpose of the exercise was to faithfully record or reproduce the observed sound then you would choose your sampling rate according to the fidelity requirements, but given that the application seems to be spatial location, the choice of sampling rate will be dictated by the desired spatial precision.

    What I mean by that is, if we imagine a sound wave travelling from its source to the four microphones, if it is to reach one microphone one microsecond before another, the fact that the microphone's bandwidth does not extend to 1MHz does not prevent the nearest microphone from outputting a signal 1 microsecond earlier than the next microphone. You won't gain anything in the frequency domain (since that is limited by the transducer) but you will gain time domain precision by sampling faster. That does of course depend greatly on the required precision and the separation of the microphones. If they are far apart, they will be more tolerant of slower sampling for a given angular precision than if they were close together (delta T will be smaller, the closer they are).

    The choice of 4 microphones suggests and/or allows 3 dimensional localisation if, for example, arranged as four vertices of a tetrahedron. Comparing the time of arrival of a wave front at all four locations and solving simultaneous equations could yield a 3D vector pointing to the origin of the sound.

    The other consideration in choosing a sampling rate is the processing overhead of doing the wave correlation between the recorded signals. No point in sampling so fast you don't have time to process the data.

    Hope this helps,

    Pat.

  • Indeed there is considerable expertise on display - yet (adapting) to a, "Just bought" Tiva user's (expected) level of capability/understanding (may) warrant some consideration.

    Tall stack of chips on, "Responses (far) exceeding poster's (current) grasp..."