go_away

Author Topic: convert input from microphone to pwm input  (Read 1446 times)

0 Members and 1 Guest are viewing this topic.

Offline blackbeardTopic starter

  • Supreme Robot
  • *****
  • Posts: 575
  • Helpful? 4
convert input from microphone to pwm input
« on: November 09, 2010, 10:35:27 AM »
so i want to detect sound from standard microphones by converting the low voltage they generate to pwm signals. i'm thinking if i use an op amp chip i could have it output either +5v or 0v so that a micro could understnd it as usefull data
« Last Edit: November 09, 2010, 05:04:39 PM by blackbeard »
"sure, you can test your combat robot on kittens... But all your going to do is make kitten juice"

First step: Build androids with AI
Next step: Give them vaginas

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: convert input from microphone to pwm input
« Reply #1 on: November 09, 2010, 06:50:24 PM »
Hi,

so i want to detect sound from standard microphones by converting the low voltage they generate to pwm signals. i'm thinking if i use an op amp chip i could have it output either +5v or 0v so that a micro could understnd it as usefull data
I doubt that you'd get anything usable from PWM'd sound - each time you convert the signal, you loose some and that is detrimental to speech recognition (if that's what you're trying to do).

What you need for the conversion is a digital audio amplifier, and since they're now quite common, you should be able to find enough articles to study all the intricacies of such a beast.

In short, you create a very stable (think both X-tal- and amplitude control) triangle waveform running at 150+kHz (HiFi amps are running much higher). This signal is fed to a comparator along with the audio signal and the resulting output is your PWM signal.
Now you "just" need to program the controller to read 150+kHz PWM - better you than me ;D

I'd rather use an A/D-C input, unless the main purpose is experimenting and learning.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline blackbeardTopic starter

  • Supreme Robot
  • *****
  • Posts: 575
  • Helpful? 4
Re: convert input from microphone to pwm input
« Reply #2 on: November 10, 2010, 06:23:04 AM »
Ok I should have been more detailed in the description of my project. I am not trying to add speech recognition but sound detection. It would be used to allow a robot to hunt down noises. It wouldn't need to understand what it is hearing but when it detects a noise on one of it's two microphones it would adjust it's position accordingly.
"sure, you can test your combat robot on kittens... But all your going to do is make kitten juice"

First step: Build androids with AI
Next step: Give them vaginas

Offline azy

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: convert input from microphone to pwm input
« Reply #3 on: November 13, 2010, 06:18:21 AM »
I got some source code somewhere , and a standalone exe file (Freebasic, Compiles into c i think, not interpreted at run time so its fast and light as basic goes)


plug in a analogue mic in to your sound card, run the prog and then a text file is created

in the text file is a volume and a time, eg volume = 77 , time = 12:35:17  

updates a couple of times a second, text file gets bigger 1 line at a time, can easily distinguish 10 different volume levels of sound. Just write a snippet of code to snoop the txt file in the language of your choice

any good to you ?

Original code was a spectrum analyzer that output to the screen in real time, i just sampled some screen pixels to get the peak volume levels at any given point in time. Butt ugly but it works !

« Last Edit: November 13, 2010, 06:31:44 AM by azy »

 


Get Your Ad Here

data_list