Update to 3-Phase PLL sketch

Quoting https://www.arduino.cc/en/Main/ReleaseNotes:

ARDUINO 1.8.6 2018.08.23

[ide]
* Updated arduino-builder to 1.4.0:
  - parallel build (improve compile speed)
  - better reuse of already compiled files
  - Windows: fixed build for sketch stored under OneDrive cloud folders

That parallel build could be a root cause… I looked through the rest of the release notes back to 1.8.1 and nothing else stood out as a possible cause.

So did I, and nothing stood out for me either. But it’s a significant change of behaviour from previous versions.

Respectfully to whom it may concern … (@TrystanLea @Gwil @glyn.hudson)

For the benefit of others, I do hope this latest version will soon be placed/linked to in the Resources section.

Frankly - I find it difficult/impossible to locate single & 3 phase sketches as clicking on links just takes me in a circle back to where I started from.

On a separate/related topic - There is an excellent guide - ‘Using the Arduino IDE’ within the LEARN Electricity Monitoring section. There should be a prominent link to this in the RESOURCES section, in my opinion.

Respectfully …

Edit - added names to post. BT -Moderator

1 Like

I have extended the 3-phase PLL sketch to cover now a 3-wire (no neutral) system as well as the 4-wire (with neutral) system.

In the 3-wire setting, one phase is treated as the neutral, and the system then collapses into a 2-phase system with the second phase lagging 60° behind the “reference” phase, the a.c. adapter being connected line 1 – ‘neutral’ phase. In this configuration, the two phase “powers” are meaningless, only the total power (real and apparent) is a valid physical quantity so the total power is reported as “power1”, and “power2” is always zero.

The principal changes are:

  1. A switch to set 3-wire or 4-wire,
  2. Each c.t. can now be allocated to any phase.

MD5 Hashes:

emonTx_3Phase_PLL_V1.4.zip f6f0fd4e57290ed985f23596e1f55bc0
emonTx_3Phase_PLL.ino c8e684a2549cde41629f2db205794b45
config.ino ae9cc9c91f67ed3a6b47e49cc1f47b32
rfm.ino 44a0b048b14e5e013625809736853c57
emonTx 3-phase PLL User Doc.pdf: c18387136424b903cdf49366f30fde9b

Extract the directory “emonTx_3Phase_PLL” and put it in your “sketches” folder. You can put the documentation where you wish.

emonTx_3Phase_PLL_V1.4.zip (151.9 KB)

This version is now obsolete – see post no.13 below.

Should this be in Github (GitHub - openenergymonitor/emontx-3phase: emonTx 'approximate' 3-phase firmware) with the “other” 3-phase sketch? Is there any reason this one doesn’t supersede the one already in Github?

From my point of view, it’s immaterial. I’m happy to be responsible for the version I publish, once a third party makes a change of any sort, responsibility passes to them. The GitHub version was put there by @Simsala, then Dan Bates made a change - a very poorly thought out change - that I could not agree to, so he’s now responsible for that version.

[Moved as the question was off-topic - nothing to do with the operation of the sketch.]

The last commit was done by @glyn.hudson
Is there any reason we shouldn’t create a PR for this version and merge it in?

I don’t “do” GitHub, it’s an impenetrable mess to me, so I’ve no view on the matter.

To be clear a ‘Pull request’ in github is a suggestion for a change, and @danbates pull request was not merged in this case. I’m sure Dan was just trying to help and suggest an improvement, is there a discussion somewhere that discusses the proposed changes?

I’ve upload your v1.4 changes @Robert.Wall available here in a development branch for testing:

https://github.com/openenergymonitor/emontx-3phase/tree/v1.4

You can download a zip file of v1.4 which should be identical (content, not file names) to your zip posted above here

https://github.com/openenergymonitor/emontx-3phase/archive/v1.4.zip

Im happy to merge this in if your happy with it @Robert.Wall

14 posts were split to a new topic: EmonTx - use of EEPROM

This PR has now been merged. Current master branch of emontx-3phase is now V1.4 with 3-wire and 4-wire support.

Credit @Robert.Wall

Following on from difficulties in using this sketch with an ESP8266 module, the documentation has been changed to note that the baud rate setting in the ESP module must be reduced to 9600 baud. This release has no changes to the sketch, which remains at V1.4.

MD5 Hashes:
emonTx_3Phase_PLL_V1.5.zip 4bc19cd409bf43f32bdf835ea3b59355
emonTx_3Phase_PLL.ino c8e684a2549cde41629f2db205794b45
config.ino ae9cc9c91f67ed3a6b47e49cc1f47b32
rfm.ino 44a0b048b14e5e013625809736853c57
emonTx 3-phase PLL User Doc.pdf: 019524b053c3370380ebcbaf657f5d46

 

Extract the directory “emonTx_3Phase_PLL” and put it in your “sketches” folder. You can put the documentation where you wish.
If you are updating your documentation, it is only necessary to extract that.

emonTx_3Phase_PLL_V1.5.zip (152.4 KB)
This version is now obsolete – see post no.15 below.

An incorrect space character in the formatted output (3-wire system) for the ESP8266 has been corrected. There is no other change.

MD5 Hashes:
emonTx_3Phase_PLL_V1.6.zip 9b109f26f7a0ec81c8798d20e185cf4c
emonTx_3Phase_PLL.ino : 71adf0fc1c51dcfaf54ddde9f85a2971
config.ino: ae9cc9c91f67ed3a6b47e49cc1f47b32
rfm.ino: 44a0b048b14e5e013625809736853c57
emonTx 3-phase PLL User Doc.pdf: 9ca0eef63994381fe3ee7474778005f8

 

emonTx_3Phase_PLL_V1.6.zip (152.4 KB)

2 Likes

7 posts were split to a new topic: Git and GitHub

For the estimation of the power the AC-AC trasnformer should be connected between F1-N or can be any other phase?

Only Phase Rotation is important. For the emonTx, the phase that the a.c. adapter uses is always Phase 1. The other two phases must have the correct sequence relative to that. Phase 1 as labelled by your supplier need not be the phase that the emonTx considers is Phase 1.

It is written as clearly as I can in the PDF document that you downloaded with the 3-phase sketch as part of the zip file.

Thanks for the great sketch @Robert.Wall
I’ve got an emontx v2 laying and wanted to use it for the 3 phase measurements - is the lack of support for rfm12b a hardware problem or software ? Not sure if i have to desolder the rfm from the board.

I will be mainly using EmonESP with an esp8266 but i have an emonglcd laying around and was thinking i could use the rfm12b to send data to the lcd (ofc not needed - i can develop a new firmware for emonglcd with wifi etc)

1 Like

Welcome, Marcin, to the OEM forum, and thank you for those kind words.

The problem with the RFM12B is it doesn’t have an internal buffer big enough to hold the complete message, it is only one byte big - therefore the JeeLib library needs to send the data one byte at a time with no gaps. And that is where it fails - the processor is too busy maintaining phase lock. What actually happens is the data has gaps - so it’s corrupted, and the sketch loses phase lock - so that’s wrong too.

The RFM69CW does have a big enough buffer, so that can easily be filled a few bytes at a time, then the RFM69CW does the rest without any help from the main processor.

You don’t need to remove the RFM12B, simply do not use it. Although you can use an ESP8266, my colleague @borpin recommends a Pi Zero W in preference. Note you can only send serial data slowly at 9600 baud or less.

1 Like

An updated version of this sketch is attached here, correcting a minor problem with reading the configuration under certain conditions, and the two previous issues showed the wrong version number.

MD5 Hashes:
emonTx_3Phase_PLL_V1.7.zip 067e98e295c9c2fcd14f31c784f5183a
emonTx_3Phase_PLL.ino a1208c832e132b00087b69b593bc785b
config.ino 678e7b2a2514a4068ab6d45bb576ae74
rfm.ino b830300d088943a64a4b54ee92e8e4a0
emonTx 3-phase PLL User Doc.pdf 00f2ccc51c5d4452e9d7a94ab6b9c547

emonTx_3Phase_PLL_V1.7.zip (131.8 KB)

An updated version of this sketch is attached here.

The significant change is this now incorporates a switch to choose between the JeeLibs “Classic” radio format and the new “RFM69 Native” format. Full details of that are posted separately under the heading “The EmonPiCM” (The emonPiCM) which explains when the ‘Native’ format must be used.
Although the name of the sketch now includes “rfm69n” signifying the “Native” format, the sketch can be set to transmit using the old “Classic” format to maintain compatibility with the emonPi that has not been upgraded to continuous monitoring.

The code for the RFM69CW radio is no longer part of the sketch, either the “Native” format library rfm69nTxLib.h or the “Classic” format library rfmTxLib.h is needed.

The other changes are the correction of a typo in the Serial output, and the restriction on the serial baud rate to 9600 has been removed.

This release is the version linked in the “The EmonPiCM” post.(The emonPiCM)
and future updates to this sketch will appear here.

MD5 Hashes:
emonTx_3Phase_PLL_rfm69n.zip 427b02b563eab4d6b782e5d54e158f29
emonTx_3Phase_PLL_rfm69n.ino 7f0d982b8ecaa2d37ce344e1f8be574a
emonTx_3Phase_PLL_rfm69n_config.ino e90bcffbaaa8f87296f69f8491f2e2da
emonTx 3-phase PLL User Doc.pdf b94ebe6dc103a71520ae3579437694e5

emonTx_3Phase_PLL_rfm69n_V2.0.1.zip (137.0 KB)

This sketch will also require one of the following libraries:

rfmTxLib.zip (61.3 KB)
or
rfm69nTxLib
depending on whether ‘Classic’ or ‘Native’ format is required for the radio.

1 Like