Robin's Mk2 Code variants and associated tools.

While working on my Mk2 PV Router concept, various Arduino-based tools have been developed along the way.  Although these have already appeared on various forum threads, it may be helpful for them to be grouped together in one place.  This will hopefully provide a useful resource for anyone who is interested.

--- >  Please also visit my website at http://www.mk2pvrouter.co.uk/  from where various items can be purchased  :-)

First, the tools; then the various versions of the Mk2 code itself:

MinAndMaxValues.  Displays raw sample values from a voltage or current sensor, along with their Min and Max values.  Originally posted on 01/07/12 at http://openenergymonitor.org/emon/node/789#comment-5072, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/minAndMaxValues.in... Note the improved version is below

 MinMaxAndRangeChecker.  An improved version of the above tool, this one records raw ADC values for the first four of the Atmega processor's analog inputs.  Posted on 20/04/13 at http://openenergymonitor.org/emon/node/2269, this tool is available at http://openenergymonitor.org/emon/sites/default/files/minMaxAndRangeChec...
 
RawSamplesTool.  A one-shot tool which displays a single mains cycle's worth of raw voltage and current samples to the Serial monitor.  Useful for checking that both sample streams look sensible.  The mid-point for each sample stream can be readily seen, also how much of the ADC's range is being effectively used.  Originally posted on 09/07/12 at http://openenergymonitor.org/emon/node/824, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/rawSamplesTool.ino...

RawSamplesTool_4ss_2.  An improved version of the simple one-shot tool.  This captures several mains cycle's worth of raw voltage and current samples.  This data is then sent to the Serial monitor, both as a low-res ASCII display, and also as pairs of raw samples.  This latter format allows raw samples to be imported into a spreadsheet for hi-res display.   Originally posted on 21/12/12 at http://openenergymonitor.org/emon/node/1705#comment-8535, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/RawSamplesTool_4ss...

PhaseDiagramTool.  Another one-shot tool which displays a single mains cycle's worth of raw voltage and current samples to the Serial monitor.  A PHASECAL algorithm is included whereby the voltage stream can be aligned with the current.  Data is displayed in graphical form and also as a Lissajous "eye" diagram.  Originally posted in a "Phasecal for Dummies" pack around 23/07/12 at http://openenergymonitor.org/emon/node/870#comment-5927, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/PhaseDiagramTool.i...

PhasecalChecker.   A tool which determines the correct phaseCal value to be used so that a resistive load is seen to have a Power Factor of one.  Note that a long-standing bug in the emonLib code has been fixed (Vrms needs to use the phase-shifted version of the filtered voltage stream).  Originally posted on 27/8/12 at http://openenergymonitor.org/emon/node/870#comment-5927, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/PhasecalChecker.in...

MeterAnalysisTool.  This sketch was written to monitor, analyse, and display the LED activities at a digital supply meter.  This material has been incorporated into later Mk2 code releases.  Originally posted on 18/07/12 at http://openenergymonitor.org/emon/node/857#comment-5257, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/MeterAnalysisTool....

MeterSimulation.  This is a simple simulation of a digital supply meter.  The user can vary the rate of energy consumption and generation to investigate how the meter's upper and lower energy limits are likely to behave.  Originally posted on 30/09/12 at http://openenergymonitor.org/emon/node/857#comment-6442, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/MeterSimulation.in...

DigitalMeterEmulator.  This sketch uses V and I sensors to determine real power, with the on-board LED being set to behave just as the LED on a digital supply meter.  Originally posted on 26/10/12 at http://openenergymonitor.org/emon/node/857#comment-6867, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/DigitalMeterEmulat...

FlickerDemo.  A tool to demonstrate the effects of flicker and how this problem may be reduced.  Uses only a single energy threshold.  Posted with video footage on 23/12/12 at http://openenergymonitor.org/emon/node/841#comment-8657, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/FlickerDemo.ino_.z... <<< Note revised versions below

FlickerDemo_2.  A revised version which uses two energy threshjolds rather than just one.  Posted Jan 2013 at http://openenergymonitor.org/emon/node/1637, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/FlickerDemo_2.ino_...

Mains Frequency Checker.  A tool to record the variation in mains frequency.  Data, via the Serial monitor, is suitable for inporting to a spreadsheeet.   Posted on 18/1/13 at http://openenergymonitor.org/emon/node/1930, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/MainsFreqChecker.i...

