sagreen83
Posts: 22
Joined: Wed Sep 05, 2018 2:54 pm

Re: Using a Pi to Log Data in a Magnum Energy System

Sun Nov 18, 2018 11:29 pm

CharlesGodwin wrote:
Sun Nov 18, 2018 11:10 pm
I have not tested that way for a while. I use eclipse which is slightly different. I'll look at it later. I'm not near my PC.
Ok, I just installed the normal (non build) way. If I add .SSSZ to the date format, as follows, the webserver does not return results (must be crashing somewhere in the json build).

dateformat=yyyy-MM-dd HH:mm:ss.SSSZ

If I drop the SSSZ it works fine. I'm not seeing anything in the server log, and on a hope I added trace=true to the server.options file but that didnt produce any more output.

Scott...

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Sun Nov 18, 2018 11:35 pm

Strange. I did that earlier and it worked. The old code worked by just dropping the Z.

I'm still not near my PC

sagreen83
Posts: 22
Joined: Wed Sep 05, 2018 2:54 pm

Re: Using a Pi to Log Data in a Magnum Energy System

Sun Nov 18, 2018 11:42 pm

CharlesGodwin wrote:
Sun Nov 18, 2018 11:35 pm
Strange. I did that earlier and it worked. The old code worked by just dropping the Z.

I'm still not near my PC
No hurry. The new code works by dropping the Z as well. so if i do .SSS it works. Its the Z that is killing it. Hoping I'm not confusing things. I assumed that you were trying to fix the Z (timezone) part of dateformat.

Scott...

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Mon Nov 19, 2018 2:53 pm

@scott

I am confused as all my tests with release 1.0.6 supports the Z. This morning I did the following:

