transistor to drive a relay - BJT or MOSFET?

Hi gang, I've got a couple of these relays that I scavenged from something else http://www.westfloridacomponents.com/mm5/graphics/ds5/TF2SA-5V.pdf AROMAT HD1E-M-DC12V They need 12V, have 515 ohm coil resistance, so about 23mA of current draw when active. This is the first time I've used a relay in a circuit. I plan to add a 2nd 33 ohm resister in series with the existing resister, then use the relay to short it out for a simple hi/low volume control under arduino control. I have some NPN transistors that I use to sink current for 4 columns of LEDs from 12V, comparable current. Do you think that would be good enough? Or should I go with a very low Rds N-MOSFET instead? I have a bunch of the NPNs already, so would prefer that if operationally it doesn't make a difference.

I suspect that any old npn transistor you happen to have will switch a relay coil needing 12vdc @ 23ma just fine. No need to gild the lilly at that V & A requirement. However the circuit you posted is very strange as audio in and out are shown so I guess I don't really understand what is being attempted with that circuit. If you are going to be switching that output pin fast enough to create a audio frequency your poor relay is going to go nuts. And what are the relay contacts going to be doing, lower the volume? Perhaps if you could draw out what you are actually planning on building it would be more clear on how best to wire it up.

Lefty

Thanks guys. I don’t really know what the transistor is, I have a small parts drawer full of these NPN transistors in fairly largish cans (just over 5/16" diameter) that have the Motorola symbol & “183”, and date codes like “U8024K” or “U8010K”. Some have an F instead (Fairchild?) and some have the TI symbol. So I don’t really know what they are.

On the schematic, the input into Q1 comes from an Arduino which is creating tones using the Tone tutorial from the playground. I just have it warble between A5 & C6 a few times.
The capacitor goes to an offboard speaker (Gento P/N ZSP99023A, http://www.mpja.com/prodinfo.asp?number=14618+SP which I have not been able to find any data on) and back from the speaker to ground. Pretty basic MOSFET amplifier like I found here
http://john-h-davis.com/ee438Fall04Tasks/Task%206_files/image006.jpg
just without the offset voltage on the gate, as the input only switches from 0/5V anyway.

What I want to do is add a second resister in series with the one I have, and use the diode to bypass it - 2 Rs will give 1 volume level, only 1 will yield a higher volume level, so the result would look like this. With a coil resistance of 515ohm, the current should be around 23mA (or maybe a little less with the drop across Q2).
(I realized I had the cap polarity shown backwards in the original).

That looks useable. I would change the 100 ohm base resistor for the npn transistor to 1000 ohms as 100 would draw around 43ma from the Arduino output pin, too high and not needed, 1K will work fine. Also it is considered a good practice to wire a reverse biased diode across the relay coil to clamp transients, cathode towards +12v.

Lefty

Thanks Lefty. Will give it a shot.

Okay, I’ve got this code creating a sound (just a warble, really) that gets amplified.

// info on alarm sound
 #include "g_pitches.h"

// notes in the melody:
int thisNote = 0;
int noteDuration = 0;
int pauseBetweenNotes = 0;
int melody[] = {
NOTE_C6, NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
12,12,12,12,12,12,4};

// nothing in void setup() about this

// in void loop(), is eventually called out like this:

  for (thisNote = 0; thisNote < 8; thisNote++) 
  {
    // to calculate the note duration, take one second 
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    noteDuration = 1000/noteDurations[thisNote];
    noTone(6);       //apparent known bug - need this for the tone to play next.
    tone(6, melody[thisNote],noteDuration);
    // to distinguish the notes, set a minimum time between them.
    // using the note's duration + 10%:
    pauseBetweenNotes = noteDuration * 1.10;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(6); 
  }

The problem is I think the MOSFET is being left in the on state and just pumping DC thru the 33 ohm resistors, which are pretty good sized parts, but got hot enough to start melting the plastic case around it. How can I set up pin D6 so that I can write it low and make sure the amp is not sitting there turned on until the ‘melody’ above is played, and then make sure its off again?
Can I just treat it like a regular output and write it Low in setup then write it low again afte the tone code above? Will the Tone code just set it like it needs when it uses the output?

Thanks

But if te Tone code leaves the output High won't I still have the same issue? Thats why I am thinking define D6 as as output, and then write it low.

See my earlier schematic Richard - you mean add another cap between the drain and the 'lower' RL, where the cap to the speaker is? This thing is getting complicated. Now have 8 CCAs wired up & all interconnected, 2 Prominis talking to each other, plus 2 remote prominis to drive extension lights (same code at least), and another in the remote control, the speaker, and the fencers swords. Trying to get the speaker volume control working, plus reading 2 buttons and some new status lights (small board at the middle right - one of the RLs actuall fell off I don't know if due to the heat it was creating, or just poor mechanical connection to start with) so I can call this thing done ... until I start PCB designs for it all. At least there I won't have to worry leaving room around parts for wirewrapping.

Oh, I like that! I’ll have to find a way to wire that in. What size cap would you suggest? Another big electrolytic like I have on the speaker?
Right now, I finished defining speakerout as pin6, have it as an output written low in a few places (like after tone finishes), gonna see if that works. Compiler didn’t complain about it.

Cool - thanks!