|
|
Basic Electronics » Relay Question
| February 26, 2010 by disneyd7 |
I have a reed relay with a coil amperage of 12mA and I want to actuate it with the ATmega168. The relay has a built in diode. Lets assume it is a 5 volt relay. Since the ATmega168 supports up to 40mA should I be able to put 5v to one side of the relay coil and the other side to an output on the ATmega168 and actuate it with that? Second question: My reed relay is a 12 volt relay that also has a coil current of 12mA. Can I put 12v to one side of the coil and use the ATmega168 to switch the other side to ground? Also, is the maximum current on the ATmega168 40mA total or 40mA per output? Could I connect 8 of these relays to 8 of the ATMega outputs and trigger them all at once? Thanks for any advice! BTW, What I am working towards is a system with six to eight relays that I can operate via the usb nerdkit. Any advice on the best way to hook this up is appreciated. I'm asking about the 12v relays because I already have them, but I could get 5v versions if it would be easier. |
|---|---|
| February 26, 2010 by Rick_S |
The Absolute Maximum package current rating is 200mA. The Absolute Maximum current per pin is 40mA. While these low current relays could be triggered by the uC directly, my preference is not to. You definitely can not sink 12V with the uC... Bad things will happen. This is from note 3 at the end of the datasheet where it talks about current.
I'd recommend using a driver IC such as a ULN2803. This IC not only can handle the current you need with ease (500mA continuous for the package total)and has 8 outputs, it also takes a TTL input, such as that from your uC, and can sink up to 50 Volts. In effect, you isolate your uC from harms way, you can use your 12V relays, and can have them all on at the same time without any worry of uC damage. Just a thought, Rick |
| February 26, 2010 by bretm |
You might think you could set a pin to output mode and set it to ground level, so it wouldn't matter that there was 12V at some other point in the circuit because at the pin it's 0V. The problem is that if you do exceed the current limit, which can easily happen briefly when switching an inductive load like a coil, the microcontroller might not be able to maintain the 0V condition at the pin. |
| February 26, 2010 by Frozenlock |
Don't forget to use flywheel diodes with your relays, the back EMF can fries many IC components. (Yes, I learned it at my expense.) |
| February 26, 2010 by Rick_S |
That's where a device like the ULN2803 is so great has the diodes built in. Handles all the current need. Handles up to 50VDC devices. |
| February 27, 2010 by disneyd7 |
Thanks for all the info so far! Can anyone explain to me how the ULN2803 works and how I would connect it to the AT168? I've read the datasheet for the ULN2803 but it isn't helping me much. Would I use the AT168 to bring a pin high on the 2803 or ground it? I'm not sure how it works (still learning). |
| February 27, 2010 by mongo |
The ULN2803 is a bunch of transistors... 8 pairs of Darlington sets on a common emitter format. The output of a circuit, like the MCU can be directly connected to an input pin of the driver. the output pin of the driver connects directly to the negative (-) side of a load, like the cathode of an LED. (the straight bar). The positive side of the load (+) connects to it's supply, (The arrow side of the LED) through it's own current limiter if required. The outputs can also drive relays and other loads just as easily and if more current is required, they can be wired in parallel. Only one pin is necessary for power connection, which is a common ground termination. All 8 drivers have internal free-wheeling diodes that can be connected to the driven power source positive to control inductive kickback spikes from relay coils, etc. Otherwise, it does not need to be connected at all. The drivers are called 'current sinking' drivers because they do not supply power to their loads, rather, they provide a path to ground for a 'live' circuit already present. Hope that helps... Mongo |
| February 27, 2010 by disneyd7 |
Ok, let me see if I have this straight... On the ULN2803: I ground pin 10. The MCU output connects to one of the input pins on the ULN2803 and when activated it provides a ground on the corresponding ULN2803 output pin which completes the circuit to operate my relay. What constitutes activating the ULN2803 input? Do I have the MCU take that pin high (5v)? I assume the 2803 needs some sort of positive voltage to work. Also, what is pin 10 on the 2803 used for? I'm not familiar with the concept of a free-wheeling diode. Thanks again! |
| February 27, 2010 by Hexorg |
Um... Wouldn't just using a transistor be much easier? I remember, before I got a nerdkit, I wanted switch rotating direction of the 12V high torque motor, with an LPT port (which has only 3.3V on my old machine). So I've just stuck a PNP transistor to it, and then, connected a 12V power supply (from the wall) to power the coil in the relay and the motor itself. |
| February 27, 2010 by Rick_S |
Pins 1 thru 8 are your ttl level inputs. A high signal on these pins cause the corresponding output pin to go low. Pin 9 is connected to ground this would be a common ground with the 5V of your NerdKit and the 12VDC of your relays. Pin 10 is used as a common connection for the free wheeling Diodes built into the chip for each output. These act similarly to the diodes you said your relay's have built in. Per the datasheet from the Motorola version of the part: "All devices feature open–collector outputs and free wheeling clamp diodes for transient suppression." Pin 10 would usually be connected to the positive side of the voltage the chip is sinking. In your case, the +12VDC you are using to drive your relays. Hope I didn't just make things more confusing. :D Rick |
| February 27, 2010 by mongo |
Here is a simple application on how a Darlington pair can be used.
It's a simple continuity tester. The resistor on the left is an unknown value. Insert it there and if it has any conductivity, it will light the LED. Darlington pairs have a very high gain and even your fingertip will light the LED. The ULN2803 has eight such pairs and they are great for this type of level shift. |
Please log in to post a reply.