Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: Help needed with audio in circuit

  1. #1

    Help needed with audio in circuit

    Here is my circuit design which is intended to take Eurorack modular audio (-5V..5V), and convert it to the range (0V..1.2V), for the Teensy 3.6 ADC. The first op-amp is in an inverting summing op-amp configuration. 5V is added to the input, putting it in the range of 0V..10V, and the op-amp reduces this to the range (-1.2V..0V), the second op-amp, inverts this signal at unity gain, giving a signal from (0V..1.2V). The circuit appears to work, but it is very noisy. There is a LOT of background noise coming from somewhere. I've tried adding capacitors across the feed back resistors, but that doesn't change much. Can anyone tell me if there's a fundamental mistake with my schematic? All help much appreciated!Click image for larger version. 

Name:	Screen Shot 2017-08-12 at 20.31.29.jpg 
Views:	26 
Size:	36.2 KB 
ID:	11248

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,314
    Quote Originally Posted by unicornpower View Post
    Here is my circuit design which is intended to take Eurorack modular audio (-5V..5V), and convert it to the range (0V..1.2V), for the Teensy 3.6 ADC. The first op-amp is in an inverting summing op-amp configuration. 5V is added to the input, putting it in the range of 0V..10V, and the op-amp reduces this to the range (-1.2V..0V), the second op-amp, inverts this signal at unity gain, giving a signal from (0V..1.2V). The circuit appears to work, but it is very noisy. There is a LOT of background noise coming from somewhere. I've tried adding capacitors across the feed back resistors, but that doesn't change much. Can anyone tell me if there's a fundamental mistake with my schematic? All help much appreciated!
    get rid of the diodes, exit your 5V circuit with a capacitor followed with a simple voltage divider to obtain 0.6V bias. choose capacitor high enough to avoid significant high-pass effect.

  3. #3
    Member
    Join Date
    Jan 2017
    Location
    Pella, Iowa, USA
    Posts
    64
    Agreed - you might be able to do this in one stage. The input cap will let you bias the +/- 5V input to 0.6V, with the positive input to the op-amp also biased to 0.6V and then you can scale the op-amp gain to 8.33. Click image for larger version. 

Name:	Level shifter.jpg 
Views:	3 
Size:	98.9 KB 
ID:	11253Click image for larger version. 

