Shop OBEX P1 Docs P2 Docs Learn Events
Electret Condenser Microphones and the MCP3208 ADC to a propeller — Parallax Forums

Electret Condenser Microphones and the MCP3208 ADC to a propeller

Jeffrey KaneJeffrey Kane Posts: 48
edited 2013-06-06 12:13 in General Discussion
Hello,

I've been looking at connecting a CMA-4544PF-W to a MCP3208 and having the data processed by the propeller, I've connected a photoresistor to ch0 on the mcp3208 and all works fine, i send the data to the parallax serial terminal and everything works fine, dark i get basically 0, about 127 and with a flashlight i get about 3800, so this works, but what i want is to use a electret mic as input but i have not found any suggestions on how to set up the circuit. or an example of some code, I looked at the sigma Delta circuit on the prop demo board, and also the microphone to vga and microphone to headphones. but the numbers never look correct when i intercept the sample from the circuit and display it on the serial terminal. I also want to use the mcp3208 over sigma delta for possibly use of more channels, and working on a breadboard, So basically i was wondering if someone has a circuit using the propeller and a electret mic to the mcp3208 adn then otuput to the propeller serial terminal.

this is the spin code for the photoreister

CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

cpin = 0
dpin = 1
spin = 2

OBJ

adc : "MCP3208"
pst : "Parallax Serial Terminal"

VAR
long sample

PUB main
pst.Start(115200)
adc.start(dpin,cpin,spin,%1111_1111)

repeat

sample:=adc.average(0,500)
pst.dec(sample)
pst.newline

the curcuit is listed here: http://www.gadgetgangster.com/tutorials/397

regards

Jeff

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-06-06 08:49
    I think you might run into similar problems with the MCP3208 as you did by just reading the Sigma Delta of the microphone directly. The reason is because the microphone is AC in nature meaning it fluctuates above and below the zero line or reference voltage, where as the photo cell does not. What you need to do is integrate the values over time and filter the signal above or below zero. In software you simply look for signals above a particular threshold (or below; but not both). In hardware you use a diode to rectify only the top or bottom portion of the signal. As an example I would start with something like the front end of a LED VU meter... such as this...

    http://www.aaroncake.net/circuits/vumeter.asp

    ...in this circuit the transistor amplifies the small microphone signals where the diode allows the LED DOT/BAR display driver to only "see" the top half of the AC input signal.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-06 09:20
    You have to decide what you want to do with the microphone's signal first. Do you want to look at the raw waveform? Do you want to look at the overall sound volume? How much detail do you want? How fast do you want to sample the signal?

    As Beau indicated, the signal from the microphone goes positive and negative and, over time, averages out to near-zero. An ADC usually works with positive voltages only.

    The VU Meter front end rectifies the incoming signal (uses only the positive-going bits) and averages it over time (to provide a voltage for the envelope ... the overall shape ... of the sound waveform).
  • Jeffrey KaneJeffrey Kane Posts: 48
    edited 2013-06-06 09:56
    Ok, two goals, first lean how to use the microphone and adc chip, second goal, create a sound box for testing a specific frequency. we have a piece of hardware, printer head, this head has about 2600 piezo jets, when a jet is working it emits a high frequency sound, so i have software (i.e. fpga code) that activates each piezo, half second between each, basically i will activate the piezo and listen for the sound, walk thru all the jets, and display on a lcd (from parallax), the number of failed jets and total scanned.


    so in pseudocode

    init jet_counter = 0
    init jet_errro_counter = 0

    while loop
    activate sound
    listen for sound
    update jet_counter by 1
    if sound not found update jet_error_counter by 1
    until there are no more piezo's jump to while loop

    display Jets counted
    display Jets_failed

    regards

    Jeff
  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-06 10:57
    What you want to do is actually fairly complicated and well beyond what we can help you much with here. Perhaps someone else can point you to some references for possible filters or you can start with "bandpass filter" in the Wikipedia.
  • Jeffrey KaneJeffrey Kane Posts: 48
    edited 2013-06-06 11:45
    darn, oh well, so from what i see i'm using the wrong adc to convert the microphone data to viewable data on the propeller. for now, I would just like to see what the recorded data would be like from the mic. If this is possible, what would the circuit look like to record . or should i switch to a LM3915 Audio Level IC?
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-06-06 11:45
    Do you happen to know what the specific frequency is? If the specific frequency is fixed, then there might be alternate path solutions.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-06-06 11:48
    "should i switch to a LM3915 Audio Level IC" - No! ... the reference is just to look at how the "front end" circuitry was accomplished.... the ADC in place of the LM3915 should still be fine.


    "...from what i see i'm using the wrong adc to convert the microphone data to viewable data on the propeller. for now" - Not necessarily, what your looking for could be accomplished in software, it's all about how you look at and understand the signal.
  • Jeffrey KaneJeffrey Kane Posts: 48
    edited 2013-06-06 12:10
    The frequency is fairly high, a rather high pitched whine, and yes it is always the same. I will try to record it and figure out the exact frequency.

    Jeff
  • Jeffrey KaneJeffrey Kane Posts: 48
    edited 2013-06-06 12:13
    good, so the mcp3208 is fine, and the amount of data is not so important, if the mcp3208 can do 50,000 samples per second, i will sort out the backend processing. for now it is a matter of capture, "i think"
Sign In or Register to comment.