-
• #2
I would use a USB charge adapter that plugs into the cigarette lighter in a car, and use a 12V battery.
-
• #3
There are a whole bunch of ways to do this - EVERYONE has to deal with this task!
The correct solution, though, depends on a few considerations:
- How much current your project needs, and at what voltage?
- Is the current more or less constant, varying, or low most of the time with occasional spikes
- How much do you care about power efficiency?
(etc)
Some solutions (in descending order of effectiveness)
DC-DC converter module (the car charger @tage mentioned above is almost certainly a fixed dc/dc converter that outputs 5v)
Search ebay for DC-DC converter, they are usually pretty cheap (though more expensive than other options). I've listed a few examples below. Be sure to check the wad of engrish that passes for specs - make sure they explicitly state whether it's step-up or step-down (they often use "buck" and "boost" incorrectly in descriptions, but they understand words like "up" and "down"). Also, the top line current spec they give usually assumes you put a heatsink and fan onto it ("heat dissipation please enhance"). If the picture doesn't show two inductors, it only goes one direction (step up or step down).
http://www.ebay.com/itm/251405700250 (this one goes up and down)
http://www.ebay.com/itm/111380436169
http://www.ebay.com/itm/131138656670
http://www.ebay.com/itm/360781636011 (5 amps pushes this, even with a heatsink on the chip and board underneath*)
http://www.ebay.com/itm/201084486537These typically have efficiency of 90-95%, and are generally pretty stable. They do not need additional external capacitors. They operate via a feedback loop controlling a buck/boost circuit (wikipedia has explanations of how they work - Inductors are weird!).
LDO Regulator
Voltage regulators are available from digikey and just about everywhere else. They're typically a 3 pin chip - ground, Vin, and Vout. Vin must be higher than Vout, due to "drop out" (see, LDO stands for "low drop out"). The current in Vin and Vout is the same. So you might have 10v coming in, 5v going out, if you're pulling an amp, you're getting 5W out, but you're putting 10W in, and the chip is dissipating the difference as heat. Because of this, they should only be used for low current applications and/or where Vin is not that far above Vout. Regulators need a capacitor on the output to guarantee a stable voltage. I often use regulators if I need 3.3v off of 5v, or 5v from 12 if current needs are low.Charge pumps:
There exist IC's that contain charge pumps, where you connect an external capacitor or two to them, and apply power, and they'll double, the voltage, or produce negative voltage, etc. These are usually only good for low current applications. I've never used them.Zener + Resistor
Finally, for a few cases (very low current, and a lack of concern for efficiency), you can do it with a zener diode and a resistor (diode and resistor in series - in this situation, though, the current will flow regardless of whether the load is drawing any current, and that current must be higher than the maximum current the load needs.The switching regulators you mentioned - look carefully at the datasheets. Some of them require a lot of external components (one of the ones in the list there looked like it was just a controller for a DC-DC converter!), though the one V78-500 just needs a few resistors and capacitors... Also, look carefully at the PRICE - those are $5-6 parts! Whereas an LDO regulator is under 50 cents, zener + resistor like 10 cents, and a DC-DC converter module from our friends in china is a couple of bucks for a nicely packaged PCB with a pot to adjust the voltage, and for the price of a V78-500 counting shipping, you could get a step up/down module with voltage adjust and adjustable constant current limiting (first link above). On the other hand, if you're really tight on space, those self-contained switching regulators could be just what the doctor ordered.
*They have thermal vias between the chip and the ground plane; In order for it to run at near 5A current at a temperature that I was comfortable with, I had to put one of those tiny heatsinks (available on ebay, ofc) on the chip AND the underside of the board)
- How much current your project needs, and at what voltage?
-
• #4
Are you trying to switch a AC or DC load with the relay?
-
• #5
Wow, these are some great answers. @tage, that didn't even occur to me, but I think I can do that tonight without having to order anything from overseas. Awesome. @DrAzzy, I feel like I should copy/paste your answer into the Espruino docs. :) @user7143, the load is DC, and the battery powers everything: the load and the Espruino.
-
• #6
@lavamantis - It's nice to see you progressing with your project.
Depending on your specific project requirements it might be worth investigating alternative methods of switching the DC load. Using a standard relay might not be the most efficient.
If it has to be a relay, look into using a bi-stable relay. This only requires a quick pulse to change the contact state.
-
• #7
@tage @DrAzzy : Quick update, I sacrificed a car USB adapter and successfully made the voltage regulator. Also I made a DIY 4-AA cell battery pack and put it in series with another one, successfully yielding 12 volts input --> 5 volts output.
It powered the board ok, but when the relay triggers the load, the Espriuno goes dark and resets. My feeling is there isn't enough amps to power everything (I'm basically doing this: http://www.espruino.com/Heater+Controller).
Assuming I'm right, I probably need to dig deeper into making a custom voltage regulator myself with sufficient capacity for the amps I need (of which I have no idea! Just... "more").
@StuntMonkeh hmmmm... what are these alternative relays you speak off? Maybe those would make my life easier.
-
• #8
It's probably capping the power at 500ma or something wimpy like that (500ma from USB chargers is common).
Alternately, wait, how do you have it wired? Even if the power supply will supply more current, if you're pulling the power from vbat pin on espruino, and the power is going in through the JST-PH-2 connector, there's a 1 amp self-resetting fuse that could be getting in the way - you want to give the load it's own power wire, coming right from the power supply (and through the relay, either before or after the load)
I highly recommend those converters I linked to you on ebay - they're adjustable, and some of them are so cheap they're disposable (I use those 5-for-$8 buck converters all over the place)
If you're using a common ground, I wouldn't even use a relay - i'd use a mosfet instead. But mosfets that work well with 3.3v gate drive are nigh impossible to get except in surface mount packages.
-
• #9
@DrAzzy re: "Alternately, wait, how do you have it wired?" That's another weird thing that probably needs it's own thread. I have a JST-PH-2 connector, and it's spliced directly into the power supply (the 5V output from the regulator). But, plugging it into the actual JST-PH-2 female socket on the board does NOT power up the Espruino - it stays dark. Plugging the exact same connector onto some pin headers for BAT and GND DO power up the Espruino tho, so that's what I'm using. So, something's not right I think. 5V power via the USB connector works fine.
I have a couple of these guys: http://www.espruino.com/ULN2003 I'm going to drive a single motor with it for this same project. I'm using a common ground. Maybe I could also use the ULN2003 for this?
-
• #10
If you overload a supply the voltage will start to fall. The reason the Espruino resets is that the in-rush current for the relay coil is pulling down your supply voltage.
There are usually datasheets for relays with this information on.@lavamantis
I would suggest working back from what you are switching.- What device on the relay are you switching? i.e. boiler, heater, light etc.
- The voltage and current are you switching with the relay? i.e. the device load.
- How long are you switching the device on for?
The ULN2003 will switch up to 500mA. The relay you are using has contacts rated at something like 10A @ given voltages. As you can see this is a big difference.
Bi-stable relays or 'flip flop' relays switch the contact state each time you energise the coil. Again it depends what you are switching. If the power fails you need to make sure it fails to a safe state!
- What device on the relay are you switching? i.e. boiler, heater, light etc.
-
• #11
Have you thought about running Espruino directly off the battery (it can run off up to 16v as it has its own 3.3v voltage regulator), and then running the relay off the regulated supply?
That should ensure the Espruino itself will keep going, even if the regulated supply dips momentarily.
Also are you connecting the heater itself to the battery, or to the regulated supply? You could probably connect that straight to the battery as well.
My project requires controlling a relay module from Espruino, and to be powered by batteries in cold temperatures. At room temperatures, so far everything works great by connecting 4 AA cells (about 6 volts) to the Espruino. The relay comes on fine. However, at cold temperatures (< 0 degrees C), the voltage in the battery pack drops to around 4 volts. This is not enough to flip the relay and power the board and the connected items. (I tried alkalines and lithiums - lithiums hold out a bit longer but eventually succumb to same problem).
I tried using a 9 volt battery, but this is TOO much for the relay module, and it just stays on.
My next thought is to use a voltage regulator, and run 6-8 cells (9 volts or 12 volts) on the battery pack. This way, the Espruino would get a steady 5v no matter what wide variances in voltage come from the battery pack.
Then I thought something from these guys (http://www.digikey.com/product-highlights/us/en/cui-v78-regulators/1177) would do the trick. Something like the V78-500-SMT: http://www.cui.com/product/resource/v78-500-smt.pdf
So:
Thanks!