Name:	Level shifter output.jpeg 
Views:	3 
Size:	211.8 KB 
ID:	11254

    This is an LTSpice schematic that should show what I'm thinking.

  4. #4

  5. #5
    Thanks for your help and suggestions everyone! I had read both of those links beforehand, Paul. I decided to use op-amps for the input rather than a potential divider, as I thought this was better to ensure the input was high-impedance. I'm rather new at this so I apologise if my questions are a little basic.

    WMXZ - why do you think I should remove the diodes, they are there to protect the teensy from high voltages, do you think they might cause the noise? I tried removing them but the problem persisted. I'm using schottky diodes for these. The capacitor you suggest adding, should that be between 5V and ground?

    I have had some PCBs made with this circuit design for prototyping, so I'm keen to find a solution which can be hacked into this circuit, if one exists. Does the schematic look wrong to you guys? I've measured the outputs on an oscilloscope with a signal generator on the input, and the ranges do seem correct (e.g. it's correctly mapping -5V/+5V to 0V/1.2V. I plan to go back to my breadboard and see if the problem exists there. The interesting thing is that when an audio signal is present at the input the noise seems to disappear. Which suggests something might be floating? I shall do some more head scratching!

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    14,869
    Is the 5V noise free?

    Any noise on that 5V ought to couple right into your signal...

  7. #7
    What kind of noise? Is it AC hum or white noise?
    I do not see any power supply bypass caps in your circuit. That could be a problem. They should be added even if not causing this particular problem.
    It may be noise on the unfiltered +5 volt line. You could test that by powering the +5 connection with a battery temporarily and see if the noise is still there.
    In your program, do you have AGC code? That would increase noise when there is no signal in.
    Are you testing with long unshielded wires? They act as antennas and will pick up noise. If you are close to a radio station or other types of radio transmitters( like a cell phone ), they will pick that up also.

  8. #8
    Quote Originally Posted by PaulStoffregen View Post
    Is the 5V noise free?

    Any noise on that 5V ought to couple right into your signal...
    There was noise on the 5V line actually. I was using a voltage regulator only regulated up to 100mA, and I was drawing slightly more than this (Teensy 3.6, plus PIC, plus LEDs), and showed some noise on the scope. I replaced the regulator with a meatier 2A one, but unfortunately the problem remained. I shall post my power circuit when I get home, for reference. It would make sense if the problem was there.

  9. #9
    Quote Originally Posted by rcarr View Post
    What kind of noise? Is it AC hum or white noise?
    I do not see any power supply bypass caps in your circuit. That could be a problem. They should be added even if not causing this particular problem.
    It may be noise on the unfiltered +5 volt line. You could test that by powering the +5 connection with a battery temporarily and see if the noise is still there.
    In your program, do you have AGC code? That would increase noise when there is no signal in.
    Are you testing with long unshielded wires? They act as antennas and will pick up noise. If you are close to a radio station or other types of radio transmitters( like a cell phone ), they will pick that up also.
    It's white noise. The noise seems to go when an audio signal is present. AGC is Auto Gain Control? (had to Google ) I don't have that, no. Just a simple pass-thru in the audio library. It's a PCB, so the wires are short. I shall post up the schematic tonight.

  10. #10
    Senior Member Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    822
    Thus, it's the noise of the "dirty" 5V supply rail which is greatly amplified by your op-amps. Professional engineering requires normally separate power supplies or at least separate voltage regulators for analog and digital circuitry.

    A simple but not so efficient quick fix for your existing circuit would be replacing that 8.3k resistor (R2) by a T-lowpass filter:

    +5V >---[2k1]---(x)---[6k2]--->pin2 of TL074A and a 4.7uF electrolytic capacitor from (x) to GND.

  11. #11
    Member
    Join Date
    Jan 2017
    Location
    Pella, Iowa, USA
    Posts
    64
    Click image for larger version. 

Name:	Capture.JPG 
Views:	7 
Size:	63.0 KB 
ID:	11263
    Insert a simple R/C filter on the 5V supply to see what happens. I used 100 ohms and 100uF as approximate values but the goal is to turn that 5V supply into a super quiet reference voltage. Ideally, you'd use an actual precision reference.

  12. #12
    Quote Originally Posted by Neutronned View Post
    Click image for larger version. 

Name:	Capture.JPG 
Views:	7 
Size:	63.0 KB 
ID:	11263
    Insert a simple R/C filter on the 5V supply to see what happens. I used 100 ohms and 100uF as approximate values but the goal is to turn that 5V supply into a super quiet reference voltage. Ideally, you'd use an actual precision reference.
    Many thanks for your help! I shall report back when I've had time to try this out.

  13. #13
    Quote Originally Posted by unicornpower View Post
    It's white noise. The noise seems to go when an audio signal is present. AGC is Auto Gain Control? (had to Google ) I don't have that, no. Just a simple pass-thru in the audio library. It's a PCB, so the wires are short. I shall post up the schematic tonight.
    For reference, this is the power circuit I'm using, adapted from Radio Music module. Iím actually using 10uF for C6 instead of 1uF. Not sure how much difference that makes..

    Click image for larger version. 

Name:	Screen Shot 2017-08-14 at 18.18.15.jpg 
Views:	5 
Size:	21.4 KB 
ID:	11264

  14. #14
    Quote Originally Posted by unicornpower View Post
    It's white noise. The noise seems to go when an audio signal is present...
    Do you mean the noise goes away, or you hear the noise when an audio signal is present?

    On Teensy 3.2 the noise increases when audio is present, and I now know why (and fixed it).
    Could it be this issue? I have a fix in my fork
    https://forum.pjrc.com/threads/45770...input_adcs-cpp

    One way to test is take your audio output right off the input to the ADC, bypassing the whole software side of things. Then you can hear what it is like right at the input of the ADC. This will help you know if your op amp circuit is getting noise or if it's something inside the Teensy after the ADC.

    It's good to separate these things in functional blocks and test down through the system. Something common in the DIY stompboxes community is an Audio Probe

    [EDIT] I do recommend using the diodes for input protection. The only change to the circuit is put a 47 ohm resistor feeding the ADC input with a 47n to 150n capacitor to ground at the ADC input. The parasitic capacitance in the diode works as a nice low impedance to inject switching noise on the ADC input. The capacitor will shunt this to ground and the resistor gives it some impedance to work against. This also serves as a basic anti-aliasing filter.

    Here is what I am doing for a guitar input. My circuit is optimized to guitar signal levels, and it is hard limited between 0V and 1.2V. I noticed wrap-around when the ADC is overdriven -- in fact the ADC makes noise when it gets signal between 1.2V and 3.3V (another possible source of your problem -- maybe you are overdriving the 1.2V range).

    I decided to use a precision voltage reference to clamp the voltage just shy of 1.2V, and used the discrete "op-amp" circuit to give me decently linear operation right down to the 0V rail. The second harmonic measured in SPICE simulation is around -80 dB for a 0.5Vpp output and the remaining harmonics are in the noise floor (<90 dB). For a 1Vpp output the first harmonic is about -60dB and the final visible harmonic before dropping into the -90 dB floor is the 6th. I am expecting the nice mix of even harmonics will not sound bad on guitar as it approaches the limit and it is on-par with typical stompbox effects.

    I have added several stages of ground-earth capacitors for anti-aliasing. This comes to about -6dB at 20kHz, intentionally starting to roll off at around 14 kHz since this is not too hard to correct with a digital filter.

    Click image for larger version. 

Name:	ADC_INPUT_BUFFER.jpg 
Views:	0 
Size:	53.9 KB 
ID:	11289
    Last edited by Transmogrifox; Yesterday at 05:12 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •