Shop OBEX P1 Docs P2 Docs Learn Events
Audio out with just 1 resistor & 1 cap — Parallax Forums

Audio out with just 1 resistor & 1 cap

RaymanRayman Posts: 14,220
edited 2007-11-11 08:57 in Propeller 1
If you don't have the demo board, you can easily get (high impedance) audio output with just one resistor and one capacitor...

I just wired up Pin#10 of my Proto board with a 1000-Ohm resistor and 0.1-uF capacitor and get good audio both with the line-in input on my computer and with Parallax's 2.5" LCD display.·

For robustness, one should probably add a DC blocking cap (but I like to live on the edge!)...

I put a circuit diagram here:

http://www.rayslogic.com/propeller/Programming/dac/dac.htm


Note:· I've increased the resistor value to 1k Ohm to put less stress on the chip and·better filter out the modulation while staying below the typical line-in impedance (deSilva says it's 47k).

Post Edited (Rayman) : 11/10/2007 10:45:20 PM GMT

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-11-10 19:25
    How to choose the RC network

    There are good reasons why the demo board has a 10k - 10nF configuration (RC = 100µs). Whereas Rayman's 100 Ohm - 100nF = 10µs is bound to major distortions.

    How does this "integrator" work?
    (a) The value of each of the parts is of minor importants, but the following device should have an input impedance much larger than the R, 10xR will be o.k. 100xR will further reduce any distortion. The cap should not be an electrolyte..

    (b) The WAV data consists of amplitude information, used to determine the length of a PWM signal generated by a counter within a 60µs cycle. A value of 255 will output a high all that cycle (=100%).

    (c) Now, to what voltage will the cap be loaded? Well, within RC = 10µs already upto 70% of 3V... Bingo!

    (d) So for reduced distortion it would be good to not load it over - say - 1/2 RC = to around 1.5 V. Which will suggest something like:
    R = 470 Ohms (to reduce the current)
    C = 60µs*2/470 = 220 nF


    Note that you will find a low pass in many places until the signal reaches the membrane of the speaker. So you will hear something even without any additional circuitry of your own. The here discussed integrator is meant to improve signal quality, or in otherwords to reduce signal distortion.

    Post Edited (deSilva) : 11/10/2007 7:32:09 PM GMT
  • RaymanRayman Posts: 14,220
    edited 2007-11-10 20:14
    Problem is that Line-In impedance is ~1000 Ohms. So, I think you need a resistor much smaller than that, unless you use an amplifier... But, I agree that I may not have the best C. This is just the only one I had handy...
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-10 20:35
    Hmm, line-in is generally +/- 1V and about 47k which would fit nicely to my settings....
  • RaymanRayman Posts: 14,220
    edited 2007-11-10 20:36
    I'll try a 1k resistor and see how it sounds...
  • RaymanRayman Posts: 14,220
    edited 2007-11-10 21:08
    Sounds good with 1k. So, this is a much better way to go...
  • rokickirokicki Posts: 1,000
    edited 2007-11-11 02:08
    Is PWM at 60uS the way to go, or just use the mode of the counter that outputs the carry bit from bit 31 (I think this is called
    duty cycle mode but I'm not sure)?
  • RaymanRayman Posts: 14,220
    edited 2007-11-11 02:28
    for DAC, duty cycle mode is best because it give the highest frequency output...
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-11 08:57
    The counter mode outputting bit 31 to the pin(s) is called NCO/PWM. This allows a constant cycle frequency.

    When using the "duty-dycle mode", you only get "spikes" of 10.5 ns each cycle, which means you have to adjust the cycle lengths accordingly. This is useful for PFM.

    Post Edited (deSilva) : 11/11/2007 9:10:57 AM GMT
Sign In or Register to comment.