Connect with us

Audio interface to microcontroller?

Discussion in 'Microcontrollers, Programming and IoT' started by Texton, Aug 30, 2012.

  1. Texton

    Texton

    14
    0
    Jul 27, 2012
    HI All.

    I am building a audio interface for my microcontroller, PSoC5. Problem is audio is transmitted through mini jacks in the range -2V to +2V and my PSoC5's ADC can only measure 0-5V.

    So I have to raise the -2 to +2V to my ADC range, but how? further more I assume that some kind of AC coupling is nessesary?

    Next I need to output the audio to a mini jack again - same problem but the other way around using the microcontrollers DAC?

    I come up with some suggestions, but I dont know if it's right, so pls help :)

    Here is my suggestion:
    https://dl.dropbox.com/u/1737568/20120830_182558.jpg

    And here is the problem described in picture:
    https://dl.dropbox.com/u/1737568/20120830_183146.jpg
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,361
    1,901
    Nov 17, 2011
    Suggestion 1 will not work. The PSoC will still see +-2V.
    A serious solution would use an amplifier (e.g. OpAmp) to decouple the input from the PSoC. But a simple alternative could do the job as well:
    [​IMG]
    Input (green) is -2V ... +2 V
    output (blue) is 0.4V ... 4.4 V. By reducing R1 to 3.2kOhm you can adjust it to 0V... +4V
     

    Attached Files:

    • bla.gif
      bla.gif
      File size:
      15.6 KB
      Views:
      662
  3. Texton

    Texton

    14
    0
    Jul 27, 2012
    Ok, that seems like a good solution. Actually my intentions was to put a internal OPAMP (in the PSoC) to buffer the Vdd/2 reference. Would that make my suggestion work?. Or how would you use the OPAMP?
     
  4. Texton

    Texton

    14
    0
    Jul 27, 2012
    And btw. what simulation application are you using? :)
     
  5. Harald Kapp

    Harald Kapp Moderator Moderator

    9,361
    1,901
    Nov 17, 2011
    You can use the OpAmp with my circuit. Set it to a unity gain buffer.

    I simulate with LTSPICE.
     
  6. Texton

    Texton

    14
    0
    Jul 27, 2012
    Okay ill try that. What about the output?.. My ADC range is 0 to 4V, so could I just make a 2V reference and then put it direct on to the mini jack with the reference as ground?..
     
  7. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,266
    Nov 28, 2011
    You had the right idea initially. Use a series capacitor from the input jack to the ADC, and a resistor from the ADC input to a 2.5V reference voltage to centre the ADC input at half scale.

    For the output, all you need is a series capacitor between the DAC output and the jack connector. You can also add a resistor from the jack connector to ground, so the output is forced to straddle 0V. Depending on what load you're using, this may not be necessary, but at least it will prevent the thump you would hear when you plug in the output device.

    The only mistakes on your first diagram are that the ground terminals of the jacks should be connected to 0V not to 2.5V. It is standard for the earth sides of input and output connectors to be connected to the 0V rail of the circuit.

    . . . . . . C
    v----------| |--------------->ADC
    ==--- . . . . . |
    . . . | . . . . . ---/\/\/---< +2.5V
    . . 0V . . . . . . . R

    . . . . . . . . . . C
    DAC >-----------| |----------------------v
    . . . . . . . . . . . . . . | . . . . . . ---=
    . . . . . . . . . . . . . . .---\/\/\/---|
    . . . . . . . . . . . . . . . . . R. . .|
    . . . . . . . . . . . . . . . . . . . . 0V

    With a 4V p-p signal you will only see 4/5ths of the ADC input range used. You can use an op-amp with a gain of 5/4 to fix this but you'll need a higher supply voltage or an op-amp with a rail-to-rail output. The normal way to handle this would be to reduce the input range of the ADC.

    Please excuse the ASCII art :-/
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-