FlickerDemo_multiLoad.  Anti-flicker is no longer a bolt-on extra; it is included as standard with 'normal' mode just using different values  This is a comprehensive simulation with which we can hopefully get to grips with a fundamental problem which affects any burst-mode power diversion system.  Caters for multiple loads of different ratings, and can be run without need for an AC voltage source.   Floating Point maths has been retained for ease of use.  Posted on 22/1/13 at http://openenergymonitor.org/emon/node/1637, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/FlickerDemo_multiL...

FlickerDemo_multiLoad_2.  A max rate of change of surplus power has been added for realism.  Overflow and underflow of the 3600J energy bucket are now properly detected and displayed.  An ideal vehicle for playing around with different anti-flicker schemes.  Posted on 27/1/13 at http://openenergymonitor.org/emon/node/1637, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/FlickerDemo_multiL...

FlickerDemoWithMeter_1.  A single load version of the latest multiload demo, but this one also simulates the meter.  This sketch clearly shows how the meter responds in reverse flow conditons.  Also how the meter and router become out of alignment whenever energy flow strays outside the meter's "sweet zone".   An ideal vehicle for playing around with how the router and meter interact.  Posted on 31/1/13 at http://openenergymonitor.org/emon/node/1637, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/FlickerDemoWithMet...

TwoAFschemes_1.xls  A spreadsheet in which two different anti-flicker schemes are presented.  The performance of each scheme can be determined by varying the relevant parameters.   Posted on 2/2/13 at http://openenergymonitor.org/emon/node/1937, this tool is available at
http://openenergymonitor.org/emon/sites/default/files/TwoAFschemes_1.xls

 

Several variants of Mk2 code have been posted, of which only 9 should be regarded as 'current':

Mk2_PV_Router.  The original version has extra code for a simulation (DEBUG) mode, but the PHASECAL algorithm was not included.  Posted with full supporting information on 15/07/12 at http://openenergymonitor.org/emon/node/841, this code is available at
http://openenergymonitor.org/emon/sites/default/files/Mk2_PV_Router.ino_...

Mk2_PV_Router_mini.  This is essentially just a cut-down version of the original.  DEBUG mode and various print statements have been removed and the PHASECAL algorithm has been added.  Originally posted on 27/08/12 at http://openenergymonitor.org/emon/node/841#comment-5925, this code is available at
http://openenergymonitor.org/emon/sites/default/files/Mk2_PV_Router_mini...

Mk2_PV_Router_mini_2.  Updated in order to improve the performance at start-up.  All non-essential processing is now disabled while the LPF is allowed to settle.  Posted on 15/03/13 at http://openenergymonitor.org/emon/node/841, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2_PV_Router_mini...

Mk2_PV_Router_mini_3.  Bug-fix, to force the triac to be 'off' during the startup phase.  Posted on 14/04/13 at http://openenergymonitor.org/emon/node/1912 (different thread), this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2_PV_Router_mini...

Mk2_PV_phaseAngle.  A phase-angle controlled variant.  This requires a trigger which acts immediately rather than a zero-crossing one.    Originally posted, with full supporting information, on 01/11/12 at http://openenergymonitor.org/emon/node/841#comment-6990, this code is available at
http://openenergymonitor.org/emon/sites/default/files/Mk2_PV_phaseAngle....

temporalAlignment_dev.ino   This demonstrates an alternative way of tracking the true zero point of the current waveform.  With non-sinusoidal waveforms, such as half-rectified AC, this works much better than the standard HP filter.  Could be useful for applications where Power Factor is required.  Originally posted on 20/12/12 at http://openenergymonitor.org/emon/node/1705, this code is available at
http://openenergymonitor.org/emon/sites/default/files/temporalAlignment_...

Mk2a_PV_Router.ino.  An updated version which uses integer maths for greater speed, and twin HPFs for the V & I sample streams.  All general processing is done within ADC conversion periods so the sampling process is both faster and more regular than before.  Also includes TALLYMODE for obtaining high quality performance data.  Originally posted on 17/12/12 at http://openenergymonitor.org/emon/node/1681.  After fixing a couple of bugs, a tidied-up version is available at
http://openenergymonitor.org/emon/sites/default/files/Mk2a_PV_Router_rev...
  A spreadsheet, with a suitable 'scatterplot' graph for displaying raw sample 'TALLYMODE' values, is available at
http://openenergymonitor.org/emon/sites/default/files/3heatSettings_30s.xls

