Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Mico: A PDM to USB Microphone Based on the Raspberry Pi RP2040 (electronut.in)
130 points by rcarmo on Dec 26, 2021 | hide | past | favorite | 42 comments


Instead of Pi it could have been a dozen different IC, but interesting part in this kind of project is audio theory, and MEMS microphone performance.

MEMS microphone used here is mp23db01hp

https://www.st.com/en/mems-and-sensors/mp23db01hp.html

and it looks like better than ICS 43434 that I stumbled on before

https://invensense.tdk.com/wp-content/uploads/2016/02/DS-000...

For theory about how microphone works and performs interesting read is

https://www.analog.com/en/analog-dialogue/articles/understan...


Today I learned that there are now MEMS microphones which rely on fabricated silicon, not conventional electrical coils or electrostatic/electrets/magnet pickups, to pickup sound waves.


I believe this is the most common type of microphone today. There’s just not enough space in devices like phones and smart watches for anything else. My SM7B is probably the only non-MEMS mic I own.


64dB SNR is pretty standard these days for MEMS – you will pay a lot more to get up in the 70s. Good studio mics will be in the 80dB+ range.

Here's the highest performing one today: https://www.digikey.com/en/products/detail/tdk-invensense/IC...



I wrote a series of blog posts about how to convert a PDM signal to traditional PCM values: https://tomverbeure.github.io/2020/10/04/PDM-Microphones-and....


I found the article, and the linked one, about audio recognition on a Raspberry using ML, very interesting. Now, if only you could buy these microphones assembled... :-)


Earlier this year I got a ReSpeaker mic for video conferencing, and it's been working great! I did have to upload the latest firmware once I got it. I then combined it with NoiseTorch for a basically perfect video chatting experience.

NoiseTorch detects speech and mutes the mic when you aren't speaking. I had tried Hushboard, which mutes the mic when you are typing, but sometimes I talk when I type. ReSpeaker is a microphone array, and it has a speaker output and can do noise cancelling on the mic from what is sent to the speaker. It was about $60.

https://www.seeedstudio.com/ReSpeaker-USB-Mic-Array-p-4247.h... https://github.com/lawl/NoiseTorch https://www.kryogenix.org/code/hushboard/


Yes, I'd love something simple like this that is cheap, you plug in and it "just works" without any faffing.

Microphones on computers can be such a source of pain - maybe not quite such a nightmare as printers, but it seems like you can never get them to work reliably for any period of time. I'd be willing to pay in an instant if I knew it would save me the hassle!


Possible interesting fun project: voice recognition on a USB device that emulates a keyboard that types what it hears.


Neat!

I’m curious if one could design a usb type A plug/port that is reversible such that the PDM is always facing up. I know there are some flexible/thin pcb that allow for this, although not sure how robust that design is (otherwise I’d assume we’d never have to worry about rotating the USB cable three times before getting it right side up. Maybe I just described usb type C :))


Interesting. You would have to invert the voltage on D+ and D- when it's in backwards. Or flip the lines somehow. Nice little puzzle that one


One could just have the contacts wired differently on the otherside of the board. The larger problem would be the contacts in the "backside" of the plug getting shorted by the USB connector shield. Outside of that it does sound doable. Maybe with a thin pcb and a USB-A shell it'd be doable...


Why not just put two plugs on the board, one in each orientation (and put the mic and rp2040 in the middle)?


I think you've hit the nail on the head: just use the type-C connector. Bonus, it means the connector could be on the same side of the PCB as all the surface mount components and not impact insertion direction. If you need a type-A, good news, there's adapters for that.


Hmm, why use the RP2040 over something like an ESP8266? The author mentions a few advantages, but can someone elaborate?


The goal here is to have a USB peripheral, so that this little device can plug in on USB and identify to the host system as an audio source (likely without even needing to install a driver, since audio sources & sinks are part of the USB spec). The RP2040 has built-in support for being a USB peripheral in its hardware, plus good support in the SDK for it.

By contrast, the ESP8266 is not designed to be a USB peripheral. Usually it's used with a USB-to-serial converter when you need to connect it to a host computer. This allows, well, serial transfers. It can't appear to a host computer as an audio source. There might be ways to do it, such as bit banged USB or custom drivers on the host computer that treat a serial port as an audio source, but by using a microcontroller with built in USB support, a lot of headaches can be avoided.

