Detail for my sketch, Mk2_RFdatalog_multiLoad_1a.ino * * This sketch is for diverting suplus PV power to one or two dump loads using * triac-based output stages or Solid State Relays. Routine datalogging is * avalable if a suitable RF module is fitted (either RFM12B or RF69). A 4-digit display * showing the Diverted Energy each day is also supported. * * This sketch is intended for use with 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. When the RF module is * in use, the display can only be used in conjunction with an extra pair of * logic chips. These are ICs 3 and 4, which reduce the number of processor pins * that are needed to drive the display. * * This sketch 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 * * September 2014: renamed as Mk2_RFdatalog_3, with these changes: * - cycleCount removed (was not actually used in this sketch, but could have overflowed); * - tidier initialisation of display logic in setup(); * * December 2014, upgraded to Mk2_RFdatalog_4: * This sketch has been restructured in order to make better use of the ISR. All of * the time-critical code is now contained within the ISR and its helper functions. * Values for datalogging are transferred to the main code using a flag-based handshake * mechanism. The diversion of surplus power can no longer be affected by slower * activities which may be running in the main code such as Serial statements and RF. * Temperature sensing is supported by re-allocating the "mode" port for this * purpose. A pullup resistor (4K7 or similar) is required for the Dallas sensor. The * output mode, i.e. NORMAL or ANTI_FLICKER, is now set at compile time. * Also: * - The ADC is now in free-running mode, at ~104 us per conversion. * - a persistence check has been added for zero-crossing detection (polarityConfirmed) * - a lowestNoOfSampleSetsPerMainsCycle check has been added, to detect any disturbances * - Vrms has been added to the datalog payload (as Vrms x 100) * - temperature has been added to the datalog payload (as degrees C x 100) * - the phaseCal mechanism has been reinstated * * January 2016: renamed as Mk2_RFdatalog_4a, with a minor change in the ISR to reinstate * the phaseCal calculation. Previously, this feature was having no effect because * two assignment lines were in the wrong order. When measuring "real power", which * is what this application does, the phaseCal refinement has very little effect even * when correctly implemented, as it now is. * Support for the RF69 RF module has also been added. * * January 2016: updated to Mk2_RFdatalog_4b: * The variables to store copies of ADC results for use by the main code are now declared * as "volatile" to remove any possibility of incorrect operation due to optimisation * by the compiler. * * February 2016: updated to Mk2_RFdatalog_5, 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. * - 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 * * March 2016: updated to Mk2_RFdatalog_5a, with this change: * - RF capability made switchable so that the code will continue to run * when an RF module is not fitted. Dataloging can then take place * via the Serial port. * * October 2017: updated to Mk2_RFdatalog_multiLoad_1, with these changes: * - temperature sensing commented out(formally supported via D3 at the "mode" port") * - support for a second load added (vcontrolled via D3 at the "mode" port") * * * February 2020: updated to Mk2_RFdatalog_multiLoad_1a with these changes: * - removal of some redundant code in the logic for determining the next load state. * * Robin Emley * www.Mk2PVrouter.co.uk */