Mk2a_PV_Router_rev3.ino  The twin HPFs have been replaced by a simpler scheme that's more appropriate when dealing just with Real Power.  An anti-flicker mode has also been added.  Posted, with full supporting information, on 03/01/13 at http://openenergymonitor.org/emon/node/1681, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2a_PV_Router_rev...

Mk2a_PV_Router_rev3a.ino  Bug-fix to remove a long-standing error in the Tallymode facility.  Now displays data in Watts which is more user-friendly than before.  Posted on 19/06/13 at http://openenergymonitor.org/emon/node/1681, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2a_PV_Router_rev...

>>> WARNING - Early Mk2i builds do not support 'Tallymode' due to lack of RAM.  This problem was fixed in Mk2i_rev4

Mk2i_PV_Router_rev1.ino  Similar operation to Mk2a_rev3, but more efficient because the measurement sequence is controlled by interrupts.  The ADC is either free-running or triggered by a fixed rate hardware timer.  WORKLOAD_CHECK allows the spare processing capacity to be determined.  Tally values (in Watts) are now displayed rather than just the index values.  Posted, with full supporting information, on 14/01/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev2.ino  Identical operation to Mk2i_rev1, but with the addition of 3 LEDs primarily for use when running in anti-flicker mode.   Posted, with full supporting information, on 22/01/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev3.ino  This build suffered from RAM being overloaded, so should not be used.

Mk2i_PV_Router_rev4.ino  As for Mk2i_rev2, but with the ability to switch between normal and anti-flicker modes on the fly using a switch.  'normal' operation is now just a special case of 'anti-flicker' mode.  After rev3 was found to be problematic, a lot of RAM space was reclaimed, mainly by the removal of Serial statements.    Posted, on 28/01/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev4b.ino  Bug-fix to remove a long-standing error in the Tallymode facility for (rev4 code only).  Posted, on 19/06/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Bug-fix to remove a long-standing error in the Bug-fix to remove a long-standing error in the Tallymode facility.  Posted, on 19/06/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev... to remove a long-standing error in the Bug-fix to remove a long-standing error in the Tallymode facility.  Posted, on 19/06/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev5.ino  As for Mk2i_rev4, but supports multiple loads including an RF-controlled remote load, with switchable priorities. Uses a new power-distribution algorithm which works well with multiple loads need to share surplus power    Posted, on 18/03/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev5a.ino  Bug-fix, to prevent the triac being 'on' during the start-up period.  Posted, on 14/04/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev5b.ino  Bug-fix to remove a long-standing error in the Tallymode facility (rev5 code only).  Posted, on 19/06/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev5c.ino  Upgrade to allow correct operation at different mains frequencies, and the size of the energy bucket to be changed to match the supply meter.  Posted, on 04/02/14 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev5d.ino  Upgraded to minimise the disturbance to recorded data when transmitting RF.  Posted on 09/06/14 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev5e.ino  The function, decreaseLoadIfPossible() has been tided because the previous version appeared to contain cut-and-paste errors.   Posted on 13/07/14 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

RF_for Mk2_rx.ino  A suitable receiver for a remote dump-load.  Intended for use with the Mk2i_rev5 base-station sketch.    Posted, on 18/03/13 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/RF_for_Mk2_rx.ino_...

Mk2i_PV_Router_rev6.ino  Upgraded to include datalogging via an RFM12B module.  A second current sensor is now supported so that the amount of diverted energy can be accurately monitored.  Posted, on 22/04/14 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_PV_Router_rev6a.ino  Upgraded to minimise the disturbance to recorded data when transmitting RF. Posted, on 09/06/14 at http://openenergymonitor.org/emon/node/1912, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2i_PV_Router_rev...

Mk2i_3phase_RFdatalog_1.ino  A 3-phase router which can run on any Atmega 328 platform where access is available to all six of the analog IO ports.   Supports multiple loads and datalogging.  Posted, on 29/01/15 at http://openenergymonitor.org/emon/node/10099, this code is available at http://openenergymonitor.org/emon/sites/default/files/Mk2_3phase_RFdatal...

 

Using an emonTx V3.2 as a Mk2 PV Router This describes using the emonTx V3.2 rather than an Arduino to supply the processing power. Posted, on 14/2/2105, at http://openenergymonitor.org/emon/node/10171.

Using an emonTx V3.4 as a Mk2 PV Router This describes using the emonTx V3.4 rather than an Arduino to supply the processing power. Posted, on 20/2/2105, at http://openenergymonitor.org/emon/node/10203.

Using an Emontx V3.4 as a MK2 PV Router with phase angle control This describes using the emonTx V3.4 rather than an Arduino to supply the processing power. Posted, on 09/07/2015, at http://openenergymonitor.org/emon/node/10865

 

I've also posted various videos along the way:

IMGP9627.AVI at  http://www.youtube.com/watch?v=FoOniINhqTc  Feeding AC mains power to a resistive load using different mark-space ratios.  For more information on this topic, see the forum at www.openenergymonitor.org

IMGP9630.AVI at  http://www.youtube.com/watch?v=w0OpfWBmYz8  Showing how the current in a test circuit can be used to control a resistive load.  For further info, visit openenergymonitor.org

IMGP9648.AVI at http://www.youtube.com/watch?v=-lk6Me3cwuw  Heating Domestic Hot Water with spare PV Power

IMGP9689.AVI at http://www.youtube.com/watch?v=EzwFlZau80w  Early trials of Mk2 PV Router

IMGP9720.AVI at http://www.youtube.com/watch?v=QzTAAVOkVAs  An Arduino-based system that uses a triac to divert surplus PV power to an immersion heater.  More trials of the burst-mode system

Mk2 PV Controller test results  at http://www.youtube.com/watch?v=WVqL30uOluQ  Initial trial of Mk2 rig with an disc-style meter, to show balance between import and export. "Errata: At 08:02, I should have said that the bucket is half-full, not full."

IMGP9987.avi at  http://www.youtube.com/watch?v=v8ifoUJvcXY  The effects of PHASECAL and POWERCAL on the performance of my Mk2 PV Router. For details of the design, please visit http://openenergymonitor.org/emon/node/841

Simple demo of Mk2 PV Router (1 of 2) at http://www.youtube.com/watch?v=MopB2NAU4TU  A simple way to check the operation of a PV Power Router when insufficient PV is available for normal operation.  All that's needed is a lightbulb and some thin mains wire.  When correctly routed, the current drawn by the bulb is seen by the current transformer (CT) as if it were being generated by PV.  The effect can be easily be amplified by passing the feed wire several times around the CT.  For more info about this setup, please visit http://openenergymonitor.org/emon/node/841

Simple demo of Mk2 PV Router (2 of 2) at  http://www.youtube.com/watch?v=lefSTLTfUN0  A simple way to check the operation of a PV Power Router in isolation.  In place of the normal 3kW immersion heater, I'm using a 3kW electric kettle.  To simulate the PV, I'm using the current drawn by a 100W bulb.  By passing one core of each of these circuits through the current transformer (CT), the effect is just as if the system were being measured at the supply point when real PV is available.   The effect of the bulb can be amplified by passing its feed wire several times around the CT.  For more info about this setup, please visit http://openenergymonitor.org/emon/node/841

How to check that PV Router is set up OK at http://www.youtube.com/watch?v=oF8HACCsK4M  A really easy way to check that a Mk2 PV Router system is set up correctly for operation next day.  For more info, please visit http://openenergymonitor.org/emon/node/841

test of p-a controlled PV router at http://www.youtube.com/watch?v=TTglRINjSyw  Bench testing of my Mk2 PV Router in phase-angle control mode. 
For details of this project, please visit http://openenergymonitor.org/emon/node/841.  Errata: At 3:00, I should have said 1500  and 1400 Joules, not Watts.  At 8:08, I was incorrect to say that the triac could sometimes fire before the mid-point of the cycle.  When the energy bucket is half-full, the triac will always fire after the mid-point, never before.

First results for p-a controlled PV router at http://www.youtube.com/watch?v=p_IoNohZJAY First 'live' results for my Mk2 PV Router in phase-angle control mode.
For details of this project, please visit http://openenergymonitor.org/emon/node/841

Mk2a PV Router, first results at http://www.youtube.com/watch?v=epozcslYPRs  Initial test results for the Mk2a PV Router code that I posted yesterday on the Open Energy Forum at  http://openenergymonitor.org/emon/node/1681

Flicker Demo Tool at http://www.youtube.com/watch?v=U-gW0ccroYc  A simple tool to quantify the effects of mains flicker when a dump load is repeatedly cycled on and off.  The effect itself is demonstrated, as is a simple way to reduce its undesirable consequences.  For further information, please visit http://openenergymonitor.org/emon/node/841#comment-8657 (page 12, posted 23/12/12)

