PIC 18F22K14 as class D audio output amplifier, 2 components... first test

Feb 24, 2010 5 Replies

PIC 18F22K14 as class D audio output amplifier, 2 components... first test results.



I thought why not, after all it's PWM generator can drive a bridge, the ADC is 10 bits, the internal clock 16 MHz, and a 4 x internal PLL makes it



64 MHz... The I/O can do 25 mA sink / pull..... Diagram: ftp://panteltje.com/pub/audio_pic/audio_pic_1.gif

Some notes to the diagram, I use a small ear piece from a mobile phone, about 80 Ohm, between pin 14 and 15, that is a full bridge! Also tried my Sennheiser headphones, about 33 Ohm for one ear piece, much better sound, especially at high volume, I think I am losing some LSBs somewhere, need to look at the code again. OK for simple headphone or small speaker driver I think.



The sampling frequency measures 86 kHz, the PWM frequency measures 62.7 kHz, do not ask me questions about that :-) A pulse is output on pin 13 for every sample sequence (for test). Of course both PWM and sample frequency are derived from the same clock, so things are locked.



The ADC uses the internal 1.024 reference, internally multiplied by 2, so it needs bias at about 1 V at the input to prevent the signal at the ADC from going negative. For this purpose I output the DAC (yes PIC has one) with 1 V on pin 19, that is why the resistor. I also tried a simple 100k pot between ground and +5V, nice to test the PWM duty cycle change.



Audio sounds nice, I play music on it now, impressive even. Here the PWM out versus 1000 Hz on the input: ftp://panteltje.com/pub/audio_pic/audio_pic_1000Hz_pwm_img_1843.jpg See, it is locked! And here after a simple 1 pole RC lowpass at the output: ftp://panteltje.com/pub/audio_pic/audio_pic_1000Hz_filtered_out_img_1844.jpg



Here is the asm source, there is lots of stuff in it, as it is just some io_pic project code quickly modified to test an idea, most of that code is inactive: ftp://panteltje.com/pub/audio_pic/audio.asm So ignore the comments in that file, look for the markers 'YYY" and 'XXX' to see where it counts, and the true docs is what I just wrote.



I love it when an idea works:-)


Jan, what would it cost to license this from you, 1000-4000 pieces per year?

Steve

On a sunny day (Wed, 24 Feb 2010 08:49:52 -0800 (PST)) it happened snipped-for-privacy@uakron.edu wrote in :

Nothing, have fun! Just publish source with your product, it says GPL at the start of the source.

urce.

Cant do that, competition.. Can we credit you ? Jan, I'm serious, Corporate email has been sent...

Steve

Time for that dual licensing scheme.

Tim Wescott Control system and signal processing consulting www.wescottdesign.com

On a sunny day (Wed, 24 Feb 2010 11:19:32 -0800 (PST)) it happened snipped-for-privacy@uakron.edu wrote in :

Check your mail.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required