# Adding DC bias to signal?

If I have an arduino output an audio signal, the voltage obviously could vary from 0 to 5v.

How could I add the correct DC bias to make the signal centered on 0v?

Could I use a circuit like this: 555 negative voltage generator to create a negative voltage, and use it as the negative voltage supply for an op amp to get the correct bias?

How about just putting a capacitor in series with the output signal? That will block the DC component.

The Ruggeduino: compatible with Arduino UNO, 24V operation, all I/O’s fused and protected

sciguy: If I have an arduino output an audio signal, the voltage obviously could vary from 0 to 5v.

How could I add the correct DC bias to make the signal centered on 0v?

Could I use a circuit like this: 555 negative voltage generator to create a negative voltage, and use it as the negative voltage supply for an op amp to get the correct bias?

First an arduino can't output an analog signal, only digital outputs including PWM outputs. If you could generate a audio signal that was biased to +2.5 so that it's complete wave was confined to 0-+5vdc then converting back to a true 0v based audio AC voltage would simple require that you wire the signal through a series capacitor. Recall that a cap will pass AC but block DC.

Lefty

I'm using PWM with a simple RC lowpass filter to generate an analog output. I made a simple MIDI synth that right now outputs an 8 bit triangle waveform tone that has 8 steps, so it's a pretty blocky triangle.

I tried recording the output of the arduino with my mpc so I could see the waveform, and apparently the mpc's analog input automatically corrects for a dc offset. (I can see the tone start with an offset, then the offset gradually decreases for about a second until it has a dc bias of 0. Then, once the tone stops, there is a part where the displayed waveform dips below 0 then gradually corrects itself up to 0.)

I didn't have too many capacitors at hand to try in series with the output, so it was either too great capacitance, and it didn't affect the offset much, or too small, distorting the blocky triangle waveform.

Then I got bored and made this: bored song

So I did a few things:

Made the triangle wave 16 steps, half as blocky. Made the wavetable index updated by a timer interrupt (improving tuning, and now it's completely run by interrupts) Tried some more capacitor values, I found some that worked pretty well with the blocky triangle wave. But the flat parts of the wave still drop back to 0 some before the next step in the waveform. So the capacitor idea I think won't work, especially when I decide to use a square wave.

But the flat parts of the wave still drop back to 0 some before the next step in the waveform.

After the capacitor put a pull up and pull down resistor on the end. That will restore the DC bias to 2.5V, if that is what you want. Although I don’t know why you want it like that.

Sorry, I wasn’t clear. This is what I meant:

Does anyone know how to place an attached image file in the main post? Okay, I got it but is there an easier way than posting it, then copying each download link from the bottom of the page into the original post?

Anyway, the first picture is a screenshot from the trim screen- square wave (about 3 seconds long) without dc blocking cap.
The mpc seems to correct for the dc offset.

The second one is zoomed in on the same sample- pretty much square.

The third one is with the dc blocking cap. The sample had a dc bias of 0 throughout. But, not so square. That’s what I meant by flat parts of the wave sloping back towards 0.

But, not so square.

That is showing that the low frequency response is poor. This can be improved by making the capacitor larger. What value do you have and what value load is it running into. A value of 470uF is not out of the question.

So I tried a 100uF dc blocking cap, but I still got a similar result, where the signal would start with a positive dc bias, then settle to 0 after a short period of time. So still not ideal, because it clips, even though it sounds quieter.

But I thought of something else: Would it work to use a voltage divider to get 2.5V from the original 5v, then connect the 2.5V source to the sleeve of the audio jack, instead of ground, as usual?

Yes but you have to make sure you two grounds (arduino and audio amplifier) are floating with respect to each other.

However, I still don't know why you want to do this, what do you think it will achieve?

Say, for example, I have an audio signal that ranges 0-5v, but my audio device only has headroom for a signal that varies from -2.5 to 2.5 volts. Although a signal would sound the same centered on 0 or 2.5 volts, the 0-5v signal would be clipped if put into the audio device. The dc offset just seems to limit the headroom of the mixer/recorder/whatever.

0-5v, but my audio device only has headroom for a signal that varies from -2.5 to 2.5 volts.

It will not matter, your audio device will be AC coupled it will see no difference. I have never come across a DC coupled audio device, they just don't exist because of the problems you describe.

I have never come across a DC coupled audio device, they just don't exist because of the problems you describe.

In the mid 70s, a golden era of hi-fi equipment, several of the top brand manufactures of the era offered some top of the line amplifiers and receivers that had true DC coupling from input all the way to the speaker terminals. They usually did have an input selector switch where you could AC couple the input audion signals or use DC. But yes you have to be careful with what you hooked up when using 100% DC coupling.

It was mostly a marketing driven thing and once one company offered it in it's top of line stuff others had to copy them. I would never run in pure DC coupling, because I'm aware of the damage that could result.

Lefty

I have a similar, maybe opposite question. I would like to bring in a line level AC coupled signal and apply an offset to it to make it 0 - 5 VDC for an arduino analog input. (I intend to use the DSP library to turn my 5 band EQ setup into a 10 - 15 band EQ.)

I know I covered this in school but I can't for the life of me find good information about it online. I was attempting to use a clamping op amp circuit.

Thanks!

-Mike

Sorry for the hijack

Just use a capacitor to couple into a potential divider, like the front end of this:- http://interface.khm.de/index.php/labor/experimente/arduino-realtime-audio-processing/