Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Audio Input from Electret Mic


  • Please log in to reply
11 replies to this topic

#1 Palioh

Palioh

    New Member

  • Members
  • Pip
  • 3 posts

Posted 22 March 2011 - 05:54 AM

Hi, I am very new to any sort of hardware and Netduino projects in particular, so bear with me if I say anything that may seem silly to the more seasoned vets. Our first Netduino project is an electronic tuner and it involves taking in an audio input via an electret microphone (linked below) and determining what the frequency of the sound was. The mic: http://www.sparkfun.com/products/9964 I do not know how the Netduino accepts the input from the microphone and if it's an analog or digital input (I'm assuming analog). If you guys could get me moving in the right direction here with some code (examples, classes, etc), I'd be unbelievably appreciative. I just feel so lost at the moment. :unsure:

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 22 March 2011 - 08:34 AM

I guess you are going to implement such a signal-analysis by programming the Netduino. Electrically speaking, you cannot connect a microphone (even an electret) directly to an ADC input. The main reason is that an electret mike outputs an analog signal which has to be adapted to the Neiduino's ADC input, that is 0..3.3V. Otherwise, probably won't happens, but you could damage the microcontroller. However this is not a complex activity to sort out, at least if you have some electronic basis. From the software viewpoint, the problem is much harder...I'd say quite impossible. If you are going to sample audio signals (e.g. from 20Hz to 20KHz), you should make the ADC reading at 40KHz min, then make computations. That is out of any attempt by using classic C#. I don't know what kind of computations you are going to do for the analysis, but bear in mind that the "pure" ADC sampling (without any computation) could reach 1KHz. Be more detailed and probably I may give some additional info. Cheers
Biggest fault of Netduino? It runs by electricity.

#3 Chris Seto

Chris Seto

    Advanced Member

  • Members
  • PipPipPip
  • 405 posts

Posted 22 March 2011 - 05:07 PM

Contrary to the post above, that mic should be fine, provided Vcc is 3.3V, which looks like it will work. As for DSP, NETMF is NOT very DSP friendly (It is not a realtime OS), but if you used some form of native interopt you would be fine, or you could also use a native coprocessor to capture input and process it, then send only what's required to the Netduino.

#4 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 22 March 2011 - 06:44 PM

Contrary to the post above, that mic should be fine, provided Vcc is 3.3V, which looks like it will work.

The problem is not only the signal amplitude, but also the offset: the mic outputs a signal AC-coupled, above and below 0.0V (i.e. negative respect ground). The ADC input should not tied below ground, that is you must add a polarization (e.g. 1.5V)

As for DSP, NETMF is NOT very DSP friendly (It is not a realtime OS), but if you used some form of native interopt you would be fine, or you could also use a native coprocessor to capture input and process it, then send only what's required to the Netduino.

The problem is that the Netduino+C# is really slow: that is the worst side of any kind of signal processing with a similar device.
I am trying to process some analog signal, but even a basic filtering needs dozen of milliseconds. The best FFT I was able to do (64 points) takes over 80ms to give the result. By adding some extra work, I really cannot sample a signal higher that 4-5Hz.

An external DSP would be a solution, but how Netduino could fit in that way?
Cheers
Biggest fault of Netduino? It runs by electricity.

#5 Palioh

Palioh

    New Member

  • Members
  • Pip
  • 3 posts

Posted 22 March 2011 - 07:46 PM

An external DSP would be a solution, but how Netduino could fit in that way?


Would you mind elaborating on this? Is that like using my computer as a DSP, then passing the important info to the Netduino?

#6 Chris Seto

Chris Seto

    Advanced Member

  • Members
  • PipPipPip
  • 405 posts

Posted 22 March 2011 - 11:54 PM

Trust me, I know how NETMF works when it comes to timing critical stuff ;) When I said native interopt, I meant NOT C#. I meant native code running on the Netduino. As for an external DSP, you could use a chip like an ARM Cortex to process input from the mic and then let it communicate with the Netduino over SPI, I2C, UART, etc.

#7 Edward

Edward

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon, UK

Posted 23 March 2011 - 12:32 AM

but also the offset: the mic outputs a signal AC-coupled, above and below 0.0V

That's not true either - look at the schematic - this is a mic circuit specifically designed for this application.
Why are you being so negative?

Is real-time analysis a requirement? If not then obvioulsy the Netduino will be capable - if you are prepared to wait.

If simple (single) frequency detection is all that's required then you don't need to do FFT's on the signals. There are other much less computationally expensive techniques available (eg, peak detection).

#8 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 23 March 2011 - 04:49 AM

When I said native interopt, I meant NOT C#. I meant native code running on the Netduino.

By using native code is relatively easy to make the MCU working as a DSP, but where's the beauty of the managed code? Why just Netduino and not Arduino (or whatever else)?
I mean using "pure" C# only (read my first answer).
From my viewpoint, the native solution is the same as using an external hardware/coprocessor, then sending data to a Netduino.

That's not true either - look at the schematic - this is a mic circuit specifically designed for this application.
Why are you being so negative?

I apologize for my mistake! The mic-shield includes the level-adapter, using a op-amp as level-shifter. I was considering a normal mic, without any additional circuitry.

Would you mind elaborating on this? Is that like using my computer as a DSP, then passing the important info to the Netduino?

I don't know what exactly you are going to do, but an easy task using a normal PC is to collect audio samples from the PC microphone, then make any kind of computation on it. Even on a "slow" PC, you may use managed code to make computations.
Again, from my viewpoint, the "Netduino device" is a MCU with the .Net Microframework where you can program managed code like C#. As soon you cut some of these features, you are not using a "Netduino" anymore.

If simple (single) frequency detection is all that's required then you don't need to do FFT's on the signals. There are other much less computationally expensive techniques available (eg, peak detection).

I didn't know the "peak detection", but it seems like a spline interpolation across the sampled data. What could be fit a similar algorithm to find a frequency?
Biggest fault of Netduino? It runs by electricity.

#9 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 23 March 2011 - 05:11 AM

If simple (single) frequency detection is all that's required then you don't need to do FFT's on the signals. There are other much less computationally expensive techniques available (eg, peak detection).


In fact could you not do this with hardware using a bandpass filter? Not 100% accurate but maybe good enough.

Regards,
Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#10 Troll feeder

Troll feeder

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationArizona, USA

Posted 24 March 2011 - 06:50 PM

In fact could you not do this with hardware using a bandpass filter? Not 100% accurate but maybe good enough.

Regards,
Mark

You could even get remotely operated capacitors and potentiometers so you could actively tune the circuit. The problem is it will be slow. There are several easy mathematical formulas for finding frequency of simple waveforms but they generally rely on getting an accurate peak to peak time, which appears to be difficult in c# without having to write a special piece of external c++ code. Wikipedia has a fairly good page on it.

#11 Palioh

Palioh

    New Member

  • Members
  • Pip
  • 3 posts

Posted 26 March 2011 - 12:24 AM

I appreciate all the responses so far. Once I do some more research into the suggestions given, I will reply back. Thanks so much.

#12 bradodarb

bradodarb

    New Member

  • Members
  • Pip
  • 1 posts

Posted 25 March 2012 - 07:01 AM

Any progress on this? I want to stream the sound to a server over TCP for processing. -Brad




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.