I see that it is recommended to have a Vin between 7 and 12 VDC.
I'm putting together a current sense circuit and I want to have an arduino monitor the current across it.
The circuit is 120 VAC (US nominal).
I would like to have the arduino draw its power from the same circuit it is going to be sensing voltage on.
What I'm trying to understand, is first, what is the optimal voltage for Vin. USB provides 5V, but the arduino spec states 7-12 is best.
Second, what do I need to switch down from 120 VAC to 7-12 VDC? I know a "Wall wort" will do it, and that I could always tear one apart and make use of it for my circuit, but I would rather figure out how to design a circuit to do that for me. I'll learn something, and I won't rely on using a piece of equipment in an unusual way.
If anyone can help answer my questions and point me in the right direction I'd appreciate it!
I'm kind of new to basic electronics myself, but I think to convert from AC to DC, you arrange a series of diodes in a special pattern to get, first half-wave, then full wave rectification. I think it's called a "bridge rectifier" and on most schematics appears as a diamond pattern of diodes. You have to make sure the polarity of each diode in the diamond pattern is correct for it to work properly. After that you'll need a capacitor to smooth, or flatten, the waveform of the, now "positive only" waves coming out of the rectifier... That'll give you DC, with a bit of "ripple" in there because the flattening probably won't be perfect... Then going from a higher voltage DC to a lower voltage should be straightforward. Not sure if the higher voltage should be stepped down before or after rectification though, so maybe someone else will chime in on that...
The transformer definitely comes before the rectifiers. Simplest to implement would be a regulated supply based on a 7805 voltage regulator. Here's a good basic circuit. Not sure how much current is needed but a 2-amp transformer is overkill for a microcontroller that's just reading sensors. I'd look for one that's rated somewhere between 300mA and 1A. Any diodes in the 1N400x series would be OK; bridge rectifiers with all four in one package are also available. The secondary voltage on the transformer could be between 6 and 9 volts.
EDIT: Opps, forgot what we were doing here. The above circuit is fine, and its output can be fed directly to the 5V pin on the Arduino. But, the Arduino has its own voltage regulator on board, so that could be eliminated from the above circuit and the output of the rectifier (pin 1 on the regulator) can be fed directly to the Arduino's Vin pin, or to the power jack (the two are connected). C3 of course is also eliminated along with the regulator. I might keep C2, but I'd use 0.1µF instead of 0.01µF. If I were building the entire circuit, I'd use 0.1µF for both C2 and C3.
This will give you approximatly 12v DC, you will then need a regulator. The 78xx linear regulators are good and I have used them for years, however they are not that efficent and they generate quite allot of heat at higher loads. If you are only powering the arduino and a few other small components the 7809 would give you 9v that you cold feed into the arduino Vin, the arduino would then use its own internal regulator to get its 5v.
You could instead use a 7805 and connect this to the 5v pin on on the arduino and leave Vin disconnected, if the 7805 is attached to a heatsink you can take upto 1A from it.
I adjust them to 5v and connect directly to the 5v pin on the arduino, these can give you as much as 3A and have a very wide input voltage.
I have managed to buy these boards from "direct from china type online stores" for about £1.50 each. If you need higher loads these are far more efficent than the linear regulators.
I am guessing for your application, you could select an appropriet transformer, rectifer(could just be 4 diodes), and capacitor and connect the supply to the Vin pin this will make use of the on board linear regulator.
Like someone said, the 7805 isn't the most efficient these days, but it still beats a Zener handily. For a very low current circuit, that has nearly constant current requirements, a Zener might be OK, but when used as a power supply, it's more of a "point solution". Properly designed, a Zener circuit can provide good regulation. I still use my share of linear regulators, I don't sweat the efficiency when powering circuits that only need a couple watts or less. I need about three seconds of design time for a linear regulator, a Zener circuit would take a fair amount longer, finding the required Zener current, checking the load current, calculating the proper dropping resistor and wattage, etc. etc.
But seriously, all that is needed to go into the Vin pin or power jack is rectified and filtered DC between 7 and 12 volts. I wouldn't even get too terribly carried away with the filtering. I'd go see what I had laying around, between 100µF and 470µF.
I was just making sure there were no fatal flaws with where I was trying to go here.
So Zener diodes can work well/decently with static load (and low current load). I would guess then for changing loads, a linear regulator, and for larger loads I would need a switching power supply or something a bit beefier.
I think I'm going to stick with zener for now, as it should be low heat and not require much real estate, and I think I have a bit to learn from doing it this way.
Ummm, I sorta looked at that schematic a bit late... If it really needs to supply 400mA, I sure wouldn't use a Zener. If this is going to feed Vin on an Arduino, there isn't any real reason to pre-regulate at all. I also couldn't buy off on a mains connected circuit like that without seeing the values for the components (and the whole circuit, bottom seems cut off). The usual Zener circuit would have a resistor in the positive rail between the top of C2 and the Zener's cathode.
Is there some reason to avoid a transformer? Much safer with one. A small 6.3V filament type transformer, four diodes, and an electrolytic capacitor should work well.
That may be, but that circuit is not the equivalent of a 78xx linear regulator, it just illustrates using a Zener as a simple regulator. A 78xx has several important advantages over that circuit.
It doesn't NEED 400 mA, but the only maximum current rating I could find on Arduino spec sheets was the ~550 mA rating of the USB power input for the Arduino. I selected a fuse at 500 mA and backed off 20% to come up with some rough capacity number.
I'm not sure how much current an Arduino draws. I could easily back down to whatever the max Arduino rated current is. I don't plan on powering anything else with it, just the Arduino itself. Is there a good place where I can find the expected/maximum current draw of the Arduino?
As for not having any values, I'm not there yet. I'm just trying to get close to what the circuit needs to look like before I do my circuit analysis.
I was planning on coming off a main. I know this circuit provides no isolation. I'm planning on having this inside an enclosure and not exposed, and I work in an environment with three phase 6900 VAC loads and have had electrical safety training, so I'm not too concerned about it from a personnel safety standpoint, only an equipment protection standpoint (if I am underestimating the risk please let me know). The fuse and varistor should provide some level of protection to the arduino, and I might need to put a little more into the circuit to limit potential failures, particularly the consequences of an instantaneous short of C1.
What I want to do with the arduino is set up a device which measures power consumption for a load using inline shunt resistors. I'm going to have an enclosure, with one end plugging into a wall outlet, and the opposite end plugging into the load to be measured. On the front of the enclosure will be a display (likely a 7 segment) with a button to swap between W and kWh, a reset button for clearing cumulative kWh, and a power switch. I was hoping to power the Arduino using the same 120VAC that I'm measuring as that is what is present in my system. The Arduino will measure the current from the load, the current that its own power supply is drawing, and the voltage across the two rails and compute instantaneous power draw and cumulative energy use. I'd also like to be able to transmit this to another system for trending.
There's no real reason to avoid a transformer. I was having a hard time finding/selecting one, and I do not want to pull apart a "Wall wort" and repurpose it. I believe a transformer also takes up more space and generates more heat than a capacitive AC-DC rectifier, but I could be wrong.
I'm going to reduce my current draw assumption down to 100 mA max, 80 nominal. Should have plenty of margin for my purposes.
With regard to transformers, I'm going to pursue the possibility of using one. I may not, but I at least want to see what the analysis looks like.
I think it might be difficult to select parts/components with 120VAC running across it, but if I can transform it down to 12 VAC that should be much easier to deal with.
Also...I'm concerned about the floating ground on the DC voltage side. Even when I remove the R1 resistor, there is still a diode between the Arduino GND pin and actual GND (never mind the current sense resistor. <= 1 mOhm). What I'm wanting to do is take the voltage across the current sense resistor (which is in the AC side of the circuit), run my -20 to +20 mV through an OpAmp, and get it into the 0-5 VDC range the Arduino needs. Because the Arduino's GND is floating, that means I'll need to not only raise my -20 to +20 mV signal to 0-40 mV, but I'll also need to add in the floating ground as an offset. Are there any good examples on how to do this? Can I simply add a level shift for the Arduino's GND on the DC side to my OpAmp circuit, or will the DC/AC be an issue? Imgur: The magic of the Internet (Also, I understand this circuit does not correct the -20 mV to +20 mV to 0-5V. I'm not there yet)
Here is a fairly complete application note that may have a lot in common with your project. RMS measurements of mains voltage and current, transformerless power supply, etc.
I think it might be difficult to select parts/components with 120VAC running across it, but if I can transform it down to 12 VAC that should be much easier to deal with.
Such transformers have been made and sold for many many decades and are usually called filament transformers as they were commonly used to power the 6.3 or 12.6VAC filament for common vacuum tubes. They came in many physical sizes depending on the output current rating for the transformers and small 100-200 ma ones did exist.
Jack, that's a big help and an interesting read. I need to sit down some time and figure out DC/AC coupling/decoupling. They use a lot of capacitors.
They are using CTs. I was hoping to avoid CTs and try to directly use a shunt resistor since CTs seems "too easy". I think some of what is in here though will help quite a bit.
@lefty, I have to laugh, I don't have a lot of use for Radio Schlock in general, but the two things that they were my standard supplier for were project boxes and filament transformers. I still have a bunch around that are probably decades old. Doesn't look like they've changed much. I liked the small 300mA models.
LOL, but now they sell Arduinos and stuff, so they have improved a little in my book. I did a quick search on small filament transformers and nobody came even close to the price they want for their 300ma one. They probably aren't aware that they are sitting on the last large quantity inventory in existence.