If you are particularly "into" the Espressif ecosystem, the ESP32-S2 and ESP32-S3 microcontrollers both have native USB support which would make them potential candidates for a similar project.


It is possible to do USB on microcontrollers that lack hardware USB support: https://github.com/obdev/v-usb


This project makes heavy use of the RP2040 "Programmable IO" PIO subsystem to do precise timing of input signals without needing to keep the cpu in a busy loop. No other microcontroller has that same subsystem, although other microcontrollers have differently-designed systems that allow similar results. The audio library would need to be rewritten though.


i've used spi modules to interface with pdm mics aplenty. no weird r-pi stuff needed.


Ahh, thanks! That makes sense.


The RP2040 is $1 in quantities of 10, so it’s really the perfect choice for this application. Personally, I only consider other microcontrollers if I must have some feature the RP2040 is missing (usually hardware floating point).


That's slightly more expensive than an ESP32, isn't it? I should get a few RP2040 boards to play with, though I really love the integrated wifi on the ESP...


Complexity wise it's CH552 < PIC18F < RP2040 < ESP8266


My only complaint about the RP2040 is that it doesn't have an external SPI ram interface.


That's usually a niche feature. Core IP and fabrication have become so cheap that it is preferred to get a Cortex-A part and real DRAM. What usecase do you have for larger memories on an embedded controller?


QSPI memory is real DRAM without the profusion of pins, routing density, and signal integrity issues of traditional devices. Lots of memory poor micros can benefit from expandability. Running a network stack in conjunction with other app code on 100K is challenging. Throw in a few megabytes of expansion and it becomes a more manageable task.


Sure, I meant ~DDR2/3 RAM. Implementation may be easier with QSPI but I have tried to use embedded core parts and had very bad times with the software when doing things you need the memory for, like graphics or network. Seems like a better use of time to reuse an existing design and put Linux on it so I'm not half-responsible for drivers.

A cortex-a part with QSPI/octSPI interface would be nice. I vaguely remember something, but I can not find it again.


It is, but running a 3.5" display would be nice. You could probably make something work within the ~200K on this part. Really I just want a better/competitor for the ESP32.


Is there a difference between pulse-density modulation and sigma-delta modulation? I've seen the sigma-delta hardware in STM32s and wanted a project to use them.


I would say that pulse-density modulation is more of an abstract concept and sigma-delta is a particular implementation. Or in other words, sigma-delta is a one technique used to produce a pulse-density modulation.


I've used the same microphone you used in your first experiment and yes... it sucks!

Really happy to see now your project, I'm only wondering how to had one of that.


So how would someone go about purchasing this ? Would it require custom ordering the PCB ? Seems like a very cool way to make affordable cheap USB microphones.


Yes, you’d need to do exactly that.

The PCBs can be ordered dirt cheap at Chinese shops like JCPCB. They are associated with LCSC, a cheap component supplier of Digikey, that also provides the RP2040 microcontroller (though currently out of stock, as expected with today’s supply chain.) They even provide cheap PCB assembly services.


JCPCB is not a PCB shop. They get the order, and then run to an actual PCB shop of their choosing.


Does it matter who they subcontract it to? At the end of the day, you as a customer only interact with them.

It’s like pedantically correcting somebody that Acer isn’t a monitor maker because their monitors are produced by an ODM like Qisda…


1) It's JLCPCB, not JCPCB: http://jlcpcb.com/

2) What is the source of this information? (honest question)


2. Worked in electronics. Been in, and out of Shenzhen since 2009


Got it, thanks. Btw, have you followed their SMT Assembly service offering? I've assembled 40+ designs with them this year, and it does seem like they do it on their own instead of delegating. Nobody comes close to their prices and assembly time.


If you give any SMT house JLCPCB's volume, they will do everything for you, sameday service included


The magic of JLCPCB is that they can do SMT mounting quickly, cheaply and for as low as 3-5 boards. My standard iteration time is about 8 days (which includes shipping from Shenzhen to SF Bay Area) and it liberates me from a need running an assembly shop locally and I can spend more time on what matters.

Traditional SMT houses usually have very rigid and expensive processes on setting up their Pick&Place machines, so giving them JLCPCB heterogeneous volume would not necessarily yield their interest.


FYI, there are already microphones with PCM, I2S, or even complete SoundWire protocol support.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: