Maker Pro
Maker Pro

Changing a positive and negative audio signal to positive only

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.
 

Harald Kapp

Moderator
Moderator
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.
I'll leave the definition of better to you.
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.
 
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.
 
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.

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.
 
What's the reason you want to do this?
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.
 
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
 

hevans1944

Hop - AC8NS
This one is a 'clamp', it auto-adjusts to keep the negative peaks at zero.
View attachment 46876
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.
 

Harald Kapp

Moderator
Moderator
My brother wants to build a "decorative" osilloscope for lack of a better term. Using an Arduino and a small oled screen.
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).
 
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:
View attachment 46899


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).
I'll give this a try, thank you
 
Top