### Using one power supply - Ideas

Being able to use one power supply to provide power to run the hardware and also give a voltage sample to be used in the power calculations seems to be a popular topic. Here are some ideas and diagrams to think about. Feel free to pick these apart and maybe use them as a springboard for other methods.

(Please excuse the quick-n-dirty schematic diagrams, I didn't want to spend all night drawing them up neatly. No component values are given for the most part.)

First, a low-component-count solution that doesn't require changing anything existing and is able to use a single output, off-the shelf AC supply:

The second transformer would not need to be a power transformer, a small signal transformer with a 1:1 turns ratio that could pass mains frequency would suffice. This transformer would provide absolute isolation, and allow use of current versions of hardware and sketch code.

Next, a somewhat more complicated system that uses a center-tapped AC adapter/power transformer, and a DC-to-DC converter for isolation:

My favorite, I think, is using an Opamp to both isolate the voltage sample, and to provide the needed bias voltage:

The gain of the opamp could be unity, or over or under unity as needed to provide the proper level of sample. The biasing network might not be necessary, as an opamp running from a single-ended power supply (+5v instead of + & - 5V) would naturally have a 2.5 volt offset at the output, which works to our advantage.

Finally, how about eliminating all the fuss and get rid of the bias altogether:

Feed the voltage sample in as an alternating full wave, everything above the base line, so no bias is needed. This would require some tweaks to the code, to change the calibration decimal value (half the RMS voltage in a full wave compared to a sine), and any phase and power factor calculations would need a rework to function properly. Could probably get rid of the digital offset filtering, possibly speeding up the program significantly.

A variation would be to use a half-wave rectifier, allowing the use of a simple AC-AC adapter. The missing half-wave would need to be compensated for somewhere in the software, though:

Ultimately, the simplest solution is what's in use right now, redundant power supplies, as unappealing as that is.

### Re: Using one power supply - Ideas

Sharkey, Thanks a lot for taking the time to create diagrams and write up about this, its really interesting to see the different possibilities side by side.

It was a while back I last looked into this so my memory is a little rusty, I had simulated a centre tapped circuit in LT Spice which suggested that it would work, I will try to remember the schematic and do the simulation again and post it up.

In the end I came to the same conclusion that you have come to that it is simpler just to go with two separate power supplies and also safer as I couldn’t find pre-packaged AC-AC adaptors with centre tapped outputs and I think its a good idea for the energy monitor to not require working with high voltage circuitry.

PS, those are really nice looking circuits, what software do you use?

### Re: Using one power supply - Ideas

Trystan, I've been thinking about what it would take to use a single output supply transformer to use in the above circuits, and have reasoned that it would be possible to use a half-wave rectifier so that one leg of the AC supply could be connected to the circuit ground. Since the supply must be regulated anyway, some amount of ripple would be acceptable.

I do have concerns about sample waveform distortion, having rectifier(s) in the circuit will introduce commutation products when they conduct. The amount of distortion could be significant. I'll try and get some example transformer/rectifier circuits built and look at them with my oscilloscope.

I'm still partial to the opamp circuit, I may go ahead and actually build that one...

The drawings were done in Micro\$oft Publisher. I really didn't take the time to clean them up, there are a lot of sloppy overlapping lines, lines that don't quite connect, bad component alignment, etc. All of the components were created by myself using vector drawing or edited copy-and-paste objects in libraries. Publisher isn't really a CAD program, and it's very labor intensive to get good schematics out of it.

### Re: Using one power supply - Ideas

Here's the circuit I simulated a while back: centretap.zip

The waveform distorts quite quickly once you increase the series resistance of the transformer coils.

### Re: Using one power supply - Ideas

Did anyone try the solution with the 1:1 tranformer?

### Re: Using one power supply - Ideas

I've been meaning to build up that circuit, run some tests, and post the results, but the weather has been too nice, and I've been outside pruning trees and cleaning up the planters. Now that nasty storms are forecast for the next several weeks, I'll have some indoor time to get out the oscilloscope and try out a few circuits.

I've also ordered up some switching regulators and associated components for the purpose of using them instead of the LM7805 linear regulators that are so common. I'll report on that too as I know more.

### Re: Using one power supply - Ideas

What would you use for an isolating transformer in option 1?

Would this work? I'd like to try it out.

http://search.digikey.com/scripts/DkSearch/dksus.dll?vendor=0&keywords=76601%2F1C

Ben

### Re: Using one power supply - Ideas

Yes, that might work. The only real criteria for the transformer is that it doesn't saturate at the input voltage, causing clipping or ringing. I think that the biggest concern about this circuit is that the rectifiers might cause waveform distortion. If I were building it, I'd put some resistance in series with the rectifiers, perhaps 15-20 ohms to soften the switching transients.

Build one up and let us know how it works!

### Re: Using one power supply - Ideas

Hey!

The graphs disappeared from your post. Could you please upload the pics to the forum?

Thanks

### Re: Using one power supply - Ideas

I'm new to this forum - its all very interesting.

I have a nanaode base and EmonTx monitoring a heat pump. We are doing CTs with volt input, and have both a USB supply and ac adaptor. It obviously makes sense to power via the ac adaptor.

I am digesting the ideas above.   thanks

I read that the 7805 needs a heat sink if Vin is over 7v  Is that true? Is that only at high load?   Anyhow, if the EmonTx uses say 40mA / 200mW, then the regulator could be small.  I have looked at the RS 739-0460 - a 200mA regulator in to92 transistor-type package.    Any reasons not to try one of these?

How important is the 1:1 isolation?  debatable I guess.   Maybe depends on the quality/cost of the ac/ac adapter!!

I like the idea of removing the need for orientation of the CT.  I guess any rectified or half-wave versions would sort this.

### Re: Using one power supply - Ideas

According to my simulation, if you can accept half-wave rectification, then it's possible to use the standard AC adapter and capacitively couple the raw voltage into the standard voltage sensing input. I don't want to post the circuit until I've tested it, but it looks very much like Trystan's (above) but without the other half of the transformer and the associated diode.

As Mr Sharkey says, the answer to Trystan's distortion problem is to include a low value resistor in series with the diode, which will reduce the peak current and increase the conduction angle. Of course, the resistor must not be so large that the regulator runs out of headroom and fails to maintain the output voltage - 12 Ohms appears to be the maximum with a 100uF smoothing capacitor. (This assumes the Mascot adapter, and that the emonTx draws 8 mA as measured, at 5 V).

@John Cantor: The 7805 and 78L05 regulators are "internally limited" - meaning they'll shut down if they get too hot. The data sheets give the maximum junction temperature and thermal resistance: for the 78L05 in a TO92 package these are 125 deg C and 230 deg C/W. So I make it OK without a heatsink (emonTx: measured current 8mA, volt drop 7V worst case with 12 V input gives a dissipation of 56 mW, and that implies a junction temperature rise of  13 deg C).

### Re: Using one power supply - Ideas

On the subject of regulators: Myself, I've gone off using linear regulators such as the 78XX series. They are too inefficient, load the power supply with needless current, and produce a lot of waste heat even when supplying small load currents.

My latest project is using a switching regulator to supply the +5 volts at ~180 mA, and the heat sink for the switching chipset is the circuit board traces under the 8 pin DIP package, there's that little waste heat. Much more efficient, nearly as compact, and only two additional components over using a 78xx series linear regulator.

### Re: Using one power supply - Ideas

Impressive diagram, Mr Sharkey. It downloaded for me just now with no problem. (I tend to use Inkscape - again not a specialised electronic CAD package but once you have accumulated a private library it suffices. But one drawback, it doesn't import well into LibreOffice).

### Re: Using one power supply - Ideas

Hi all,

Can I make a suggestion for a better emonTx power supply?

My understanding is that any load on the 9V supply is likely to distort the voltage waveform, which is not acceptable.

The solution then is to run the power supply only when the Arduino is asleep. This could be done by charging an electrolytic capacitor to, say 5V, and running the 3.3V regulator from this. The 3.3V would then remain stable while the Arduino was awake, even if the 5V decays slightly.

What does anyone think?

### Re: Using one power supply - Ideas

Excuse me, but how are you going to charge the electrolytic capacitor? How does the charging circuit know when the Arduino is asleep?

The problem is this: the normal rectifier with capacitive smoothing draws a large spike of current from the transformer only at the peak of the voltage waveform (OK, from a little before the peak to just after) as it supplies in that brief period the current consumed by the load during the rest of the cycle or half-cycle until the next peak.  The worry is: that current spike causes a voltage dip that distorts the waveform that is being measured and used to calculate real and apparent powers. It has nothing to do with the 5 V or 3.3 V rails, unless the regulator runs out of headroom.

I've recently tested the UK standard Mascot 9 V transformer with a configuration that lowers the peak-peak voltage by less than 1% and adds only about 0.2% to the total harmonic distortion of the voltage wave (which is already distorted somewhat by the transformer saturation). I think that small amount of added distortion is probably acceptable. I've sent a report to Messrs. Hudson and Lea. I'm awaiting a response.

### Re: Using one power supply - Ideas

Obviously, an active device is needed to switch the supply on and off.

The Arduino can signal to the supply when it is about to go to sleep.  If the LED flash is done last thing before the sleep, the LED output could even be used to signal to the supply when to charge the capacitor (so we wouldn't even need to use another output pin).  The power supply would run when the LED was on, and for a fixed short period after the LED went off.

The supply would also need to come on by default at start up for a fixed period.

This way you could be sure that zero current was drawn from the transformer while the Arduino was taking measurements.

### Re: Using one power supply - Ideas

Hey,

If grid powered by a transformer, the emonTX does not need to sleep! does it? we are talking about milliamps at 3.3v...

it can drive a pin high when it´s not taking measurements, and then drive it low, take the measurement and then drive it high again. a simple circuit.

I´m working in a firmware that constantly pools every waveform (see other thread "emonTX based on interrupts"). In such case, this solution will not work, since it will be pooling the data all the times. But with the actual emonTX firmware, i think it should work. I´m using two transformers.

### Re: Using one power supply - Ideas

It would be much easier to use an output pin. You don't need to sleep the Arduino, all you need do is, when you enter the critical energy measuring loop switch off the charge circuit while you perform that task. You will obviously need to balance the charge time and the charge rate against the time that the critical measuring period takes. It looks feasible. I'd be interested to see how you get on with this.

### Re: Using one power supply - Ideas

Thanks Pcunha and Robert.  You are right, we don't need to sleep the Arduino.  I think we can take as much current as we need, as long as we do it while the Arduino is resting and not while it is measuring.

I see you can buy a voltage regulator with an enable, which suits our applicaton and could be driven from the Arduino.

However, I observe that one side of the 9VAC supply goes to the mid point between GND and VCC, so we would need to make changes to the measurement input circuit as well.

### Re: Using one power supply - Ideas

"However, I observe that one side of the 9VAC supply goes to the mid point between GND and VCC, so we would need to make changes to the measurement input circuit as well."

Now I'm confused!  If you want to do as I thought you were suggesting, you need to use a half-wave rectifier. This brings its own problems: to charge the capacitor you draw double the current for half the time (i.e. only on alternate half-cycles).

My circuit (excuse the lack of a diagram: this site only accepts links, apparently) is in outline:

One side of the 9 V a.c is common to the emonTx 0 V rail.

Other side of the 9 V a.c is connected to (1) the present emonTx voltage input (100K resistor) via a 1uF d.c blocking capacitor; and (2) to a rectifier diode, the switch (an NPN transistor) and the storage capacitor, then to a 3.3 or 5 V regulator.

The base of the switch transistor is driven by another NPN transistor in common emitter mode, its base driven by the output pin.

Various bias and current limiting resistors.

I hope that makes sense. (If not, PM me with your email address and you can have an LTSpice circuit - not proven but it looks as if it might work).

Beware the sense of the enable: you do need to be able to start up.

(And you can run the RF, write output and do other housekeeping etc after you complete the measurements while the storage capacitor is recharging).

### Re: Using one power supply - Ideas

Thanks for that.  I agree with what you say.  Perhaps I did not make myself clear.

The EmonTx circuit given on Solderpad shows one side of the 9VAC going to the mid point.  I assume that the board I bought is the same.  This will have to be changed, because, as you say, one side of the 9VAC will need to go to 0V.

I haven't done the sums, but I would not have thought there was a problem charging rapidly, since the power requirement is small, and is only a tiny fraction of the power available from the supply.

### Re: Using one power supply - Ideas

If the a.c. voltage is only being measured to determine the direction of current flow, I think the final option (half-rectification) would do the job very nicely.

### Re: Using one power supply - Ideas

Robin:

The easy way to test is to add the extra components (rectifier, regulator, switch etc) on a separate board (Vero?) and make connections via the centre pin of the ac input and the programming header.

Calypso_rae:

The Spice simulation (and a lash-up) shows that half-wave rectification seems to work acceptably well simply by adding a series resistor to increase the conduction angle of the rectifier and reduce the peak charging current to the smoothing capacitor, without the need for a program-controlled switch. The dip on the positive voltage peak is just less than 1%, so I think it's acceptable, bearing in mind the ac adapter visibly distorts at the UK centre voltage of 240 V.

The soundcard 'scope picture (phase inverted!) is a composite image at 253 V (UK max. voltage) supplied by a Variac. The two traces show mains voltage and Arduino input voltage (phase shifted to the left). If you zoom in and look at the negative peak, you can just see the two traces separate in grey, from 13.2 ms to 17.4 ms - the larger amplitude is unloaded and the smaller is loaded with the half-wave rectified emonTx supply. The ac adapter is the standard UK Mascot one.

### Re: Using one power supply - Ideas

I'm thinking about using a small PCB mounted twin output 6V block transformer like this

Using one output for powering the emontx and the other output for voltage measuring.

### Re: Using one power supply - Ideas

Since both outputs share a common ground, you cannot just use this type of transformer without other circuit modifications, because the ground of the voltage sensor must be biased by vcc/2 volts. This way the microcontroller is able to pick-up the full ac wave .

Regards

### Re: Using one power supply - Ideas

According the specsheet both outputs have their own 2 pins so why would they have common ground or i'm a missing something ?

### Re: Using one power supply - Ideas

Pcunha, did you not read the data sheet?  The two secondary windings are separate.

The only problem that I see here - assuming 6 V gives enough headroom for the regulator to function correctly - is the very remote possibility that the charging spike of current into the reservoir capacitor is reflected through the leakage inductance into the other winding.

 Prensel, you beat me to it!

### Re: Using one power supply - Ideas

OK. Now i see what you are talking about.

There are two types in the PDF. If you pick the 2x 12V or the 2x8V or even the 2x6V type they ara isolated and you shoud be OK.

You will need to dimension your voltage divider to the voltage you selected.

### Re: Using one power supply - Ideas

I've just ordered on of these tiny transformers together with a bridge-rectifier, 78L05 and 2 capacitors and plan on feeding the 5V output into the MCP1702 on the emontx to get 3.3V. that part should work.

Divider resistors 22k-120k should work, this will give 916mV of AC if i'm correct

### Re: Using one power supply - Ideas

Your divider chain looks wrong to me. Don't forget that the transformer is very lightly loaded so the voltage will be in excess of 6 V (possibly + 20-30%) due to regulation. Then you need to add 10% for the maximum system voltage and at the same time, if your nominal system voltage is not 230 V, maybe factor that in as well. Oh, and tolerance on the resistors.

I think you might have 3.5 - 3.75 V peak-peak into a 3.3 V input. Oops!

### Re: Using one power supply - Ideas

Since my EmonTx in in a prototype board, i´ve added a multi turn precision variable resistor, that way i´ve calibrated the gain watching the output of the arduino. As soon as the values are in the 100-900 (adc) range i stopped. The greather the voltage you feed to the arduino, better the resolution.

### Re: Using one power supply - Ideas

According the specsheet the 'leerlaufspannung" is a factor 1.8 so the output will be 6*1.8=10.8V

22k/(22k+120k)*10.8V+Vref/2 = 3.23V... you're right thats too close to 3.3V.

So 22k/150k might be a better divider which will give 3.03V

### Re: Using one power supply - Ideas

That regulation is awful!  I didn't download the spec sheet, I just looked at the web page and thought "The regulation on that will be bad - let's guess 30%!" I didn't expect 80%.

But wait: You are using rms values, and you need to work on the highest mains voltage: 230 V + 10%.

So your peak-peak input voltage = (10.8 + 10%) * 2 * sqrt(2) * 22k / (22k + 150k)  = 4.3 V  >> 3.3 V !

Maybe the original 10k / 100k is as close as you can get.

### Re: Using one power supply - Ideas

You need to divide the output by 2, because the ground of the voltage sensor is biased by vcc/2 volts to get the full ac wave.

The peak max output of the voltage sensor passing though the resistor divider must be below 1.65 volts.

### Re: Using one power supply - Ideas

Once you are finished you shoud test and see if the peak output is less than wai it shoud be. If you dont have an oscilloscope to attach the arduino pin, you can use the following code:

const int analogInPin = 2;  //set to the sensor pin
int sensorValue = 0;        // value read from the adc
void setup() {
// initialize serial communications at 57600 bps:
Serial.begin(57600);
}
void loop() {

Serial.print("sensor = " );
Serial.println(sensorValue);
delay(2);
}

The serial output value must not be never equal to 1024. Is shoud be less than 1000. preferred less than lets say, 950, that way we can measure some voltage spikes.

### Re: Using one power supply - Ideas

Thanks for your replies sofar.

I'll try the standard 10k/100k divider first and see what it does before connecting anything on the emontx/arduino ;-)

Would be nice if this setup works so i can put the transformer, CT and emontx in a plug-through/plugbox or whatever its called like this:

http://www.budgetronics.eu/N_frame.html?http://www.budgetronics.eu/Stekk...

### Re: Using one power supply - Ideas

I don't know if it's of use to anyone but I used a 12v ac adaptor,  there is a bridge rectifier going to a 5V regulator. the voltage reference is taken before the bridge rectifier using a couple of 4.7uf ac caps on each leg across the voltage divider of 100 and 1K resistors.

### Re: Using one power supply - Ideas

I wanted to generate both 12V dc and 24V ac and thought that I had a workable setup.  When switched on, my setup seemed to behave nicely for a few seconds, but then the transformer started to fizz and it gracefully expired.  I put this episode down to my poor understanding of such things, and have since used entirely separate supplies for these two purposes.

If you have really cracked this one, Mark, I for one will be most impressed!

### Re: Using one power supply - Ideas

Markbeal2: I don't understand what your circuit looks like - circuit diagram please?

Prensel: With the regulation of transformer you have ordered being so poor, I would be concerned that the current pulse that causes the dip in the voltage wave in the winding that supplies the emonTx power, will be reflected through the flux and appear also in the winding that is being used to measure the line voltage. It would be good to check the waveform, if you have access to an oscilloscope - otherwise you could do something like the test rig used to measure the Mascot a.c adapter. (http://openenergymonitor.org/emon/buildingblocks/report-mascot-9v-acac-a...) but do not measure the mains voltage unless you really know what you are doing.

### Re: Using one power supply - Ideas

Here it is Calypso Rae, this is something like I have but i'm not using 24v only 12v AC adaptor before the bridge rectifier and the caps want to be AC ones.

Mark.

### Re: Using one power supply - Ideas

I'll try again.

[Moderator's comment:
This circuit suffers from a fundamental design flaw and does not operate as intended. DO NOT USE THIS DESIGN.
The reasons are explained in some of the posts below but the poster still refuses to accept that the design is flawed.]

### Re: Using one power supply - Ideas

Robert: the transformers arrived today so i can do some testing later on. I also ordered the 1W version  which i believe is a bit better/solid then the .375W version  I'll let you how things work out.

### Re: Using one power supply - Ideas

Mark:  Many thanks. Are you using an isolating transformer between the two points marked 'input' and the voltage input on the emonTx pcb? Because if not, am I missing something or is the 10uF decoupling capacitor on the bias chain in series with your 4.7uF coupling capacitor (the one to the 1k) and both effectively shorting out the bottom left diode in the rectifier bridge?

### Re: Using one power supply - Ideas

Prensel:

That's a good idea. You are much more likely to have an undistorted measuring output with the bigger transformer.

### Re: Using one power supply - Ideas

Mark, in the standard circuit, the AC signal is applied to just one input pin, with voltage measurements being made w.r.t. ground.

Your circuit shows the reading being taken between two points.  Is one of these to be grounded?

### Re: Using one power supply - Ideas

Is this any better Rae? I've just drawn it on "paint".

### Re: Using one power supply - Ideas

It's done it again..... :(

[Moderator's comment:
This circuit suffers from a fundamental design flaw and does not operate as intended. DO NOT USE THIS DESIGN.
The reasons are explained in some of the posts below but the poster still refuses to accept that the design is flawed.]

### Re: Using one power supply - Ideas

I think your 2.5V reference point would be dragged up and down by this circuit :(

### Re: Using one power supply - Ideas

Seems to work ok for me, stable on the lcd display.

### Re: Using one power supply - Ideas

I put a trimmer pot in place of the 1k resistor.

### Re: Using one power supply - Ideas

Mark, if your reference point is being cyclically pulled up and down, this may not be apparent unless checked with a 'scope.  In any case, this effect may not matter so long as the resulting waveform stays within the 0-5V range at the input pin.

Current drawn by your regulator chain will presumably affect the shape of the AC waveform, this being a drawback shared by any circuit of this type.  As the standard voltage-sensing circuit only places a resistive load on the transformer, the shape of the source waveform should be as accurately preserved as is possible.

I wonder why users are measuring voltage?  If it's to determine power more accurately than by measuring RMS current alone, then it would seem desirable to use a pristine voltage waveform rather than one that's dependent on the load of the bridge rectifier.  But if it's just to see whether the voltage is high or low today, rather like having a barometer on the stairs that you tap while going past, then a single-transformer approach may be fine.

Please (anyone), how do you post pictures?

### Re: Using one power supply - Ideas

File attach just above save and preview.

### Re: Using one power supply - Ideas

What I am using this for is to control a 3KW Immersion heater with all surplus power from the PV generation therefore I just want the currents really but I have put a 4 line lcd display in it and display Volts, PV Generation in watts, Domestic generation in Watts and Water heater input on and off.

I have built it on some veroboard complete with the pic.

Thanks

### Re: Using one power supply - Ideas

Well Calypso_rae, I have lashed my controller up in the house and while there was enough sun to operate it seemed to work ok.

Basically,, I have volts input as described earlier and two clamp CT's one on the PV Live and one on the domestic Live.

Immersion heater is split off from the domestic. In the sketch the domestic is deducted from the PV generation and whats left is fed to the Immersion heater via the controller.

I have a 4 line lcd on the unit which indicates Mains Volts, PV generation Watts, Domestic Watts and water heater on.

The sketch is Basic monitor by Trystan which I modified for my purpose, some idea's from Paul Reeds sketch and a few of my own. All this has made me understand what is going on.

I got the chips from this guy on ebay http://www.ebay.co.uk/itm/130669891243?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#ht_1359wt_1270

He also does a USB to TTL Converter, only thing is that you have to hold the reset until it has done compiling to upload as it has no auto reset, but for this I just put a push button in.

Controller :

http://www.kemo-electronic.de/en/Light-Sound/Effects/Modules/M028N-Power-control-110-240-V-AC-4000-VA.php

### Re: Using one power supply - Ideas

Mark:

I think your voltage monitor is not working in the way that you think it is. I suggest you get hold of a copy of LTSpice

http://www.linear.com/designtools/software/

and enter the circuit you have into that, and check the currents and voltages that result.

### Re: Using one power supply - Ideas

It;s working fine Robert.

### Re: Using one power supply - Ideas

This is the circuit I am using so that the 9V AC can be used for both power supply and voltage measurement. It enables the power supply to be switched off for up to 600mS while the voltage measurements are taken. During this time the power supply runs from a storage capacitor. After this the power supply needs to be switched on for 200mS to charge up the storage capacitor for the next set of readings. The switching is controlled using a digital output from the Arduino. The circuit fails safe: it switches the power supply on again after 1 second without interruption of the 3.3V supply if, for any reason, the signal from the Arduino is not received.

A MOSFET is used to switch the supply off, so that it takes virtually no current (less in fact than the ADC input circuit). The existing input circuit to the voltage ADC cannot be used, and is replaced with the one shown in the circuit diagram.

The circuit operates as follows. At start up, the capacitors are discharged, and the mosfet switches on, charging the storage capacitor to about 11.6V. When the Arduino output goes high, to switch the PSU on, the 1μF capacitor is charged up (and the 3.3V supply continues).

When the Arduino output goes low, to switch off the supply, the gate of the MOSFET is taken high, switching it off. Now, the storage capacitor is supplying the power, and its voltage starts to fall. At the same time, the 1μF capacitor is discharging through the 1.8MΩ resistor. After 600mS, the storage capacitor has fallen to about 8V, and under normal circumstances the Arduino will switch the supply on again, charging up the storage capacitor again.

If something goes wrong and the supply is not switched on again by the Arduino, the 1μF capacitor discharges and starts to switch the supply on again after about 1 second. The storage capacitor reaches a minimum of 5.5V after about 1.3 seconds, then starts to increase again, while the 3.3V supply remains steady.

The sequence of switching off the supply, taking readings, and switching on again for 200mS is repeated for each CT in use. I am using 2 CTs so the sequence is repeated twice, then the power supply remains on for the remainder of the program loop. The sleep period at the end of the cycle can be reduced or removed altogether.

I decided to increase the number of cycles (actually half cycles) to 60 since power consumption is no longer an issue. This takes about 611mS. The sleep or rest period can also be reduced or removed altogether.

The existing 3.3V regulator can not be used because this would involve putting 11V on to PWR, which is normally 5V - this would be unwise. Another approach would be to use a 5V regulator which could be connected to PWR, and would feed the 3.3V regulator, however, the 5V supply is often unused.

I can post waveforms and a matrix board layout if anyone is interested.

### Re: Using one power supply - Ideas

Hey robin,

this is an interesting approach you have there. I'd like to know how good the power supply signal is.

Could you maybe post the waveforms?

thanks

### Re: Using one power supply - Ideas

Hi Amin,

These are the mains voltage waveforms as measured by an Arduino ADC, with the power supply switched on and off.  I measured each one twice in order to assess the repeatability.

The "PSU on" measurements were taken immediately after the off period, so the current, and distortion to the waveform, were at the maximum.  You can see that the distortion reduces slightly each cycle as the storage capacitor charges up.

### Re: Using one power supply - Ideas

Hi Robin,

I'm intrigued as to why you are measuring AC voltage in this way.  The standard Voltage and Current measures the AC voltage many times per mains cycle, so your novel approach presumably wouldn't work in that case.  But if your purpose is to record how the RMS voltage changes with time - on a much longer timescale - then I can see that this approach would be of benefit because it does away with the need a second transformer.

A measured value of Vrms could presumably be used to support the Current Only sketch.  Although this wouldn't allow the direction of the current/power to be determined, it would seem to give an improvement over using a fixed nominal value such as 240.

From memory, this thread was started by MrSharkey who provided several interesting circuit diagrams for alternative approaches.  I can't see these diagrams any longer, and Mr S now appears as Anonymous.  Is this just my system playing up, or are others similarly affected?

### Re: Using one power supply - Ideas

Hi calypso_rae,

The waveforms I posted above were measured in order to test the system.

In normal use, the "PSU off" waveform is measured using the standard emonTx algorithm, except that the number of half cycles is increased to 60.

A slightly higher peak voltage is acceptable because the rail is now stable at 3.3V instead of decaying gradually to 2.7V

### Re: Using one power supply - Ideas

I should have said I am using the algorithm that measures both voltage and current.  The PSU is switched off when the measurements are taken so that the undistorted waveform is measured.  Then the PSU is switched on again to recharge the storage capacitor.  It takes 200mS to charge up the storage capacitor before measuring the next CT.

### Re: Using one power supply - Ideas

"I can't see these diagrams any longer, and Mr S now appears as Anonymous.  Is this just my system playing up, or are others similarly affected?"

I'm seeing the originator as "Anonymous", and the diagrams have disappeared for me too. His profile says:

• Name  Anonymous
• Member for 32 weeks 2 days

### Re: Using one power supply - Ideas

Thanks robin :)

I'll buy a suitable transistor on monday and try to reproduce your results.

### Re: Using one power supply - Ideas

These are the waveforms from the PSU switch circuit given above.

The PSU switch waveform is from the Atmega 328 output pin. The ADC measurements of the mains current and voltage start at roughly 0.22 seconds when the supply switches off.  The first set of readings is completed at 0.82 seconds.  The second set of readings (for CT2) starts at 1.02 seconds and finishes at 1.62 seconds.  I am measuring over 60 half wavelengths.

Between the sets of readings, the storage capacitor is charged up for 0.2 second.  Its voltage receives a boost during each cycle of the mains AC voltage (there are 10 cycles in 0.2 second).  During this charging period, the supply waveform from the transformer is distorted as shown in the graph I posted above.

While the PSU is switched off, the 2200 microfarad storage capacitor discharges at approximately 5.75 volts per second, implying that the current draw is about 13mA.

### Re: Using one power supply - Ideas

I'm gonna build this myself and see how it goes. I'm putting 7 emontx into a single enclosure [5 3phase and 2 single phase nodes] so am going to try to build this into the 'unit' also. stay tuned.....Eamonn

### Re: Using one power supply - Ideas

Hi all, I'm not sure if this thread is still current (no pun intended!). I have been keeping an eye on the OEM site for a while with the intention of building an energy meter myself. I have now, sort of managed it, but think I have run headlong into the problem you guys are all trying to solve here. I have used 2 x transformers, one to supply the arduino power via a rectifier and  regulator, and another transformer to provide the voltage measurement step down, these are wired parallel at the mains ac side.

The problem I am experiencing is that the voltage measurement reading every now and again fluctuates wildy, sometimes upwards of an extra 50+ volts, giving me a reading of 300+ac. Simultaneously measuring with a multimeter the voltage as you would expect remains constant during this fluctuation at circa 240v.

When running the arduino via an external power supply, i.e 5v from usb I do not experience these fluctuations.

Is this the same problem you're all trying to resolve in this thread? Or have I got other issues? I've attached a diagram of my circuit, all of which has been derived form this site. Thanks for all your help so far.

### Re: Using one power supply - Ideas

You have the burden resistor connected to the input of the op amp instead of the output. That could be affecting things.

### Re: Using one power supply - Ideas

Yes, as Martin has pointed out, your current sensor is not connected to the reference supply as it should be.  Pin 3 of the op-amp is a high-impedance input.  Nothing should be connected there other than the mid-point of your voltage divider.

The purpose of the op amp is to convert that high impedance 2.5 V point to a low impedance rail.  Just connect your current sensor to Pin 2 or Pin 6 of the op-amp rather than pin 3 and you should be fine.

### Re: Using one power supply - Ideas

Thanks for pointing that out. I have amended my drawing in my post above so that the burden resistor is connected correctly to pin 2 of the op amp. I've also added two diodes that I missed off. However as far as I can tell my circuit appears to be wired correctly, yet exhibits the strange behavior I mentioned before. I guess then that there is therefore some other problem with it, (presumably some dodgy soldering somewhere!). It's late now, I'll have a thorough check at the weekend.

Am I right in thinking then, that using two transformers with one to power the logic and the other to provide the voltage measurement, things should function as expected?

### Re: Using one power supply - Ideas

The problem I am experiencing is that the voltage measurement reading every now and again fluctuates wildy, sometimes upwards of an extra 50+ volts, giving me a reading of 300+ac.

Are you talking about Vrms hitting 300+ or instantaneous V?  V instantaneous is a sine wave swinging between about +340V and -340V so you'd expect to capture some of them in the 300s.

Another thing to check would be the input voltage into the 7805.  If Tran1 really outputs 6V, then by the time it's been through your rectifier it may be getting a bit low for the 7805.  I think you want at least 7V there.

### Re: Using one power supply - Ideas

Am I right in thinking then, that using two transformers with one to power the logic and the other to provide the voltage measurement, things should function as expected?

Yes, it's really just 2 separate power supplies and won't suffer the problems discussed in this thread.

You might want to add some 100nF capacitors across the 5V supply. The electrolytic capacitor is fine for filtering 50Hz but it won't suppress the high frequency spikes cause by the digital switching. Also, if you are using the standard sketches, you shouldn't connect AREF to Vcc. In most sketches AREF is configured as an output and should just be connected to a decoupling capacitor.

### Re: Using one power supply - Ideas

When I built a simple 5V supply recently, it appeared to work OK but the processor kept on resetting when more than a couple of LEDs came on simultaneously.  The problem was solved by increasing the value of the smoothing capacitor that's between the transformer and the voltage regulator.  10uF was not enough, but 100uF was fine.  You could easily check the capability of your supply by loading it up with extra resistor.  Maybe a 220R, to check that it can supply an extra 20mA or so.

Have you tried running the RawSamplesTool sketch?  With a load of around 3 kW, if you're seeing a sensible pair of waveforms for voltage and current, then the measurement side of your system is fine.  A suitable test rig is shown in Chapter 8 of my Diverting Surplus PV article

### Re: Using one power supply - Ideas

I'm not surprised you had the processor resetting with a 10uf capacitor 100uf may still be in the low side.

An easy calculation for the size of the capacitor would be to determine the total current drawn, red Leds ran at around 15ma other colors around 30ma so add together the total for the leds and the processor max current and anything else you want to power. Look at the regulator spec for maximum acceptable ripple I would aim for 1/10th of the value, Then use (or transpose to find what ever value you need).

Vrip = I load * .007 / C

For higher current supplies you will also need to look at the ripple current rating of the capacitor also.

This is one reason I wouldn't rely on powering the Arduino on anything but an external source, and possibly why some people have success with a USB supply whilst others don't.

### Re: Using one power supply - Ideas

There isn't really much point in building a transformer based 5V supply, or attempting to design a dual-function supply, when you can buy a ready-made quality, switch-mode 230-5V supply for less than £10. I'm sure that over the lifetime of the installation the extra efficiency would cover any extra cost and it results in a much more professional build.

### Re: Using one power supply - Ideas

There just might be one reason, but admittedly it's a bit flimsy: space. By the time you have added the socket (assuming of course you're talking about the plug-top type) it does take up quite a bit of room.

### Re: Using one power supply - Ideas

I was thinking more of a PCB mount version like this. Not really any bigger than a transformer.

### Re: Using one power supply - Ideas

Two standard power adaptors, one for the DC and one for the AC voltage source, plus a double 13 Amp wall outlet does take up a lot of space and look rather unsightly.  A single transformer with two secondary coils hidden inside the box seems to do the job pretty well.

For the purpose of diverting surplus PV power, I've yet to see any evidence that any particular type of AC transformer gives performance that is better than any other.

### Re: Using one power supply - Ideas

Ah thanks, for your input. It was indeed power supply related. The time the voltage (rms) reading went haywire was roughly the same time as the arduino takes to reset itself. I measured the voltage after the rectifier and was getting about 5.5 volts. After the regulator I measured it at about 4.5 volts. So it looks like my circuit was underpowered. I've now put in a different transformer rated at 12v rms on the output, and all seems to be fine now. Thanks for your help.

I guess we'd better let this thread get back to it's original purpose. :-)

### Re: Using one power supply - Ideas

One technique I use is to reprogram the BOD fuses to be the highest voltage below my intended design voltage.  Most of these AVR devices can run at 5V or 3.3V (sometimes dependent on how fast you're clocking them).  The Arduino IDE tends to set their BODs to 2.7V since they don't know what voltage it'll be used at.   Once I've dedicated a device to a particular design, if it's a 5V design, I reprogram the BOD fuses to 4.3V.   That way I know I'll at least get a clean reset rather than strange behaviour if the 5V sags.

### Re: Using one power supply - Ideas

calypso_rae said: Two standard power adaptors, one for the DC and one for the AC voltage source, plus a double 13 Amp wall outlet does take up a lot of space and look rather unsightly.  A single transformer with two secondary coils hidden inside the box seems to do the job pretty well.

That may be so but the PSU I suggested is PCB mounted and measures 32x27mm. It replaces one transformer (or one winding), the rectifier, smoothing capacitor and regulator and is 70% efficient. Considering your desire to save micropence I'm surprised you're advocating an inefficient linear supply over a modern switch-mode version which will probably take less space and certainly look neater.

When you hide a mess inside a box you've still got a mess! I once asked a clockmaker why he bothered to polish the reverse side of his dials when nobody could see them. He said: "just because you can't see it, that doesn't mean it's not there". Something I've tried to bare in mind ever since when I build anything.

Hoppo - don't forget, you still need to disconnect AREF from Vcc

### Re: Using one power supply - Ideas

When you hide a mess inside a box you've still got a mess!

Sure, but I don't see a neatly constructed conventional power-supply as being a mess.

### Re: Using one power supply - Ideas

After you posted that link, Martin, I looked at options for an open-frame SMPS, thinking that a PCB-mounted module might not be everyone's choice, but they come at 5 W or greater with a serious cost penalty.

### Re: Using one power supply - Ideas

anyone seen this for the 5V supply ? I think it's a neat solution.

http://www.ti.com/lit/an/slyt391/slyt391.pdf

when I get some time :-), I'll get an application pcb and check it out....

Eamonn

### Re: Using one power supply - Ideas

While this being a hot-topic, I haven't seen the most recommended solution yet? The TI 5V PSU looks very interesting, as does the single component switching powersupply block, though looks quite significant in cost.

So any news yet? Very very interesting overall however!

## Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.