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

Feb 26, 2010 7 Replies

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


I have updated the asm file, this the latest one: ftp://panteltje.com/pub/audio_pic/



This is now a little universal module. This PIC has 3 extra inputs that you can connect a switch or logical signal to:



Pin assignement: pin 1 Vdd 5V pin 2 volume up (internal pullup present, switch to ground) range 1-100. pin 3 volume up same. pin 5 PWM out speaker + pin 6 PWM out speaker - pin 10 serial out for RS232, 19200 Bd, 1 start bit, 8 data bits, 1 stop bit. pin 11 mute, 0 V mutes, internal pullup active, so if left open no muting. pin 12 serial in for RS232. pin 13 test puse out, to measure AD conversion speed and time. pin 17 audio in, 2 Vpp, needs 1V DC bias. pin 19 1V out, can be used to bias pin 17 via a 100k resistor. pin 20 Vdd + 5V, needs to be decoupled.



You can set volume via RS232 too.



The code needs some cleaning up, to remove the not used stuff, probably more work then writing it... Have fun.


On a sunny day (Fri, 26 Feb 2010 19:24:12 GMT) it happened Jan Panteltje wrote in :

New version now out. ; 0.4: ; Added debounce for volume up and down. ; Removed large parts of old not related code and variables. ; Set PWM to mid range during mute. ; Delibarately leave pin 7 (P1C) and pin 14 (PID) free for full bridge external PWM. ; Enabled timeout in tx_w: . ; Enabled brownout reporting via RS232. VBOR set to 2.85 V nominal. ; Enabled watchdog reporting via RS232, watchdog timout is 4 seconds. ; Added audio streaming, typing 'S' at the terminal will enable audio streaming mode via RS232. ; send unsigned 8 bits audio at whatever baudrate you can, remeber 19200 Bd abd

10 bits per character amounts to only about 2000 Hz sample rate: ; Make a 8 bits audio file like this in Linux: ; sox some_cd_track.wav -c 1 -r 2000 -b -u test.wav resample. ; cat test.wav > /dev/ttyS0 ; So for 8000 samples / second (the absolute minimum) you need 160000 Bd, not likely to be from a PC. ; But this mode can also be used to send lots of values to the PWM output. ; Only a cold [re-]start will exit audio streaming mode,
[...]

Seems to be popular these days. Yesterday I read in Flying Magazine that a seasoned pilot (a check airman no less) opted to cycle the circuit breakers when both of the newfangled glass cockpit computers on his Boeing froze up. So I am not the only one doing this sort of stuff :-)

Regards, Joerg http://www.analogconsultants.com/ "gmail" domain blocked because of excessive spam. Use another domain or send PM.

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

formatting link

On a sunny day (Sat, 27 Feb 2010 11:53:47 -0800) it happened Joerg wrote in :

There is a simple reason in the audio_pic case. Once you send the chararter 'S' it expects a stream of 8 bit characters. Now if you assigned anything else as character or string to exit stream mode, then some music or noise sooner or later would have that sequence, and it would drop out of stream mode. So, it is intended for sane users who

1) know about the RS232 interface, 2) need stream mode, and 3) do not want it to stop all of the sudden on some sound.

The audio header should contain 'S', then send raw 8 bits unsigned audio.

This is totally deliberate and in the interst of the application, and has nothing to do with any Boeing bugs. FYI.

Thought so, because it comes via the same channel, then you have no other choice.

It wasn't Boeing, the computers came from some other company.

Regards, Joerg http://www.analogconsultants.com/ "gmail" domain blocked because of excessive spam. Use another domain or send PM.

On a sunny day (Sat, 27 Feb 2010 13:13:47 -0800) it happened Joerg wrote in :

Well, I see that a bit different. Of course when you buy a zillion dollar airplane, you could expect the stuff in it to have been tested to the extreme limits... Maybe it had no brown out detection and the Boeing generators dipped.... hehe

Encode the data in a manner such as SDLC (six '1's == frame mark, always insert '0' after fifth data bit)

Join the Discussion

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

Didn't find your answer?

Ask the community — no account required