Current Transformer Energy Harvesting for PICaxe PV Power Management

AllyCat

Senior Member
Hi,

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.
 

AllyCat

Senior Member
Hi,

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.
 

AllyCat

Senior Member
Hi,

This thread is basically "thinking aloud" the design of a Test Bed for the project, so it's worthwhile to summarise the present hardware proposal and a provisional "shopping list", etc. The PICaxe will be a 20M2, with most pins already having a provisional function allocated, but a 14M2 might be sufficient for a simpler final design. The power supply will be a "3 volt" battery, based on AA cells, for development convenience and because it seems that the Energy Harvesting might not be sufficient over some long periods of time (hours or days).

Personally, I will use a LiFePO4 or 2 x NiZn cells (both 3.2 volts) since I already have them, but even 2 x Alkalines have some "recharging capability". A pair of NiMH or moderately depleted Alkalines (2.4v) may be too much of a design challenge (mainly caused by too-high FET resistances at low supply voltages). Therefore a "final" design might use a 3.7v Li-Poly (or 3 x NiMH) with a "Low Quiescent Current" (not necessarily the same as a LDO) Regulator to protect at least the planned (3.3 v) Radio Transceiver chip. It appears that the average harvested current may be 0.5 mA (for a nominal "house" load of 1 Amp, or 6 kWh/day).

The processor board will have two 3.5mm sockets for Current Transformers that will require some minor modifications: Firstly, a split metal tube to be attached inside the jaws/ferrite ring of each CT to create a coaxial capacitor around the mains cable. The tube walls could be as thin as metallised or aluminium foil, but probably will use sheet brass or tin foil for ease of soldering the additional wire through to the "ring" of the jack plug. One end of the CT coil will be connected to the screen(s) of the coaxial cable that probably will need to be replaced (because the plug is moulded on). However, the cost of a ready-made 2m or 3m jack plug-to-plug cable (to cut in half for the soldered ends) is quite modest compared with the price of the Current Transformers. These CTs must be of the "current-to-current" type (typically 1 : 2000 turns), so any internal (SMD) Burden resistor (in a "current-to-voltage" type) needs to be removed. This shouldn't be an issue provided that the CT has a Varistor (or a TVS : equivalent to a pair of reversed end-to-end zener diodes) fitted internally across the coil, to prevent the generation of an excessive voltage if / when the CT is disconnected.

On this board, the 3.5 mm jack socket sleeves will be connected not directly to the zero volts / "Earth" rail, but to the output of a low-pass R-C filter driven from a PWM output pin (i.e. to create a rail-to-rail 10-bit DAC). This allows the PICaxe to set up a variable bias voltage (typically = FVR1024 or ~ 1 volt), to allow the current-sensor ADC(s) to see a full peak-peak voltage swing (within the FVR2048 ~2-volt reference). The other end of each CT coil (i.e. the jack tip) will be connected via a (tbd) low impedance "analogue switch" to the Burden resistor and to an ADC input, except when the switch is opened to allow an "over-swing" to harvest the power supply voltage (i.e. most of the time): A capacitor of about 1.5 uF resonates with the CT coil, that AFAIK does not increase the current as such, but can boost the sinusoidal voltage and may lower the output impedance (to assist the rectification to a dc rail). However, the peak (to peak) voltage will still be restricted by the Varistor in the CT and between the supply rails of the (integrated circuit) Bilateral Switch if used.

The processor board is planned to have no (other) external electrical connections, so its 0v rail might not behave as a true "Earth". Therefore the two CT "capacitor" inputs are connected via separate "Wien Bridge" (50 Hz) filter networks to the differential inputs of a PICaxe internal Comparator. However, it might be possible to simplify these filters (to a basic Low-Pass), with the phase of the signal(s) being corrected instead by program software. This differential arrangement, in association with clipping the two CTs to separate Live and Neutral cables (not needing to carry the same, or any, current) should ensure reception of a satisfactory Mains Voltage signal amplitude, regardless of the Earth level. But if necessary, an external connection to a local Earth wouldn't totally compromise the "no mains connections" concept.

Calculation Method:

