2N2222 use?

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Freaks,
I am trying to drive a speaker from M48. I am using PB0 to send an ON/OFF pulse to my speaker. The speaker is 16 ohms. However when connected, the speaker does beep but the sound is too low. I looked at the datasheet and the M48 is supposed to drive 40 mA but this is not enough. Can I use a 2N2222 transistor to drive my speaker harder? If yes, how do I connect my 2N222 to drive my speaker louder? I checked and the beta for this transistor is about 180. U

Unfortunately I do not know the power rating of this speaker. It must be definitely higher than 25.6 mW since the sound is very faint with 40 mA and 16ohms.
Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, you can use a 2N2222. A simple way is to drive the speaker as if it was a relay coil. Speaker to Vcc and the 2222 collector, 2222 emitter to ground, base through a resistor to the port pin, diode across the speaker coil.

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had already tried that but without the diode. I had used 1.2K as the base resistance. There was no sound from the speaker. Is that too small? Do I need a collector resistance as well?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also is the beta too large for this? With 180 as a current gain, collector current will be about 7 A.Maybe I need to reduce the current gain?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you heard no sound at all, perhaps the circuit is wired wrong, or you are not supplying pulses from the port pin. Lots of beta is a good thing. You want to fully saturate the transistor when it is on to supply as much voltage as possible to the speaker. I would lower the base transistor to 470 or 330 ohms to supply more base current. But, you should still have heard something if everything was wired right. Ohm out the speaker to make sure it is still good- if the driver transistor was on continuously for some reason, it could have fried the speaker.

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, Tom.
Ok it is working (I think I had my connections wrong). The sound is still not loud. I measured the collector voltage and it is oscillating between 0.7V to 4.8V.
(the pulse duration is 500ms ON, 500 ms OFF).

I will try increasing the pulse duration but maybe the speaker is rated for a lower power and hence has a faint sound? I have tried with base resistance of 200ohms.

I will also try changing the transistor for higher gain.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also does higher power rating mean louder sound when you drive the speaker at it's highest power rating?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A higher gain device won't make any difference if the transistor is already turning fully on and off.

Leon

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Pat,

I reckon there is nothing wrong with your circuit. The problem is that with a 500ms on/500ms off, you are generating a 1Hz "tone". Your ears simply are not designed to hear such low frequencies. You can probably look at the speaker cone and see it vibrating once a second.

I suggest that you change the 500 ms to be say 5 ms and this will give you a 100 Hz tone that you will hear .. unless you are deaf :lol:

Isn't learning fun?

Cheers,

Ross

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok that worked Ross. Thanks. NOW I can annoy my neighbors :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And of course, switching to a 8 ohm speaker or two 16s in parallel should make more noise too. Sound output is also enhanced by "loading" the speaker with some sort of enclosure or horn so the pressure from the back doesn't cancel the pressure from the front.

Tom Pappano
Tulsa, Oklahoma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK Pat ... I'll bite. Why do you want to annoy your neighbours?

Cheers,

Ross

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just kidding. It's nice when so much work produces a tiny little beep. :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok now I am trying to produce a beep from my speaker. I am trying to use the fast PWM mode with ICR1 as the TOP value. Here is what I have so far:

 
   DDRB = 0xFF;
   TCCR1A = 0;
   TCCR1B = 0;

//Set PWM mode, note that bits 13 and 12 are in TCCR1B and bit 11 is in TCCR1A
//more info. on page 131 of M48 datasheet

      TCCR1B |= (1 << WGM13) | (1 << WGM12) | (1 << CS12) | (0 << CS11) | (0 << CS10); //Use a prescalar of 256
      TCCR1A |= (1 << WGM11) | (1 << COM1A1);//set up fast PWM mode; see page 131 of M48 datasheet

   
      ICR1 = 32;//Value that the micro will compare with current count 8MHz/256/1kHz
      OCR1A = 0.85 * ICR1;

  
 for (;;)
    
	{			
	      if (PINB & ( 1 << PB1))
               
	         {
			    
	           PORTB = (1 << PB0);
                 }
	      else
		   { 
		      PORTB = ~(1 << PB0);
		 	    
                   }

         }


   

So, PWM o/p is on pin PB1 and speaker is on PB0.

With this I am getting a continuous tone of 1 KHz and not a beep. What I want is ON/OFF beep and when it is ON the frequency is 1 KHz.

I think the PWM is working with 1KHz but how can I gate it to give me an ON/OFF beep?

In the for loop I am trying to read PINB value (which should be my OC1A value) to toggle pin PB0 which is my speaker.

The duty cycle is 85% since I want the speaker to be on > 50% in one period.

What am I missing?