Author Topic: Latching relay and timer on/off for Raspi  (Read 9000 times)

desitter

  • Newbie
  • *
  • Posts: 3
Latching relay and timer on/off for Raspi
« on: July 29, 2013, 04:12:37 pm »
I have been looking into the Digispark with the relay and RTC shield as a low power solution to turning my raspberry pi on and off at preset times. From what I have been reading, non-latching relays require a constant 'driver current' in order to keep the contact open, if power is lost the relay reverts back to its previous state. The problem is that I am seeing required currents in the range of 30-80mA, while the model A pi only draws around 120-150mA while idle. As a way of keeping power usage down by powering off the pi when not needed, adding 30-80mA to it's operational usage just won't do. From what I can tell, latching relays only require power when they change state. Having a relay that stays in an 'open' state even when power is lost is of no concern to me, so such a relay would be most beneficial if it truly does not constantly consume power.

I'm fairly hopeless at electronics (so much so that I had to wiki transistors and relays only a few hours ago to bring myself up to speed), so I'm fairly limited to solutions that are well documented with complete instructions as to what wire goes where etc. My question is therefore two part, a.) Is my understanding of latching relays correct, and would such a relay used with a Digispark provide a substantial enough power reduction when power to the pi is shut off. And b.) If I was to purchase the relay kit, could I use an alternative latching relay in place of the existing relay without having to buy additional resistors and transistors?

If you have any links to latching relays you think would be sufficient I would very much appreciate them, or perhaps an idea on what specifications I need to look out for.
Are such relays overkill for something as relatively low power as the Raspberry pi? I notice these relays can handle mains power, which certainly seems overkill for my application. If anyone thinks they have a better solution I would very much like to hear that as well, again keeping in mind my lack of electronic prowess.

Thank you very much for your assistance,
- deSitter

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Latching relay and timer on/off for Raspi
« Reply #1 on: July 29, 2013, 10:50:16 pm »
deSitter
Your information regarding latching relays is correct.
They have two coils, one for ON and one for OFF.
Sometimes called Set and Reset.

Don't panic about the absolute ratings of 230v, 10A ...etc. This is like the carrying capacity of a lift/elevator where its the maximum and still works if a single person uses it.

One thing the RasperryPi likes is being shut down.
A bit like your windows machine where pulling the plug can cause issues and corrupt the hard drive (or SD card).

You may wish to look at a way of sending something to initiate the shutdown, and then power it off 10-15 secs later.

I'm about to do this but using a full Arduino as there are many other things to do which exceed the DS capabilities.


Cheers
Mark


desitter

  • Newbie
  • *
  • Posts: 3
Re: Latching relay and timer on/off for Raspi
« Reply #2 on: July 30, 2013, 08:14:45 am »
Thank you Mark, that was very informative. I assume it's just a process of programing the pi to listen into a particular pin on the Digispark, that when set to high executes some shutdown procedure? I just purchased a few books on 'beginners' electronics, and aim to rapidly consume those and hopefully get up to speed on the basics when they arrive. In the meantime, if anyone has any comments or suggestions for replacing the default Digispark relay with a latching relay, it would certainly be of appreciated.

Cheers,
- deSitter

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Latching relay and timer on/off for Raspi
« Reply #3 on: July 31, 2013, 06:34:05 am »
deSitter

Its very timely, because it will help with my project.
Setting a pin that connects to one of the GPIO (which then executes a script) is a possibility, and something I thought about too.

I would suggest pulling the pin LOW to shutdown (never apply a voltage to a pin that is greater than the supply ...ie shutdown)
Check which pins are forced HIGH to avoid one of those.

The other one (a kickstarter) I've seen is send it serially, which may also require the logon, etc. This is not available on the DS.


An alternative to the relays that might work.

1. An SCR or Triac is designed to switch AC.

Once triggered it is effectively latched ON, and won't 'let go' until the gate drive is removed AND the current passing through it is reduced below its hold point.

If a triac (or SCR) and the normally closed (NC) relay contact (relay contacts are specified in their un-powered state) were in series with the supply, you could send a signal to the SCR to turn it on, and pulse the relay to turn it off.

The RPi is 5v, so its not going to worry the DS how you configure it, and you can always use an opto-coupler to isolate if the supply voltage is greater than 5v, or insure the triac/SCR is in ground side of the RPi/Load.

2. Use a PNP transistor in series with the 5v supply to the RPi. (Emitter to 5v, Collector to the RPi/Load)
You then connect the base (through a resistor) to the DS pin and make it LOW to turn power onto the RPI.
This will consume some power (10-20mA depending on the transistor).

3. Use a Mosfet which doesn't require much gate current to hold ON.
There is a Mosfet shield which is designed to switch the ground side of the load available, and the info to connect is here
http://digistump.com/wiki/digispark/tutorials/mosfet
(The RPi is not inductive so you don't need the Vin connection, just Ground and Out).

Let me know if this might solve your issue.

Mark
 
« Last Edit: July 31, 2013, 06:40:07 am by Mark »

MichaelMeissner

  • Full Member
  • ***
  • Posts: 166
Re: Latching relay and timer on/off for Raspi
« Reply #4 on: July 31, 2013, 11:46:58 am »
The RPi is 5v, so its not going to worry the DS how you configure it, and you can always use an opto-coupler to isolate if the supply voltage is greater than 5v, or insure the triac/SCR is in ground side of the RPi/Load.

While the RPi takes 5 volts to power it, the GPIO pins are 3.3 volts.

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Latching relay and timer on/off for Raspi
« Reply #5 on: July 31, 2013, 07:54:25 pm »
Quote
While the RPi takes 5 volts to power it, the GPIO pins are 3.3 volts.

Quite right ... that didn't actually enter my thought process at the time.

So to be clear ... we will need to use a pullup resistor to 3v3 on the GPIO pin and a diode to the DS (or opto/transistor) to pull it down.

Cheers
Mark

desitter

  • Newbie
  • *
  • Posts: 3
Re: Latching relay and timer on/off for Raspi
« Reply #6 on: July 31, 2013, 09:05:57 pm »
Great stuff Mark, lots for me to think about  ;D .

MichaelMeissner

  • Full Member
  • ***
  • Posts: 166
Re: Latching relay and timer on/off for Raspi
« Reply #7 on: August 01, 2013, 06:10:27 am »
Quote
While the RPi takes 5 volts to power it, the GPIO pins are 3.3 volts.

Quite right ... that didn't actually enter my thought process at the time.

So to be clear ... we will need to use a pullup resistor to 3v3 on the GPIO pin and a diode to the DS (or opto/transistor) to pull it down.

Cheers
Mark
Or use something like this http://www.adafruit.com/products/757.  Given the RPi supports i2c, perhaps using i2c would allow more transfer than a single pin.
« Last Edit: August 01, 2013, 03:27:29 pm by MichaelMeissner »

Tempest2k8

  • Newbie
  • *
  • Posts: 2
Re: Latching relay and timer on/off for Raspi
« Reply #8 on: August 01, 2013, 09:59:24 am »
I purchased one of these for my PI. http://www.pi-supply.com/

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Latching relay and timer on/off for Raspi
« Reply #9 on: August 01, 2013, 11:00:35 am »
Michael
Yes that would also work ...thanks

Tempest2k8
Thanks for the link.
Its a rather expensive relay that indeed latches.

This also requires you to initiate a shutdown sequence, which needs to come from somewhere.

deSitter was interested in NOT adding the current consumption of a relay, hence the use of a proper latching relay.


They do have a very nice looking GPIO sheet that worth downloading.
Cheers

Mark