So I thought I would tidy up and test a few things out before putting them away, then this happened. SHIT EVERYWHERE.





So I have had this pile of Ebay sitting on my desk for sometime and today I have gotten excited enough to actually start taking a look at it all and seeing how it works. I got these frequency generator chips for like a buck and after setting them up with the test circuit, i could not get them to work, it happens, now and again you get Ebay’d in the butt.
So I figured next i should test out the TDA2822 audio amps. I for 50 for 2 bucks which is a lifetimes supply. Do they work, well, yes they do and here are the results.
Here is the test circuit straight out of the PDF. As you can see parts count is low. So I put the IC on the breadboard and used just 1 1/2 for a mono amp. I also used just 2 caps, pin8 to ground, 470uf as it was already on the breadboard and the input cap on pin 1. Powered with 8v as its a handy voltage i have on my breadboard. 12v would probably be a better option to allow for a larger voltage swing.
As you can see, nothing fancy here, just the IC and 2 caps and my signal gen and oscilloscope probes doing there thing allowing the pixies to in and out and display them in the screen.
So we stick in 0.1v 600hz sinewave and see what happens.
Well, we actually hit the voltage rails and clip somewhat. 0.1v in almost 8v out, that is the voltage gain there. And when i do some da finger poken, the IC itself is cool to the touch, not warm, not hot, but about the same as ambient temperature of the room. So i am thinking Bye Bye LM386, and hello life time supply of TDA2822. And being a stereo IC, I can also bridge the left and right for even greater output. Not that I think i would need it.
So you might be thinking, Bullshit, you cannot get an 8mhz pwm signal out of an arduino. But you can. Ignoring the sine like shape of the waveform below for a minute, that is the actual PWM output from an arduino uno I was using to do this. So, why is it so.
Well, all you have to do is use some code wizardry using interrupts, timers and registers in such a way that the maximum pwm frequency you can get from most microcontrollers is 50% of the clock speed. Given that the arduino usually has a clock speed of 16mhz, this gives an actual maximum pwm out of 8mhz. And while this is nice, in practice it is not all that useful as the discrete numbers of frequencies that can be derived this way is not all that useful.
The code is below, I did not write this code and sorry to whomever did, I do not have a link back to it and your name was not included in the snippet, so i cannot credit you. Enjoy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include <avr/interrupt.h> #include <avr/io.h> #define TMR1 0 //for 8MHz: TMR1 = 0 , for 10kHz: TMR1 = 799 void setup() { // put your setup code here, to run once: pinMode(9, OUTPUT); //********************************************************************* //TIMER1 (16 bits) in mode TOP TCCR1B |= (1 << CS10); //selecting prescaler 0b001 (Tclk/1) TCCR1B &= ~((1<<CS12) | (1<<CS11)); // turn off CS12 and CS11 bits TCCR1A |= ((1<<WGM11) | (1<<WGM10)); //Configure timer 1 for TOP mode (with TOP = OCR1A) TCCR1B |= ((1<<WGM13) | (1<<WGM12)); TCCR1A |= (1 << COM1A0); // Enable timer 1 Compare Output channel A in toggle mode TCCR1A &= ~(1 << COM1A1); TCNT1 = 0; OCR1A = TMR1; //********************************************************************* } void loop() { } |