0
\$\begingroup\$

I am working on a voice transmission project by using Spartan 3e. My code works just fine. My problem is that I give analogue input to adc side by using a potentiometer and see the changes (as digital) on leds ( digital output is assigned to leds). Here is the problem,I cut a headphone into two and connected 3.5mm jack side to my phone to play music. There are 3 cables which are golden, blue and red. Golden one is connected to "GND" pin , Red one goes to "Va" pin (at adc input). I didnt touch the blue one.

When I play music,I see no change on leds despite the fact that I did see by using potentiometer. What am I missing ? Do I have to setup an external circuit before giving the analog signal to Va input ?

Thanks in advance.

\$\endgroup\$
2
\$\begingroup\$

Two problems:

  1. The ADC is (I presume) 0 to 5 V. Your audio will be much less than this.
  2. The ADC accepts positive signals only. Your audio is AC (alternating current). The polarity alternates between + and - with an average value of zero.

At a minimum you need to rectify your signal and ensure that the ADC input on your micro only sees positive signals between zero and the maximum rated input voltage. If you put a diode in circuit (banded end pointing towards the ADC) it might start to work but with the low voltages you will only get low numbers out of your ADC.

For a better job look up precision rectifier circuits. You'll want one that will give you some gain - 5 to 10 would probably do the trick.

[Edit]

I had a look at the data sheet and I understand that the ADC is biased at half V-max. You should connect up as shown here:

schematic

simulate this circuit – Schematic created using CircuitLab

Without the capacitor your audio signal will be +/- with respect to 0 V. Adding the capacitor and resistors will bias it towards 1.65 V, same as the internal reference.

In your software you'll have to run a loop that

  • Takes a reading.
  • Subtracts to bias value (half ADC max).
  • Get the absolute value of the result (remove the - sign, if present).
  • Average these over some number of cycles since sometimes you'll sample on a peak and sometimes when the audio signal is crossing zero volts.
|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ do not rectify ! you will lose too much infomation \$\endgroup\$ – JonRB Dec 20 '15 at 10:49
  • \$\begingroup\$ If you don't rectify you may loose too many Spartans! You have to rectify to prevent negative signal to the ADC. You won't lose 'information' - with a diode you will drop voltage but with a precision rectifier you won't. Explain what you mean by losing too much information. \$\endgroup\$ – Transistor Dec 20 '15 at 10:52
  • \$\begingroup\$ I don't recall saying "don't do anything" ... The signal needs to be buffered, offset and then passed to an ADC. You do not destroy the info when better solutions exist \$\endgroup\$ – JonRB Dec 20 '15 at 10:54
  • \$\begingroup\$ There is a gain setting in fpga. I tried it in several different constants (-1 to -100). For example -1 requires the input voltage between 0.4-2.9. ( and this interval gets smaller as the gain increases (negatively). So can we say that our input signal is NOT between 0.4-2.9 ( most probably less than 0.4V) and that's why internal amplifier does not work, need an external amplifier ? \$\endgroup\$ – CuriousPuppy Dec 20 '15 at 11:02
  • 1
    \$\begingroup\$ @JonRB: He's lighting LEDs so he's probably wants to change the intensity based on sound level. My approach is to rectify the signal in the hardware and look at the positive peak voltage. I think what you're suggesting is to offset the AC signal to half ADC max level, sample frequently and rectify in the software. Your first comment was too terse to allow the reader to deduce that. \$\endgroup\$ – Transistor Dec 20 '15 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.