Shop OBEX P1 Docs P2 Docs Learn Events
Propeller audio class D amplification — Parallax Forums

Propeller audio class D amplification

ErlendErlend Posts: 612
edited 2013-01-09 00:11 in General Discussion
Hi,

Using the Prof Dev board with the audio out connected to two flatspeakers (salvaged from a dead mobile phone) does not give the volume level I would like. First I designed a small transistor-based amp, defaulting to thinking class A and lots of PWM noise filtering. Then the idea struck me; why not run it class D all the way? I have lots of small JFETs lying around, but probably only one per channel is enough? I'm thinking why not skip the on-board audio amplifier, and instead run the ouput PWM from the Propellor pins directly to a simple class D amplifier, then let the speakers sort out the overlaid PWM frequencies, or if required run the output through a simple LR filter.
Am I on the right track? Anyone done this before?

Erlend

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-01-05 10:40
    It should work. I've given it some thought, but it remains on a back burner. I'd come up with a scheme like the following that would use the phase offset of standard pwm produced by ctra and ctrb for bridge drive to a speaker. The code would be something like pik33 came up with in Yet-another-wave-player-now-NCO-based-and-noise-almost-free?. Except, instead of the two counters providing stereo, they would be coupled to provide monaural bridge drive.

    classDpwm.png
    941 x 276 - 18K
  • rosco_pcrosco_pc Posts: 468
    edited 2013-01-06 00:54
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-01-06 23:01
    I forget those earlier threads. You guys are way out ahead on this. Back in high school in 1966, I built a class D, using a sawtooth generator, summed with the audio, to a comparator and then to a power transistor. It sounded terrible! Much more recently I've tried the Texas Instruments TPA2006, and it soundrd good. It uses a ramp/comparator scheme too, as seen from its internal circuit:
    TPA2006_internals.png

    Base ramp frequency around 250kHz.
    But it is a shame to have to convert digital from the Prop to analog only to turn it back to class D.

    Here is the basic class D diagram, straight constant-frequency PWM, and it contrasts with Phil's low-frequency duty-mode scheme.
    classDpwm.png

    The TPA2006 uses a slightly different scheme. I think this is what Mark is doing in the code from post #5. (Mark, please correct me I I'm mistaken). Here is the diagram from TI:
    TPA2006_modulation.png

    For a given % drive, it generates twice the frequency of the scheme above, and thus 1/2 the ripple current. Is that right?
    722 x 214 - 19K
    802 x 447 - 53K
    941 x 276 - 18K
  • ErlendErlend Posts: 612
    edited 2013-01-07 00:50
    Thanks for all the good info. I am going to use the obex sourced SD wav player, so the PWM format is given. The sound quality of the on-board (demo board) is quite good, and I'm hoping to achieve the same with a few FETs. A problem thogh that is taking priority is that I wired the SDcard adapter wrong and cannot make it work. Maybe something has burned. Propeller outputs are fine, fortunately. I am at loss how to troubleshoot the SD without a scope. Any tips?
    Erlend
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-01-07 09:51
    The issue with the OBEX wav driver (afaik) is that it involves lots of transitions at high frequency, pulses on the order of 10µs. That is about the same as the turn-on or turn-off time of a typical small mosfet. The output waveform ends up looking like a triangle rather than a clean on-off waveform, and power is dissipated in the transistor when it is in its linear region. The other PWM schemes mentioned here have generally fewer transitions or longer pulses, so the switching time is less of a factor. You mentioned jfets in your first post. Is that what you meant? Most amenable to this task are enhancement mode mosfets.

    Is your SD card wired correctly now? (Have to ask!). If it is simply a mechanical adapter, there is not much that could burn out, and even if the power were applied incorrectly, that could only affect the card, not the adapter. Which adapter is it? You should start a separate thread if you need additional help with it.
  • Mark_TMark_T Posts: 1,981
    edited 2013-01-07 10:31
    The issue with the OBEX wav driver (afaik) is that it involves lots of transitions at high frequency, pulses on the order of 10µs. That is about the same as the turn-on or turn-off time of a typical small mosfet. The output waveform ends up looking like a triangle rather than a clean on-off waveform, and power is dissipated in the transistor when it is in its linear region.

    Which MOSFETs are you thinking of? A smallish (say SOIC8 size) MOSFET is usually < 100ns switching (assuming suitable gate driver).
  • Mark_TMark_T Posts: 1,981
    edited 2013-01-07 10:42

    Here is the basic class D diagram, straight constant-frequency PWM, and it contrasts with Phil's low-frequency duty-mode scheme.
    classDpwm.png
    That's not the best way as you get cross-over distortion for small signals - PWM duty cycle cannot be too narrow or you get runt pulses.I thought the "standard way" was to use
    a single PWM signal and drive the speaker in antiphase from it - 50% PWM = zero signal. There is then high ripple current all the time though as the filter
    sees a square wave.
    The TPA2006 uses a slightly different scheme. I think this is what Mark is doing in the code from post #5. (Mark, please correct me I I'm mistaken). Here is the diagram from TI:
    TPA2006_modulation.png

    For a given % drive, it generates twice the frequency of the scheme above, and thus 1/2 the ripple current. Is that right?
    This way means the differential signal is small on overage for common case (so low ripple current in the filter, low power losses). However it swings
    the speaker leads in common-mode, suggesting only short cables and/or big ferrite beads (or common-mode choke) to reduce EMI.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-01-07 11:05
    The OP mentioned "small" fets on hand, so I was looking at SO23 or TO92 types like the VN10 or BSS123, 10ns, ~50pf, ~5Ω Rds.

    There are complementary pairs like the Infineon BSL215C in tssop6, 12ns, 100pF, 0.15Ω for the N type, Its P type mate comes in at double the delay+rise times, and double the input capacitance.

    The TPA2006 is capable of delivering 1.5W peak from a 3.3V supply, so internally the output bridge must have some pretty capable mosfets.
  • ErlendErlend Posts: 612
    edited 2013-01-09 00:11
    Tracy,
    Yes, the wiring is now correct - triplechecked : ) - and I've started a new thread "microSD frustrations". Class D soldering is put on hold until there again is sound.
Sign In or Register to comment.