The Phase of the Mains Voltage (and its exact period) can be determined from the zero-crossings detected by the PICaxe Comparator. This could be measured entirely by software, e.g. using PULSIN commands, but would occupy at least 20 ms of the time/power budget. Therefore it's proposed to use one or more of the "base PIC" silicon "CCP" Capture Latches, which can copy the (16-bit) value of "Timer 1" at any (rising and/or falling) input "edge" event. PICaxe Basic already sets Timer 1 to run with a default 20 ms period (for Servo pulses and a prescaler for the "time" variable) so we have a ready-made system to measure the phase (and period) of the Mains Voltage (relative to an "asynchronous" 50 Hz timebase) in a background task.

Once the capture latches have been initialised, the program can READSFR the present Timer 1 value(s) as a time reference and then start to "sample" the Current waveform for a period of just over 20 ms. A PICaxe program loop is probably too slow, so the code will take the form of a list of identical instructions such as READADC{10} adcpin , @bptrinc . Such a command takes around 200 us to execute (at 16 MHz) so the program could grab about 100 bytes, more than we need (or may have time to process efficiently). It's not yet decided how the samples might be organised, but perhaps two interleaved strings of current measurements, or including some "housekeeping" or a data overflow check, etc.. It's worth noting that the Open Energy Project (Arduino) takes about 50 sample-pairs per cycle (i.e. "every 7 degrees") using its 5 volt ADC reference.

When all the "buffer" data has been acquired, the post-processing can begin by calculating a few Global values such as the number of samples in one Mains cycle and the average of all the values within one cycle, to determine the "zero" or bias level. The number of samples in a cycle is not necessarily going to be a "tidy" number, nor even a constant for all measurements. This is because the Mains and PICaxe clock periods are not synchronous with the Timer and may show some variation (although less than +/- 1%). Unless the program has made an attempt to pre-synchronise to one of the waveforms, there will be two "arbitrary" time markers corresponding to (say) the positive-going zero-crossings of the Current and Voltage waveforms. Thus the data tables (representing the waveforms) can be "aligned" either by physical movement (i.e. copying bytes) or implicitly (via data pointer offsets).

The Current waveform exists as a list of byte values in RAM, but the Voltage waveform only as a single pointer or "marker" from an edge of the "zero crossing" square wave. However, we know that the Mains Voltage is a sine wave and we can calculate any required time or angular offset through the cycle, so the program can READ a corresponding voltage from a Lookup Table in EEPROM. Since the sampling is asynchronous, the Current and Voltage samples may not be accurately aligned; some time ago I did devise a Code Snippet to interpolate Trigonometric functions from quite small data tables, but it would be too slow. Therefore here, the Lookup table may need to be quite large, for example 256 or 360 byte entries (with most being skipped for any single Mains cycle), but perhaps this number can be reduced due to the symmetry of the tables for the four quadrants (i.e. 0 - 90 degrees, etc.) of sine/cosine waves.

The average Power calculation is achieved by first multiplying each "instantaneous" (signed) Current sample by its associated (signed) Voltage sample to give a (signed) instantaneous power level. These values can be accumulated "on the fly" and averaged (i.e. by addition and then division by the number of samples) over one full mains cycle. The signed data format takes into account any phase shift between the waveforms, by including regions of "negative" power (i.e. where the I and V have opposite signs due to a phase offset).

Initially, the data may be transmitted by a "dumb" 4-pin 433 MHz transmitter module (Supply, Data, Ground and Antenna) using RFOUT and RFIN commands, but that's likely to exceed the Power Budget. The longer term aim is to use one of two (so far identified) very similar low cost Smart Transceivers, although both of those under consideration require a 4-wire SPI Bus control and their modules have 2 mm pitch edge connections. :( The CC1101 (Texas) has a PC API available (by jumping through a few hops), but the only related thread on this forum is a long discussion as to why its SPI Bus does NOT appear to behave "as expected". Thus I'm more inclined to adopt the RFM69CW (HopeRF microelectronics) for which at least the documentation appears to be more readable than the traditional "Chinglish", but it does seem to be supported by an undocumented Windows program and "HopeDuino". :)

The "Accuracy" and "Overall Dynamic Range", etc. of the data calculations are a complex issue, particularly as PICaxe usually limits us to integer and even single-byte calculations. Therefore, since I'm nearing the 10000 character limit again, I'll hold over these aspects until my next post (and a few more thoughts).

Cheers, Alan.
 
Top