TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Making an on/off switch for 12v

Wed Aug 15, 2012 6:56 pm

Hi guys,

I've tried to read up a bit on this but I'm sort of stuck, being quite new at electronics. I drew, etched and soldered my own tiny things back in high schoolish.

What I'm basically after, is a RPi replacement of this 12v timer.

Basically, instead of a set timer, I need one that can be turned on and off by GPIO or Gertboard etc. to turn on and off a 12v router and WiMAX antenna for image uploads.

The primary demands are that it can take some 20-30w load or so as the antenna requires a good bit of power (but stays on a short time). Secondly it needs to take little power in itself, as the whole solution is currently running on a 200ah battery and a very old 60w solar panel.

I've been guessing that my best solution may be a solid state relay with 3.3v control and 12v allowed throughput but I can find no such thing, and if I did I still wouldn't know what to do with it.

So! Will Gertboard help me in any way here? Do I still need a separate relay? Do I need a relay at all or is there another smart solution I don't know of? How would I hook it up to the GPIO? What should I read?

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Making an on/off switch for 12v

Wed Aug 15, 2012 7:44 pm

I found alot of answers in this post, but I'm still unsure of what sort of relay it would take, and how much this would draw when it's running. Wouldn't a solid state relay be "nicer" on the juice?

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Making an on/off switch for 12v

Thu Aug 16, 2012 7:41 am

Here's a link to what you need. http://www.susa.net/wordpress/2012/06/r ... sing-gpio/

It mentions 240V but will work with 12V just fine. As to whether a regular relay or solid state is better have a look at the spec sheets (RS and Farnell have spec sheets for virtually all their relays though I'm guessing you're in the states in which case maybe Radioshack is the place to look). I suspect the difference is minute especially when you are driving a 20W load off it.

I was going to build the above circuit as I want to build a very similar timer to you but instead have brought one of these http://www.ebay.co.uk/itm/300735738629? ... 1423.l2649 as it worked out about half the price as getting components themselves, you can buy versions with many more relays if you need. Its the exact same as the link above but with a few leds for status.

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Making an on/off switch for 12v

Thu Aug 16, 2012 8:07 am

Thanks a bunch - that one you linked is more or less exactly what I'm looking for!

My worry about the coils, probably unwarranted, is that they would ALWAYS be on, instead of just on when it's activated. I've no problem with them taking several mA while on, but they must not while off.

Will those relays take 5v 20mA continuously, or just when switching, or just when on?

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Making an on/off switch for 12v

Thu Aug 16, 2012 8:25 am

Perhaps an electronics expert can correct me if I'm wrong but the coils will only take power when energised. If you look at the circuit the transistor will have cut all power to the coils when it isn't getting a high signal.

The transistor will *I think* always draw some power but it is a tiny tiny amount.

YodaTheCoder
Posts: 14
Joined: Fri Jul 27, 2012 5:02 pm

Re: Making an on/off switch for 12v

Thu Aug 16, 2012 8:26 am

Wouldn't something like this be simpler? Example here (for Arduino but it'd be a simple transition).

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Making an on/off switch for 12v

Thu Aug 16, 2012 9:34 am

YodaTheCoder wrote:Wouldn't something like this be simpler? Example here (for Arduino but it'd be a simple transition).
This looks much more like I initially thought of with a solid state relay! And, simpler I guess. I don't need any leds or anything, this is to be (and is already) an automated installation far away.

Hugh Jarse
Posts: 46
Joined: Mon Mar 05, 2012 5:03 pm

Re: Making an on/off switch for 12v

Thu Aug 16, 2012 10:10 am

TarjeiB wrote:Hi guys,
What I'm basically after, is a RPi replacement of this 12v timer.
You can do this with a simple npn transistor circuit. The process is roughly as follows

1. Work out the maximum current needed (add a little 10-20% for good measure), assuming this is less than a few hundred mA, a transistor will do the job.

2. From the datasheet for the transistor find out the current gain of the transistor (called hfe) - at the maximum current . This tells how many mA you need to supply at the base to get the current you need.

3. Now stop and check that this base current does not exceed the maximum that the GPIO can provide. This is the most important step. Assuming does not, continue...

4. From the datasheet find out the base/emitter voltage drop (usually 0.6-0.7v)

5. using Ohms law, the fact that you are using a 3.3v signal and the V in step 4, calculate the size of the base resistor. e.g. Rb=(3.3-0.7/required base current)

6. Now if you were to build this and turn the GPIO on the required current will flow from the collector.

The point here is that whilst it is important to protect the GPIO with a suitable base resistor, you also need to make sure that the base resistor is not so large that it does not provide enough current for the application being switched. It is a common mistake to do the former without considering the latter.

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Making an on/off switch for 12v

Thu Aug 16, 2012 12:35 pm

So, I can either do a relay, a MOSFET or a transistor. The two latter seem very similar and suited since I'm only working with ~20w DC.

Transistor: http://bildr.org/2011/03/high-power-con ... nd-tip120/ (like the suggestion above)
MOSFET: http://bildr.org/2012/03/rfp30n06le-arduino/
Relay: http://www.susa.net/wordpress/2012/06/r ... sing-gpio/

Do I understand it correctly - if I get a relay, it doesn't matter if it only specifies AC; it will take DC all the same (at least at my current requirement)?

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Making an on/off switch for 12v

Thu Aug 16, 2012 1:02 pm

Relays specify both their AC and DC limits if you look at the specs. Since the voltage is 12V and the power is 20W a 2A relay would be sufficient (P = IV) but you might want to get a 3A one just in case you're not correct about the power. There should only be pennies difference in cost if any.

Return to “Automation, sensing and robotics”