Detail for my sketch, Mk2_fasterControl_RFdatalog_1.ino /* Mk2_fasterControl_RFdatalog_1.ino * * (initially released as Mk2_bothDisplays_1 in March 2014) * This sketch is for diverting suplus PV power to a dump load using a triac or * Solid State Relay. It is based on the Mk2i PV Router code that I have posted in on * the OpenEnergyMonitor forum. The original version, and other related material, * can be found on my Summary Page at www.openenergymonitor.org/emon/node/1757 * * In this latest version, the pin-allocations have been changed to suit my * PCB-based hardware for the Mk2 PV Router. The integral voltage sensor is * fed from one of the secondary coils of the transformer. Current is measured * via Current Transformers at the CT1 and CT1 ports. * * CT1 is for 'grid' current, to be measured at the grid supply point. * CT2 is for the load current, so that diverted energy can be recorded * * A persistence-based 4-digit display is supported. With this sketch that supports datalogging * via RF, the display can only be used with the pin-saving hardware: ICs 3&4. * * September 2014: renamed as Mk2_bothDisplays_2, with these changes: * - cycleCount removed (was not actually used in this sketch, but could have overflowed); * - removal of unhelpful comments in the IO pin section; * - tidier initialisation of display logic in setup(); * - addition of REQUIRED_EXPORT_IN_WATTS logic (useful as a built-in PV simulation facility); * * December 2014: renamed as Mk2_bothDisplays_3, with these changes: * - persistence check added for zero-crossing detection (polarityConfirmed) * - lowestNoOfSampleSetsPerMainsCycle added, to check for any disturbances * * December 2014: renamed as Mk2_bothDisplays_3a, with some typographical errors fixed. * * January 2016: renamed as Mk2_bothDisplays_3b, with a minor change in the ISR to * remove a timing uncertainty. * * January 2016: updated to Mk2_bothDisplays_3c: * The variables to store the ADC results are now declared as "volatile" to remove * any possibility of incorrect operation due to optimisation by the compiler. * * February 2016: updated to Mk2_bothDisplays_4, with these changes: * - improvements to the start-up logic. The start of normal operation is now * synchronised with the start of a new mains cycle. * - reduce the amount of feedback in the Low Pass Filter for removing the DC content * from the Vsample stream. This resolves an anomaly which has been present since * the start of this project. Although the amount of feedback has previously been * excessive, this anomaly has had minimal effect on the system's overall behaviour. * - removal of the unhelpful "triggerNeedsToBeArmed" mechanism * - tidying of the "confirmPolarity" logic to make its behaviour more clear * - SWEETZONE_IN_JOULES changed to WORKING_RANGE_IN_JOULES * - change "triac" to "load" wherever appropriate * * November 2019: updated to Mk2_fasterControl_1 with these changes: * - Half way through each mains cycle, a prediction is made of the likely energy level at the * end of the cycle. That predicted value allows the triac to be switched at the +ve going * zero-crossing point rather than waiting for a further 10 ms. These changes allow for * faster switching of the load. * - The range of the energy bucket has been reduced to one tenth of its former value. This * allows the unit's operation to commence more rapidly whenever surplus power is available. * - controlMode is no longer selectable, the unit's operation being effectively hard-coded * as "Normal" rather than Anti-flicker. * - Port D3 now supports an indicator which shows when the level in the energy bucket * reaches either end of its range. While the unit is actively diverting surplus power, * it is vital that the level in the reduced capacity energy bucket remains within its * permitted range, hence the addition of this indicator. * * February 2020: updated to Mk2_fasterControl_twoLoads_1 with these changes: * - the energy overflow indicator has been disabled to free up port D3 * - port D3 now supports a second load * * February 2020: updated to Mk2_fasterControl_twoLoads_2 with these changes: * - improved multi-load control logic to prevent the primary load from being disturbed by * the lower priority one. This logic now mirrors that in the Mk2_multiLoad_wired_n line. * * March 2021: updated to Mk2_fasterControl_withRF_1 with these changes: * - addition of datalogging by RF * - removal of the option for standard display hardware (which is incompatible with RF) * * March 2021: updated to Mk2_fasterControl_2 with these changes: * - extra filtering added to offset the HPF effect of CT1. This allows the energy state in * 10 ms time to be predicted with more confidence. Specifically, it is no longer necessary * to include a 30% boost factor after each change of load state. * * June 2021: updated to Mk2_fasterControl_withRF_3 with these changes: * - to reflect the performance of recently manufactured YHDC SCT_013_000 CTs, * the value of the parameter lpf_gain has been reduced from 12 to 8. * * July 2022: updated to Mk2_fasterControl_withRF_4, with this change: * - the datalogging accumulators for grid power, diverted power and Vsquared have been rescaled * to 1/16 of their previous values to avoid the risk of overflowing during a 10-second * datalogging period. * * September 2022: updated to Mk2_fasterControl_RFdatalog_1, with this change: * - reinstated the code for constraining the energy bucket's level to within its * working range. This important section of code has unfortunately been missing * in all versions of the fasterControl_withRF line. The new name should make the * purpose of this sketch more obvious. * * Robin Emley * * www.Mk2PVrouter.co.uk */