Connect with us

Changing a positive and negative audio signal to positive only

Discussion in 'General Electronics Discussion' started by Braeden Hamson, Jan 11, 2020.

Scroll to continue with content
  1. Braeden Hamson

    Braeden Hamson

    217
    13
    Feb 18, 2016
    Hey guys long time no post,

    I've got a standard audio signal out if a computer which has a positive and negative portion. I'd like to shift the whole signal up so it's only positive. I've seen this done with a voltage divider where the signal is connected to the node of R2 that isn't connected to R1. Then R1 is connected to a bias voltage. The measurement is taken at the node that R1 and R2 share.

    Does anyone have a better solution for this? I'll leave the definition of better to you. With the caveat that power and space is no issue.
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,486
    1,953
    Nov 17, 2011
    What you want to achieve is called "DC offset". Quite an unusual request as usually one seeks to minimize DC offset.
    The resistor method is good.
    You can use an operational amplifier to build a summing amplifier for this purpose. The two inputs are the offset free audio signal plus the DC offset to be added.
    This is unfair. Since we do not know your boundary conditions, especially not why you need the offset, it is hard to define "better". Often the most simple solution (resistors) ist the best, but it has drawbacks, too. For example the output impedance is comparatively high. This may or may not pose a problem depending on the circuit following the adder.
     
  3. Audioguru

    Audioguru

    2,649
    599
    Sep 24, 2016
    Audio is not DC, instead it is AC. So add a series coupling capacitor then bias the output to whatever voltage you want.
    Note that high levels still might produce some negative parts.
     
    Braeden Hamson likes this.
  4. Hunter64

    Hunter64

    17
    7
    Nov 20, 2018
    What's the reason you want to do this?
     
  5. Braeden Hamson

    Braeden Hamson

    217
    13
    Feb 18, 2016
    Thank you, I knew it was something relatively simple and I was just spacing on what it was.

    And you're right I should just be upfront about why I need the circuit. My brother wants to build a "decorative" osilloscope for lack of a better term. Using an Arduino and a small oled screen. This will be used to visualize wave forms in music. I know music looks like a mess on a scope but this will be very basic tones, that will be assembled into music. Like colors into a painting. So the scope he made works, except the Arduino can't measure negative voltage values thus you get the positive portion of the signal.
     
  6. Braeden Hamson

    Braeden Hamson

    217
    13
    Feb 18, 2016
    My brother wants to build a "decorative" osilloscope for lack of a better term. Using an Arduino and a small oled screen. This will be used to visualize wave forms in music. I know music looks like a mess on a scope but this will be very basic tones, that will be assembled into music. Like colors into a painting. So the scope he made works, except the Arduino can't measure negative voltage values thus you get the positive portion of the signal.
     
  7. Ylli

    Ylli

    238
    50
    Jun 19, 2018
    This one is a 'clamp', it auto-adjusts to keep the negative peaks at zero.
    Annotation 2020-01-11 140138.png
     
    hevans1944 likes this.
  8. Minder

    Minder

    2,908
    609
    Apr 24, 2015
    You can get neat effects with a 'scope producing Lissajous figures.
    M.
     
    darren adcock likes this.
  9. Braeden Hamson

    Braeden Hamson

    217
    13
    Feb 18, 2016
    That's pretty awesome not gonna lie. That's why I didn't define better. I didn't know I wanted clamping.

    Thank you
     
  10. Braeden Hamson

    Braeden Hamson

    217
    13
    Feb 18, 2016
    True, but he does want it to actually show the sound's waveform.
     
  11. AnalogKid

    AnalogKid

    2,327
    653
    Jun 10, 2015
    Note that the battery in the clamp circuit can be just about anything, such as a single AAA cell, coin cell, etc. Even a watch battery (309, 393, whatever) will work, though it won't last very long.

    ak
     
  12. hevans1944

    hevans1944 Hop - AC8NS

    4,272
    2,012
    Jun 21, 2012
    I don't think you actually need the "bias" supply, it's series resistor, and the 1N4148 diode with its cathode connected to ground. As shown, the "bias" supply simply forward biases D2 all the time, draining current from whatever 5V voltage source is provided by V2. The connection of D2 anode and D1 anode therefore remains one diode drop above ground since D2 conducts continuously.

    Leave all this stuff off and just connect the anode of D1 to ground. This will clamp the audio signal from C1, as it appears across of R2, to one diode drop above ground. C1 will charge up through D1 to some voltage between the peak positive voltage coming in and one forward diode voltage drop above ground potential. This voltage on C1 will add to the input voltage to ensure there is always a positive voltage across R2. Problem is, this "offset" voltage varies with the peak-to-peak amplitude of the audio signal, so larger audio signals produce a larger DC voltage drop across R1.

    This may not give the effect you want after the Arduino digitizes the 0 to +5 V audio signal, but it's a start. More complicated shenanigans involve operational amplifiers that would, for example, allow the input audio to the Arduino to appear as a positive DC signal with the positive and negative peaks centered between zero volts and five volts for any audio input amplitude between zero and five volts peak-to-peak. Some more work will be required to achieve this, an exercise I will leave to other deep thinkers and tinkerers here on this forum.
     
    Braeden Hamson likes this.
  13. Harald Kapp

    Harald Kapp Moderator Moderator

    9,486
    1,953
    Nov 17, 2011
    For that you need to simply add a positive offset of 2.5 V which can easily be done using a capacitor and 2 resistors:
    upload_2020-1-15_8-29-3.png


    Be aware that you will have to low pass filter (R3, C2) the audio signal in order to:
    • Keep the max. signal frequency at < 1/2 of the arduino's sampling rate to stay within the limits of the Nyquist-Shannon sampling theorem.
    • Reduce the max. signal frequency even more to be able to update the screen in real time.
    In the arduino software a 2.5 V input (should read somewhere around 512 using analogread() in 10 bit ADC mode) is equivalent to 0 V on the audio input. This is your baseline (0) from which you measure either positive voltages (reading > 512) or negative voltages (reading < 512).
     
    bertus and hevans1944 like this.
  14. Ylli

    Ylli

    238
    50
    Jun 19, 2018
    Will clamp at 1 diode drop *below* ground.
     
  15. Braeden Hamson

    Braeden Hamson

    217
    13
    Feb 18, 2016
    I'll give this a try, thank you
     
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

-