Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is the audio hardware set up exactly? #3

Open
level20peon opened this issue Jan 26, 2016 · 16 comments
Open

How is the audio hardware set up exactly? #3

level20peon opened this issue Jan 26, 2016 · 16 comments

Comments

@level20peon
Copy link

I would like to see some detailed pictures of how your mbec codec looks like with those wires soldered to it as well as how the microphone circuit is connected.

@jasaw
Copy link
Owner

jasaw commented Jan 27, 2016

I'm at office, don't have a picture with me right now, but I've added a diagram in readme to show what I've done. The GND wire just connects to the nearby via. To connect the microphone, connect mbed codec GND, MIC BIAS, MIC IN to the microphone circuit's AGND, MIC BIAS, MIC IN respectively.

@level20peon
Copy link
Author

Thanks for the explanation. The sentence "Wires were soldered from the 2 MIC and GND pins of the IC to the unused side of the header." is too ambiguous for me to understand. It sounds like I have to solder the ICs multiple GND pins to a header, but using the "hole" besides the "IN" connector is far easier.
So I soldered pin 17, and 18 for the MIC as well as pin 25 for the Clock directly from the IC to the header.
But I got "AR", "Out", "Gain", "Vdd" and "GND" on the MAX9814 based amplifier (https://www.adafruit.com/product/1713), not "AGND", "MIC BIAS" and "MIC IN". I am not really sure which pins of the mbed coded I should connect to which pins of the amplifier.

@jasaw
Copy link
Owner

jasaw commented Jan 28, 2016

Thanks for the feedback. That's what happens when I don't proofread. :-)
Disclaimer: I have never used the MAX9814 amp before, so I suggest you play around with the circuit to test it out.

You could try this connection:
AR: float
Gain: float
Vdd: --- mbed codec 3V3
GND: --- mbed codec GND
Out: --- 1uF capacitor --- mbed codec MIC IN

Play around with the max gain (by shorting Gain to either Vdd or GND) if it's too loud.

@level20peon
Copy link
Author

No problem :)

Ah ok, I bought it because you listed it here and I didn't want to experiment with hardware I have no clue about.

Do you mean "NC" by "float" ?
Also, Vdd -> mbed codec 3V3? Don't you mean MIC BIAS? Because for which purpose did you solder a wire to the ICs MIC BIAS if you don't use it?
I have 100uF, 10nF and 100nF capacitors laying around, will any of those do in your oppinion? The documentation states that one should use 1-100uF when using it for LINE input so I am wondering if I need a capacitor at all.

@jasaw
Copy link
Owner

jasaw commented Jan 29, 2016

Yes, float is NC.

Yes, Vdd ---> mbed codec 3V3 is correct. The MIC BIAS is for driving the mic directly. Here you have the MAX9814 supplying its own mic bias, and yes, there's no need to bring the MIC BIAS out from the mbed codec chip.

As for the capacitor, 100uF should work just fine. The MAX9814 output is DC biased, so we use the capacitor to filter out the DC component.

@level20peon
Copy link
Author

ok, but I can't get it to work at all.

A arecord -L outputs:

default:CARD=sndrpimbed
    snd_rpi_mbed,
    Default Audio Device
sysdefault:CARD=sndrpimbed
    snd_rpi_mbed,
    Default Audio Device

So the codec seems to be connected to the Pi.

A sudo i2cdetect outputs a "UU" at addresses 1b and 3b. It seems that this stands for "reserved" or something?

So I tried:
amixer -c 1 sset 'Mic' cap
amixer -c 1 sset 'Mic Input' on
amixer -c 1 sset 'Mic Booster' on
arecord -D hw:1,0 -f DAT -r 8 /tmp/my_record.wav

The resulting "my_record.wav" contains no sound though.

I tested the MIC on an oscilloscope, it produces output although I had to connect it to 5V on the PI because the 3V3 on the mbed codec didn't suffice. So I got no idea what else to test, this audio part is driving me crazy...

What I don't understand is that even if the microphone wouldn't work or wouldn't even be connected, it still should record some static noise, right?

I tested playback on the mbed codec and I could hear some static noise, but that's due to the fact that I haven't shortened the connector-cables yet. I want to get it to work first, then assemble it and cut the cable lengths accordingly once everything is in place.

By the way: are you sure that CS hast to be connected to the PIs 3V3 instead of connecting 3V3 to 3V3, same for MODE connecting to GND instead of connecting GND to GND!?

Could you maybe provide an image of a working RaspBian instance to double check whether it's hardware related or software related?

@jasaw
Copy link
Owner

jasaw commented Jan 30, 2016

