Step 4: Normalize the Input and Output

Picture of Normalize the Input and Output


This is the only real "trick" when it comes to the hardware for this system. Audio happens as an AC signal from -1 V to +1 V, but the analog inputs on the Arduino run from 0 V (Ground) to some positive voltage called the analog reference (5 V by default). You can specify this positive voltage in code or with an external reference.

Since -1 V to +1 V is a 2 V range, we'll choose something smaller than 2 V for our analog reference value. It turns out 1.1 V is specified as a built in internal reference, which works out nicely.

From here we have to normalize the -1 V to +1 V as 0 V to 1.1 V. I did this using a resistor in series followed by a voltage divider circuit. A guitar cannot directly drive this circuit, it needs a preamp (like another pedal) to drive it. I'm sure you could add a transistor or op-amp preamp to the perf board so you could plug into the pedal directly.


For the output, we're going to be using PWM. With some low level hacks in software, you can get an 8-bit PWM running at 62kHz = 16 MHz / 28

There are some other methods for audio output on the Arduino. A good overview can be found at uC hobby. I got some great results from an R2R DAC, but considering it needs around 40 resistors for 10-bit stereo output, I decided against it. Instead I went with the weighted pins technique, which is kind of like a cross between standard PWM and a resistor ladder.

Building the Circuit

I built two of each circuit on one perf board. I had a ground strip down the center that helped for arranging things as neatly as possible. The first time I built the circuit, it was too tall and didn't fit in the enclosure, so I had to build it again.

When you have capacitors in series like this, they will cut off some of your low frequencies. WIth a 2.2 uF capacitor, it's low enough so it doesn't really affect sounds in our hearing range. The larger the value, the better; but capacitors tend to get physically larger as their value increases.
missingmax5 years ago
I see you used ceramic and electrolytic caps. Which one works better? 
Also, what would be the polarity if you used the electrolytics in your schematic?
kylemcdonald (author)  missingmax5 years ago
I didn't evaluate ceramic vs electrolytic for their "sound" really, so I can't say which one is "better". You'll have to try both out and let me know if you hear a difference!

I vaguely remember, on the outputs, the electrolytic caps facing the output. But again, you should try it both ways -- this was two years ago now and I have been writing a lot more code that making circuits since then :)
 Any chance you could post a picture with the other side of the perfboard circuit for the DAC? I'd like to have a go at this project but am having a little trouble with this stage.

Someone should make an audio input/output sheild for the Duemilanove with all the DAC on board for projects like this!
kylemcdonald (author)  loneguitarist5 years ago
Sorry, I don't have this pedal any more, I made it for a friend!

If I remember correctly, the perf board wasn't connected on the back and everything was manually soldered. So hopefully the diagrams/schematics on this page will explain anything missing from the pictures. The pictures were meant more as a layout guide for fitting the components in a smaller space.
larsby5 years ago
Hi there,

love your work, I have one question about this though, the r1 on the in-part, what is it good for, why do you need it?
kylemcdonald (author)  larsby5 years ago
Hi Larsby,

The r1 acts to "scale" the incoming signal. I generally think in terms of software rather than hardware, so you can imagine the chain on the input acting like this:

- r1 divides the signal (scales it down slightly)
- c1 centers the signal around zero (removes the DC component)
- r2 and r3 add a constant DC component back in -- shifting the signal up