zedin
Posts: 38
Joined: Tue Oct 18, 2011 1:20 pm

GPIO and Ground with 3.3V and 5V question

Mon Sep 30, 2013 8:26 pm

So am working through a project mainly to learn using the GPIO. My overall goal is to eventually use the PI, a shift register, and relay board to control Christmas lights. I am using the adafruit 4 channel logic level converter to keep the PI safe since the relay board will use 5V as well as the shift register. To test my setup I was just going to use LEDs off the shift register to make sure it works properly but was not sure on the best way to power the 5v or connect the ground.

If I use the 5V pin off my pi would that be sufficient to run the relay board (or at least the LEDs)? Also is it ok to have a 5v line going to the raspberry pi's ground pin? Obviously it is not a straight shot from 5v to ground but goes through the components.

And if I use an external 5v power source should I connect the two grounds together? Aka the ground from the Pi GPIO and the 5V ground.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13006
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO and Ground with 3.3V and 5V question

Mon Sep 30, 2013 8:37 pm

always connect all GND's together. Never connect any power supply voltages directly to GND (its called short-circuiting).

GPIO's can source or sink only a few mA, up-to a maximum of about 15mA for the sum of all GPIO's.

I would not use the 5V header pin, all currents running through the micro USB port go through a fuse rated just a bit over 1A, so there isn't much reserve current for the 5V from the PI headers, and even less current from the 3.3V regulator.
If you need to power power-hungry 5V (or 3.3V) devices connect them directly to an external 5V (3V3) source.

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: GPIO and Ground with 3.3V and 5V question

Mon Sep 30, 2013 8:45 pm

zedin wrote:If I use the 5V pin off my pi would that be sufficient to run the relay board (or at least the LEDs)? Also is it ok to have a 5v line going to the raspberry pi's ground pin? Obviously it is not a straight shot from 5v to ground but goes through the components.
Powering a shift register and LEDs from 5V works (for about 8) if the LEDs are driven by the shift register.

To drive relays you WILL need an external PSU to drive the relays. Are you sure the shift register can drive the relays?
zedin wrote:And if I use an external 5v power source should I connect the two grounds together? Aka the ground from the Pi GPIO and the 5V ground.
GNDs should normally be connected between all sources (except where isolation is needed but that is more copmplicated). Without the GNDs tied together the voltage from the shift register will not drive the relays without the same GND reference.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

zedin
Posts: 38
Joined: Tue Oct 18, 2011 1:20 pm

Re: GPIO and Ground with 3.3V and 5V question

Mon Sep 30, 2013 10:56 pm

Thanks for all the answers.

As to can the shift register power the relay.. no clue.. if not I will just throw in some transistors so they can switch the relays.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13006
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO and Ground with 3.3V and 5V question

Tue Oct 01, 2013 7:11 pm

If you power the shift register with 5V, chances are that the PI's logic high level of 3V3 will be insufficient, as most 5V TTL types of logic (including HCT) will have a minimum logic high of 0.7 x VCC, or 3.5V, so controlling the shift register becomes a problem. The solution is to choose HC or Cmos logic, and to power it with 3V3.

The outputs of the shift register, regardless whether 5V or 3V3 powered, will only provide a few mA, so you need to drive either a darlington, or (better) an nFet with a low gate turn on voltage, to switch on the relay. also, don't forget the flyback diode over the relay, or you will blow up the transistors.

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: GPIO and Ground with 3.3V and 5V question

Tue Oct 01, 2013 7:19 pm

zedin wrote:Thanks for all the answers.

As to can the shift register power the relay.. no clue.. if not I will just throw in some transistors so they can switch the relays.
Look at using Logic FETs like FDV303N can handle 2A and have low on impedance, no need for biasing resistors between shift register and FET.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

zedin
Posts: 38
Joined: Tue Oct 18, 2011 1:20 pm

Re: GPIO and Ground with 3.3V and 5V question

Tue Oct 01, 2013 10:49 pm

So use a FET in place of a transistor to gate the higher voltage to switch the relay? (If I understand what it says about FETs in wikepedia =p)

User avatar
Tage
Posts: 287
Joined: Fri May 24, 2013 2:29 am
Location: St Thomas, Ontario Canada

Re: GPIO and Ground with 3.3V and 5V question

Wed Oct 02, 2013 1:29 am

FDV303N for sure is better than a npn transistor or a Darlington. There are other alternatives such as Si2302CDS (buy at Mouser for $0.14 if you buy 10pcs) that can handle more current. The Si2302CDS can handle about 2.6A continuous load at room temperature compared to 0.68A for the FDV303N. (cost $0.25 at Mouser)
If you want to drive the load directly without relay, you could use something like SiR404DP. It can drive about 45A because when you apply 3.3V to the gate you can expect that it does not have more than about 0.002ohm resistance from Drain to Source. The package is a bit bigger, and you may have to ask around to get samples or to buy small quantity.

zedin
Posts: 38
Joined: Tue Oct 18, 2011 1:20 pm

Re: GPIO and Ground with 3.3V and 5V question

Wed Oct 02, 2013 2:46 am

Well the ultimate goal is to switch relays connected to AC outlets to turn Christmas light on and off.

I want to tie this to a script to make an equalizer visual and have them switch when a channel reaches a given volume. So I can basically play any song via pi and have light timed to it.

User avatar
sparky3489
Posts: 32
Joined: Sun Jan 05, 2014 5:22 am
Location: Earth
Contact: Website Yahoo Messenger

Re: GPIO and Ground with 3.3V and 5V question

Sun Jan 05, 2014 5:35 am

For stability and reliability, you'd be FAR better off using zero-cross optocouplers and triacs. I have done exactly what you want to do, just not with a Pi. My little project uses a laptop running windows with a VB program controlling it all. I've also incorporated an ATI Remote Wonder RF remote control.

I would love to move all this functionality over to my Pi.

My current design from start to finish - http://sparky3489.webs.com/pcinterfaceproject.htm

I'll make you a circuit board if you can get all the programming figured out.

Return to “General discussion”