Sorry, I just realized that I've left out the mbed 3V3 and GND connection in the readme. You'll have to connect the 3V3 from Pi to mbed CS and 3V3, GND from Pi to mbed MODE and GND. That may be the cause of your audio problem.

For testing, there's a plot_wave python script in tests directory. You can try using that to plot the wav file that you've captured and see what values you're getting.

@level20peon
Copy link
Author

I added the 3V3 and GND connections and I transfered the recordings to a PC to listen to them but there's nothing in those recordings, they just don't contain any sound.

Anyways, even after adding the two connections it still isn't working.

Could you maybe post your kernel.img, or better yet, your boot folder here?

I just had the bright idea to scope the I2S lines. Turns out that there's nothing coming in at the PIs DIN (P5-05). So the mbed codec doesn't send any data, which in turn produces no output in the WAV file. So the question is, why is there no data being sent.
Even if I set the Line as capture device (amixer -c 1 sset 'Line' cap) no data is being sent while recording. I don't get it.
When I play back a soundfile on the PI I can see data being sent from the PIs DOUT (P5-06), so the connection seems fine.

@jasaw
Copy link
Owner

jasaw commented Jan 31, 2016

It sounds like your mbed codec chip is not even running.

Did you remove the crystal on the mbed codec? If you remove it, you're going to need to feed the GPCLK0 into the mbed codec's MCLK pin. Btw, there's no need to remove the crystal.
If you haven't removed the crystal, you can follow this readme on how to set up your I2S and mbed drivers.

Here's a working kernel and drivers. It assumes the Pi's GPCLK0 is fed into the mbed's MCLK pin (pin 25 on the codec chip).
kernel_n_drivers_3.12.26.zip

@level20peon
Copy link
Author

I removed the crystal and followed your "main" guide (https://github.com/jasaw/bbPiCam/blob/master/README.md) for setting up the software and hardware. Even with the kernel and drivers you sent me I didn't get it to work. I ordered another codec to make sure it isn't defective. I think it's running though, because I can find it via aplay -l and arecord -l.

Oh and I also bought this (http://au.rs-online.com/web/p/condenser-microphone-components/8837917/), in case I can't get the mbed codec to work. I have no idea yet of how I would implement the software part of this, but the hardware part seems perfect.

@jasaw
Copy link
Owner

jasaw commented Feb 2, 2016

It's odd that you're not getting any signal out of the codec. I don't know what else to try.

You're in luck, there's already a driver for the MEMS microphone.

@level20peon
Copy link
Author

I will report back when I get the new hardware.

I have seen that driver, but it hasn't found its way into the raspbian repository so I think I am out of luck here.

@level20peon
Copy link
Author

I am still waiting for the hardware, because this time I wanted to let someone else handle the soldering - just in case.
In the meantime, the MEMS microphone arrived and I opened a thread in the Raspberry Pi forums (https://www.raspberrypi.org/forums/viewtopic.php?f=71&t=134842) but apparently, nobody is able to help me integrate the driver... maybe it's not possible.

@level20peon
Copy link
Author

I received the new mbed codec and I am actually able to record from the microphone now. However, there is a lot of static noise making this not feasable as an audio source. I tried connecting the mic via capacitor and without capacitor, and with and without resistor (all combinations)... I even held its contact pin directly on the pin of the mbed codec... didn't make a difference, it sounds like there's wind blowing into the microphone all the time.
I already shortened the cables for the I2S communication from the codec to the Pi so that shouldn't be the cause of the static noise. Also, there's only silence recorded when the mic is not attached to the codec, so I think the problem is somehow related to the mic itself !?
I am powering the mic with 3V3 directly from the Pi and the ground wire also runs directly into the Pi. Maybe I need to filter this power input... what do you think... what could the the source of my problem?

@jasaw
Copy link
Owner

jasaw commented Feb 13, 2016

Which mic are you using? Are you using the mic with automatic gain control (MAX9814)? If you are, try limiting the max gain. Also check the actual samples you're recording. I plotted the samples using the plot_wave python script which is quite helpful for debugging.
I used a passive mic front end circuit as described in the readme, and that worked fine for me, except the gain is not high enough. Another issue I had was occasional corrupted audio samples on the first channel (the highest bit stuck high).

@level20peon
Copy link
Author

I am using the MAX9814 one, yes. I tried to limit the gain but it didn't help.
After spending more than 100€ on 2 mbed codecs + MAX9814 + soldering and hours if not days worth of testing I still didn't receive a reply on that MEMS driver integration thread in the RasPi forums.
So I decided to go with a USB mic and just successfully tested the Soundblaster Play 2 with a hama microphone and will base the rest of the project on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants