Current Transformer Energy Harvesting for PICaxe PV Power Management


Senior Member

This thread follows on from another with a rather unspecific title, aiming to "divert" surplus electricity from Solar PV panels into heating a Hot Water Tank. There, the solution adopted a method described in an excellent PICaxe Finished Project from 2009 with a very relevant title. The WARNING is particularly appropriate because the implementation involves making electrical connections not just to mains voltages, but at and around the "Consumer Unit", Mains Distribution Board or Fusebox, etc., which might not be protected even by an isolating switch or circuit breaker.

Therefore, even some commercial manufacturers now balk at that practice and have adopted a wireless (radio) architecture. Also, in the 13 years since that original thread began, a number of new systems and methods have evolved, for example PV Battery Storage, multiple (stratified) heating elements in the Hot Water Tank, Electric Vehicle charging, "Off-Peak" control of Refrigeration and now (in UK) perhaps Air Conditioning, etc.. However, the (direct) "restriction" of power to Washing Machines, Microwave Ovens and similar heating devices may not be practical, either because the heating is required "immediately", or because their Timer might "forget" the present stage of their operating sequence. Also sometimes, "Low Frequency" power-cycling (i.e. neither true "PWM" nor overall On/Off control) is used in "heating" systems, for example a thermostatic (soldering) iron or Microwave Oven (to control the Temperature or average Power Level), might conflict with the operation of the PV energy diversion system.

Thus the primary purpose of this tentative project is to measure "continuously" if (and how much) electricity is being Imported or Exported from/to the "National Grid", and to broadcast sufficient data to allow other devices (or Users) to make an "informed decision" about their (short-term) power consumption. As described in my comments from paragraph 2 in post #30 linked above (and a few before and after), the first aim is to learn from and adapt the methods used by some products already in the market place. In particular, "Harvi" from myenergi who appear to be at the forefront of the technology, and have made available several useful documents. The particular features of interest here are that their sensor module (Harvi) simply clips a standard Current Transformer onto a "meter tail", not just to monitor the current flow, but also to "Harvest" the power needed to run the microcontroller and to operate the Radio Transmitter, etc.. Therefore, I will begin with a theoretical / mathematical analysis of some of the practical issues, such as the Power Budget, Computing Budget, Realistic Accuracy and Components Inventory, etc..

The development of any Wireless (Radio) system should start with (at least) two questions : Is it Legal? and Where does its Power come from? I had already decided that the "most suitable" frequency would be in the 868 MHz "ISM" (Industrial, Scientific and Medical) Band, so it's encouraging that this was also chosen for Harvi. The band is "License Exempt", but NOT "Regulations Free", however here the restrictions can actually help us with the design process. In many countries the Transmitted Power is limited to typically 10 - 20 mW (13 dBm) and sometimes to a (Transmitting) "Duty Cycle" as low as 1% (averaged over a period of maybe one minute). This leads us to the Power Budget: An "acceptable" wire-less power supply could be typically 2 x AA cells, to be replaced approximately once every year, giving an average current drain of around 2.5 Ah / 10,000 hours = 250 uA. A first estimate is that Energy Harvesting from the monitoring Current Transformer could be a little higher than this.

Power Budget :

For now, I'll assume a minimum average "primary" mains power drain of 1 Amp (as quoted for Harvi) , i.e. 230 watts, or a "house" consumption of around 6 kWh/day. However, a "flaw" in this estimation is that a primary purpose of the project (particularly when a storage Battery is included in a Solar PV system) is to absolutely minimise the energy Imported or Exported (i.e. via the electricity meter/tails). My personal target for a "good" day is to neither import nor export more than 1 kWh, which blows a hole in this power harvesting budget. But for many other days, particularly in mid Winter/Summer, the average current may be far higher, so one solution is to employ a rechargeable battery in the power supply (typically the size of a few NiMH AA cells, or an equivalent Lithium battery) to average the available power over a much longer period (perhaps months). Another method (hinted in the Harvi specification) could be to connect a ~10uF "Motor Start" type capacitor across the mains (possibly in the Immersion Heater Controller) which would drain a "reactive" 1 Amp a.c., but cause NO power consumption or dissipation. This method would need to be reviewed if Smart Meters are ever modified to measure the "VA Product" instead of Real Power and seems to be a good reason for avoiding a Smart Meter. ;)

Another possibility is to add a second Current Transformer in a location where more current flows (for example the input to the Consumer Unit / Fusebox). The CTs are not cheap (the lowest I've found is 5 UKP upwards) but comparable to a mains transformer in a regulated power supply, whilst avoiding the need for any direct mains electrical connections. A second CT also potentially avoids the need to "switch" a single CT between Harvesting and Monitoring modes. Alternatively, a typical Solar PV system has at least three major current paths (PV Panels, Grid and House) so a second current sensor can give another value (from which the third current can be calculated). Therefore, my analysis will retain the capability of switching (at least) one CT to deliver both "Power" and "Data".

Thus, an estimated Power Budget is around 0.5 mA (with a 1 : 2000 turns ratio Current Transformer), but there are a few tricks which could increase this a little, if necessary. The Voltage available from the Energy Harvesting is not defined (yet), but my present target is for a "3 volt" main supply rail. This is ideal for a PICaxe, which can indeed operate with less than 0.5 mA (at a clock frequency of 1 or 2 MHz). However, the target is to use a 16 MHz clock (consuming around 2 mA and leaving some headroom if needed), but running at this frequency for only around 10% of the time (each second) and then "Sleeping" for the remaining period, i.e. an average consumption of about 200 uA.

Similarly, there are various "four-pin" ISM Transmitters available (usually 433 MHz) which for 20 mW output may drain around 25 mA, i.e. an average of 250 uA for a "compliant" 1% duty period. However, my (long term) preference is for an 868 MHz Transceiver module (such as the CC1101 or RFM69) both of which are ideal to use with a ~3 v supply rail and also consume around 25 mA when transmitting. Sadly, both of these modules require a 4-wire SPI Bus interface, however the intention is NOT to use either Bit Banging nor X2 commands, but dedicated PEEK/POKESFR byte commands, directly to the "silicon" hardware of the "base PIC" chip. Most of the other required hardware functions (ADC, Comparators, etc.) also should be available within the PICaxe, or perhaps in the Transceiver (Data Formatting and FIFO, etc.), but there is perhaps another surprising load consideration:

The Current Transformer needs to be loaded by a low impedance "Burden" resistor, usually below 100 ohms, to give 2 volts peak-peak (to the PICaxe ADC) from a maximum primary current of say 60 Amps rms (170 A pk-pk), i.e. 85 mA pk-pk in the CT secondary winding = 24 ohms. But to Harvest 5 volts (or hopefully more) at 0.5 mA, requires a parallel resistance of well above 10k ohms. The Burden resistance directly affects the accuracy so a very low resistance analogue (or "bilateral") switch is needed (ideally around 0.1 ohm). A traditional CD4016 4-channel Bilateral Switch has a typical resistance of 2,000 ohms (max, at 5 volts supply) and even the improved HC{T} 4066 derivatives are still around 60 ohms (or higher with a 3 volt rail). A few (in one 4066 package) might be connected in parallel, or there might be better (SMD) devices available, but all a "google" found me is still around 5 ohms. Then, two ADC inputs could perform a differential measurement across the Burden alone, which does offer some other potential benefits, but an easier method could be to use the contacts of a "mechanical" Relay :

A single-contact (pair) SIL miniature Reed Relay is smaller than a DIL package and can have a contact resistance of a little over 0.1 ohm, rated up to at least 108 operations (i.e. 3 years at 1 closure per second). This could be extended by switching the relay only when required, e.g. not overnight (when there is no PV to be measured), etc.. Of course the relay coil requires a significant current, but a 500 ohms relay has a "must operate" rating around 3.75 volts (i.e. 7.5 mA), which can then fall back to typically half of that, once the contacts are closed. The measurement period will be just over 20 ms for one mains cycle in each second, i.e. an average of <100 uA added to the power budget. A typical "latching" relay doesn't appear to offer much benefit over this; I do have an alternative trick but have reached the forum's 10,000 characters limit.

Therefore, I must pause here and will continue with details of the Computational methods and overall design, etc. in due course.

Cheers, Alan.


Senior Member

The choice between the above Electronic (CMOS) and ElectroMechanical (Relay) methods for switching the burden resistor is still an open book at the moment. All the Latching Relays that I could find are significantly less efficient than a single NO contact/coil, typically 250 against 500 ohm coils, with longer Operate/Release times and less easy to drive directly from the PIC(axe) pins (particularly at 3 volts). However, a (not proven) trick, which also might be useful in other applications, is to create the Latching function with an external permanent magnet:

A small (manually positioned) "button" magnet could be attached onto a standard SIL/DIL relay, such that its magnetic field holds the reeds closed, centred between the "must operate" and "must release" field strengths. Then, the relay can be Closed by a reduced "normal" current pulse, and Released by a "reverse" current pulse, perhaps trimmed by a PWM driver. This would need some trial-and-error because the internal magnetic shielding of the relay is not known, but the aim here is not to produce an "out of the box" solution which will always work with "Data Sheet" rigidly specified Make and Break currents. The control software and PWM output could allow (automatic) "trimming", particularly of the release current (that needs to cancel the permanent magnet field, without reactivating the reeds in the reverse direction).

Power Calculation:

The "Harvi" sensor measures only the current waveform (from the CT), analyses the data-samples (using a FFT) and transmits the average current amplitude with some "timing" data. The "Receiver" then performs a similar operation for the Voltage waveform: It multiplies the average Voltage by the Current from Harvi, then by the Power Factor (Cosine of the Phase Angle between these two Sine Waves) to give the overall Power. However, for the PICaxe a simpler approach is proposed, by estimating the Supply Voltage and calculating the Power directly within the Current-Monitoring / Transmitter microcontroller. The key to this is in obtaining the Phase of the Mains Voltage (relative to the current) without making any electrical connection to the Live or Neutral cables:

Voltage Measurement :

Most of the parameters of the Mains Voltage are "known" and quite stable (within a few percent). The sine wave should be quite pure (since it's tied to the National Grid) and its amplitude isn't needed to distinguish between Import and Export (only its phase or polarity). The amplitude can be assumed to be (say) 230 volts rms and the "Receiver" can adjust the power value (linearly) if it measures the true mains voltage to be different. Furthermore, the "Transmitter" PICaxe may be able to calibrate itself by monitoring the flashes of a LED on the local Smart Meter (if available), or from any other source of data.

Therefore the only significant "unknown" is the Phase of the mains Voltage (relative to the Current waveform). This can be conveniently and accurately derived from the "zero-crossing" time events, where the positive or negative voltage gradient (i.e. slope) is steepest. With any a.c. coupled signal (i.e. from a capacitor or transformer) the zero-crossing is at the average level of the voltage waveform. PICaxe Basic doesn't "support" negative numbers, but neither does the microcontroller ADC nor the hardware tolerate negative voltages (relative to Earth). The simple solution is to add a "bias" voltage to the signal, typically half of the supply rail (or perhaps half of the ADC reference) which can be subtracted in the software when appropriate.

In principle, the mains sine wave can be extracted via the small "stray" capacitance between the insulated mains cable and the Current Transformer. The capacitance will be very small (perhaps 1pF) but the mains voltage is around 700 volts pk-pk and it's only necessary to detect the approximate zero-crossings of the waveform. That might be done by any suitably biassed Digital input, but here I'll assume a (PIC internal) comparator, which can give more control over the threshold voltage. The Input requires a bias network (resistor) which also will act as the lower element of a voltage divider, in association with the upper (stray) coupling capacitance.

Normally, one wouldn't contemplate a circuit using 1pF at 50 Hz, because putting those values into a Capacitor Impedance Calculator gives a result of 3,183 MegOhms ! But the 700 volts needs to be attenuated to perhaps 0.7 v, so a bias resistor of 3.3 M ohms is not unreasonable. The PIC(axe) input(s) may drain a small current through the bias resistor - the data sheet suggests a typical leakage current (D060) of +/- 5 nA and maximum of 125 nA @ 85 degrees C, which might just fail in the "worst case". However, we know that the comparator should be delivering a (symmetrical) square wave output, so the program/system can use a control loop to adjust the bias accordingly. The only requirement is that the bias resistor mustn't be so high (>~10 M) that there's insufficient control range to feed the 125 nA. Also, an error in the "zero" level up to about 50% of the peak is not a serious problem, because the times of the two zero-crossing points will change in opposite directions if they move up or down the sides of the sine wave. Thus an average time value can be calculated that corresponds to the "peak" (or trough) of the sine wave, which represents a 90 degrees phase offset that can be easily taken into account.

In "Analogue Computer" terms, this C-R network is a "differentiator", i.e. the output is still a sine waveshape, but the zero-crossing points are now at the peak and trough (zero gradient) parts of the original sine wave. Alternatively (in the "Frequency Domain") the C-R is a "High Pass Filter", where in this case the "wanted" 50 Hz frequency is very heavily attenuated (i.e. 1 / 1000). It's often overlooked that most filters have not only an "Amplitude" response but also a "Phase" response and in this case it is almost at the maximum (for a "single pole" filter), i.e. 90 degrees Phase Advance. Again the phase shift is not a problem, we just need to take it into account when calculating the overall phase shift. However, the amplitude response does raise a potential problem, because any high frequency "noise" or spikes on the mains waveform may pass through the filter almost unchanged, i.e. "magnified" by up to 1000 times relative to the wanted 50 Hz. Thus this simplistic concept needs some refinement for a reliable design:

Practical Design:

In practice the above stray capacitance is probably less than 1 pF because the CT coil is "beside" the cable, not around it. Also the negative/earth end of the coil needs to be connected to a bias voltage for the ADC measurement and it's probably not sensible to attempt to fully isolate both ends of the coil from the burden resistor and the ADC, by using a 2-pole Analogue Switch. Therefore the CT coil itself is probably not directly useful, but instead we can consider mounting a thin metal sleeve (~12mm in diameter, split lengthwise to allow it to be fitted) around the insulated cable. This forms a small capacitor which can be analyzed as if it were a short length of coaxial cable :

Assuming a copper core diameter of 5 mm and insulation (dielectric) permittivity of ~2.4, a Coaxial Cable Calculator gives a capacitance of ~150 pF/metre. A 2 cm length sleeve can fit neatly within the width of the CT clip to give a capacitance of around 3 pF and use the "spare" core in the cable to the "stereo" 3.5 mm jack plug. Sadly the third core (screen) in the YHDC CT cable appears to be NOT connected within the moulded jack plug. So a substitute cable may be needed, perhaps of the individually-screened ("shotgun" or figure of 8) type to avoid any crosstalk between the current and voltage signals.

This connecting cable itself will have a significant capacitance, perhaps 100 pF/metre, which forms a capacitive divider with the "stray" source capacitance (similar to a conventional resistor Potential Divider). Thus the amplitude of the sine wave (and any noise/spikes) will be reduced by a factor of perhaps 30 before it reaches the bias resistor, or even more if we choose to add a "real" capacitor (i.e. of a known value) to "swamp" the cable capacitance (e.g. if not accurately known). This won't greatly affect the signal amplitude because the "source" impedance becomes much lower (i.e. the parallel connection of all the capacitances) so the overall division ratio remains largely unchanged.

This capacitor divider arrangement may now sufficiently attenuate any noise or spikes, but the larger time constant (C * R) reduces the phase shift to an "unknown" (but Calculable) value between 0 and 90 degrees (in Advance). Therefore an interesting modification is to insert a "Low-Pass" filter before the comparator input, to further "clean up" any noise and spikes. If the same R-C values are used as in the High Pass filter then the associated Phase Delay compensates for the Phase Advance of the HP filter. These two R-C filters then form a Band-Pass filter (ideally at 50 Hz) in a well-known configuration called a Wien Bridge, often used in the construction of Sine Wave oscillators. The advantage here is that we now have a standard "building block" which is known to give a narrow bandwidth, zero phase-shift and attenuation to 1/3 of the input amplitude at the centre frequency (i.e. R = XC at 50 Hz), for example 1 nF in association with 3.3 M.

Well, that's another 10,000 characters so my next post will deal with the basic Program structure.

Cheers, Alan.