Anti-flicker demo for Mk2a PV Router, rev3 at http://www.youtube.com/watch?v=BcZON8YFabw   Full details at http://openenergymonitor.org/emon/node/1681

Hardware comparison: my Mk2 H/W v. emonTx.  A pair of videos, posted on http://openenergymonitor.org/emon/node/2044 on 9/4/13.  The first one at http://youtu.be/h8HDdIpAD_c just shows how the test rig behaves on its own.  The second video, at: http://youtu.be/nq8U3v0nzr4 shows each type of Mk2 Router controlling a dump load in order to balance the flow of simulated PV.  There is minimal difference between their performances.

How to test that your triac is working, using little more than a 9V battery, is at at: http://youtu.be/hpClB_5mjRc

 

If you spot any errors, please let me know so I can keep this post up to date.  Thanks, Robin

 

markcarter10's picture

Re: Robin's Mk2 Code variants and associated tools.

Thanks Robin

much easier to find now

TrystanLea's picture

Re: Robin's Mk2 Code variants and associated tools.

Thanks Robin, I have made the post sticky.

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

Er, sorry for my ignorance, Trystan, but please could you explain what has changed ...

Robert Wall's picture

Re: Robin's Mk2 Code variants and associated tools.

If you go to Forums -> General Discussion, this thread is and will remain at the top (unless another 'sticky' pushes it down).

TrystanLea's picture

Re: Robin's Mk2 Code variants and associated tools.

In the general discussion list it will now always appear at the top of the list, which should make it easier to find.

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

Well, how 'bout that, top of the bunch eh? 

That's almost as impressive as James May flying his model glider over to Lundy - as has just been on TV.

Thanks Trystan.

jack_kelly's picture

Re: Robin's Mk2 Code variants and associated tools.

Great resource, thanks Robin.

Have you considered getting yourself a github account to make it even easier for folks to see your code and, just as importantly, to see modifications and alternative versions (branches)?

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

Have you considered getting yourself a github account to make it even easier for folks to see your code and, just as importantly, so see modifications and alternative versions (branches)?

No, not really, Jack, because I don't see how it would bring any benefits - just extra work for me.  If there were several people working on the same task in some co-ordinated way, then that would be different. 

My various sketches haven't all evolved from the same place, they have been assembled as necessary to meet the need of the day.  FWIW, I think my code is mighty easy for folks to see already!

jack_kelly's picture

Re: Robin's Mk2 Code variants and associated tools.

There certainly is a bit of hassle involved in setting up a repository for the first time but once it's setup it's very easy to maintain (probably easier than attaching code archives to forum posts).  Some benefits of using github:

  • full version control (so you can easily make modifications and then switch back if the modifications don't work out)
  • easy management of different versions
  • issue tracker for handling bugs and feature requests (this is really useful even if you're working on a solo project)  e.g. you start feature request for each feature idea you have and this provides a single place to keep all your ideas about that feature and you can reference feature requests from git commits... if you also limit each commit to only cover a single issue then it makes life much easier if you ever have to backtrack.
  • wiki for writing user manuals etc
  • the code is presented on the web using syntax highlighting and you can link from forum posts to specific lines of code
  • people can submit patches really easily (you have total control over whether or not to accept those patches)
  • and more...

But, as you say, your code is already very easy for people to get a hold of.... it just strikes me that you now have a significant body of code that you're very kindly sharing with the community.  You might actually make your own life *easier* by maintaining that code on github (or a similar service - I'm in no way affiliated with github!)  Github is specifically designed to help people "code socially".

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

OK Jack, I look forward to inspecting your code on Github in due course :-)

PaulOckenden's picture

Re: Robin's Mk2 Code variants and associated tools.

There's loads of Jack's code on Github!!!!

 

P.

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

Great, but what does it all do, and which parts can be relied upon to work as intended? 

Probing around someone else's area, just to see what's there, doesn't sound a very efficient process to me.  Much better to be pointed towards a known version when it's ready for inspection/use by others.

There's lots of code on my hard drive that hasn't made the cut!

jack_kelly's picture

Re: Robin's Mk2 Code variants and associated tools.

Great, but what does it all do, and which parts can be relied upon to work as intended?

Those questions should all be answered in the project's short description, the README or in the project's wiki (assuming the author has taken the time to write this documentation.  Taking my github projects as an example: some have documentation (e.g.) but by no means all!  One day, one day...)  The project's "issue tracker" might also give some information about how reliable the code is  (e.g. if there a loads of unfixed bugs in the issue tracker).

better to be pointed towards a known version when it's ready for inspection/use by others

In an ideal world, the default branch of each github project should be fairly stable: any experimental features should go in an "experimental" branch.  And yes, I agree, all projects have an "incubation" period where the code is so immature that it should never see the light of day (and I've certainly made the mistake of putting such immature code onto github in the past); but once the code is vaguely stable it seems like a good idea to allow users access to every update you make to the code, as soon as you write (and test) that update.

There's lots of code on my hard drive that hasn't made the cut!

That's certainly a problem with github: there's lots of code on there (including in my own repositories) which are failed / abandoned attempts at something, and wading through that cruft can be time consuming.

I really didn't mean to start a debate over which software development practices are "best".  It just occurred to me that using github for your code might have benefits (i.e. save you time in the long run).  If you're not interested then I certainly don't mean to come across like I'm "selling" github.  Each to their own.  As you say, your current strategy works very well. 

 

Robert Wall's picture

Re: Robin's Mk2 Code variants and associated tools.

My problem with Github is I know how to drive it, for example to maintain up-to-date local copies of emonLib and the examples, but I haven't figured out how to use it to my best advantage when I am not a developer, or when I am developing but working on my own with a local repository - and that's not the same thing.

I came across this a few days ago - I've yet to read it.

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

Each to their own.  As you say, your current strategy works very well. 

Well, that's not really for me to say, but I certainly hope that my 'strategy' - such as it is - is useful to others. 

Thanks for your vote of support :D

Paul Reed's picture

Re: Robin's Mk2 Code variants and associated tools.

Robin, as always a great read, and thanks for all the work that you have done.
Just a quick question - in your article you mention using a EmonTX and wondered if the captured data is integrated into the 'bigger' openenergymonitor system via the RFM12B to a EmonBase? and if so, do you average out the data (as it normally updates every 6 seconds or so).

Paul

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

Hi Paul,

Although my name is given at the top of each page, not all of what you see is my own work.  A couple of pages in that article are not actually mine at all!  Much has been added by our editor-in-chief who prefers to do his good work quietly in the background. 

My personal experience with EmonTx and RF kit is minimal, to the extent that I'm struggling to control an LED at the other side of the room.  I know that others have successfully developed PV Router code with various RF capabilities.  This kind of material will hopefully appear in the appropriate places in due course.

Robin

dockarl's picture

Re: Robin's Mk2 Code variants and associated tools.

That's brilliant Robin - I'm going to try to adapt your system for use in my semi-offgrid environment - at the moment only one circuit in our house is off-grid (I use that circuit to test offgrid hardware before I field deploy for my telecommunications business). We have plenty of excess power during the summer and I think I'll use the DC voltage of the system to initiate and moderate a 'bleed off' to our immersion heater (currently on an 'on grid' circuit) once the batteries are at absorb.

Nice elegant code, by the way :)

fcoelho's picture

Re: Robin's Mk2 Code variants and associated tools.

Dear all, 

I am using Mk2_PV_Router_mini_3 without problems with arduino mega.

But, i can not your later versions, i can compile without errors , but i get always time-out erros when downloading any specific programming that only works with arduin uno ?

example : Mk2a_PV_Router.ino and latest versions .

Each time i try to download into arduino i get a time-out of communications.

Any help will be appreciated.

 

Best Regards,

TIA.

 

F. Coelho

 

[Did you not see the forum topic "IF YOUR POST ISN'T VISIBLE IMMEDIATELY, HERE'S WHY"?

You posted the same message 4 times. Please do not do it again, you waste everybody's time that way.]

 

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

Maybe there is a problem with your libraries.  The original Mk2 Router sketch did not use any libraries, but most of the more recent versions need them:

TimerOne is for hardware timers

Jeelib is for the RF module

OneWire is for temperature sensing.

Near to the top of the sketch you should be able to see which libraries you need. 

I hope this helps.  You didn't need to send me a private message too.

fcoelho's picture

Re: Robin's Mk2 Code variants and associated tools.

Robin,

Many thanks for your quick reply.

I understand that with "i" versions there is some special include like "timer1", and i get an error when compling ( but it is normal i dont have the  library for compling), but for   "Mk2a_PV_Router_rev3" i didnt see special includes. It compiles OK. but when downloading i get the time-out and i can not download the code.

With "Mk2_PV_Router_mini_3"  there is no downloading problem.

questions:

1) Arduino IDE version: 1.0.5r2  can be the problem ?

2) In pratical terms What are really the advantages of  "Mk2a" and  "i" version vs. Mk2_PV_Router_mini_3 ?

 

TIA

 

F. Coelho

calypso_rae's picture

Re: Robin's Mk2 Code variants and associated tools.

2) In pratical terms What are really the advantages of  "Mk2a" and  "i" version vs. Mk2_PV_Router_mini_3 ?

In practical terms, there are no advantages.  "mini_3" will heat water just as well as any other Mk2 version, and the code is a lot simpler to understand.

fcoelho's picture

Re: Robin's Mk2 Code variants and associated tools.

Robin,

Many thanks for your help. Now the system it is locally working, but the real diverter load is far....

Is it possible to have the Triac circuit block out side the  "Mk2 PV router box" , that means connect both parts using a RJ45 TP cable with about 30m ? 

Note: the trigger to MOC ic Is 5V can be changed with 12V and  change of the resistor ? what is the Resistor value recommend in this case

Have you made something like that, have you other more  simple suggestion (not using RF)

 

TIA

 

F. Coelho

 

 

Robert Wall's picture

Re: Robin's Mk2 Code variants and associated tools.

Robin might not be able to answer you for a little while.

Yes, you can separate the "controller" from the "load switch". I put together exactly that for a friend. Due to illness and an impending house move, it was never installed, but on test it worked faultlessly on "telephone" unscreened twisted pair cable with a length of probably about 80 m (estimated, it was on a drum), using an emonTx running at 3.3 V. Therefore, I do not expect a problem with Cat 5 cable. It may be better not to use screened cable.

Why do you want to run the trigger from 12 V? Voltage drop in the cable should not be a problem at only 20-30 mA over 30 m. The Arduino cannot run at that voltage? A quick estimate of the resistor value for a 12 V supply is 470 Ω, which will give a LED current of around 22 mA (the MOC3041 requires > 15 mA to guarantee to trigger).

fcoelho's picture

Re: Robin's Mk2 Code variants and associated tools.

Robin,

Many thanks for your ultrafast answer. I will follow you recomendations.

I will give you the feedback when ready.

Best Regards,

 

F. Coelho.

 

fcoelho's picture

Re: Robin's Mk2 Code variants and associated tools.

Robin,

First , The  separation of  the "controller" from the "load switch"  was a success.

Second, I have from the past (not related to the separation of controller and switch) a strange behaviour , i can explain in order to get some help 

I have a PV with output of 4A ( maximum) , when i connect a electrical motor( 10A) , the current measured in the neutral in the main cabinet CT is ( 6A) absorved by the system from the grid, it is correct

But for example if have the MK2 PV router running and the PV has 4A  with the electrical motor is off, the energy goes correctly to the load ( absorving de 4 A) , the current indication in the neutral of the electrical cabinet is about 4A and not near 0A, because the balance is near zero. The power it is near zero float a little.

There are two CT measurement systems in the neutral.

One generic based on open energymonitor  sending via ethernet from 6 to 6 seconds, and was calibrated with a known load and if the MK2 it is working the values are correct.

The other is connected to the MK2 power router also calibrated. The sign of the connection it is ok , because when i reverse it the power go to the load always.

The power given by MK2 router it is near zero and i think it is correct but the current is about 4A stable .

where really is the Problem? How the flicker mode influences the values. Any explanation ?

 

TIA

Robert Wall's picture

Re: Robin's Mk2 Code variants and associated tools.

Fernando, I am not Robin! Robin cannot answer at the moment.

I think I do not understand your problem.

First, what sort of motor do you have, and do you know what the power factor is? This might be important because the Mk2 energy diverter works on energy, not on current. Therefore, if your motor has a power factor of 0.6, it might be drawing a current of 10 A, but the power will be equivalent to a heater that draws only 6 A.

Second, what is the "generic [CT measurement system] based on open energymonitor sending via ethernet..." Is it an emonTx or an Arduino, do you have a voltage sensor and a current sensor and which sketch are you using?

When "The power given by MK2 router it is near zero", how do you know that? Is it your energy supplier's meter that tells you?
And when that is so, which system measures the current of 4 A?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.