turning on relay from 5v signal

I'll have to do this tomorrow night. I've got a dmm that will measure current but only 1.

The CPU will act as the pulldown won't it?

Michael

Reply to
Michael C
Loading thread data ...

Michael has already stated that this ouput pin is open collector/drain and not push-pull so it is incapable of supplying any current to drive a transistor.

Michael - just go with the two npn transistors as we already discussed.

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com 
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
Reply to
Alan

Now I understand what andy was trying to say and why it doesn't matter :-) Current draw from the CPU is not a problem, the pin is designed to be able to be shorted to ground when it is high. Forcing it to 5V when it was low would be a problem but not the other way round.

Do you think the uln2003 is not the way to go? I'm starting to think this myself but will give it a try tomorrow anyway.

Michael

Reply to
Michael C

If it is what I suspect, then it will not supply any current. A typical open collector is usefull only for sinking current.

I am begining to think you have a lot more problems than you think, and I beleive that the origonal circuit you have may not fit the problem you describe.

I am assuming that the output of your micro is is an open collector transistor that has its emitter internally tied to ground? If so, can you read the datasheet and tell us how much current the output pin can sink? Can you also tell us how much current the relay draws?

If you have an open collector output that has the emitter internally grounded then you are better of using a PNP transistor.

I doubt that you will need a uln2003, unless you are driving solenoids.

Reply to
The Real Andy

This is getting far too complicated for such a simple problem.

You can use either the two transistor (and two resistor) per relay method or try the ULN2003 (plus two resistors per relay driven). Either solution will work, just depends on how much space you have/what takes your fancy/etc.

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com 
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
Reply to
Alan

It has an internal pullup, although I could just as easily use a pin that doesn't have the pullup.

It looks like the CPU pins can sink 3.2mA. I measured the relay at 120mA.

I tried that and it worked but there was a voltage drop of approx 3V and the relay didn't give such a positive click at 9V.

Michael

Reply to
Michael C

I think I've dropped the idea of uln2003 because the cost will be higher and it still needs 6 resistors anyway. I gave it a try and it has about a 0.8v drop where the transistors had a 0.2v drop. Unless the real andy can find anything wrong I'll go with the transistors. Thanks for all your help, it is much appreciated :-)

Michael

Reply to
Michael C

I'm sure the atmel 89C series is different to the atmel 90S series but did I hear that you have it working using two transistors?

:) as i understand it a similar trick is done with PC parallel ports to use the data pins as inputs.

Bye. Jasen

Reply to
Jasen Betts

what causes that? I'd have expected the opposite.

He measured ~0.7V on the ouput driving that 2k2 and the transistoor base in serries.

it seems that his outputs are essentially open collector.

--

Bye.
   Jasen
Reply to
Jasen Betts

I se transistors or ULN2003/2803 depending on the number of circuits (relays,etc) I need to drive.

You have the additional unfortunate problem of not being able to source drive current out of your micro. No big deal - just needs a few more components (another transistor and resistor) to get what you want.

The pnp idea won't work in your case because the base of the transistor (ie the micro output) can only go between 0v and (probably) one diode volt drop above the micro power supply (I guess +5v) that is assuming the micro has built-in I/O protection diodes.

I'd say stick with the two transistors and two resistors. It's easy, cheap and doesn't really take up much room plus it works!

Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com 
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
Reply to
Alan

plenty of current :)

Lower the current limiting resistor at the base of the transistor.

Reply to
The Real Andy

You dont know what you are talking about. The micro will be barely able to source any current. IT is designed to sink current.

You dont know what you are talking about. The output does not go anywhere. When the output is diven into its active state, the uC's output transistor will conduct. Most micro's which supply an open collector/drain have the emitter/source internally tied to ground. This means that when the output is active (active low) then the saturated output transister is essentially at ground potential plus the small collector-emmiter voltage.

So if you decide to use a PNP then all you must do is put the relay between the collector and ground, and connect the emitter to 12Volts. The circuit is essentially reversed.

2 transistors will only be needed if there is insufficient gain with the transistor being used. You cannot design an good circuit without some basic understanding of what is going on. I doubt very much that modern transistor will have such little gain that a darlington is required. This would only be required if the OP wants to switch a large current.

I just went searching for a good web page and found this.

formatting link

Use the PNP circuit, this is what fits you application. This is a very brief description and is not entirely correct, but i should help the OP to understand.

To drive the relay on, set the port pin to its active state, in your case I am assuming that this will be '0'. Use the internal pullup, whose sole purpose in life is to keep the output in a known state when your output is not in its active state.

Reply to
The Real Andy

Inrush current is common with inductive loads. As the relays coil is energises, it draws a large amount of current until it becomes saturated with magnetic flux. When you pull the power, the magnetic flux collapses and induces a current in the coil, called back EMF. The reason the OP has a diode in the circuit is to suppress this back EMF.

More to the point, it seems that the output transistor is internally tied to ground, so the OP should really use a PNP transistor to drive the circuit. An NPN will be fine if it has enough gain, as all the current is being sourced from the internal pullup resistor. The internal pullups are normally quite a high value, so only a very small amount of current can be sourced through them.

If you were to use a large external pullup to souce more current, you would have to be carefull that when you turn on the uC's transistor, that it does not sink to much current through the external pullup.

Understanding that there is not enough current via the internal resistor, the OP is experiencing a problem where the transistor is not being driven into saturation. More gain will fix this, however it is better to implement a proper design in the first place rather than making a flawed design work.

Reply to
The Real Andy

Actually, dont do that just yet. Start using a PNP transistor first. Se my other post.

Reply to
The Real Andy

Very kind of you to point out that I don't know what I'm talking about, I just didn't realise that - I guess I should bow to your superiority complex.

Read what I said - quote - "You have the additional unfortunate problem of NOT being able to source drive current out of your micro".

You cannot do this because the base will not go up to +12v when the micro output is "off" IF there are protection diodes on the I/O pin.

The two transistors are not to give enough gain, they are to give a double inversion and drive a relay - nowhere did I mention using two transistors as a darlington - look at the description of how they should be wired - coll 1 to base 2 - not emitter 1 to base 2. The only close mention of darlingtons were the ULN2003/2803 which where discussed - however the OP would still need to use two sections of these to reach his objective!

You might actually read that pdf yourself and learn something. It states (4th para right hand side) that the circuit needs +12 to switch the relay off and 0v to switch it on. In actual fact it will need only need a slightly lower than 12v signal to switch in on but we won't discuss that here it might get too confusing for some.

I think before you anything else you should reread the whole of this thread to see what the OPs problems were/are and what has been suggested.

Meanwhile I'll just go back to designing things I know nothing about... Alan

--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, Western Australia
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com 
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
Reply to
Alan

And this is a problem how?

Double inversion ey?

An there I am thinking that by controlling the base current through bipolar transistors would control the collector current. Oh how silly of me. I guess all my physics books are wrong, not to mention all those application notes that I have for my old CMOS and TTL logic.

I have read the posts.

Good idea.

Reply to
The Real Andy

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.