Shop OBEX P1 Docs P2 Docs Learn Events
Collecting data from a microphone — Parallax Forums

Collecting data from a microphone

A.C. fishingA.C. fishing Posts: 262
edited 2006-08-12 02:16 in General Discussion
I have a regular mic, and have never used one before. How should I collect data from it? I would like it to detect sound levels, something loud to something soft. I assume the mic bring up resistance when the noise is louder. Should I use an RCTIME circuit? Would a .1 faram capacitor work?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Somebody said...
-Never Underestimate the power of human stupidity.
·

Comments

  • BeanBean Posts: 8,129
    edited 2006-07-18 22:32
    What type of microphone is it. "Regular" mic means nothing to me...
    Does it have any writing on it ?
    Could be: Piezo, condensor, moving coil, high-impedence, low-impedence, etc...
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "Remember, you are unique, just like everyone else." Unknown.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-07-18 22:56
    It has no writing, but I have a feeling it is piezo.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-07-20 15:25
    Bean- This is what I'm using
    http://www.radioshack.com/product/index.jsp?productId=2103751&cp=2032058.2032230&cp=2032058&f=Taxonomy%2FRSK%2F2032230&categoryId=2032230&kwCatId=2032058&kw=microphone&parentPage=search

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-20 15:37
    A. C. Fishing -

    If you're not familiar with it, you may want to look into using "TinyURL" for long links as you offered above. That service can be found here:
    http://tinyurl.com/

    Your long URL can be substituted with the following by using it:
    http://tinyurl.com/q7jls

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • BeanBean Posts: 8,129
    edited 2006-07-20 17:21
    Okay now your talkin'...

    That type of microphone will need a series resistor to a positive voltage.

    Something like:
    +5 ---\/\/\/--+--red wire   black wire --- GND
           2.2K   |
                  | 
              audio out
    

    Now the audio will be riding on a certain DC bias voltage, so you may want to run it thru a capacitor to remove the bias voltage.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "Remember, you are unique, just like everyone else." Unknown.


    Post Edited (Bean (Hitt Consulting)) : 7/20/2006 5:25:07 PM GMT
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-07-20 19:56
    And then I just use an RCtime program?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • BeanBean Posts: 8,129
    edited 2006-07-20 20:37
    What exactly are your trying to measure with the microphone ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "Remember, you are unique, just like everyone else." Unknown.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-07-21 17:05
    IT should be able to tell how loud something is.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-07-28 15:52
    Sorry, I'm not that good with schematics. What is GND?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-28 16:00
    A. C. Fishing -

    GND is just an abbreviation for GROUND ("earth" in some quarters). AKA the negative terminal.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-07-29 22:59
    so what program should I use with this schematic? I tried various simple input programs, and I want to get an output that is more complex then the digital 1 or 0.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-07-31 21:56
    I have tried this RCtime program:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    data1 VAR Word
    sensorPin CON 1
    counter VAR Word
    FOR counter = 1 TO 10000
    data1 = 0
    HIGH sensorPin
    PAUSE 2
    RCTIME sensorPin,1,data1
    iF data1 <> 0 THEN
    DEBUG DEC data1,CR
    ELSE
    ENDIF
    NEXT
    


    I can't get any response from tapping or yelling into the mic. I'm using the schematic you suggested with a .01 faram capacitor on the RCtime program.· I would like exact·RCtime·numbers·showing, like 3445.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-08-09 01:31
    I also have a PC-board condenser Microphone Element from radioshack. I can get one's and zeros from this by tapping it, but not by yelling at it. I'm pretty sure my programs I'm using for these are wrong somehow. I have also tried some RCtime programs, which can give me some bianary output with the PC-board mic. I would like more specific out puts though

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-08-10 21:31
    I can't get the mic to pick up sounds and noise, only taps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • Tricky NekroTricky Nekro Posts: 218
    edited 2006-08-10 22:53
    Well if you want to use your mic you probably need a ADC...

    which stands for analog to digital converter...

    RCtime is a kind of ADC but quite limited in use...

    You may need a serial one for easy use with BS2XX...

    MAXIM semi offers a full variety of ADC... Go check for yourself...



    Provas, Greece

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Rule your Destiny-
    --Be Good. Be Bad. Be Provas--
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-08-10 23:04
    BS2XX? I don't think this module exists... Do you mean the BS2px? Also, what if I want my BS2 to be connected to the computer serially at the same time as the BS2? Then How could I use a serial module? And are you saying that they can't be used with a regular basic stamp?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • Tricky NekroTricky Nekro Posts: 218
    edited 2006-08-10 23:42
    When I said BS2XX I mean the BS2 series including the BS2, BS2e, BS2px e.t.c.

    ADC can inderface with almost any microcontrollers... Serially is only a way...

    It can be serial asycronous, serial sycronous and parallel...

    what convinience you the most is a serial asycronous interface cause you mess up with only one wire (or maybe two(flow control pin) and connecting all devices to the ground... Serial sycronous uses three wires and has·minimal crashdown factor contrasting to asycronous... Parallel is the less convinience as you may waste too many pins but is much faster than any other connection...

    Better look for serial ADC... most of them are asycronous and you can get a very good 16bit resolution from some with less expense...

    what ever else you need just post...

    Provas, Greece

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Rule your Destiny-
    --Be Good. Be Bad. Be Provas--
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-08-11 13:15
    An analog-to-digital converter (abbreviated ADC, A/D or A to D) is an electronic circuit that converts continuous signals to discrete digital numbers. The reverse operation is performed by a digital-to-analog converter (DAC).

    Typically, an ADC is an electronic device that converts an input analog voltage to a digital number. The digital output may be using different coding schemes, such as binary and two's complement binary. However, some non-electronic or only partially electronic devices, such as shaft encoders, can also be considered as ADCs.

    From Wikipedia. So doesn't a ADC take the analog voltage data I would like, and convert it to binary data, like 1's and 0's?
    Do different modules come predefined, and say might convert all analog even numbers to 0, and odd numbers to 1? Or can you program it, or have the stamp send it a signal, which tells it what numbers are binary 1's, and which are 0's?
    Please remember that I'm hopeless at terminology.
    asycronous??
    sycronous???
    So I should hook up one of the serial ADC's to the BOE's SCB?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-08-11 13:28
    Doesn't the stamp already have one of those on each of its pins? Why else would it go to the trouble of making the raw data its getting into 1's and 0's?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • Tricky NekroTricky Nekro Posts: 218
    edited 2006-08-11 16:18
    I don't know how to explan it to you but... You have the mic circuit that Bean gave you, right...

    You say that if yell at it you get some reading... Now look...

    You went to too deep water very very early... Yes ADC converts alanog signals to logic binary... This row of binary represents a number... In order to be able to get this row you must have a input on the ADC input pin... But you can't just connect the mic to the ADC cause you might get a very small number that won't exited some very very low limits.... You also need a circuit that amplifies your mic ANALOG readings... What's why preamplifiers are for... The get an analog signal and amplify it... The output of preamplifiers is also an analog signal but "stronger" that the first one... What I mean by this... Well imagine a·everyday·man... He can lift 5kilos... But after some exercise he can lift 100kilos... Now the exercise is the preamplifier... Without it the mic can give you some reading through the ADC but these numbers won't be great even if you yell at it... But with the amplifier by yelling you get a great number at the ADC reading as well as wispers(very·"low" noices)·can give reading... So you can make your BS2 hear more things, in other words you extend it's hearing range. But also preamplifiers enables you to adjust this ability... The output of the preablifier may be too high for the ADC to recognise so a range of noise isn't audiable by the stamp, it just gets peak signals... So with a variable resistor you can control it's sensitivity... So that yelling gives the greatest numbers and wispers give only some small ones...

    With simple words you need to connect the mic first to a preamplifier then the preamplifier to the ADC and finally the ADC to the stamp...

    If you connect the mic to the ADC without the amplifier you might neven get readings...

    If you connect the mic to the stamp you get nothing...

    And if you connect the mic with amplifier to the stamp you only get 1 or 0 but you can also burn the pin if the signal is too high...



    What you want is able to be done but you need·much help (that's why I'm answearing)... You can do this... and I'll try to make a good circuit for you... Until then try to understand the basics and tell me what you did understand...



    Provas, Greece

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Rule your Destiny-
    --Be Good. Be Bad. Be Provas--
  • Tom WalkerTom Walker Posts: 509
    edited 2006-08-11 19:05
    A.C.,
    If I understand your question, then no, the Stamp does not have an ADC on each of its pins. Its pins will only respond to a "0" or a "1" as you put it. I agree with Provas that it sounds like you are trying to create a complex project without learning the underlying "simple" principles first. Have you gone thropugh the "What's a Microcontroller?" text (free download), yet? It provides good guidance and explanations of some of the functionality of the Stamp (including what it "sees" as a "0" or a "1"), as well as some good basic electronics theory and education.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-11 20:40
    Another thing to remember: The output of the microphone (or the microphone and amplifier) doesn't give you an indication of loudness. You've seen pictures of audio waveforms I assume. If not, get a simple electronics text. The signal goes up and down around a central axis which is usually considered the ground. It's the peak values you're interested in for this application. Basically, what you want is the average absolute value of the signal. A capacitor in series with the microphone (or amplifier) will "ground justify" the signal so the effective zero value is the center of the waveform. A diode in series with that will give you the absolute value and another capacitor (connected between the output of the diode and ground) will "filter" or smooth (average) the signal. There are a few resistors thrown in to make timings and the matching of one part of the circuit to another work out. The result (with probably some simple amplifier for the microphone) will be a voltage that the Stamp can measure.
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-08-12 02:13
    All I was really expecting for this project was a simple schematic with a 220 resistor attached to a capacitor, and a mic, and the other side of the mic was attached to Ground. The capacitor would be attached to a stamp pin. I would run a few RCtime programs, trial and error, and find something that works. I didn't know I would need ADC's and parts I've never heard of. I've read Robotics with the Boe-bot, and scanned What's A Microcontroller. With Mike's schematic it appears I won't even need an
    ADC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-08-12 02:16
    And... why doesn't Bean's simple schematic work? I've tried loads of programs and variations of it, but nothing really worked.
    And uh-oh...
    I said that I don't get any show of 1's when I yell.

    -I can't get the mic to pick up sounds and noise, only taps.
    -I can get one's and zeros from this by tapping it, but not by yelling at it

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
Sign In or Register to comment.