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:

Comments? Other ideas?

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

TrystanLea's picture

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? 

Mr. Sharkey's picture

Single output supply

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. For an example of a schematic that I spent a lot of time touching up, see http://www.mrsharkey.com/SCT/field.pdf . This and a number of other diagrams and drawings were created to document the wiring in my electric car (1981 VW Golf - factory conversion).

TrystanLea's picture

Single output supply

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.

Amin Zayani's picture

 Did anyone try the solution

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

Mr. Sharkey's picture

re: Did anyone try...

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.

fatlaz's picture

 What would you use for an

 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

Mr. Sharkey's picture

Yes, that might work. The

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!

Amin Zayani's picture

Hey! The graphs disappeared

Hey!

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

Thanks

John Cantor's picture

I'm new to this forum - its

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.

 

 

 

Robert Wall's picture

According to my simulation,

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).

Mr. Sharkey's picture

On the subject of regulators:

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.

Have a look at the datasheet for the ON Semiconductor LM2574 switching regulator for a simple, cheap replacement for the clunky LM78xx regulators:

http://www.mrsharkey.com/PDFs/LM2574.pdf

Good for .5 amps, and available in 3.3v, 5v, 12v, 15v and adjustable output voltage versions.

Amin Zayani's picture

Hey Mr. Sharkey, same problem

Hey Mr. Sharkey, same problem with access to your PDF link on your server: 403 forbidden.

Robert Wall's picture

Impressive diagram, Mr

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).

IvyMccormick's picture

Thank you! I can do a lot of

Thank you! I can do a lot of things (i am a programmer) but I am pretty bad at creating diagrams (this is why i joined)

i am still good at applying them though

I'll try out this one as soon as i have time!

 

________________________________________

internet radio player http://internet-radio-player.com/

 

Robin's picture

Hi all, Can I make a

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?

Robert Wall's picture

Excuse me, but how are you

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.

Robin's picture

Obviously, an active device

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.

 

Pcunha's picture

Hey, If grid powered by a

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. 

Robert Wall's picture

It would be much easier to

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.

Robin's picture

Thanks Pcunha and Robert. 

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.

Robert Wall's picture

"However, I observe that one

"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).

 

Robin's picture

Thanks for that.  I agree

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.

calypso_rae's picture

If the a.c. voltage is only

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.

Robert Wall's picture

Robin: The easy way to test

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.

prensel's picture

I'm thinking about using a

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

http://business.conrad.nl/ce/nl/product/710261/EE-2061-printtransformato...

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

 

Pcunha's picture

Since both outputs share a

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

prensel's picture

According the specsheet both

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

 

Robert Wall's picture

Pcunha, did you not read the

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.

[Edit] Prensel, you beat me to it!

Pcunha's picture

  OK. Now i see what you are

 

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.

 
prensel's picture

We'll soon know about

We'll soon know about this.

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

 

Robert Wall's picture

Your divider chain looks

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!

Pcunha's picture

Since my EmonTx in in a

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.

 

prensel's picture

According the specsheet the

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

 

 

 

Robert Wall's picture

That regulation is awful!  I

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.

Pcunha's picture

You need to divide the output

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.

 

Pcunha's picture

Once you are finished you

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() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin); 
  
  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. 
 

 

prensel's picture

Thanks for your replies

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...

 

 

markbeal2's picture

I don't know if it's of use

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.

calypso_rae's picture

I wanted to generate both 12V

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!

Robert Wall's picture

Markbeal2: I don't understand

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.

 

markbeal2's picture

Here it is Calypso Rae, this

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.

markbeal2's picture

I'll try again.

I'll try again.

prensel's picture

Robert: the transformers

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.

 

Robert Wall's picture

Mark:  Many thanks. Are you

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?

Robert Wall's picture

Prensel: That's a good idea.

Prensel:

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

calypso_rae's picture

Mark, in the standard

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?

markbeal2's picture

Is this any better Rae? I've

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

markbeal2's picture

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

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

calypso_rae's picture

I think your 2.5V reference

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

markbeal2's picture

Seems to work ok for me,

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