|
Post by beatstick on Feb 14, 2021 6:05:40 GMT
This is probably a dumb question, but even though I've worked with tons of digital circuits and embedded coding I've always been a dunce when it comes to the analog side of things.
What would be the standard way to adapt a 3.3V audio signal to the AE Modular's 5V level?
Basically I'm building my first DIY module out of a Teensy and a Teensy Audio Shield. So the audio will come out from a SGTL5000 codec, but its line level is referenced to 3.3V. I need to shift that up to the 5V, 2.5V center, that the AE modules expect.
I'm sure it's just a basic op-amp circuit or something like that, but again I'm a total analog dunce. If anyone can point me in the right direction that would be amazingly helpful.
|
|
|
Post by keurslagerkurt on Feb 14, 2021 10:13:21 GMT
Nothing dumb about your question! The standard solution is called 'ac coupling', and is pretty simple, so would be a nice way to start in analog circuitry. This video explains it way better than i ever could: From 20:00 onward is exactly what you need: offset voltage is needed to set your 2.5V center. Ac coupling is needed to be sure your center is fixed at this 2.5V. I'd suggest watching the whole video tho, it is well well worth your time and really built from the ground up for ppl without analog circuitry knowledge! Helped me a lot in the past So you'll need a capacitor in line with your signal, and a (rather big) resistor going to 2.5V (we call this our 'virtual ground' in AE, as it is the center of our waveforms). To get this 2.5V, you'll need to set up a voltage divider, in this case 2 equally large resistors between 5V and 0V. The center point of these two resistors will give us 2.5V. I think that should do the trick. You waveform afterwards should be somewhere between 1.33V and 3.666V, which is just fine, no need to be from 0V to 5V exactly. However, if you feel like the volume is too low, you might want to build a opamp circuit to boost the levels a bit further. If you wish to do so, i suggest you search for 'simple op amp gain circuit', it should be one opamp and just two resistors (or a pot if you want to controll the gain). Just remember that where there is usually 'ground' or '0V' in circuits online, that should mostly be our 'virtual ground' ie 2.5V in AE Modular. Good luck!
|
|
|
Post by keurslagerkurt on Feb 14, 2021 10:20:45 GMT
Just to be clear: in the video Moritz Klein talks about 'removing offset', ie setting the offset to his 0V (or ground). Setting the offset to 2.5V requires the same method as setting it to 0V. The only difference is that the resistor in his AC-coupling circuit goes to 0V, you would want it to go to 2.5V.
|
|
|
Post by beatstick on Feb 14, 2021 20:32:28 GMT
You're a legend. Thank you! I'll do some breadboarding and see how things go.
|
|
|
Post by beatstick on Feb 17, 2021 0:35:10 GMT
I did some breadboarding and made progress, but also got a bit of an odd result. I used two 10K 1% resistors to divide the 5V down. The Teensy Audio Shield has a 2.2uF cap on its lineout output, so all I added on the breadboard was a 100K 1% resistor from the output of that 2.2uF cap to the middle of the voltage divider.
Indeed, that worked to offset the audio signal! However my scope measures the mean at 2.36V when the divider is putting out 2.60V (measured with multimeter and scope). The divider's 2.60V is correct; I'm just testing with USB voltage right now so it's a little over 2.5V. I verified the divider by measuring each resistor's drop as being roughly equal.
Did I do something wrong?
|
|
|
Post by keurslagerkurt on Feb 17, 2021 8:41:43 GMT
I think the mean of 2.36V will be just fine for your audio signal, it's not that critical that its exactly 2.5V as far as I know. Did you connect your audio output point to something? Or only to your scope? My guess would be that maybe your scope is 'loading' the output point a little bit, meaning that its dropping the voltage a little bit because its 'using' some of that voltage. The better your scope, the less it would do that. Just a wild guess, might be something else that i'm overseeing! Anyway, I think your little circuit should do the trick now to bring audio from the teensy into your AE system!
|
|
|
Post by beatstick on Mar 4, 2021 20:41:30 GMT
Alright, a couple deep dives later and I'm back with a working circuit.
I didn't feel confident in the plain resistor divider circuit. Any kind of load on the output will influence the divider, dropping not only the mean voltage but also the minimum peak. In my SPICE simulations it was possible for it to drive a negative voltage with even modest loads.
That may or may not be a problem in practice. The DAC might just clip if it tries to drive a negative voltage; the input loads might all be 1Meg or higher; etc. But I just didn't feel comfortable with it.
Basically it's a resistor divider, but with an OpAmp in buffer configuration on the output. The OpAmp is extremely high impedance, so nothing will effect the resistor divider, giving a nice, clean 2.5V offset no matter what the load does. The first answer on that page digs in deep as to what values to use for the components.
In my case, I didn't need any gain (1), so I elided R4, R5, and C3. I also didn't need C4, because the whole point of this circuit is to be DC-coupled. C1 is already on the Teensy audio board. I used an MCP6021 OpAmp; it's single supply, 5V tolerant, rail-to-rail with low noise and low THD. It also conveniently includes a Vref pin which is internally hooked up to a resistor divider. So I get R1 and R2 for free!
I added a 1k resistor on the output, to match the AE Modular's output impedance specification (the OpAmp has ~0 impedance at most loads).
So it turns out to be a dead simple, four component circuit. MCP6021 OpAmp, 1Meg for R3, 1k output resistor, and a 2.2uF cap on Vref (2).
Here's my breadboard, working like a charm with the AE Modular (3):
(1) I configured the DAC on the Teensy audio board to output ~3V Peak-to-Peak, matching what's described in the AE Modular's specification wiki, so no gain was needed. Which is good, because those gain resistors can be a nasty source of noise.
(2) I don't know exactly what value would be needed here for the filtering cap. Probably the "ideal" configuration is actually a nearby 10uF cap and a close 0.1uF cap. But I'm bad at this stuff, and I don't have the equipment to measure these kinds of noise levels. I do know that my AE Modular is quite noisy, with noise leaking out of the modules into the headphone amp, so I'm going to experiment with the caps a bit.
(3) 5V and GND come in on the red wires from the AE's bus, powering the Teensy and everything else. The blue wire is the output of the DAC going into the breadboarded offset circuit. The green wire is the final audio output.
|
|
|
Post by keurslagerkurt on Mar 4, 2021 20:56:58 GMT
Great job figuring out the perfect solution for your case!! As you said, I mostly don't mind the naked voltage dividers for the coupling cases, as I 'always' use 1M resistors to connect the signal and a 10K pair for the divider. However, in some circuits I made for AE I did use an opamp buffer like you did to be sure there is no loading. I have actually been leaving out the cap C2 over the voltage divider, as for my use cases the 2.5V hasn't been that critical either (the human ear can not hear where your voltage is centered). But maybe I should start doing that, it's considered good design practice. As far as I know the cap should just be 'big enough', I think 2.2uF is fine, but I'd be interested to hear whether you can see a difference with different caps. And MCP6021, I didnt know that it also came in a single opamp package with extra goodies! Cool to know. I mainly use MCP602's to save some space. Anyways, again, great job, seems like you really dug into it and learned a lot! And thanks for coming back to this thread to share your new knowledge too!
|
|
|
Post by beatstick on Mar 5, 2021 0:27:34 GMT
C2 wouldn't help with centering anyway since it's low-passing Vref; it's meant to filter out audible noise from the power bus so it doesn't mix with our output. Thank you I'm glad you pointed me in the direction of the resistor divider. I really had no idea where to even start digging!
|
|
|
Post by mkjackn on Apr 8, 2021 14:31:05 GMT
Is this circuit easily adaptable for going the other way, converting ae modular 5v audio to 3.3v audio? is it a case of ac coupling with a 1.65 virtual GND and attenuating slightly?
Also is it sensible to buffer input audio in the same way as output audio?
|
|
|
Post by keurslagerkurt on Apr 8, 2021 15:44:03 GMT
Is this circuit easily adaptable for going the other way, converting ae modular 5v audio to 3.3v audio? is it a case of ac coupling with a 1.65 virtual GND and attenuating slightly? Also is it sensible to buffer input audio in the same way as output audio? Yes and yes! You can, like you said, attenuate slightly and then AC couple to 1.65V virtual ground. A buffer in front would be sensible yes, otherwise you might get unwanted voltage drops. An even better way to do this, which uses less parts: You can use your buffer as the attenuator & rescaler (you can search 'opamp attenuator'). If you connect the + of your opamp to a 1.65V reference from a voltage divider, and then you rescale with the two resistors from the negative feedback loop, you should be golden! This great, great tutorial should get you completely covered to figure out exactly which values you need:
|
|
|
Post by mkjackn on Apr 8, 2021 17:23:57 GMT
Ahhh brilliant this is exactly what I was looking for! Thanks so much
|
|