Pages: [1]   Go Down
Author Topic: Output Signal From Digital Pin to Switch Relay, Suggestions?  (Read 1665 times)
0 Members and 1 Guest are viewing this topic.
United States
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Greetings,

I'm using the G5LE PBC Relay. Datasheet here: http://www.kosmodrom.com.ua/pdf/G5LE.pdf

The goal is to turn a Relay on or off using a digital output from the Arduino so it can be done on-demand/dynamically. The relay when on, allows the throughput of a 12v, 1.5A power supply.

Currently, my set up is using Digital Pin 2 (also tried others) to output a signal to the Relay. The output from the Pin 2 when OUTPUT is HIGH is ~4v/~40mA (milliamps).

According to the Relay's datasheet, the relay requires the following volts/amps to switch:
- 3v@136mA
- 5v@79mA
- 6v@67mA
- 9v@45mA
- 12v@33mA
- 24v@17mA
- 48v@8mA

With the above listed data, I calculate it'd take a minimum of ~100mA+ at the 4v output to perform the switch, so the 40mA I'm receiving from Pin 2 isn't enough. Unfortunately I'm a noob still learning, so I didn't understand this when I purchased the relays.

The confusing thing for me however, is that while the Digital pin isn't capable of switching the relay, the direct 5v pin on the Arduino is. When I measure the "5v" pin, I read 4.1v @ 47mA which is barely more than Digital Pin's output is. If one doesn't work, I'm a bit confused why the other does.

That being said, what is the recommended course of action to provide the appropriate volts/amps to the relay to successfully perform and hold the switch?
- Buy a different relay requiring lower switching volts/amps, still allowing for 12v, 1.5A throughput? Would anyone be willing to offer some suggestions?
- Add another relay (solid-sate or otherwise,) which when powering the Digital Pin, allows the throughput of the 5v Pin to power the relay?
- Possibly swap voltage for amps? According to me calculations, even is volts dropped to 3.3, I'd only end up when 67mA when I'd need 136.
- Something else I haven't considered?

I'd really like to keep the circuit as simple as possible, however I'll do whatever necessary to bring this project to fruition.

Thanks so much for your time!

Josh
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That relay comes in versions with different nominal coil voltages, as in the list you gave. It sounds like you bought the 5V coil version. You need an NPN transistor to drive it. See http://t1.gstatic.com/images?q=tbn:ANd9GcT6fucx3aX-zTgJRxyTKkDyY29jUtv6C2Uis7rRji7xlRvUcSmg4w for a suitable schematic, but where it says +12V use +5v. Suitable components are:

Transistor: BC337 or 2N2222A
Resistor: 1K
Diode: 1N4148
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

United States
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

dc42,

Thanks for taking the time to read over and respond to my post.

If I am understanding you correctly:
* +5V should come from the power source, through the relay coil, and into the NPN Transistor?
* And when the 4V from the Arduino Pin is passed through the 1k resistor and into the NPN Transistor, that will cause the relay to switch?

Here is a diagram of the circuit I've constructed; if someone notices anything wrong or odd or just straight up not right, let me know. I'm eager to learn and willing to listen:



I'd be more willing to just go for it and see if it works, but burning things out has a tendency of also damaging one's wallet.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27357
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The emitter of the transistor should just go to Gnd.
12V Gnd needs to connect to Arduino Gnd.
Get rid of D1, D2.
By Power+ on the '328, is that the 5V Pin? If yes, put a diode from 5V (anode) to Vin (cathode) to avoid reverse driving the regulator.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Faraday Member
**
Karma: 68
Posts: 2804
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
12V Gnd needs to connect to Arduino Gnd.
What is the reason?
Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

United States
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It should be noted that in the above diagram, the GND symbol and "-" side of the Power Sources are redundant. I essentially have two power outputs on a single power supply: a 5V, 1.5A and 12V, 1.5A.

Quote
The emitter of the transistor should just go to Gnd.
It essentially does go to GND, with the exception of first passing through D2. I'll remove that as you mentioned, though.

Quote
12V Gnd needs to connect to Arduino Gnd.
Wouldn't this potentially burn out the device depending on the amount of electricity that passes through it? Why not connect it directly to the 12V GND? What benefits do I gain through passing it through the Arduino?

Quote
Get rid of D1, D2.
Done deal.

Quote
By Power+ on the '328, is that the 5V Pin? If yes, put a diode from 5V (anode) to Vin (cathode) to avoid reverse driving the regulator.
The "Power +" on the 328 Arduino refers to the Power Input to drive the Arduino, and the "Power -" refers to the pin which must go to GND to complete the circuit.

So when you say 5V pin, are you referring to the 5V output pin, or are you referring to the connector which is used to power the Arduino (as I am doing now)?





Logged

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12467
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Currently, my set up is using Digital Pin 2 (also tried others) to output a signal to the Relay. The output from the Pin 2 when OUTPUT is HIGH is ~4v/~40mA (milliamps).


Since the "absolute maximum" rating for Arduino output pin current is 40mA you shouldn't be doing that -
a sensible safe upper limit is around 25mA per pin.  The voltage drops when current is drawn as the output
transistors on the chip have a certain resistance (a few tens of ohms).  When driving the base of a transistor
through 1k the pin will be much closer to 5V as it is much more lightly loaded.

The circuit posted by dc42 is exactly what you need - if your relay is 5V winding then substitute 5V for 12V in
the diagram.  Grounds have to be commoned for circuits that talk to each other.  Note that the relay itself
isolates circuits, the contacts are not connected in any way to the winding.

Logged

[ I won't respond to messages, use the forum please ]

Sydney, Australia
Offline Offline
Sr. Member
****
Karma: 6
Posts: 397
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Quote
12V Gnd needs to connect to Arduino Gnd.
Wouldn't this potentially burn out the device depending on the amount of electricity that passes through it? Why not connect it directly to the 12V GND? What benefits do I gain through passing it through the Arduino?

I know this is a hard one to wrap your head around - it used to always trip me up when i begin with microcontrollers (as i am from the software not hardware side)

Basically (repeat after me) GROUND is GROUND is GROUND is GROUND. smiley-grin

It does not matter (there are some caveats) what the +ve voltage is - ground is always essentially Zero volts.

Craig
Logged

Offline Offline
Faraday Member
**
Karma: 68
Posts: 2804
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Quote
12V Gnd needs to connect to Arduino Gnd.
Wouldn't this potentially burn out the device depending on the amount of electricity that passes through it? Why not connect it directly to the 12V GND? What benefits do I gain through passing it through the Arduino?
Quote
Basically (repeat after me) GROUND is GROUND is GROUND is GROUND.

In this application (as shown in the schematic) there is no reason to connect the 12V GND to the Arduino Gnd.
Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

Offline Offline
Jr. Member
**
Karma: 1
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There most certainly is a reason ... without the grounds connected, what is the return current path for the emitter of the transistor???   You put a logical high into the 1K resistor where is the current flow?  It MUST be the base-emitter junction and the only way that happens is if the Arduino ground and the transistor's emitter are CONNECTED.
Logged

Offline Offline
Faraday Member
**
Karma: 68
Posts: 2804
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Re. reply #2 schematic.
Quote
return current path for the emitter
The return path is to the 5 volt supply ground not the 12 volt supply ground.

Quote
Arduino ground and the transistor's emitter are CONNECTED
The transistor is referenced/powered from the 5 volt supply not the 12 volt supply.

I said: there is no reason  to connect the 12V GND to the Arduino GND.
Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34547
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The 12V supply switching the solenoid is isolated from the rest of the circuit by the relay contacts so LarryD is correct in saying there is no need to make the grounds common in this circuit. That is the whole point of using relays instead of transistors or FETs the circuits are isolated.
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are right if using Larry's schematic.  I was referring to DC42's diagram which runs the relay from 12V.  In this instance you *do* need 12V and 5V grounds connected.  The discussion is essentially moot because he has a dual supply and the grounds are generally connected internal to the supply.  --Rob
« Last Edit: July 28, 2013, 08:13:53 pm by rmetzner49 » Logged

Pages: [1]   Go Up
Jump to: