-2
\$\begingroup\$

If I need to read and write data over TRRS to and from headphone (i.e. I read from standard (iphone/galaxy) headphone mic. and write to standard headphone earphones).

This is a schema of what I want to achieve:

scheme

The idea is to just pass the data (without any manipulation) from the headset microphone through the ADC into the BluePill (STM32F103C8) and directly transfers it to the DAC and from there to the computer.

The reverse route is from the computer to the ADC and from there to BluePill which again does anything except transfer it directly to the DAC that transfers it to the headphones.

I need proper ADC and DAC to read and write the analog waves (proper = ADC that will know how to read the full range of the headset mic and DAC that will know to write the full range for the earphone).

ADC

I checked out ADS111x (specifically ADS1115). In it's datasheets it says input ranges from ±256 mV to ±6.144 V, Now I know standard headphone line-level voltage is 1 mW to a 600 ohm load, is this mean that this ADC is the proper one for me?

DAC

I checked out MCP4725. In it's datasheets it says `VOUT is an analog output voltage from the DAC device.

DAC output amplifier drives this pin with a range of VSS to VDD` so I can put in VDD (voltage in) 5 V from bluepill, but the ground (VSS) will be 0 V (I think this is BluePill ground) I need probably different scale to it (not 0 V < x < 5 V , probably something more like -2.5 V < x < 2.5 V), How can I overcome this issue?

p.s. This is very strange, but although I was looking for quite a bit, there is not one normal breakout for the Arduino/Blue pill that applies TRRS connection for easily inserting and removing information (using microphone and earphones). Just a thought.

\$\endgroup\$
  • \$\begingroup\$ hm, why do you want to do this? what's the purpose of all this? re your p.s.: Well, that's an awefully specific thing you want to do, and the STM32F1 on the blue pill certainly isn't what anyone professionally designing sound equipment would use, so why is it surprising no board exists? \$\endgroup\$ – Marcus Müller Dec 10 '18 at 10:04
  • \$\begingroup\$ @MarcusMüller My ultimate goal is to process the sound that goes through the microcontroller, my primary goal is to succeed in moving the sound from side to side when there is microcontroller in the middle ... \$\endgroup\$ – dog scotter Dec 10 '18 at 10:07
  • 1
    \$\begingroup\$ No! When two different devices sample the same analog signal, they don't get the same bytes – not at all. For various reasons: noise, attenuation, but far more importantly: Because they aren't synchronized. Imagine a sine wave. You sample exactly at the maxima and say 4 points in between. The receiver samples somewhere else. You get totally differen numbers representing the same signal. You're not phase-synchronized. And you can't be: your analog audio signal has no way of allowing an ADC to synchronize (no timing structure, it's not a pulse-shaped digital signal). \$\endgroup\$ – Marcus Müller Dec 10 '18 at 10:19
  • 1
    \$\begingroup\$ aside from that, you're also not frequency-synchronized (your different devices run from different clocks; your phone might be sampling at 32 kHz where you are at 50 kHz; how would you even sample the same signal instants? and: even if you both nominally ran at the same rate, the oscillators would drift against each other.). And you're by no means amplitude-normalized. \$\endgroup\$ – Marcus Müller Dec 10 '18 at 10:21
  • 1
    \$\begingroup\$ You really should ask a new question explaining what your ultimate goal is, and why (for which purpose) you want to achieve that, and asking how it can be done. None of what you're planning is based on reality :( \$\endgroup\$ – Marcus Müller Dec 10 '18 at 10:22
0
\$\begingroup\$

First a warning:

Arduino is not the environment you want to develop this in.

This is relatively easy to achieve if you can just interact with the DMA hardware, set timers, and directly control what happens in interrupt service routines.

Arduino abstracts all that away, and in an inconvenient way for developers who need those functionalities.

So, drop the Arduino environment and directly go for one of the many real-time OSes that can run on that STM32. Many people use FreeRTOS, mbed does get an increasingly large fellowship, and I personally like ChibiOS.


ADC

You don't need an extra ADC, your microcontroller comes with a multi-channel ADC that is plenty fast enough for conversions of audio.

Just make sure to trigger your conversion from a timer, so that you get a regular sample rate – otherwise, any processing will be impossible to do right.

Then, program the DMA controller to automatically take the ADC value(s) and move them to where they need to be – for example, the SPI port's TXDATA buffer, if you want to send them to an SPI-attached DAC, or to some buffer, in case you want your firmware to process it first.

Whatever ADC you choose, don't forget that you need to condition your signal: analog anti-aliasing filters are mandatory, otherwise you'll get aliasing and your digital signal would be broken.

DAC

You could, again, just use your STM32's PWM units followed by a low-pass filter and not use an external DAC.

\$\endgroup\$
  • 1
    \$\begingroup\$ microprocess has indeed fast enough ADC, but its ENOB is only 9 bits at and starting to drop around 30 kHz. So external ADC might be better for audio. \$\endgroup\$ – Rokta Dec 10 '18 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.