Author Topic: Serial audio to UART  (Read 7266 times)

0 Members and 1 Guest are viewing this topic.

Offline unknowndomainTopic starter

  • Regular Contributor
  • *
  • Posts: 63
  • Country: gb
    • Blog
Serial audio to UART
« on: February 06, 2013, 08:59:27 pm »
I am working on a project where we want to send serial data out of the audio port on a computer, I have managed to get this aspect working however I am unsure how to change the output to something that will be safe to connect to the UART of an Arduino or other Atmel ATmega or ATtiny chip.

I have taken some measurements at the maximum volume level of my computer and found the signal has a slight DC offset (about -0.75V) and that the peak is only about 2.25V which isn't the 0/5 volt I would ideally see.

I have been doing some research and I think I need a capacitor to ground to remove the DC offset and a op amp to boost the signal to 5V however I am not familiar with either of these approaches as I am a hobbyist.

Another concern is that the output level may not be the same for every device. Can anyone help me to design a circuit which can correct the DC offset and the low peaks and also be flexible enough to work with different voltages, incase a different computer has a slightly higher or lower output.

The picture attached shows the signal being generated by the computer's sound card, it is transmitting 00110000.
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2806
  • Country: au
Re: Serial audio to UART
« Reply #1 on: February 06, 2013, 09:08:53 pm »
A quick Google search for "audio to TTL" found this:

http://robots-everywhere.com/re_wiki/index.php?title=Serial_on_Android_using_the_audio_port

That seems like a reasonable starting point.
 

Offline unknowndomainTopic starter

  • Regular Contributor
  • *
  • Posts: 63
  • Country: gb
    • Blog
Re: Serial audio to UART
« Reply #2 on: February 06, 2013, 09:14:43 pm »
Hey David,

I tried that circuit but I just seem to get the same level out as I get in, if I adjust the potentiometer it seems to invert the signal, but it doesn't adjust, it just suddenly flips over.
 

Offline unknowndomainTopic starter

  • Regular Contributor
  • *
  • Posts: 63
  • Country: gb
    • Blog
Re: Serial audio to UART
« Reply #3 on: February 09, 2013, 11:42:18 am »
I went ahead and rebuilt the circuit from David's link again and I am still getting the same issue, the output level is lower than the input and it's also got a offset which means it never exceeds 0V, it's -0.5V to 0V rather than 0V to 5V, there is also a considerable slope on the rising edge which may not be great.

Any help urgently needed, my weekend project is about to fall flat on it's face!

 

Offline lewis

  • Frequent Contributor
  • **
  • Posts: 704
  • Country: gb
  • Nullius in verba
Re: Serial audio to UART
« Reply #4 on: February 09, 2013, 04:17:42 pm »
You could try something like this (attached). The two series diodes on the non-inverting input of the comparator generate an approx 1.2V reference so if the audio in signal goes above 1.2V it will make the comparator output go low, or high if it's below 1.2V. This then gets inverted by the inverter to produce a high or low output respectively. The 100K resistor around the comparator provides a limited amount of hysteresis by increasing or decreasing the current through the reference diodes. The two other diodes and 100K series resistor protect the input of the comparator if the input voltage goes too high or low. The 4.7K resistor is a pullup for the comparator's open-collector output. Use a comparator like LM393 or LM339, not an op-amp. Not shown on the diagram are the power pins for the gate which obviously need to be connected to the 5V and GND rails. I haven't tested this so you'll almost certainly need to play with it.

One thing to watch out for is that computer sound cards almost always have coupling capacitors at the output which means it will not pass any DC. If you have a long sequence of 1's or 0's, the coupling caps will gradually discharge giving an exponentially decaying voltage at the audio input of this circuit. You'll need to structure the data so there's enough transitions so this doesn't happen. I've never tried outputting serial through a sound card, so it might not be a problem.
I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Serial audio to UART
« Reply #5 on: February 09, 2013, 07:18:18 pm »
One thing to watch out for is that computer sound cards almost always have coupling capacitors at the output which means it will not pass any DC. If you have a long sequence of 1's or 0's, the coupling caps will gradually discharge giving an exponentially decaying voltage at the audio input of this circuit.

Look up "constant-weight code" - this isn't too hard to implement.
No longer active here - try the IRC channel if you just can't be without me :)
 

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5127
  • Country: nl
Re: Serial audio to UART
« Reply #6 on: February 09, 2013, 07:33:02 pm »
I went ahead and rebuilt the circuit from David's link again and I am still getting the same issue, the output level is lower than the input and it's also got a offset which means it never exceeds 0V, it's -0.5V to 0V rather than 0V to 5V, there is also a considerable slope on the rising edge which may not be great.

Any help urgently needed, my weekend project is about to fall flat on it's face!

The fact that you manage to get a negative output from the LM324 while it has no negative supply makes me think that you used the red numbers in the diagram as pin numbers for the op-amp, while you should use the little blue numbers...  :-//
Keyboard error: Press F1 to continue.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Serial audio to UART
« Reply #7 on: February 09, 2013, 07:34:54 pm »
If that's the case I want to know where he found pin 0.
No longer active here - try the IRC channel if you just can't be without me :)
 

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5127
  • Country: nl
Re: Serial audio to UART
« Reply #8 on: February 09, 2013, 08:04:47 pm »
If that's the case I want to know where he found pin 0.
That's the NC pin, you should know that  ;)

Just saying, if the result he shows on the scope is what he gets out of the circuit there must be something wrong with the way he built it.
Keyboard error: Press F1 to continue.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Serial audio to UART
« Reply #9 on: February 09, 2013, 08:09:26 pm »
Maybe he just drew the ground line in the wrong spot.
No longer active here - try the IRC channel if you just can't be without me :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf