Go Down

Topic: Output Signal From Digital Pin to Switch Relay, Suggestions? (Read 7751 times)previous topic - next topic

JDBurnZ

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

dc42

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
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.

JDBurnZ

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.

CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

larryd

Quote
12V Gnd needs to connect to Arduino Gnd.

What is the reason?
No technical PMs.
The last thing you did is where you should start looking.

JDBurnZ

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)?

MarkT

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.

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

craigcurtin

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.

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

Craig

larryd

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.
No technical PMs.
The last thing you did is where you should start looking.

rmetzner49

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.

larryd

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.
No technical PMs.
The last thing you did is where you should start looking.

Grumpy_Mike

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.

rmetzner49

#12
Jul 29, 2013, 03:08 amLast Edit: Jul 29, 2013, 03:13 am by rmetzner49 Reason: 1
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

Go Up