Note: There are some changes to prior build instructions. I will list them at the bottom. I am also attaching a log of all these activities.
  • I created a new directory on a Pi
  • I installed ant and a Java Development Kit (JDK) as all I had previously was just a runtime.
  • I downloaded a zip of the source for Release_1.0.6 branch from gitHub
    https://gitlab.com/Magnum_Energy/distri ... _1.0.6.zip
  • I deleted 2 files that should not be in the zip file(No longer needed)
  • I followed build instructions in BUILD_INFO.md
  • I created a new test directory
  • I copied the two files needed for an install into the test directory
  • I ran the setup program
  • Because I have no Magnum system nearby I modified the magnum_server.options file to reference a mock json file and I copied the .json file into the folder
  • I started the server with an override of the dateformat

    Code: Select all

    ./startserver dateformat="yyyy-MM-dd'T'HH:mm:ss.SSSZ"
  • I got the expected result from the server using

    Code: Select all

    curl localhost:19450
    . The full record is in the log but it starts with {"Date":"2018-11-19T09:05:49.373-0500","timezone":"-05:00"
  • I then modified the options file to include dateformat=yyyy-MM-dd'T'HH:mm:ss.SSSZ setting instead of using the command line override
  • I restarted the server and got the same result.
I'm not sure where your problem is. I can only guess. Did you copy the pair of files for an install to your target directory (magnum_xxxx.zip and setup_xxxx) and then run the setup_xxxxx script? This is important as it modifies some jar file names in the lib directory. Can you send me a directory listing of the lib folder? "ls -l lib"

What is 'wrong' with the zip file?

The interim release source zip file contains two files that should NOT be included. Once you have unzipped the source files delete these two files before the first ant step.

As of 2018/11/19 10:20 Eastern these files were removed from the zip file.

The document BUILD_INFO.md has been revised to include how to install ant and JDK for Pi systems and some refinements to the steps. The fundamentals remain unchanged.

I will remove the two extra files before the official release.
Attachments
magnumbuild.zip
(5.04 KiB) Downloaded 29 times

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Mon Nov 19, 2018 4:54 pm

@scott

I notice that building extra plugins can be complicated if you need to checkout the entire source, add your code and then build a private version. That's a lot of work.

My method is to have a separate project for just compiling the extra plugin code. I then build a jar file with a different name containing just that code. I then place that jar into the pi lib directory and all is good. I only need to rebuild this jar when my code changes.

It would not be too much effort to create an ant build file and short document to support this. Is anyone interested?

sagreen83
Posts: 22
Joined: Wed Sep 05, 2018 2:54 pm

Re: Using a Pi to Log Data in a Magnum Energy System

Thu Nov 29, 2018 12:00 pm

Thats interesting... I just ran the same commandline as you did.

./startserver dateformat="yyyy-MM-dd'T'HH:mm:ss.SSSZ"

I get the following in the logger log...

2018-11-29 05:53:55 Error encountered:file_get_contents(http://localhost:19450/): failed to open stream: HTTP request failed!
2018-11-29 05:53:55 Sleeping for 60 seconds

I'll try to do this with the process you described in your message.

Scott...

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Thu Nov 29, 2018 1:07 pm

I hope its' something simple.
Before you rebuild and replace I suggest you delete all your magnum*.jar files in the lib directory so there are no old rogue versions getting in the way.

Code: Select all

rm lib/magnum*.jar
If you hit glitches please email me as my responses can be quicker and more specific. Thanks

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Thu Jan 10, 2019 10:07 pm

This is addressed to anyone using my software.
I haven’t published any changes to my software but I plan a cleanup. More like pruning dead branches. Take a look at this https://gitlab.com/Magnum_Energy/distri ... FOR_2.0.md and tell me if there are any problems. I’m trying to make it simpler to use, maintain and document.

If you are using my software please email me so I know who is out there when I plan changes.

magnum-at-godwin-dot-ca

User avatar
RDK
Posts: 244
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Using a Pi to Log Data in a Magnum Energy System

Sun Feb 24, 2019 5:51 am

Charles....It has been a while since I communicated on this subject. My system, which spies on the MAG-Web communications, has been working just fine, although it does stop working, as documented, when we lose internet. Now I would like to look into setting up your system on a different Pi.

We have a MS4448PAE inverter, ME-ARC, and the ME-BMK, and the Outback Flexmax 80 MPPT charge controller with a ASX-Port. The ASX-Port allow us to remotely monitor and modify the charge controller parameters.

Will your system see the data for the Battery and Inverter units and also the Outback charge controler's data?

By the way, you've done an excellent job of developing and documenting your work - congrats......RDK

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Sun Feb 24, 2019 1:56 pm

Hi

I hope my system can help.

The software as published will handle all your Magnum Energy (ME) components but, alas, not the Outback Energy ASX-Port.

I presume, since you have managed to deal with the ME magweb device, that you have programming skills. I don't think it would be hard to extend the reader to support the ASX-Port but I have no experience. I have an unpublished java extension that reads the ModBus interface of my MorningStar charge controller and provides the data as part of the JSON record produced. A quick Google search for the Outback interface reveals that it uses a semi-public protocol called Sunspec (https://sunspec.org). They officially publish a Python library and I see there are various third-party Java implementations.

In this document https://gitlab.com/Magnum_Energy/distri ... ASERVER.md I discuss alternative ways to building extensions to the server, either as a Java plugin or using a wrapper. I have no opinion which would be preferable in your situation. I provide an example plugin written in Java that can be a model. Read this: https://gitlab.com/Magnum_Energy/distri ... N_BUILD.md

If you would like detailed help write me: magnum-at-godwin-dot-ca.

Thanks for the kind words.
Last edited by CharlesGodwin on Tue Mar 26, 2019 5:55 pm, edited 1 time in total.

User avatar
RDK
Posts: 244
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Using a Pi to Log Data in a Magnum Energy System

Sun Feb 24, 2019 3:04 pm

Charles....OK, thanks. I will let you know if we decide to got head with this idea.....Rob

owen_a
Posts: 56
Joined: Sun Sep 09, 2012 3:31 pm
Location: United Kingdom
Contact: Website

Re: Using a Pi to Log Data in a Magnum Energy System

Sun Mar 24, 2019 9:56 pm

Ah, I've just come across this post as I lost the code to communicate with my TS-MPPT-60. Charles, you sent me the code a few years ago and the software worked flawlessly. Any chance this is in git?

Also, I'm having trouble understanding the documentation for the Modbus protocol for the Morningstar's, any chance you could please explain how one can make a call to the controller for, say, battery voltage? As in, the PDUAddr on the table in that PDF, the battery voltage is 0x0018. The logical address is 25. From what I can see online, you give a starting address and a quantity, whatever this means...

Just need someone to shed some light onto this.

Thanks,
Owen

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Mon Mar 25, 2019 12:35 pm

The Morningstar code is not on Gitlab - yet. I hadn't considered it as no one asked. But I can share if you send an email to magnum-at-godwin-dot-ca. I'll look for your email.

The code is a bit different that what I would have sent you before. The difference is not in reading the ModBus information but in the way the data is sent back to you. The messaging has changed. I developed the software for the data reader to be modular and it will support multiple, all optional, readers. I ship it with a magnum device reader but I have developed the Morningstar reader as well as a temperature sensor reader. In you case, you could use it with ONLY the morningstar reader.

Concerning how to read the data using modbus. Each read request is to an address and the quantity is "how many consecutive registers do you want?" For example a request at logical address 25 for a quantity of 4 would return the values at 25,26,27, and 28.

The confusing part with the morningstar data is that they have a few registers with base multiplier values. These registers must be read, massaged and then used as multipliers to calculate true values in other registers.

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Tue Mar 26, 2019 6:35 pm

I'm going to try to explain getting battery voltage from MorningStar. It's not simple and I fear my language skills will get in the way.

Voltages, as I mentioned in a prior post, are based on several values. Referring to page 3 of the document you referenced.
A voltage value( adc_vb_f_med) is the value in register at 0x0018 (25) multiplied by voltage scale multiplier (V_PU) multiplied by 2 to the power of -15. This won't copy and paste. :(
What is V_PU you ask? It is the float value created by using the value in register 0x0000 (1) as the whole part and the value in 0x0001 (2) as the fractional part. In Java I use this to calculate V_PU

Code: Select all

v_pu =  vpuhi + (float) (vpulo / 0x8000);
vpuhi is the the whole part and vpulo is the fractional part.

so voltage adc_vb_f_med is

Code: Select all

adc_vb_f_med  = (float) (value at 0x0018) * v_pu / 0x8000;
Similar formulae for amps.

May not be pretty, may not be the best code, but it worked so I stopped revising it.

owen_a
Posts: 56
Joined: Sun Sep 09, 2012 3:31 pm
Location: United Kingdom
Contact: Website

Re: Using a Pi to Log Data in a Magnum Energy System

Wed Mar 27, 2019 8:35 pm

Hi Charles,

Thank you for getting back to me (I sent you an email also).

Thank you for trying to explain this to me, that does not seem easy at all haha! I was under the impression it would return me the value as is.

- Owen

CharlesGodwin
Posts: 70
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Using a Pi to Log Data in a Magnum Energy System

Wed Mar 27, 2019 9:14 pm

It's not as complicated as it sounds. I have a small function that does all the fiddly calculations and it's also code that's forgotten once it works.

Return to “Automation, sensing and robotics”