A Forum run by Enthusiasts of MidNite Solar

The Open Source software/hardware corner => Raspberry PI => Topic started by: cpfl on May 01, 2015, 04:15:04 PM

Title: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on May 01, 2015, 04:15:04 PM
Having setup my Raspberry Pi to monitor and control my Classic 150 via its ethernet modbus interface, I was very happy with the results. What was missing was the ability to monitor my MS4448PAE Magnum Energy Inverter. Anyone who owns or who has looked at this inverter knows that you can buy an ethernet or a wireless network interface for around $300 and $400 respectively.

Rather than pay out that kind of money and given that the physical interface to the inverter is stock RS485, I decided to try connecting my Pi to the inverter via an RS485-USB adapter. I purchased such a device direct from China on ebay for $1.39. To cut a long story short, I can now monitor both my charge controller and inverter with the Pi.

My software, written in Python, although basic and limited in scope has been working perfectly for the last week. Something worth bearing in mind is that the data stream from the inverter is sent in repeated bursts. The RS485-USB interface cannot detect the start of a burst, so it starts reading at any point in the stream. A certain amount of detective processing is required to work out where the start of the data is located in the stream. Once it has been located, the data can be extracted.

The following link is to the only known Magnum Energy network communications protocol document.

http://static.us-inverters.com/docs/support/

Document named: Magnum-Networking-Communications-Protocol-(2009-10-15).pdf

Since each device residing on the RS485 network is transmitting data, the Pi (or any other connected computing device) can read it. This includes data from the inverter itself, the battery monitor kit (BMK), the auto generator start (AGS), the remote control (RC), advanced remote control (ARC) and the router (RTR).

I have not tried, but it should be possible to spoof the existence of a remote control so, for example, a Pi (or other computing device) could control the inverter.

The advantage of collecting data directly from the inverter, is that a constant internet connection that is a requirement of the Magnum Energy solution, is not required. The data can be collected locally on the Pi and written to a database from which data tables and/or graphs can be produced at any time.

Attached are a couple of examples showing data from the Classic 150 and the MS4448PAE on the same graph. The third image shows the inverter output closely tracking the solar input as the Pi tweaks the AUX2 settings for maximum output to the water heater, but that's another story.

If anyone is interested, I purchased the adapter from the Ebay seller golden.supplier, item number 281345074995. There are most certainly other sellers of similar devices, but I can confirm that in my experience, this one works.
Title: Re: RS485 monitoring of Magnum Energy Inverter/Charger
Post by: boB on May 18, 2015, 01:43:33 AM
Hey, great stuff, cpfl !

The Magnum protocol uses the dead space between packets to tell when one packet stops and a new one starts.

Just add a time counter that is reset every byte received and when it accrues a few (couple ?) milliseconds
of dead space, reset your packet byte counter to zero and the next byte will be the first of the new packet.

Kind of like modbus does  over RS232/RS485.

This looks pretty cool !

boB
Title: Re: RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on May 18, 2015, 05:23:45 PM
Thanks boB!

Working on improving the code now.

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 05, 2015, 10:29:40 PM
Hi Chris,

I would be very interested to learn more of your Python code you use to decode the data stream from the inverter, if you are willing to share?
The reason I ask is that I am wanting to integrate the ability to read this data stream in my Quadlog application.
This application is written in C.

I don't have a Magnum inverter, but I am working with a chap that does, and who has a Cubieboard connected to to the Magnum via a EIA-485 to USB converter.
I have a remote ssh connection into the Cubie and using picocom, a simple command line communications program, I can see the data is coming into the USB port of the Cubie just nicely.

The data is human unreadable as it is 8 bit binary, but I see the reoccurring data pattern, so I know it will just be a matter to decode this.
I'm about to make a start with writing a stand-alone C program to do this work, and should be able to nut it out given some time.
But, if I were able to see how you did it in Python, that would be a tremendous help for me.

EDIT: also, can you tell me exactly which port you plugged the EIA-485 from the USB converter into, was it the RTR or AGS and does it matter or make any difference.
I have a capture file with the binary data and can not find any of the constants that should be present, such as the inverter model number, which should be seen as 0x73.
I don't yet seem to see any recognisable data that is talked about in the Magnum networking document, though I do see reoccurring data blocks in the captured data.

And just to confirm, the port settings are 19200, no parity, 8 data bits, yes ?
Thanks
____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on June 06, 2015, 10:09:59 PM
Hi Paul,

Attached is my code. It needs cleaning up, but is functional and can be modified to suit your needs.

I am currently using a secondary Pi dedicated to communicating with the inverter, which sends the data back to my primary Pi using HTML. The primary Pi opens the URL to the secondary Pi which executes the python code to collect the data on demand.

A problem that I had when first connecting the RS485 wires to the inverter was that the wires were the wrong way round. As soon as I swapped A and B, the data looked better. It definately sounds like your wires are crossed.

I put a two-way RJ11 splitter on the GREEN inverter port where the BMK is normally connected. Both the BMK and the Pi connectors are plugged into it.

Chris
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 07, 2015, 07:55:47 PM
Thank you Chris,
Indeed, the EIA-485 lines needed to be switched over for it to work correctly, not sure why though.
But is does give the correct data, and I have a captured hex file to work with at present.

What I am doing is programming up a small Arduino UNO to act as a Magnum inverter MagNet simulator, together with remote and BMK and AGS data.
This will then be used to test my main C application that will do the decoding.

I have looked over your code and it has provided some useful hints and thoughts for me, knowing that you get reliable data from it.

I have studied the Magnum MagNet protocol document pretty well now and think I have most of it understood in terms of the weirdness of how they do things.
By week's end, I hope to have something that is displaying data from inverter, remote, BMK and AGS units.

It is a stand alone program initially and I'll make it available to those that would like it.
After that, I should be able to modify this program so that it can operate in an Arduino with an EIA-485 converter connected to the mail serial async port.

Thanks again Chris for your assistance, my appreciated.
____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on June 08, 2015, 05:32:08 PM
Paul,

I would be very interested in your C source code.

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 08, 2015, 09:40:55 PM
Hi Chris,
Yes, for sure.

I'm wonder if it is best for me to put it up on Github and anybody can copy it from there ?

What I have done so far is to create the Magnum MagNet simulator, which I coded up and have running in a small Arduino UNO.
It simply presents static data in the correct packet sequence with correct packet timing.
It has packets for inverter, remote with all 6 different tail sections, the BMK and AGS and RTR.

Actually, here is the Arduino simulator code  ;D
I code in Eclipse and use tabs for my indentation, so I don't know how nice it will appear below, but it is neat in my IDE.

As you can see, I used actual data as captured by a serial terminal program which has been saved as Hex file.
I worked out all the individual packets and each data parameter.

After the inverter packet there appears to be a terminating byte, typically FF, and is mentioned in the network spec, but not shown in the inverter table.

It's quick code, not a lot to it.

Now that I have this, I can code up and test the next stage, and that is the main C application to receive and decode and then display all this data on a computer.
When I complete this code, I will hope to have it running and tested on Mac OSX and GNU/Linux.
I expect it will also work for Microsoft windows as well.

I have made a start on the code, but it is at its early stage of just grabbing serial data in a non-blocking method and detecting for specified bytes at specified bye positions in the buffer.

Chris, if you have an Arduino to test this on, maybe could you test it with your Python code to see if it work sat this level?
If you don't I can try it later on.

____
Paul


/* ---------------------------------------------------------------------------------------------------------------------------
* Data capture from actual MagNet with MS4448PAE, RTR, AGS and BMK devices:
*
* Inverter 40 00 01 F8 00 04 77 00 01 00 33 17 2E 22 73 01 00 01 02 58 00 FF
* Remote_B+A0+A1 00 05 50 94 64 1E 16 08 00 D5 9B 84 07 19 17 26 14 00 73 00 A0 A1 02 35 FC 00 7D
*
* Inverter 40 00 01 F8 00 04 77 00 01 00 33 17 2E 22 73 01 00 01 02 58 00 FE
* Remote_B+A1+A2 00 05 50 94 64 1E 16 08 00 D5 9B 84 07 19 20 20 90 3C 3C 78 A1 A2 01 00 00 00 00
*
* Inverter 40 00 01 F8 00 04 77 00 01 00 33 17 2E 22 73 01 00 01 02 58 00 FF
* Remote_B+A2+RTR 00 05 50 94 64 1E 16 08 00 D5 9B 84 07 19 00 64 00 3C 0A 3C A2 91 01
*
* Inverter 40 00 01 F8 00 04 77 00 01 00 33 17 2E 22 73 01 00 01 02 58 00 FF
* Remote_B+A3 00 05 50 94 64 1E 16 08 00 D5 9B 84 07 19 50 28 00 20 0A 00 A3
*
* Inverter 40 00 01 F8 00 04 77 00 01 00 33 17 2E 22 73 01 00 01 02 58 00 FE
* Remote_B+A4 00 05 50 94 64 1E 16 08 00 D5 9B 84 07 19 3C 3C 00 00 00 00 A4
*
* Inverter 40 00 01 F8 00 04 77 00 01 00 33 17 2E 22 73 01 00 01 02 58 00 FF
* Remote_B+Z0 00 05 50 94 64 1E 16 08 00 D5 9B 84 07 19 17 26 00 00 00 00 00
*
* Inverter 40 00 01 F8 00 04 77 00 01 00 33 17 2E 22 73 01 00 01 02 58 00 FF
* Remote_B+80+81 00 05 50 94 64 1E 16 08 00 D5 9B 84 07 19 17 26 00 00 28 00 80 81 61 13 AF FF D2 12 4C 18 BB FF E9 FF FF 00 5E 0A 01
* ---------------------------------------------------------------------------------------------------------------------------
*
*
*
* buffer pos   size data description value
* ----------------------------------------------------------------------------------------
* Inverter Packet
*  0 0 8 0x40 Inverter status Invert mode
*  1 1 8 0x00 Inverter fault No fault
*  2 2 h8 0x01 DC Volts 256: (1 * 256 + 248) ÷ 10 = 50.4Vdc
*  3 3 l8 0xF8 DC Volts 248:
*  4 4 h8 0x00 AC Amps (not implemented)
*  5 5 l8 0x04 AC Amps (not implemented)
*  6 6 8 0x78 AC Volts output 120Vac
*  7 7 8 0x00 AC Volts input 0Vac
*  8 8 8 0x01 Inverter LED On
*  9 9 8 0x00 Charger LED Off
*  10 10 8 0x33 Inverter revision 3.3
*  11 11 8 0x17 Battery temp 23ËšC
*  12 12 8 0x2E Transformer temp 46ËšC
*  13 13 8 0x22 FET temp 34ËšC
*  14 14 8 0x73 Inverter model ID MS4448PAE
*  15 15 8 0x01 Stack mode Parallel stack - master
*  16 16 8 0x00 AC Input Amps 0 Amp
*  17 17 8 0x01 AC Output Amps 1 Amp
*  18 18 h8 0x02 AC Hertz 02: (02 * 256 + 88) ÷ 10 = 60
*  19 19 l8 0x58 AC Hertz 88:
*  20 20 8 0x00 No used
*  21 21 8 0xFF End of Packet marker
*
* Remote Packet
*  22 0 8 0x00
*  23 1 8 0x05
*  24 2 8 0x50
*  25 3 8 0x94
*  26 4 8 0x64
*  27 5 8 0x1E
*  28 6 8 0x16
*  29 7 8 0x08
*  30 8 8 0x00
*  31 9 8 0xD5
*  32 10 8 0x9B
*  33 11 8 0x84
*  34 12 8 0x07
*  35 13 8 0x19
*  36 14 8
*  37 15 8
*  38 16 8
*  39 17 8
*  40 18 8
*  41 19 8
*  42 20 8
*  43
*  44
*  45
*  46                this part needs completing to show all packet possibilities
*  47                first number will be buffer position in main C application
*  48
*  49
*  50
*
*/

#include "Arduino.h"
//#define debug

int count = 0;
int buflen = 0;
uint32_t  last_loop = 0; // current value of loop timer:
const uint32_t period_loop = 100; // loop timer preset value, every 100mSec:

// on periodic 100mSec send buffer_inverter as start of data stream:
uint8_t buffer_inverter[] = {0x40, 0x00, 0x01, 0xF8, 0x00, 0x04, 0x78, 0x00, 0x01, 0x00, 0x33, 0x17, 0x2E, 0x22, 0x73, 0x01, 0x00, 0x01, 0x02, 0x58, 0x00, 0xFF};

// after buffer_inverter sent, pause 10mSec, then send buffer_remote_base followed by selected tail buffer:
uint8_t buffer_remote_base[] = {0x00, 0x05, 0x50, 0x94, 0x64, 0x1E, 0x16, 0x08, 0x00, 0xD5, 0x9B, 0x84, 0x07, 0x19};
uint8_t buffer_remote_A0[] = {0x17, 0x26, 0x14, 0x00, 0x73, 0x00, 0xA0}; // add buffer_AGS_A1
uint8_t buffer_remote_A1[] = {0x20, 0x20, 0x90, 0x3C, 0x3C, 0x78, 0xA1}; // add buffer_AGS_A2
uint8_t buffer_remote_A2[] = {0x00, 0x64, 0x00, 0x3C, 0x0A, 0x3C, 0xA2}; // add buffer_RTR
uint8_t buffer_remote_A3[] = {0x50, 0x28, 0x00, 0x20, 0x0A, 0x00, 0xA3};
uint8_t buffer_remote_A4[] = {0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0xA4};
uint8_t buffer_remote_Z0[] = {0x17, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t buffer_remote_80[] = {0x17, 0x26, 0x00, 0x00, 0x28, 0x00, 0x80}; // add buffer_BMK

uint8_t buffer_BMK[]       = {0x81, 0x61, 0x13, 0xAF, 0xFF, 0xD2, 0x12, 0x4C, 0x18, 0xBB, 0xFF, 0xE9, 0xFF, 0xFF, 0x00, 0x5E, 0x0A, 0x01};
uint8_t buffer_AGS_A1[]    = {0xA1, 0x02, 0x35, 0xFC, 0x00, 0x7D}; // send after buffer_remote_A0
uint8_t buffer_AGS_A2[]    = {0xA2, 0x01, 0x00, 0x00, 0x00, 0x00}; // send after buffer_remote_A1
uint8_t buffer_RTR[]       = {0x91, 0x01}; // send after buffer_remote_A2

void setup() {
Serial.begin(19200, SERIAL_8N1);
}

void loop() {
if (millis() - last_loop >= period_loop)
{
#ifdef debug
Serial.print("\nInverter\t\t");
#endif
buflen = sizeof(buffer_inverter); // send inverter data:
for(int i = 0; i < buflen; i++)
Serial.write(buffer_inverter[i]);

#ifdef debug
Serial.print("\nRemote\t\t");
#endif
delay(10); // delay after inverter data:

buflen = sizeof(buffer_remote_base);
for(int i = 0; i < buflen; i++) // send remote bytes 0 - 13:
Serial.write(buffer_remote_base[i]);

if (count == 0) // packet remote_A0 + AGS_A1:
{
#ifdef debug
Serial.print("\nA0 + A1\t\t");
#endif
buflen = sizeof(buffer_remote_A0);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_remote_A0[i]);

delay(10); // small delay to separate remote data from AGS data:

buflen = sizeof(buffer_AGS_A1);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_AGS_A1[i]);
}

if (count == 1) // packet remote_A1 + AGS_A2:
{
#ifdef debug
Serial.print("\nA1 + A2\t\t");
#endif
buflen = sizeof(buffer_remote_A1);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_remote_A1[i]);

delay(10); // small delay to separate remote data from AGS data:

buflen = sizeof(buffer_AGS_A2);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_AGS_A2[i]);
}

if (count == 2) // packet remote_A2 + RTR:
{
#ifdef debug
Serial.print("\nA2 + RTR\t\t");
#endif
buflen = sizeof(buffer_remote_A2);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_remote_A2[i]);

delay(10); // small delay to separate remote data from RTR data:

buflen = sizeof(buffer_RTR);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_RTR[i]);
delay(8); // dead time of 8mSec as per spec (both 8 and 18 are mentioned):
}

if (count == 3) // packet remote_A3
{
#ifdef debug
Serial.print("\nA3\t\t");
#endif
buflen = sizeof(buffer_remote_A3);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_remote_A3[i]);
}

if (count == 4) // packet remote_A4
{
#ifdef debug
Serial.print("\nA4\t\t");
#endif
buflen = sizeof(buffer_remote_A4);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_remote_A4[i]);
}

if (count == 5) // packet remote_A1 + Z0:
{
#ifdef debug
Serial.print("\nA1 + Z0\t\t");
#endif
buflen = sizeof(buffer_remote_A1);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_remote_A1[i]);

buflen = sizeof(buffer_remote_Z0);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_remote_Z0[i]);
}
if (count == 6) // packet remote_80 + BMK
{
#ifdef debug
Serial.print("\n80 + 81\t\t");
#endif
buflen = sizeof(buffer_remote_80);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_remote_80[i]);

delay(10); // small delay to separate remote data from BMK data:

buflen = sizeof(buffer_BMK);
for(int i = 0; i < buflen; i++)
Serial.write(buffer_BMK[i]);
delay(14); // dead time of 14mSec as per spec:
}

count++;
count = count%7;

last_loop = millis();
}
}

Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on June 12, 2015, 10:24:52 AM
Paul,

I do have an Arduino Uno but I am out of town right now and won't be back for another week at least.

Looks like you are making excellent progress!

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 17, 2015, 08:57:14 AM
After some days with head down, fingers burning, I've taken your program Chris and massage it a little, well, ok, a lot :)
It is coming up close to 1000 lines of Python code and should break past that figure very soon before it is complete.

The program, which I have given the name 'MagPy' (a bird we also have in Australia), is designed to decode pretty well everything in the Magnum protocol document.
Earlier today, I ftp'd it up to a Cubieboard II which I am setting up in North America and tested it on a real live MS4448PAE, and to my surprise, it spat out actual data very quickly.
I had to try a few times to make sure the data was actual and changing, yes it was :)

I'm hoping to get it complete in the next day or two, as I've spent the best part of a week on it now I think.
I even tinkered with the built in GUI TKinker, and also Python 3, but have all that on hold for another day.
It's my first Python program, and I quite like the language.

As soon as I finish it, I'll pop it up here and would really appreciate it if you were able to try sometime on your setup.
____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on June 17, 2015, 09:10:21 AM
Paul,

Excellent! I look forward to testing it on my system.

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 18, 2015, 10:47:43 AM
Finally I think I have this MagPy program fairly well sorted now.

The setup I tested on was both an Arduino acting as Magnum network simulator and then final tests on a remote system via ssh.
I will continue more testing, to check all data is valid at all ranges.

The code as of right now is attached below.

To install, your system needs, of course Python, which comes with GNU/Linux as well as BSD systems like Mac OSX.
It was developed on Python 2.7.1, and should work on Python 3 as well, though I need to run those checks yet.

You will also need to import the pyserial module, which you can look here to read all about it.
http://pyserial.sourceforge.net/pyserial.html (http://pyserial.sourceforge.net/pyserial.html)

From there you will read to download it from
http://pypi.python.org/pypi/pyserial (http://pypi.python.org/pypi/pyserial)

Then to install
python setup.py install


To run MagPy you have a few options.
Running the program without arguments will use a default communications port of "/dev/ttyUSB0'
You can override this with the -p or --port argument, so for example;
cubie@Cubian:~$ python MagPy.py -p /dev/ttyUSB1

or for my Mac, I use
prompt$ python MagPy.py -p /dev/tty.usbmodem621
Notice the period '.'

Microsoft users, I guess you'll nut it out fine :)

Below is a sample from the live system:

cubie@Cubian:~$ python MagPy.py
MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

Decoding Packets Remote_Base, A2, RTR
Decoding Packets Remote_Base, A3
Decoding Packets Remote_Base, A4
Decoding Packets Remote_Base, Z0
Decoding Packets Remote_Base, BMK80, BMK81
Decoding Packets Remote_Base, A0, A1
Decoding Packets Remote_Base, A1, A2

Live Data
Clock                     08:33
Inverter Mode:            Invert
Fault:                    No Faults

Inverter Input Volts:     55.2 Vdc
Inverter Input Amps:      0 Amps DC

Inverter Output AC Volts: 120 Vac
Inverter Output AC Amps:  0 Amps
External Input AC Volts:  0 Vac
External Input AC Amps:   0 Amps
Inverter Line Frequency   60.0 Hz

Temperature Battery       25 C
Temperature Transformer   42 C
Temperature FETs          35 C
Battery State of Charge:  100 %

Generator Run Time        0.2 Hrs
Generator Last Run        3 Days

Remote - ver(2.2)
Status:                   Remote Command Clear

Router - ver(0.1)

BMK - ver(1.0)
Fault Status:             No Faults
Battery Volts DC:         55.26 Vdc
Amps DC:                  52 Amps
Battery Max:              63.31 Vdc
Battery Min:              46.84 Vdc
Battery Amp Hour Net      1 AmpHr
Battery Amp Hour Trip     6553 AmpHr
Battery Amp Hour Total    9800 AmpHr

AGS - ver(5.3)
Status:                   Ready
Gen Start Mode:           Off
Quiet Hours:              Off
Quiet Time Start  20.0 Hrs
Quiet Time Stop   10.0 Hrs

Auto Start                Disabled
Start Time        8.0 Hrs
Stop Time         8.0 Hrs

Start Delay               60 Sec
Stop Delay                60 Sec
Warm Up Time              60 Sec
Cool Down Time            60 Sec
SOC Start                 0 %
SOC Stop                  100 %
Amps Start                0 Amps
Amps Stop                 10 Amps
Amps Start Delay  60 Sec
Amps Stop Delay   60 Sec

Maximum Run Time          12.0 Hrs
Top Off Time              0 Min
Exercise Day Period       0 Days
Exercise Start Time       8.0 Hrs
Exercise Run Time         1 Hrs
Start Temperature         0 F
Start Volts               46.0 Vdc
Stop Volts                57.6 Vdc

Inverter - ver(5.1)
Inverter Model ID:        0x73
System Buss Voltage:      48 Vdc
Inverter Stack Mode:      Master in Parallel Stack
Search Watts:             5 Watts
Charger Amps:             100 %
Shore AC Amps:            30 Amps
Parallel Threshold:       60 %
AC Volts Trip:            80 Vac

Battery Settings
Battery Size, remote:     800 AmpHr
Battery Size, BMK:        400 AmpHr
Battery Type:             Custom
Battery Efficiency:       0 %
Float Volts:              52.8 Vdc
Absorb Volts:             58.8 Vdc
Equalise Volts:           62.0 Vdc
Battery Low Trip:         42.6 Vdc
cubie@Cubian:~$


Again, many thanks to Chris.
If you find errors, which I'm sure will be found, please let me know so I can fix
____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on June 19, 2015, 10:10:26 AM
Paul,

It is looking good!!

Can your code cater for systems that have none, or few, of the optional hardware components (AC, ARC, RTR, AGS, BMK)?

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 19, 2015, 10:31:22 AM
Thank you Chris,

To answer your question, I believe so, because of the way it looks for the individual packets from various devices.
It is something i thought about, but I have no idea what the range of possibilities are for different systems.
I guess some may have the AGS component, though, I'm uncertain of the possible combinations allowed or available.

After some more testing, it appears that there are certain values that are displayed by the actual system that don't actually get put onto the network.
For example, it appears data for AGS SOC start and stop are not the same as being displayed on the actual unit, rather, the data on the network tends to be default values, not actual presets.
There are a few that are like this and we'll be getting onto to Magnum Energy to make contact with them to ask some questions in the next day or so.
____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 19, 2015, 10:35:25 AM
I did have thoughts of putting in an HTTP server in the MagPy code.
Then all the data would be available via HTTP requests.
But if I do, it will need to wait a little while as I need to catch up on helping a few other folks with projects.
One day I'll get around to connecting my new LiFePO4 25.6Volt bank to the inverter and moving off and selling the dead weights :)
____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on June 20, 2015, 11:45:14 AM
Paul,

Running your code on my system now.

MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

Decoding Packets Remote_Base, A3
Decoding Packets Remote_Base, Z0
Error: Failed to decode, please try again. Exiting

I will investigate where it is getting stuck and report back.

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 20, 2015, 05:34:23 PM
Hi Chris,

Place the print statement at line 911, directly after the serial read, like this;

serial_byte = ord(mag_port.read(1))
print(hex(serial_byte)),


Also, enable the print at line 816.
This will print out the data bytes read and we should be able to find from that what is different.

I have yet to put in the debug levels  :-[

What components do you have in your system?

____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on June 20, 2015, 05:42:56 PM
Paul,

I have the MS4448PAE inverter, BMK and ARC.

Output produced:-

MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

1 0x40
0x0 2 0x0
0x2 3 0x2
0x1 4 0x1
0x0 5 0x0
0x4 6 0x4
0x78 7 0x78
0x0 8 0x0
0x1 9 0x1
0x0 10 0x0
0x33 11 0x33
0x20 12 0x20
0x32 13 0x32
0x29 14 0x29
0x73 15 0x73
0x0 16 0x0
0x0 17 0x0
0x1 18 0x1
0x2 19 0x2
0x58 20 0x58
0x0 21 0x0
0xff 22 0xff
0x0 23 0x0
0x5 24 0x5
0x3c 25 0x3c
0x93 26 0x93
0x32 27 0x32
0x14 28 0x14
0x17 29 0x17
0x46 30 0x46
0x0 31 0x0
0xeb 32 0xeb
0x9b 33 0x9b
0x86 34 0x86
0x7 35 0x7
0x14 36 0x14
0x50 37 0x50
0x28 38 0x28
0x0 39 0x0
0x20 40 0x20
0xa 41 0xa
0x0 42 0x0
0xa3 43 0xa3
Decoding Packets Remote_Base, A3
0xff 1 0xff
0x40 2 0x40
0x0 3 0x0
0x2 4 0x2
0x1 5 0x1
0x0 6 0x0
0x4 7 0x4
0x78 8 0x78
0x0 9 0x0
0x1 10 0x1
0x0 11 0x0
0x33 12 0x33
0x20 13 0x20
0x32 14 0x32
0x29 15 0x29
0x73 16 0x73
0x0 17 0x0
0x0 18 0x0
0x1 19 0x1
0x2 20 0x2
0x58 21 0x58
0x0 22 0x0
0xff 23 0xff
0x0 24 0x0
0x5 25 0x5
0x3c 26 0x3c
0x93 27 0x93
0x32 28 0x32
0x14 29 0x14
0x17 30 0x17
0x46 31 0x46
0x0 32 0x0
0xeb 33 0xeb
0x9b 34 0x9b
0x86 35 0x86
0x7 36 0x7
0x14 37 0x14
0x3c 38 0x3c
0x3c 39 0x3c
0x0 40 0x0
0x0 41 0x0
0x0 42 0x0
0x0 43 0x0
Decoding Packets Remote_Base, Z0
0xa4 1 0xa4
0xff 2 0xff
0x81 3 0x81
0x5d 4 0x5d
0x14 5 0x14
0x11 6 0x11
0x0 7 0x0
0x0 8 0x0
0x12 9 0x12
0x7d 10 0x7d
0x18 11 0x18
0x3c 12 0x3c
0xff 13 0xff
0xe4 14 0xe4
0xff 15 0xff
0xff 16 0xff
0x0 17 0x0
0x47 18 0x47
0xa 19 0xa
0x1 20 0x1
0x40 21 0x40
0x0 22 0x0
0x2 23 0x2
0x1 24 0x1
0x0 25 0x0
0x4 26 0x4
0x78 27 0x78
0x0 28 0x0
0x1 29 0x1
0x0 30 0x0
0x33 31 0x33
0x20 32 0x20
0x32 33 0x32
0x29 34 0x29
0x73 35 0x73
0x0 36 0x0
0x0 37 0x0
0x1 38 0x1
0x2 39 0x2
0x58 40 0x58
0x0 41 0x0
0xff 42 0xff
0x0 43 0x0
0x5 44 0x5
0x3c 45 0x3c
0x93 46 0x93
0x32 47 0x32
0x14 48 0x14
0x17 49 0x17
0x46 50 0x46
0x0 51 0x0
0xeb 52 0xeb
0x9b 53 0x9b
0x86 54 0x86
0x7 55 0x7
0x14 56 0x14
0x0 57 0x0
0x0 58 0x0
0x0 59 0x0
0x0 60 0x0
0x28 61 0x28
0x0 62 0x0
0x80 63 0x80
0xff 64 0xff
0x40 65 0x40
0x0 66 0x0
0x2 67 0x2
0x1 68 0x1
0x0 69 0x0
0x4 70 0x4
0x78 71 0x78
0x0 72 0x0
0x1 73 0x1
0x0 74 0x0
0x33 75 0x33
0x20 76 0x20
0x32 77 0x32
0x29 78 0x29
0x73 79 0x73
0x0 80 0x0
0x0 81 0x0
0x1 82 0x1
0x2 83 0x2
0x58 84 0x58
0x0 85 0x0
0xff 86 0xff
0x0 87 0x0
0x5 88 0x5
0x3c 89 0x3c
0x93 90 0x93
0x32 91 0x32
0x14 92 0x14
0x17 93 0x17
0x46 94 0x46
0x0 95 0x0
0xeb 96 0xeb
0x9b 97 0x9b
0x86 98 0x86
0x7 99 0x7
0x14 100 0x14
0x0 101 0x0
0x0 102 0x0
0x0 103 0x0
0x0 104 0x0
0x0 105 0x0
0x0 106 0x0
0x0 107 0x0
0xff 108 0xff
0x40 109 0x40
0x0 110 0x0
0x2 111 0x2
0x1 112 0x1
0x0 113 0x0
0x4 114 0x4
0x78 115 0x78
0x0 116 0x0
0x1 117 0x1
0x0 118 0x0
0x33 119 0x33
0x20 120 0x20
0x32 121 0x32
0x29 122 0x29
0x73 123 0x73
0x0 124 0x0
0x0 125 0x0
0x1 126 0x1
0x2 127 0x2
0x58 128 0x58
Error: Failed to decode, please try again. Exiting

Chris.

Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 20, 2015, 06:15:09 PM
ok, I notice a few things in there.

First line, is both the inverter and A3 packet :
Inverter       0x40 0x0 0x2 0x4 0x0 0x4 0x77 0x0 0x1 0x0 0x33 0x20 0x32 0x29 0x73 0x0 0x0 0x1 0x2 0x58 0x0 0xff (0xff is end of frame marker)
Remote_A3  0x0 0x5 0x3c 0x93 0x32 0x14 0x17 0x46 0x0 0xeb 0x9b 0x86 0x7 0x14 0x50 0x28 0x0 0x20 0xa 0x0 0xa3 Decoding Packets Remote_Base, A3

Next line is, again inverter packet with a plain remote packet I call remote_Z0 (mostly zeros at end)
Inverter       0xff 0x40 0x0 0x2 0x3 0x0 0x4 0x76 0x0 0x1 0x0 0x33 0x20 0x32 0x29 0x73 0x0 0x0 0x1 0x2 0x58 0x0 0xff (again, 0xff end of frame marker)
Remote_Z0  0x0 0x5 0x3c 0x93 0x32 0x14 0x17 0x46 0x0 0xeb 0x9b 0x86 0x7 0x14 0x3c 0x3c 0x0 0x0 0x0 0x0 Decoding Packets Remote_Base, Z0

But notice the end of frame marker from the preceding frame is now at the start of the inverter frame, 0xff 0x40 0x0.

Section of the next line:
Unknown   0xa4 0xff 0x81 0x5d 0x14 0x17 0xff 0xec 0x12 0x7d 0x18 0x3c 0xff 0xe4 0xff 0xff 0x0 0x47 0xa 0x1 (unknown start marker, also I don't recognise any of this data)
Inverter     0x40 0x0 0x2 0x3 0x0 0x4 0x76 0x0 0x1 0x0 0x33 0x20 0x32 0x29 0x73 0x0 0x0 0x1 0x2 0x58 0x0 0xff

Following on from that data I see a Remote_BMK start frame;
0x0 0x5 0x3c 0x93 0x32 0x14 0x17 0x46 0x0 0xeb 0x9b 0x86 0x7 0x14 0x0 0x0 0x0 0x0 0x28 0x0 0x80 0xff (Remote_BMK ends with 0x80)
But no following on frame, which starts with 0x81.
Rather, it ends with a end of frame marker.
I have only ever seen end of frame markers at the end of the inverter packet, never on any other packet, and this might be a software change Magnum have applied to later units.

I should be able to modify the code so that those additional 0xff end of frame markers are catered for.
This might help decode a bit more, but that still leaves a packet that I do not see in the document I have.

How old is your system and what are the revision numbers?

The 'Error: Failed to decode, please try again. Exiting', is simply that the program has detected more bytes in the buffer than any of the packet size definitions are, meaning, it was not able to track the packets as per the Magnum protocol document.

Also, where in the network do you connect in with your EIA-485 from your RPi/Cubie ?

I will look at making further contact with Magnum Energy to try to get some additional understanding and whether what you have is a later revision of the firmware, together with the more recent protocol document.

I have been advised that there is additional data being generated buy the AGS module, maybe also by other modules.
____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on June 20, 2015, 06:27:56 PM
Paul,

The system was purchased new in 2011, if I remember correctly. Also from memory, the inverter is 5.1, the BMK is 1.0, and ARC is 2.3.

The Pi is connected to the green inverter port, together with the BMK.

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on June 20, 2015, 06:36:42 PM
I've just noticed that the remote_Z0 packet is not correct, it is in fact a remote_A4 packet, as can be seen with the 0xa4 at the start of the next unknown packet, followed by the EOF marker.
That then makes the next packet a tail section of the BMK packet, which should always follow the initial BMK packet, which ends in 0x80, linking the two together, 0x80 to 0x81.

I'll look over it some more later, hopefully tonight my time UTC+10
____
Paul
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: jamesmc on March 01, 2016, 06:35:35 PM
I am encountering a similar type of packet as well.  There must be changes to the protocol from the publicly available document?  Have you made any further changes or updates to this project Paul?
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: paul alting on March 01, 2016, 07:23:02 PM
Hi James,

Gosh, looking over this topic I needed a few moments to realise it was code I developed.
I don't think there were any further modifications to the code, but I would need to check my last version against what is here.
I'll try to take a look later.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: WillEert on March 06, 2016, 05:53:40 PM
Hi Paul,

I am very interested in your work that you are doing regarding interfacing with the Magnum inverters and associated Magnum equipment. As you know I have a Magnum / Midnite system with the diversion control that you gave your time to develop code for. I  divert my excess electricity on the AC side of the system. The system has a dedicated ms4448 pae inverter  that is only used for diversion or battery charging.  I would like to turn my diversion inverter off when the Classic is resting or in bulk as it is just wasting watts as it waits for power to become available in absorb or float stage. I am pulling for you to be successful at this coding as I know that I could not do it!!!

Cheers

Will
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: RDK45 on June 20, 2016, 06:06:26 PM
I'm using a Raspberry Pi B+ configured as a bridge to spy on internet traffic which is coming from one of my weather stations and going to a server on the web. 

This is very similar hardware setup to what I also have with my Magnum Energy inverter and associated web interface box.  However, unlike the weather station application, when I use TCPDUMP to view the traffic coming from the Magnum Energy web interface I do not seem to be able to capture any readable/understandable traffic.

You folks seem to have figured out a process for capturing and decoding this traffic.  I'm very interested in UNDERSTANDING how you have your Raspberry Pi's configured and where and how are you getting access to the data which is being send to the Magnum Energy website.

I have downloaded code from some of the above links, but there are a couple which are no longer active.

Thanks for any help/direction you might provide....RDK
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 14, 2019, 06:18:40 AM
Quote from: cpfl on June 20, 2015, 05:42:56 PM
Paul,

I have the MS4448PAE inverter, BMK and ARC.

Output produced:-

MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

1 0x40
0x0 2 0x0
0x2 3 0x2
0x1 4 0x1
0x0 5 0x0
0x4 6 0x4
0x78 7 0x78
0x0 8 0x0
0x1 9 0x1
0x0 10 0x0
0x33 11 0x33
0x20 12 0x20
0x32 13 0x32
0x29 14 0x29
0x73 15 0x73
0x0 16 0x0
0x0 17 0x0
0x1 18 0x1
0x2 19 0x2
0x58 20 0x58
0x0 21 0x0
0xff 22 0xff
0x0 23 0x0
0x5 24 0x5
0x3c 25 0x3c
0x93 26 0x93
0x32 27 0x32
0x14 28 0x14
0x17 29 0x17
0x46 30 0x46
0x0 31 0x0
0xeb 32 0xeb
0x9b 33 0x9b
0x86 34 0x86
0x7 35 0x7
0x14 36 0x14
0x50 37 0x50
0x28 38 0x28
0x0 39 0x0
0x20 40 0x20
0xa 41 0xa
0x0 42 0x0
0xa3 43 0xa3
Decoding Packets Remote_Base, A3
0xff 1 0xff
0x40 2 0x40
0x0 3 0x0
0x2 4 0x2
0x1 5 0x1
0x0 6 0x0
0x4 7 0x4
0x78 8 0x78
0x0 9 0x0
0x1 10 0x1
0x0 11 0x0
0x33 12 0x33
0x20 13 0x20
0x32 14 0x32
0x29 15 0x29
0x73 16 0x73
0x0 17 0x0
0x0 18 0x0
0x1 19 0x1
0x2 20 0x2
0x58 21 0x58
0x0 22 0x0
0xff 23 0xff
0x0 24 0x0
0x5 25 0x5
0x3c 26 0x3c
0x93 27 0x93
0x32 28 0x32
0x14 29 0x14
0x17 30 0x17
0x46 31 0x46
0x0 32 0x0
0xeb 33 0xeb
0x9b 34 0x9b
0x86 35 0x86
0x7 36 0x7
0x14 37 0x14
0x3c 38 0x3c
0x3c 39 0x3c
0x0 40 0x0
0x0 41 0x0
0x0 42 0x0
0x0 43 0x0
Decoding Packets Remote_Base, Z0
0xa4 1 0xa4
0xff 2 0xff
0x81 3 0x81
0x5d 4 0x5d
0x14 5 0x14
0x11 6 0x11
0x0 7 0x0
0x0 8 0x0
0x12 9 0x12
0x7d 10 0x7d
0x18 11 0x18
0x3c 12 0x3c
0xff 13 0xff
0xe4 14 0xe4
0xff 15 0xff
0xff 16 0xff
0x0 17 0x0
0x47 18 0x47
0xa 19 0xa
0x1 20 0x1
0x40 21 0x40
0x0 22 0x0
0x2 23 0x2
0x1 24 0x1
0x0 25 0x0
0x4 26 0x4
0x78 27 0x78
0x0 28 0x0
0x1 29 0x1
0x0 30 0x0
0x33 31 0x33
0x20 32 0x20
0x32 33 0x32
0x29 34 0x29
0x73 35 0x73
0x0 36 0x0
0x0 37 0x0
0x1 38 0x1
0x2 39 0x2
0x58 40 0x58
0x0 41 0x0
0xff 42 0xff
0x0 43 0x0
0x5 44 0x5
0x3c 45 0x3c
0x93 46 0x93
0x32 47 0x32
0x14 48 0x14
0x17 49 0x17
0x46 50 0x46
0x0 51 0x0
0xeb 52 0xeb
0x9b 53 0x9b
0x86 54 0x86
0x7 55 0x7
0x14 56 0x14
0x0 57 0x0
0x0 58 0x0
0x0 59 0x0
0x0 60 0x0
0x28 61 0x28
0x0 62 0x0
0x80 63 0x80
0xff 64 0xff
0x40 65 0x40
0x0 66 0x0
0x2 67 0x2
0x1 68 0x1
0x0 69 0x0
0x4 70 0x4
0x78 71 0x78
0x0 72 0x0
0x1 73 0x1
0x0 74 0x0
0x33 75 0x33
0x20 76 0x20
0x32 77 0x32
0x29 78 0x29
0x73 79 0x73
0x0 80 0x0
0x0 81 0x0
0x1 82 0x1
0x2 83 0x2
0x58 84 0x58
0x0 85 0x0
0xff 86 0xff
0x0 87 0x0
0x5 88 0x5
0x3c 89 0x3c
0x93 90 0x93
0x32 91 0x32
0x14 92 0x14
0x17 93 0x17
0x46 94 0x46
0x0 95 0x0
0xeb 96 0xeb
0x9b 97 0x9b
0x86 98 0x86
0x7 99 0x7
0x14 100 0x14
0x0 101 0x0
0x0 102 0x0
0x0 103 0x0
0x0 104 0x0
0x0 105 0x0
0x0 106 0x0
0x0 107 0x0
0xff 108 0xff
0x40 109 0x40
0x0 110 0x0
0x2 111 0x2
0x1 112 0x1
0x0 113 0x0
0x4 114 0x4
0x78 115 0x78
0x0 116 0x0
0x1 117 0x1
0x0 118 0x0
0x33 119 0x33
0x20 120 0x20
0x32 121 0x32
0x29 122 0x29
0x73 123 0x73
0x0 124 0x0
0x0 125 0x0
0x1 126 0x1
0x2 127 0x2
0x58 128 0x58
Error: Failed to decode, please try again. Exiting

Chris.

Chris, I did a little hacking to Paul's code to get it to spit out some data. I was having similar troubles to yours.

I have 2 MS4448pae inverters in parallel, a router and bmk. I have an ags-n, just not connected at the moment. I also hsve the msg-web so I may try another option.

Also, I have added 2 more MS4448pae inverters but I have not finished the wiring....

  pi@pi3bplus:~ $ python MagPy.py -p /dev/ttyUSB0
MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

1 made it through here.
Decoding Packets Remote_Base, BMK80, BMK81
Error: Failed to decode, please try again. Exiting

Live Data
        Clock                     0.0:0.0
        Inverter Mode:            Invert
        Fault:                    No Faults

        Inverter Input Volts:     49.2 Vdc
        Inverter Input Amps:      12 Amps DC

        Inverter Output AC Volts: 120 Vac
        Inverter Output AC Amps:  4 Amps
        External Input AC Volts:  187 Vac
        External Input AC Amps:   0 Amps
        Inverter Line Frequency   60.0 Hz

        Temperature Battery       18 C
        Temperature Transformer   44 C
        Temperature FETs          33 C

        Generator Run Time        0.0 Hrs
        Generator Last Run        0 Days

Remote - ver(3.2)
        Status:                   Remote Command Clear

Router - ver(0)

BMK - ver(1.0)
        Fault Status:             No Faults
        Battery Volts DC:         49.24 Vdc
        Amps DC:                  13.9 Amps
        Battery Max:              56.26 Vdc
        Battery Min:              47.26 Vdc
        Battery Amp Hour Net      588 AmpHr
        Battery Amp Hour Trip     6553 AmpHr
        Battery Amp Hour Total    38400 AmpHr

AGS - ver(0.0)
        Status:                   NA
        Gen Start Mode:           Off
        Quiet Hours:              NA
                Quiet Time Start  0.0 Hrs
                Quiet Time Stop   0.0 Hrs

        Auto Start                NA
                Start Time        0.0 Hrs
                Stop Time         0.0 Hrs

        Start Delay               0.0 Sec
        Stop Delay                0.0 Sec
        Warm Up Time              0 Sec
        Cool Down Time            0 Sec
        SOC Start                 0 %
        SOC Stop                  0 %
        Amps Start                0 Amps
        Amps Stop                 0 Amps
                Amps Start Delay  0 Sec
                Amps Stop Delay   0 Sec

        Maximum Run Time          0.0 Hrs
        Top Off Time              0 Min
        Exercise Day Period       0 Days
        Exercise Start Time       0.0 Hrs
        Exercise Run Time         0 Hrs
        Start Temperature         0.0 F
        Start Volts               0.0 Vdc
        Stop Volts                0.0 Vdc

Inverter - ver(5.1)
        Inverter Model ID:        0x73
        System Buss Voltage:      48 Vdc
        Inverter Stack Mode:      Master in Parallel Stack
        Search Watts:             0 Watts
        Charger Amps:             100 %
        Shore AC Amps:            60 Amps
        Parallel Threshold:       60 %
        AC Volts Trip:            255 Vac

Battery Settings
        Battery Size, remote:     2180 AmpHr
        Battery Size, BMK:        1810 AmpHr
        Battery Type:             Custom
        Battery Efficiency:       0 %
        Float Volts:              54.4 Vdc
        Absorb Volts:             55.2 Vdc
        Equalise Volts:           55.2 Vdc
        Battery Low Trip:         42.0 Vdc
Error: Failed to read communications Port, exiting
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 14, 2019, 06:46:08 AM
Quote from: cpfl on June 06, 2015, 10:09:59 PM
Hi Paul,

Attached is my code. It needs cleaning up, but is functional and can be modified to suit your needs.

I am currently using a secondary Pi dedicated to communicating with the inverter, which sends the data back to my primary Pi using HTML. The primary Pi opens the URL to the secondary Pi which executes the python code to collect the data on demand.

A problem that I had when first connecting the RS485 wires to the inverter was that the wires were the wrong way round. As soon as I swapped A and B, the data looked better. It definately sounds like your wires are crossed.

I put a two-way RJ11 splitter on the GREEN inverter port where the BMK is normally connected. Both the BMK and the Pi connectors are plugged into it.

Chris

Here is some data of in the works progress using some varied code of yours.

BMK,byte[0]0x81, byte[1]soc 67, byte[2,3]volts 49.2667, byte[4,5]amps -11.2, byte[6,7]minVolts 47.26, byte[8,9]maxVolts 56.26, Ah[10,11] -600, byte[12,13]ampHr 6553.5, byte[14,15]ampHc 38.4Kah, bmkVersion 1.0, fault 1

INV,64,0,49.4,9,121,180,1,0,5.1,64.4,111.2,89.6,115,1,0,3,60.0,0,
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 16, 2019, 01:26:16 AM

Chris.


Chris, I added the AGS-N today and ran Paul's code that I hacked a little. I have a Magnum RC and I have an Magnum A-R, I thought about hooking up one of them to the
Router to see if I could get any extra data...  May do it just to see if Paul's code finds it....  Anyway, data from the AGS-N addition.


python MagPy.py -p /dev/ttyUSB0
MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

1 made it through here.
Decoding Packets Remote_Base, Z0
Decoding Packets Remote_Base, BMK80, BMK81
Decoding Packets Remote_Base, A0, A1
Decoding Packets Remote_Base, A1, A2
Error: Failed to decode, please try again. Exiting

Live Data
   Clock                     00:24
   Inverter Mode:            Invert
   Fault:                    No Faults

   Inverter Input Volts:     50.6 Vdc
   Inverter Input Amps:      16 Amps DC

   Inverter Output AC Volts: 119 Vac
   Inverter Output AC Amps:  6 Amps
   External Input AC Volts:  187 Vac
   External Input AC Amps:   0 Amps
   Inverter Line Frequency   60.0 Hz

   Temperature Battery       23 C
   Temperature Transformer   53 C
   Temperature FETs          36 C

   Generator Run Time        0.0 Hrs
   Generator Last Run        0 Days

Remote - ver(3.2)
   Status:                   Remote Command Clear

Router - ver(0)

BMK - ver(1.0)
   Fault Status:             No Faults
   Battery Volts DC:         50.47 Vdc
   Amps DC:                  16.9 Amps
   Battery Max:              56.4 Vdc
   Battery Min:              47.26 Vdc
   Battery Amp Hour Net      138 AmpHr
   Battery Amp Hour Trip     6553 AmpHr
   Battery Amp Hour Total    38800 AmpHr

AGS - ver(5.3)
   Status:                   Off
   Gen Start Mode:           Off
   Quiet Hours:              Off
      Quiet Time Start  0.0 Hrs
      Quiet Time Stop   0.0 Hrs

   Auto Start                Enabled
      Start Time        24.0 Hrs
      Stop Time         0.0 Hrs

   Start Delay               120 Sec
   Stop Delay                120 Sec
   Warm Up Time              0 Sec
   Cool Down Time            0 Sec
   SOC Start                 0 %
   SOC Stop                  0 %
   Amps Start                0 Amps
   Amps Stop                 0 Amps
      Amps Start Delay  0 Sec
      Amps Stop Delay   0 Sec

   Maximum Run Time          12.0 Hrs
   Top Off Time              0 Min
   Exercise Day Period       0 Days
   Exercise Start Time       0.0 Hrs
   Exercise Run Time         0 Hrs
   Start Temperature         0 F
   Start Volts               46.0 Vdc
   Stop Volts                57.6 Vdc

Inverter - ver(5.1)
   Inverter Model ID:        0x73
   System Buss Voltage:      48 Vdc
   Inverter Stack Mode:      Master in Parallel Stack
   Search Watts:             0 Watts
   Charger Amps:             100 %
   Shore AC Amps:            60 Amps
   Parallel Threshold:       60 %
   AC Volts Trip:            255 Vac

Battery Settings
   Battery Size, remote:     2180 AmpHr
   Battery Size, BMK:        1810 AmpHr
   Battery Type:             Custom
   Battery Efficiency:       0 %
   Float Volts:              54.4 Vdc
   Absorb Volts:             55.2 Vdc
   Equalise Volts:           55.2 Vdc
   Battery Low Trip:         42.0 Vdc
Error: Failed to read communications Port, exiting
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 16, 2019, 01:49:35 AM
Quote from: cpfl on June 20, 2015, 05:42:56 PM
Paul,

I have the MS4448PAE inverter, BMK and ARC.

Output produced:-

MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

1 0x40
0x0 2 0x0
0x2 3 0x2
0x1 4 0x1
0x0 5 0x0
0x4 6 0x4
0x78 7 0x78
0x0 8 0x0
0x1 9 0x1
0x0 10 0x0
0x33 11 0x33
0x20 12 0x20
0x32 13 0x32
0x29 14 0x29
0x73 15 0x73
0x0 16 0x0
0x0 17 0x0
0x1 18 0x1
0x2 19 0x2
0x58 20 0x58
0x0 21 0x0
0xff 22 0xff
0x0 23 0x0
0x5 24 0x5
0x3c 25 0x3c
0x93 26 0x93
0x32 27 0x32
0x14 28 0x14
0x17 29 0x17
0x46 30 0x46
0x0 31 0x0
0xeb 32 0xeb
0x9b 33 0x9b
0x86 34 0x86
0x7 35 0x7
0x14 36 0x14
0x50 37 0x50
0x28 38 0x28
0x0 39 0x0
0x20 40 0x20
0xa 41 0xa
0x0 42 0x0
0xa3 43 0xa3
Decoding Packets Remote_Base, A3
0xff 1 0xff
0x40 2 0x40
0x0 3 0x0
0x2 4 0x2
0x1 5 0x1
0x0 6 0x0
0x4 7 0x4
0x78 8 0x78
0x0 9 0x0
0x1 10 0x1
0x0 11 0x0
0x33 12 0x33
0x20 13 0x20
0x32 14 0x32
0x29 15 0x29
0x73 16 0x73
0x0 17 0x0
0x0 18 0x0
0x1 19 0x1
0x2 20 0x2
0x58 21 0x58
0x0 22 0x0
0xff 23 0xff
0x0 24 0x0
0x5 25 0x5
0x3c 26 0x3c
0x93 27 0x93
0x32 28 0x32
0x14 29 0x14
0x17 30 0x17
0x46 31 0x46
0x0 32 0x0
0xeb 33 0xeb
0x9b 34 0x9b
0x86 35 0x86
0x7 36 0x7
0x14 37 0x14
0x3c 38 0x3c
0x3c 39 0x3c
0x0 40 0x0
0x0 41 0x0
0x0 42 0x0
0x0 43 0x0
Decoding Packets Remote_Base, Z0
0xa4 1 0xa4
0xff 2 0xff
0x81 3 0x81
0x5d 4 0x5d
0x14 5 0x14
0x11 6 0x11
0x0 7 0x0
0x0 8 0x0
0x12 9 0x12
0x7d 10 0x7d
0x18 11 0x18
0x3c 12 0x3c
0xff 13 0xff
0xe4 14 0xe4
0xff 15 0xff
0xff 16 0xff
0x0 17 0x0
0x47 18 0x47
0xa 19 0xa
0x1 20 0x1
0x40 21 0x40
0x0 22 0x0
0x2 23 0x2
0x1 24 0x1
0x0 25 0x0
0x4 26 0x4
0x78 27 0x78
0x0 28 0x0
0x1 29 0x1
0x0 30 0x0
0x33 31 0x33
0x20 32 0x20
0x32 33 0x32
0x29 34 0x29
0x73 35 0x73
0x0 36 0x0
0x0 37 0x0
0x1 38 0x1
0x2 39 0x2
0x58 40 0x58
0x0 41 0x0
0xff 42 0xff
0x0 43 0x0
0x5 44 0x5
0x3c 45 0x3c
0x93 46 0x93
0x32 47 0x32
0x14 48 0x14
0x17 49 0x17
0x46 50 0x46
0x0 51 0x0
0xeb 52 0xeb
0x9b 53 0x9b
0x86 54 0x86
0x7 55 0x7
0x14 56 0x14
0x0 57 0x0
0x0 58 0x0
0x0 59 0x0
0x0 60 0x0
0x28 61 0x28
0x0 62 0x0
0x80 63 0x80
0xff 64 0xff
0x40 65 0x40
0x0 66 0x0
0x2 67 0x2
0x1 68 0x1
0x0 69 0x0
0x4 70 0x4
0x78 71 0x78
0x0 72 0x0
0x1 73 0x1
0x0 74 0x0
0x33 75 0x33
0x20 76 0x20
0x32 77 0x32
0x29 78 0x29
0x73 79 0x73
0x0 80 0x0
0x0 81 0x0
0x1 82 0x1
0x2 83 0x2
0x58 84 0x58
0x0 85 0x0
0xff 86 0xff
0x0 87 0x0
0x5 88 0x5
0x3c 89 0x3c
0x93 90 0x93
0x32 91 0x32
0x14 92 0x14
0x17 93 0x17
0x46 94 0x46
0x0 95 0x0
0xeb 96 0xeb
0x9b 97 0x9b
0x86 98 0x86
0x7 99 0x7
0x14 100 0x14
0x0 101 0x0
0x0 102 0x0
0x0 103 0x0
0x0 104 0x0
0x0 105 0x0
0x0 106 0x0
0x0 107 0x0
0xff 108 0xff
0x40 109 0x40
0x0 110 0x0
0x2 111 0x2
0x1 112 0x1
0x0 113 0x0
0x4 114 0x4
0x78 115 0x78
0x0 116 0x0
0x1 117 0x1
0x0 118 0x0
0x33 119 0x33
0x20 120 0x20
0x32 121 0x32
0x29 122 0x29
0x73 123 0x73
0x0 124 0x0
0x0 125 0x0
0x1 126 0x1
0x2 127 0x2
0x58 128 0x58
Error: Failed to decode, please try again. Exiting

Chris.

Chris, I am working on a C program to read my systems devices and I'm trying to figure out what you and Paul may already know. Hope I am not bugging you.

python MagPy.py -p /dev/ttyUSB0
MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

(1, '0x40')
(2, '0x0')
(3, '0x1')
(4, '0xf8')
(5, '0x0')
(6, '0x13')
(7, '0x79')
(8, '0xb4')
(9, '0x1')
(10, '0x0')
(11, '0x33')
(12, '0x17')
(13, '0x35')
(14, '0x24')
(15, '0x73')
(16, '0x1')
(17, '0x0')
(18, '0x7')
(19, '0x2')
(20, '0x58')
(21, '0x0')
(22, '0xff')
(23, '0x0')
(24, '0x0')
(25, '0xda')
(26, '0x8a')
(27, '0x64')
(28, '0x3c')
(29, '0x20')
(30, '0x6')
(31, '0x0')
(32, '0xd2')
(33, '0xff')
(34, '0x88')
(35, '0x0')
(36, '0x14')
(37, '0x0')
(38, '0x31')
(39, '0x0')
(40, '0x0')
(41, '0xb5')
(42, '0x0')
(43, '0x80')
(44, '0x81')
(45, '0x5c')
(46, '0x13')
(47, '0xaa')
(48, '0xff')
(49, '0x22')
(50, '0x12')
(51, '0x76')
(52, '0x16')
(53, '0x8')
(54, '0xff')
(55, '0x6d')
(56, '0xff')
(57, '0xff')
(58, '0x1')
(59, '0x84')
(60, '0xa')
(61, '0x1')
Decoding Packets Remote_Base, BMK80, BMK81
(1, '0x40')
(2, '0x0')
(3, '0x1')
(4, '0xf8')
(5, '0x0')
(6, '0x13')
(7, '0x79')
(8, '0xb4')
(9, '0x1')
(10, '0x0')
(11, '0x33')
(12, '0x17')
(13, '0x35')
(14, '0x24')
(15, '0x73')
(16, '0x1')
(17, '0x0')
(18, '0x7')
(19, '0x2')
(20, '0x58')
(21, '0x0')
(22, '0xff')
(23, '0x0')
(24, '0x0')
(25, '0xda')
(26, '0x8a')
(27, '0x64')
(28, '0x3c')
(29, '0x20')
(30, '0x6')
(31, '0x0')
(32, '0xd2')
(33, '0xff')
(34, '0x88')
(35, '0x0')
(36, '0x14')
(37, '0x0')
(38, '0x31')
(39, '0x14')
(40, '0x0')
(41, '0x73')
(42, '0x0')
(43, '0xa0')
(44, '0xa1')
(45, '0x1')
(46, '0x35')
(47, '0x4b')
(48, '0x0')
(49, '0x7d')
Decoding Packets Remote_Base, A0, A1
(1, '0x40')
(2, '0x0')
(3, '0x1')
(4, '0xf8')
(5, '0x0')
(6, '0x12')
(7, '0x78')
(8, '0xae')
(9, '0x1')
(10, '0x0')
(11, '0x33')
(12, '0x17')
(13, '0x35')
(14, '0x24')
(15, '0x73')
(16, '0x1')
(17, '0x0')
(18, '0x7')
(19, '0x2')
(20, '0x58')
(21, '0x0')
(22, '0xff')
(23, '0x0')
(24, '0x0')
(25, '0xda')
(26, '0x8a')
(27, '0x64')
(28, '0x3c')
(29, '0x20')
(30, '0x6')
(31, '0x0')
(32, '0xd2')
(33, '0xff')
(34, '0x88')
(35, '0x0')
(36, '0x14')
(37, '0x60')
(38, '0x0')
(39, '0x90')
(40, '0x78')
(41, '0x78')
(42, '0x78')
(43, '0xa1')
(44, '0xa2')
(45, '0x0')
(46, '0x0')
(47, '0x0')
(48, '0x0')
(49, '0x0')
Decoding Packets Remote_Base, A1, A2
(1, '0x40')
(2, '0x0')
(3, '0x1')
(4, '0xf8')
(5, '0x0')
(6, '0x12')
(7, '0x78')
(8, '0xae')
(9, '0x1')
(10, '0x0')
(11, '0x33')
(12, '0x17')
(13, '0x35')
(14, '0x24')
(15, '0x73')
(16, '0x1')
(17, '0x0')
(18, '0x7')
(19, '0x2')
(20, '0x58')
(21, '0x0')
(22, '0xff')
(23, '0x0')
(24, '0x0')
(25, '0xda')
(26, '0x8a')
(27, '0x64')
(28, '0x3c')
(29, '0x20')
(30, '0x6')
(31, '0x0')
(32, '0xd2')
(33, '0xff')
(34, '0x88')
(35, '0x0')
(36, '0x14')
(37, '0x0')
(38, '0x5a')
(39, '0x0')
(40, '0x78')
(41, '0x4')
(42, '0x78')
(43, '0xa2')
(44, '0xa1')
(45, '0x1')
(46, '0x35')
(47, '0x4b')
(48, '0x0')
(49, '0x7d')
(50, '0x40')
(51, '0x0')
(52, '0x1')
(53, '0xf8')
(54, '0x0')
(55, '0x13')
(56, '0x78')
(57, '0xae')
(58, '0x1')
(59, '0x0')
(60, '0x33')
(61, '0x17')
(62, '0x35')
(63, '0x24')
(64, '0x73')
(65, '0x1')
(66, '0x0')
(67, '0x7')
(68, '0x2')
(69, '0x58')
(70, '0x0')
(71, '0xff')
(72, '0x0')
(73, '0x0')
(74, '0xda')
(75, '0x8a')
(76, '0x64')
(77, '0x3c')
(78, '0x20')
(79, '0x6')
(80, '0x0')
(81, '0xd2')
(82, '0xff')
(83, '0x88')
(84, '0x0')
(85, '0x14')
(86, '0x60')
(87, '0x28')
(88, '0x0')
(89, '0x20')
(90, '0xa')
(91, '0x0')
(92, '0xa3')
(93, '0x91')
(94, '0x20')
(95, '0x40')
(96, '0x0')
(97, '0x1')
(98, '0xf8')
(99, '0x0')
(100, '0x12')
(101, '0x78')
(102, '0xae')
(103, '0x1')
(104, '0x0')
(105, '0x33')
(106, '0x17')
(107, '0x35')
(108, '0x24')
(109, '0x73')
(110, '0x1')
(111, '0x0')
(112, '0x7')
(113, '0x2')
(114, '0x58')
(115, '0x0')
(116, '0xff')
(117, '0x0')
(118, '0x0')
(119, '0xda')
(120, '0x8a')
(121, '0x64')
(122, '0x3c')
(123, '0x20')
(124, '0x6')
(125, '0x0')
(126, '0xd2')
(127, '0xff')
(128, '0x88')
Error: Failed to decode, please try again. Exiting
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 16, 2019, 05:32:47 AM
Chris or Paul

Did a little more work and was able to read all the packets on the network. I haven't decoded all of them or completely confirmed the packets are individual but, the code reads very reliably and reports data very quickly now without fail, so far.

I have these devices connected
2 inverters
1 Router
1 AGS-N
1 BMK
1 Mag-WEB

Here is what it looks like now.

python MagPy.py -p /dev/ttyUSB0
MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

(0.031391143798828125, 1, '0x40')
(0.031391143798828125, 2, '0x0')
(0.031391143798828125, 3, '0x1')
(0.031391143798828125, 4, '0xf8')
(0.031391143798828125, 5, '0x0')
(0.031391143798828125, 6, '0xc')
(0.031391143798828125, 7, '0x79')
(0.031391143798828125, 8, '0xbb')
(0.031391143798828125, 9, '0x1')
(0.031391143798828125, 10, '0x0')
(0.031391143798828125, 11, '0x33')
(0.031391143798828125, 12, '0x17')
(0.031391143798828125, 13, '0x39')
(0.031391143798828125, 14, '0x26')
(0.031391143798828125, 15, '0x73')
(0.031391143798828125, 16, '0x1')
(0.031391143798828125, 17, '0x0')
(0.031391143798828125, 18, '0x4')
(0.031391143798828125, 19, '0x2')
(0.031391143798828125, 20, '0x58')
(0.031391143798828125, 21, '0x0')
(0.031391143798828125, 22, '0xff')
(0.031391143798828125, 23, '0x0')
(0.031391143798828125, 24, '0x0')
(0.031391143798828125, 25, '0xda')
(0.031391143798828125, 26, '0x8a')
(0.031391143798828125, 27, '0x64')
(0.031391143798828125, 28, '0x3c')
(0.031391143798828125, 29, '0x20')
(0.031391143798828125, 30, '0x6')
(0.031391143798828125, 31, '0x0')
(0.031391143798828125, 32, '0xd2')
(0.031391143798828125, 33, '0xff')
(0.031391143798828125, 34, '0x88')
(0.031391143798828125, 35, '0x0')
(0.031391143798828125, 36, '0x14')
(0.031391143798828125, 37, '0x14')
(0.031391143798828125, 38, '0x87')
(0.031391143798828125, 39, '0x0')
(0.031391143798828125, 40, '0x0')
(0.031391143798828125, 41, '0x0')
(0.031391143798828125, 42, '0x0')
(0.031391143798828125, 43, '0x11')
Decoding Packets Remote_Base, Z0
(0.031391143798828125, 1, '0x91')
(0.031391143798828125, 2, '0x20')
Possibly Router
(0.031391143798828125, 1, '0x40')
(0.031391143798828125, 2, '0x0')
(0.031391143798828125, 3, '0x1')
(0.031391143798828125, 4, '0xf8')
(0.031391143798828125, 5, '0x0')
(0.031391143798828125, 6, '0xc')
(0.031391143798828125, 7, '0x77')
(0.031391143798828125, 8, '0xbc')
(0.031391143798828125, 9, '0x1')
(0.031391143798828125, 10, '0x0')
(0.031391143798828125, 11, '0x33')
(0.031391143798828125, 12, '0x17')
(0.031391143798828125, 13, '0x39')
(0.031391143798828125, 14, '0x26')
(0.031391143798828125, 15, '0x73')
(0.031391143798828125, 16, '0x1')
(0.031391143798828125, 17, '0x0')
(0.031391143798828125, 18, '0x4')
(0.031391143798828125, 19, '0x2')
(0.031391143798828125, 20, '0x58')
(0.031391143798828125, 21, '0x0')
(0.031391143798828125, 22, '0xff')
(0.031391143798828125, 23, '0x0')
(0.031391143798828125, 24, '0x0')
(0.031391143798828125, 25, '0xda')
(0.031391143798828125, 26, '0x8a')
(0.031391143798828125, 27, '0x64')
(0.031391143798828125, 28, '0x3c')
(0.031391143798828125, 29, '0x20')
(0.031391143798828125, 30, '0x6')
(0.031391143798828125, 31, '0x0')
(0.031391143798828125, 32, '0xd2')
(0.031391143798828125, 33, '0xff')
(0.031391143798828125, 34, '0x88')
(0.031391143798828125, 35, '0x0')
(0.031391143798828125, 36, '0x14')
(0.031391143798828125, 37, '0x0')
(0.031391143798828125, 38, '0x0')
(0.031391143798828125, 39, '0x0')
(0.031391143798828125, 40, '0x0')
(0.031391143798828125, 41, '0x0')
(0.031391143798828125, 42, '0x0')
(0.031391143798828125, 43, '0x0')
Decoding Packets Remote_Base, Z0
(0.031391143798828125, 1, '0x40')
(0.031391143798828125, 2, '0x0')
(0.031391143798828125, 3, '0x1')
(0.031391143798828125, 4, '0xf8')
(0.031391143798828125, 5, '0x0')
(0.031391143798828125, 6, '0xc')
(0.031391143798828125, 7, '0x77')
(0.031391143798828125, 8, '0xbc')
(0.031391143798828125, 9, '0x1')
(0.031391143798828125, 10, '0x0')
(0.031391143798828125, 11, '0x33')
(0.031391143798828125, 12, '0x17')
(0.031391143798828125, 13, '0x39')
(0.031391143798828125, 14, '0x26')
(0.031391143798828125, 15, '0x73')
(0.031391143798828125, 16, '0x1')
(0.031391143798828125, 17, '0x0')
(0.031391143798828125, 18, '0x4')
(0.031391143798828125, 19, '0x2')
(0.031391143798828125, 20, '0x58')
(0.031391143798828125, 21, '0x0')
(0.031391143798828125, 22, '0xff')
(0.031391143798828125, 23, '0x0')
(0.031391143798828125, 24, '0x0')
(0.031391143798828125, 25, '0xda')
(0.031391143798828125, 26, '0x8a')
(0.031391143798828125, 27, '0x64')
(0.031391143798828125, 28, '0x3c')
(0.031391143798828125, 29, '0x20')
(0.031391143798828125, 30, '0x6')
(0.031391143798828125, 31, '0x0')
(0.031391143798828125, 32, '0xd2')
(0.031391143798828125, 33, '0xff')
(0.031391143798828125, 34, '0x88')
(0.031391143798828125, 35, '0x0')
(0.031391143798828125, 36, '0x14')
(0.031391143798828125, 37, '0x4')
(0.031391143798828125, 38, '0x1e')
(0.031391143798828125, 39, '0x0')
(0.031391143798828125, 40, '0x0')
(0.031391143798828125, 41, '0xb5')
(0.031391143798828125, 42, '0x0')
(0.031391143798828125, 43, '0x80')
(0.031391143798828125, 44, '0x81')
(0.031391143798828125, 45, '0x57')
(0.031391143798828125, 46, '0x13')
(0.031391143798828125, 47, '0x9a')
(0.031391143798828125, 48, '0xff')
(0.031391143798828125, 49, '0x7e')
(0.031391143798828125, 50, '0x12')
(0.031391143798828125, 51, '0x76')
(0.031391143798828125, 52, '0x16')
(0.031391143798828125, 53, '0x8')
(0.031391143798828125, 54, '0xff')
(0.031391143798828125, 55, '0x16')
(0.031391143798828125, 56, '0xff')
(0.031391143798828125, 57, '0xff')
(0.031391143798828125, 58, '0x1')
(0.031391143798828125, 59, '0x85')
(0.031391143798828125, 60, '0xa')
(0.031391143798828125, 61, '0x1')
Decoding Packets Remote_Base, BMK80, BMK81
(0.031391143798828125, 1, '0x40')
(0.031391143798828125, 2, '0x0')
(0.031391143798828125, 3, '0x1')
(0.031391143798828125, 4, '0xf8')
(0.031391143798828125, 5, '0x0')
(0.031391143798828125, 6, '0xc')
(0.031391143798828125, 7, '0x77')
(0.031391143798828125, 8, '0xbc')
(0.031391143798828125, 9, '0x1')
(0.031391143798828125, 10, '0x0')
(0.031391143798828125, 11, '0x33')
(0.031391143798828125, 12, '0x17')
(0.031391143798828125, 13, '0x39')
(0.031391143798828125, 14, '0x26')
(0.031391143798828125, 15, '0x73')
(0.031391143798828125, 16, '0x1')
(0.031391143798828125, 17, '0x0')
(0.031391143798828125, 18, '0x4')
(0.031391143798828125, 19, '0x2')
(0.031391143798828125, 20, '0x58')
(0.031391143798828125, 21, '0x0')
(0.031391143798828125, 22, '0xff')
(0.031391143798828125, 23, '0x0')
(0.031391143798828125, 24, '0x0')
(0.031391143798828125, 25, '0xda')
(0.031391143798828125, 26, '0x8a')
(0.031391143798828125, 27, '0x64')
(0.031391143798828125, 28, '0x3c')
(0.031391143798828125, 29, '0x20')
(0.031391143798828125, 30, '0x6')
(0.031391143798828125, 31, '0x0')
(0.031391143798828125, 32, '0xd2')
(0.031391143798828125, 33, '0xff')
(0.031391143798828125, 34, '0x88')
(0.031391143798828125, 35, '0x0')
(0.031391143798828125, 36, '0x14')
(0.031391143798828125, 37, '0x4')
(0.031391143798828125, 38, '0x1e')
(0.031391143798828125, 39, '0x14')
(0.031391143798828125, 40, '0x0')
(0.031391143798828125, 41, '0x73')
(0.031391143798828125, 42, '0x0')
(0.031391143798828125, 43, '0xa0')
(0.031391143798828125, 44, '0xa1')
(0.031391143798828125, 45, '0x1')
(0.031391143798828125, 46, '0x35')
(0.031391143798828125, 47, '0x4b')
(0.031391143798828125, 48, '0x0')
(0.031391143798828125, 49, '0x7c')
Decoding Packets Remote_Base, A0, A1
(0.031391143798828125, 1, '0x40')
(0.031391143798828125, 2, '0x0')
(0.031391143798828125, 3, '0x1')
(0.031391143798828125, 4, '0xf8')
(0.031391143798828125, 5, '0x0')
(0.031391143798828125, 6, '0xc')
(0.031391143798828125, 7, '0x77')
(0.031391143798828125, 8, '0xbc')
(0.031391143798828125, 9, '0x1')
(0.031391143798828125, 10, '0x0')
(0.031391143798828125, 11, '0x33')
(0.031391143798828125, 12, '0x17')
(0.031391143798828125, 13, '0x39')
(0.031391143798828125, 14, '0x26')
(0.031391143798828125, 15, '0x73')
(0.031391143798828125, 16, '0x1')
(0.031391143798828125, 17, '0x0')
(0.031391143798828125, 18, '0x4')
(0.031391143798828125, 19, '0x2')
(0.031391143798828125, 20, '0x58')
(0.031391143798828125, 21, '0x0')
(0.031391143798828125, 22, '0xff')
(0.031391143798828125, 23, '0x0')
(0.031391143798828125, 24, '0x0')
(0.031391143798828125, 25, '0xda')
(0.031391143798828125, 26, '0x8a')
(0.031391143798828125, 27, '0x64')
(0.031391143798828125, 28, '0x3c')
(0.031391143798828125, 29, '0x20')
(0.031391143798828125, 30, '0x6')
(0.031391143798828125, 31, '0x0')
(0.031391143798828125, 32, '0xd2')
(0.031391143798828125, 33, '0xff')
(0.031391143798828125, 34, '0x88')
(0.031391143798828125, 35, '0x0')
(0.031391143798828125, 36, '0x14')
(0.031391143798828125, 37, '0x60')
(0.031391143798828125, 38, '0x0')
(0.031391143798828125, 39, '0x90')
(0.031391143798828125, 40, '0x78')
(0.031391143798828125, 41, '0x78')
(0.031391143798828125, 42, '0x78')
(0.031391143798828125, 43, '0xa1')
(0.031391143798828125, 44, '0xa2')
(0.031391143798828125, 45, '0x0')
(0.031391143798828125, 46, '0x0')
(0.031391143798828125, 47, '0x0')
(0.031391143798828125, 48, '0x0')
(0.031391143798828125, 49, '0x0')
Decoding Packets Remote_Base, A1, A2
(0.031391143798828125, 1, '0x40')
(0.031391143798828125, 2, '0x0')
(0.031391143798828125, 3, '0x1')
(0.031391143798828125, 4, '0xf8')
(0.031391143798828125, 5, '0x0')
(0.031391143798828125, 6, '0xc')
(0.031391143798828125, 7, '0x77')
(0.031391143798828125, 8, '0xbc')
(0.031391143798828125, 9, '0x1')
(0.031391143798828125, 10, '0x0')
(0.031391143798828125, 11, '0x33')
(0.031391143798828125, 12, '0x17')
(0.031391143798828125, 13, '0x39')
(0.031391143798828125, 14, '0x26')
(0.031391143798828125, 15, '0x73')
(0.031391143798828125, 16, '0x1')
(0.031391143798828125, 17, '0x0')
(0.031391143798828125, 18, '0x4')
(0.031391143798828125, 19, '0x2')
(0.031391143798828125, 20, '0x58')
(0.031391143798828125, 21, '0x0')
(0.031391143798828125, 22, '0xff')
(0.031391143798828125, 23, '0x0')
(0.031391143798828125, 24, '0x0')
(0.031391143798828125, 25, '0xda')
(0.031391143798828125, 26, '0x8a')
(0.031391143798828125, 27, '0x64')
(0.031391143798828125, 28, '0x3c')
(0.031391143798828125, 29, '0x20')
(0.031391143798828125, 30, '0x6')
(0.031391143798828125, 31, '0x0')
(0.031391143798828125, 32, '0xd2')
(0.031391143798828125, 33, '0xff')
(0.031391143798828125, 34, '0x88')
(0.031391143798828125, 35, '0x0')
(0.031391143798828125, 36, '0x14')
(0.031391143798828125, 37, '0x0')
(0.031391143798828125, 38, '0x5a')
(0.031391143798828125, 39, '0x0')
(0.031391143798828125, 40, '0x78')
(0.031391143798828125, 41, '0x4')
(0.031391143798828125, 42, '0x78')
(0.031391143798828125, 43, '0xa2')
(0.031391143798828125, 44, '0xa1')
(0.031391143798828125, 45, '0x1')
(0.031391143798828125, 46, '0x35')
(0.031391143798828125, 47, '0x4b')
(0.031391143798828125, 48, '0x0')
(0.031391143798828125, 49, '0x7c')
Not sure what this packet is
(0.031391143798828125, 1, '0x40')
(0.031391143798828125, 2, '0x0')
(0.031391143798828125, 3, '0x1')
(0.031391143798828125, 4, '0xf8')
(0.031391143798828125, 5, '0x0')
(0.031391143798828125, 6, '0xc')
(0.031391143798828125, 7, '0x77')
(0.031391143798828125, 8, '0xbc')
(0.031391143798828125, 9, '0x1')
(0.031391143798828125, 10, '0x0')
(0.031391143798828125, 11, '0x33')
(0.031391143798828125, 12, '0x17')
(0.031391143798828125, 13, '0x39')
(0.031391143798828125, 14, '0x26')
(0.031391143798828125, 15, '0x73')
(0.031391143798828125, 16, '0x1')
(0.031391143798828125, 17, '0x0')
(0.031391143798828125, 18, '0x4')
(0.031391143798828125, 19, '0x2')
(0.031391143798828125, 20, '0x58')
(0.031391143798828125, 21, '0x0')
(0.031391143798828125, 22, '0xff')
(0.031391143798828125, 23, '0x0')
(0.031391143798828125, 24, '0x0')
(0.031391143798828125, 25, '0xda')
(0.031391143798828125, 26, '0x8a')
(0.031391143798828125, 27, '0x64')
(0.031391143798828125, 28, '0x3c')
(0.031391143798828125, 29, '0x20')
(0.031391143798828125, 30, '0x6')
(0.031391143798828125, 31, '0x0')
(0.031391143798828125, 32, '0xd2')
(0.031391143798828125, 33, '0xff')
(0.031391143798828125, 34, '0x88')
(0.031391143798828125, 35, '0x0')
(0.031391143798828125, 36, '0x14')
(0.031391143798828125, 37, '0x60')
(0.031391143798828125, 38, '0x28')
(0.031391143798828125, 39, '0x0')
(0.031391143798828125, 40, '0x20')
(0.031391143798828125, 41, '0xa')
(0.031391143798828125, 42, '0x0')
(0.031391143798828125, 43, '0xa3')
Decoding Packets Remote_Base, A3
(0.031391143798828125, 1, '0x91')
(0.031391143798828125, 2, '0x20')
Possibly Router
(0.031391143798828125, 1, '0x40')
(0.031391143798828125, 2, '0x0')
(0.031391143798828125, 3, '0x1')
(0.031391143798828125, 4, '0xf8')
(0.031391143798828125, 5, '0x0')
(0.031391143798828125, 6, '0xc')
(0.031391143798828125, 7, '0x77')
(0.031391143798828125, 8, '0xbc')
(0.031391143798828125, 9, '0x1')
(0.031391143798828125, 10, '0x0')
(0.031391143798828125, 11, '0x33')
(0.031391143798828125, 12, '0x17')
(0.031391143798828125, 13, '0x39')
(0.031391143798828125, 14, '0x26')
(0.031391143798828125, 15, '0x73')
(0.031391143798828125, 16, '0x1')
(0.031391143798828125, 17, '0x0')
(0.031391143798828125, 18, '0x4')
(0.031391143798828125, 19, '0x2')
(0.031391143798828125, 20, '0x58')
(0.031391143798828125, 21, '0x0')
(0.031391143798828125, 22, '0xff')
(0.031391143798828125, 23, '0x0')
(0.031391143798828125, 24, '0x0')
(0.031391143798828125, 25, '0xda')
(0.031391143798828125, 26, '0x8a')
(0.031391143798828125, 27, '0x64')
(0.031391143798828125, 28, '0x3c')
(0.031391143798828125, 29, '0x20')
(0.031391143798828125, 30, '0x6')
(0.031391143798828125, 31, '0x0')
(0.031391143798828125, 32, '0xd2')
(0.031391143798828125, 33, '0xff')
(0.031391143798828125, 34, '0x88')
(0.031391143798828125, 35, '0x0')
(0.031391143798828125, 36, '0x14')
(0.031391143798828125, 37, '0x3c')
(0.031391143798828125, 38, '0x3c')
(0.031391143798828125, 39, '0x0')
(0.031391143798828125, 40, '0x20')
(0.031391143798828125, 41, '0x0')
(0.031391143798828125, 42, '0x0')
(0.031391143798828125, 43, '0xa4')
Decoding Packets Remote_Base, A4

Live Data
   Clock                     04:30
   Inverter Mode:            Invert
   Fault:                    No Faults

   Inverter Input Volts:     50.4 Vdc
   Inverter Input Amps:      12 Amps DC

   Inverter Output AC Volts: 119 Vac
   Inverter Output AC Amps:  4 Amps
   External Input AC Volts:  188 Vac
   External Input AC Amps:   0 Amps
   Inverter Line Frequency   60.0 Hz

   Temperature Battery       23 C
   Temperature Transformer   57 C
   Temperature FETs          38 C

   Generator Run Time        0.0 Hrs
   Generator Last Run        1 Days

Remote - ver(3.2)
   Status:                   Remote Command Clear

Router - ver(0)

BMK - ver(1.0)
   Fault Status:             No Faults
   Battery Volts DC:         50.18 Vdc
   Amps DC:                  12.9 Amps
   Battery Max:              56.4 Vdc
   Battery Min:              47.26 Vdc
   Battery Amp Hour Net      233 AmpHr
   Battery Amp Hour Trip     6553 AmpHr
   Battery Amp Hour Total    38900 AmpHr

AGS - ver(5.3)
   Status:                   Off
   Gen Start Mode:           Off
   Quiet Hours:              Off
      Quiet Time Start  24.0 Hrs
      Quiet Time Stop   10.0 Hrs

   Auto Start                Enabled
      Start Time        0.0 Hrs
      Stop Time         22.5 Hrs

   Start Delay               120 Sec
   Stop Delay                4 Sec
   Warm Up Time              60 Sec
   Cool Down Time            60 Sec
   SOC Start                 0 %
   SOC Stop                  0 %
   Amps Start                0 Amps
   Amps Stop                 0 Amps
      Amps Start Delay  0 Sec
      Amps Stop Delay   0 Sec

   Maximum Run Time          12.0 Hrs
   Top Off Time              0 Min
   Exercise Day Period       0 Days
   Exercise Start Time       8.0 Hrs
   Exercise Run Time         1 Hrs
   Start Temperature         0 F
   Start Volts               46.0 Vdc
   Stop Volts                0.0 Vdc

Inverter - ver(5.1)
   Inverter Model ID:        0x73
   System Buss Voltage:      48 Vdc
   Inverter Stack Mode:      Master in Parallel Stack
   Search Watts:             0 Watts
   Charger Amps:             100 %
   Shore AC Amps:            60 Amps
   Parallel Threshold:       60 %
   AC Volts Trip:            255 Vac

Battery Settings
   Battery Size, remote:     2180 AmpHr
   Battery Size, BMK:        1810 AmpHr
   Battery Type:             Custom
   Battery Efficiency:       0 %
   Float Volts:              54.4 Vdc
   Absorb Volts:             55.2 Vdc
   Equalise Volts:           55.2 Vdc
   Battery Low Trip:         42.0 Vdc

Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 16, 2019, 06:08:40 AM
~ $ python MagPy.py
MagPy Magnum Energy MagnaSine Data Protocol Decoder

Debug level : 0
serial port : /dev/ttyUSB0

Decoding Packets Remote_Base, Z0
Possibly Router
Decoding Packets Remote_Base, Z0
Decoding Packets Remote_Base, BMK80, BMK81
Decoding Packets Remote_Base, A0, A1
Decoding Packets Remote_Base, A1, A2
Not sure what this packet is
Decoding Packets Remote_Base, A3
Possibly Router
Decoding Packets Remote_Base, A4

Live Data
        Clock                     05:12
        Inverter Mode:            Invert
        Fault:                    No Faults

        Inverter Input Volts:     50.3 Vdc
        Inverter Input Amps:      14 Amps DC

        Inverter Output AC Volts: 121 Vac
        Inverter Output AC Amps:  5 Amps
        External Input AC Volts:  173 Vac
        External Input AC Amps:   0 Amps
        Inverter Line Frequency   60.0 Hz

        Temperature Battery       23 C
        Temperature Transformer   54 C
        Temperature FETs          38 C

        Generator Run Time        0.0 Hrs
        Generator Last Run        1 Days

Remote - ver(3.2)
        Status:                   Remote Command Clear

Router - ver(0)

BMK - ver(1.0)
        Fault Status:             No Faults
        Battery Volts DC:         50.08 Vdc
        Amps DC:                  15.9 Amps
        Battery Max:              56.4 Vdc
        Battery Min:              47.26 Vdc
        Battery Amp Hour Net      244 AmpHr
        Battery Amp Hour Trip     6553 AmpHr
        Battery Amp Hour Total    38900 AmpHr

AGS - ver(5.3)
        Status:                   Off
        Gen Start Mode:           Off
        Quiet Hours:              Off
                Quiet Time Start  24.0 Hrs
                Quiet Time Stop   10.0 Hrs

        Auto Start                Enabled
                Start Time        0.0 Hrs
                Stop Time         22.5 Hrs

        Start Delay               120 Sec
        Stop Delay                4 Sec
        Warm Up Time              60 Sec
        Cool Down Time            60 Sec
        SOC Start                 0 %
        SOC Stop                  0 %
        Amps Start                0 Amps
        Amps Stop                 0 Amps
                Amps Start Delay  0 Sec
                Amps Stop Delay   0 Sec

        Maximum Run Time          12.0 Hrs
        Top Off Time              0 Min
        Exercise Day Period       0 Days
        Exercise Start Time       8.0 Hrs
        Exercise Run Time         1 Hrs
        Start Temperature         0 F
        Start Volts               46.0 Vdc
        Stop Volts                0.0 Vdc

Inverter - ver(5.1)
        Inverter Model ID:        0x73
        System Buss Voltage:      48 Vdc
        Inverter Stack Mode:      Master in Parallel Stack
        Search Watts:             0 Watts
        Charger Amps:             100 %
        Shore AC Amps:            60 Amps
        Parallel Threshold:       60 %
        AC Volts Trip:            255 Vac

Battery Settings
        Battery Size, remote:     2180 AmpHr
        Battery Size, BMK:        1810 AmpHr
        Battery Type:             Custom
        Battery Efficiency:       0 %
        Float Volts:              54.4 Vdc
        Absorb Volts:             55.2 Vdc
        Equalise Volts:           55.2 Vdc
        Battery Low Trip:         42.0 Vdc
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 18, 2019, 01:19:13 PM
The router packet appears to be sent independent of any other packet. Since this code reads the stream until each data packet is met by certain identifiers, knowing what belongs with what packet due to the limited Magnum documentation, is not certain. I'll move on to coding by timing packets. This subject doesn't seem popular anymore but, I can include the code if someone wants it.

Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on January 18, 2019, 02:16:26 PM
Hi Watt_,

I have not messed with my solar stuff for a couple of years, but I see that you are making some inroads.

I would be interested to see your code.

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 18, 2019, 07:26:51 PM
Quote from: cpfl on January 18, 2019, 02:16:26 PM
Hi Watt_,

I have not messed with my solar stuff for a couple of years, but I see that you are making some inroads.

I would be interested to see your code.

Chris.

Chris, I will upload the changed code. I hope Paul doesn't mind. I best add a note in the header.  I'll make a few changes to clean up my mess. I probably won't revisit this code unless you find a need.  Thanks for your time in this.

*****On second thought, I should have considered asking you if you would be interested in running version of the changed code to see if it will complete on your system and decode your hardware.  Would you be so inclined?   
Thanks again.

Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: cpfl on January 18, 2019, 08:02:21 PM
Watt_,

I would like to run the changed code and see if it will complete on my system.

Chris.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 18, 2019, 09:34:26 PM
Quote from: cpfl on January 18, 2019, 08:02:21 PM
Watt_,

I would like to run the changed code and see if it will complete on my system.

Chris.

Chris, I will attach the code. If you get a readout of some sort with all zeros or the program stops, there is a reason for each. The zeros mean the data is being added to a buffer in the middle of a stream. Because the data checks are done via known data markers, there is no way to clear the buffer without a lot of effort or at least more than is needed at this point. Simply restart again until the program runs and either stops or reports data. If the program stops, that means it has copied 5 seconds of stream. Either way, you might copy the stream to a text file and post it so we can view the data or post all of it here if it will fit. It will time out after 5 seconds and exit. If you get data in the end, please post that data.  We can clean the code up later but for now, I'd like to try this. Thank you. Please find attached.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 19, 2019, 05:00:31 PM
Here is a byte/time txt file of about 350 some odd bytes read from the RS485 connection. This is python so the times are a bit slower than what I see with C. Could be my poor coding skills causing the increased time from processing overhead but...  Here it is at any rate.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 19, 2019, 06:00:41 PM
C code results reading 256 bytes from the stream.

loop number : First byte in loop : Second byte in loop : time between first Byte read and Second byte :


(1, '0x0', '0x1', 4.506111145019531e-05)
(2, '0x40', '0x0', 4.220008850097656e-05)
(3, '0x2', '0x14', 3.695487976074219e-05)
(4, '0x0', '0xe', 3.600120544433594e-05)
(5, '0x78', '0xae', 3.695487976074219e-05)
(6, '0x1', '0x0', 3.4809112548828125e-05)
(7, '0x33', '0x16', 3.504753112792969e-05)
(8, '0x33', '0x23', 3.600120544433594e-05)
(9, '0x73', '0x1', 3.504753112792969e-05)
(10, '0x0', '0x5', 3.600120544433594e-05)
(11, '0x2', '0x58', 3.600120544433594e-05)
(12, '0x0', '0xfe', 3.504753112792969e-05)
(13, '0x0', '0x0', 3.504753112792969e-05)
(14, '0xda', '0x8a', 3.600120544433594e-05)
(15, '0x64', '0x3c', 3.600120544433594e-05)
(16, '0x20', '0x6', 3.695487976074219e-05)
(17, '0x0', '0xd2', 3.600120544433594e-05)
(18, '0xff', '0x88', 3.600120544433594e-05)
(19, '0x0', '0x14', 3.4809112548828125e-05)
(20, '0x10', '0x3b', 3.600120544433594e-05)
(21, '0x14', '0x0', 3.504753112792969e-05)
(22, '0x73', '0x0', 3.504753112792969e-05)
(23, '0xa0', '0xa1', 0.015666961669921875)
(24, '0x1', '0x35', 3.504753112792969e-05)
(25, '0x4b', '0x0', 3.504753112792969e-05)
(26, '0x84', '0x40', 0.06273984909057617)
(27, '0x0', '0x2', 3.504753112792969e-05)
(28, '0x14', '0x0', 3.504753112792969e-05)
(29, '0xe', '0x78', 3.504753112792969e-05)
(30, '0xae', '0x1', 3.504753112792969e-05)
(31, '0x0', '0x33', 3.600120544433594e-05)
(32, '0x16', '0x33', 0.015802860260009766)
(33, '0x23', '0x73', 3.504753112792969e-05)
(34, '0x1', '0x0', 3.504753112792969e-05)
(35, '0x5', '0x2', 3.600120544433594e-05)
(36, '0x58', '0x0', 3.409385681152344e-05)
(37, '0xff', '0x0', 0.01590895652770996)
(38, '0x0', '0xda', 3.504753112792969e-05)
(39, '0x8a', '0x64', 3.504753112792969e-05)
(40, '0x3c', '0x20', 3.4809112548828125e-05)
(41, '0x6', '0x0', 3.504753112792969e-05)
(42, '0xd2', '0xff', 3.504753112792969e-05)
(43, '0x88', '0x0', 3.504753112792969e-05)
(44, '0x14', '0x60', 3.600120544433594e-05)
(45, '0x0', '0x90', 3.600120544433594e-05)
(46, '0x78', '0x78', 3.4809112548828125e-05)
(47, '0x78', '0xa1', 3.504753112792969e-05)
(48, '0xa2', '0x0', 3.695487976074219e-05)
(49, '0x0', '0x0', 3.504753112792969e-05)
(50, '0x0', '0x0', 3.504753112792969e-05)
(51, '0x40', '0x0', 3.600120544433594e-05)
(52, '0x2', '0x14', 3.719329833984375e-05)
(53, '0x0', '0xe', 3.504753112792969e-05)
(54, '0x78', '0xae', 3.504753112792969e-05)
(55, '0x1', '0x0', 3.504753112792969e-05)
(56, '0x33', '0x16', 3.504753112792969e-05)
(57, '0x33', '0x23', 3.600120544433594e-05)
(58, '0x73', '0x1', 3.504753112792969e-05)
(59, '0x0', '0x5', 3.504753112792969e-05)
(60, '0x2', '0x58', 3.600120544433594e-05)
(61, '0x0', '0xff', 3.4809112548828125e-05)
(62, '0x0', '0x0', 3.600120544433594e-05)
(63, '0xda', '0x8a', 3.600120544433594e-05)
(64, '0x64', '0x3c', 3.504753112792969e-05)
(65, '0x20', '0x6', 3.504753112792969e-05)
(66, '0x0', '0xd2', 3.4809112548828125e-05)
(67, '0xff', '0x88', 3.4809112548828125e-05)
(68, '0x0', '0x14', 3.409385681152344e-05)
(69, '0x0', '0x5a', 3.600120544433594e-05)
(70, '0x0', '0x78', 3.504753112792969e-05)
(71, '0x4', '0x78', 3.600120544433594e-05)
(72, '0xa2', '0xa1', 3.504753112792969e-05)
(73, '0x1', '0x35', 3.600120544433594e-05)
(74, '0x4b', '0x0', 3.504753112792969e-05)
(75, '0x84', '0x40', 0.07877993583679199)
(76, '0x0', '0x2', 3.600120544433594e-05)
(77, '0x14', '0x0', 3.600120544433594e-05)
(78, '0xe', '0x78', 3.504753112792969e-05)
(79, '0xae', '0x1', 3.504753112792969e-05)
(80, '0x0', '0x33', 3.504753112792969e-05)
(81, '0x16', '0x33', 3.504753112792969e-05)
(82, '0x23', '0x73', 3.504753112792969e-05)
(83, '0x1', '0x0', 3.504753112792969e-05)
(84, '0x5', '0x2', 3.504753112792969e-05)
(85, '0x58', '0x0', 3.504753112792969e-05)
(86, '0xff', '0x0', 0.01406097412109375)
(87, '0x0', '0xda', 3.4809112548828125e-05)
(88, '0x8a', '0x64', 0.016211986541748047)
(89, '0x3c', '0x20', 3.600120544433594e-05)
(90, '0x6', '0x0', 3.504753112792969e-05)
(91, '0xd2', '0xff', 3.3855438232421875e-05)
(92, '0x88', '0x0', 3.504753112792969e-05)
(93, '0x14', '0x60', 3.504753112792969e-05)
(94, '0x28', '0x0', 3.504753112792969e-05)
(95, '0x20', '0xa', 3.4809112548828125e-05)
(96, '0x0', '0xa3', 3.600120544433594e-05)
(97, '0x91', '0x20', 3.695487976074219e-05)
(98, '0x40', '0x0', 3.600120544433594e-05)
(99, '0x2', '0x14', 3.504753112792969e-05)
(100, '0x0', '0xe', 3.504753112792969e-05)
(101, '0x78', '0xae', 3.4809112548828125e-05)
(102, '0x1', '0x0', 3.504753112792969e-05)
(103, '0x33', '0x16', 3.504753112792969e-05)
(104, '0x33', '0x23', 3.600120544433594e-05)
(105, '0x73', '0x1', 3.600120544433594e-05)
(106, '0x0', '0x5', 3.504753112792969e-05)
(107, '0x2', '0x58', 3.600120544433594e-05)
(108, '0x0', '0xff', 3.504753112792969e-05)
(109, '0x0', '0x0', 3.600120544433594e-05)
(110, '0xda', '0x8a', 3.504753112792969e-05)
(111, '0x64', '0x3c', 3.504753112792969e-05)
(112, '0x20', '0x6', 3.600120544433594e-05)
(113, '0x0', '0xd2', 3.504753112792969e-05)
(114, '0xff', '0x88', 3.504753112792969e-05)
(115, '0x0', '0x14', 3.504753112792969e-05)
(116, '0x3c', '0x3c', 3.504753112792969e-05)
(117, '0x0', '0x20', 3.3855438232421875e-05)
(118, '0x0', '0x0', 3.504753112792969e-05)
(119, '0xa4', '0x40', 0.07838702201843262)
(120, '0x0', '0x2', 0.015048027038574219)
(121, '0x14', '0x0', 3.504753112792969e-05)
(122, '0xe', '0x78', 3.504753112792969e-05)
(123, '0xae', '0x1', 3.504753112792969e-05)
(124, '0x0', '0x33', 3.504753112792969e-05)
(125, '0x16', '0x33', 3.504753112792969e-05)
(126, '0x23', '0x73', 3.504753112792969e-05)
(127, '0x1', '0x0', 3.504753112792969e-05)
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: jamesmc on January 25, 2019, 09:23:12 PM
Thanks for the effort and keeping this thread alive.  I am hoping to start testing this out.  Will help give you some feedback.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on January 26, 2019, 12:52:18 AM
Hello jamesmc,

Here are a few items I have that I've been working to test and decode:

MSH3012M
MS2012
MS4448PAE
RC
ARC
RTR
*ARTR* If it ever arrives....
BMK
ME-WEB-wired
AGS-N

I'm sure there are other devices laying around I've forgot about.  Getting as many devices decoded as possible will surely help clear up a lot of information in these packets. 

I've been working on (slowly) matching different items to different inverters to see what sort of data is sent on the data wires. I have not sent any commands as of yet to keep as many bytes unchanged.  A few minutes here and there is slow progress.
My immediate goal has been met. I'm polling ever few seconds to parse voltages and current to help sort out my Classics during charge using NewModBus from RossW. Eventually, though, I want to be able to limit the current into my batteries with the inverters are charging my batteries from and AC input source. 
A little live data. The cell balancing is a bit of trouble on these AGM cells....   http://ranges.albury.net.au/watt/index.html
And a few pics of the mess. https://www.anotherpower.com/board/index.php?PHPSESSID=qr21p23eaksht1auhe3fc7b3n6&topic=872.msg14752#new
And here is the Magnum data being sent to their server.  This is nice for comparison of data....    http://data.magnumenergy.com/mw5092
Any data you can provide would be nice. Thank you.

Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on February 03, 2019, 11:44:48 AM
After playing around with this stuff, I'm thinking the A-RTR and the PT-100 charge controller may have a lot to be learned from as far as control. Guess I better get a Magnum charge controller coming and installed.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Zardiw on March 29, 2019, 11:20:08 AM
Has anybody written any software for the Magnum Inverter that uses the Ethernet Connection to a local Network?....Similar to the Classic Status Panel software?

z
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: CharlesG on April 28, 2019, 11:05:58 AM
I know this reply is late to the party, but....

I have developed  and published a complete Magnum Energy network compatible data reader that  works with a simple REST API / JSON interface. The "reader" can be extended to support other technologies. currently I have a MorningStar Charge Controller (Modbus) and a very experimental OutBack (SunSpec) interface. Alas, no Midnite solar support but contributions are welcome.

It''s available https://gitlab.com/Magnum_Energy/distribution (https://gitlab.com/Magnum_Energy/distribution) here. It is designed to be modular so bits can be added and existing bits adapted to other uses.

Also included is a generalized data logging set of tools. It too is extensible and can log to any, or all of CSV, JSON files or directly to a MySQL database.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: boB on April 28, 2019, 03:07:27 PM

Great stuff, Charles !

Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Vic on April 28, 2019, 06:53:19 PM
Thanks Charles for sharing your work.   These tools should be a great help to many,   here.   I am not quite there yet   ...

Thanks,   again,   Vic
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: CharlesG on April 29, 2019, 10:16:50 AM
I just reviewed the entire thread and, unless I missed something, I see you doing what I did when I started reading the network. My code is available at the Gitlab URL I provided earlier. I wrote mine in Java but the principles are the same in other languages.

The problem I had was finding finite records when trying the read the serial port. The Magnum protocol acts like a fire hose and just spews packets with little time in between. I too found I could not get reliable packets. My solution was to break the work into two parts.

In my application I log data every 30-60 seconds rather than maintain a full blown, full time log of packets. This allowed me to read records differently.

First I run a very tight, execution time efficient loop that just reads packets and store the result in an array. I do NO analysis at this time. Just read, store, repeat. I picked 50 as the normal count of the packets, but it is a run time parameter. 50 takes about 2 seconds and I am getting lots of packets, few malformed ones and many duplicates. But  sometimes I only get one occurrence, for example AGS generates two types of packets, the second one is infrequent. The way I read a packet is a serial read of up to 21 bytes (largest packet) into a very large buffer in case of an overrun. The read is set with timeout = 0. I loop on this, appending bytes in a packet until I get 0 bytes read. This signals I have a packet. Because this is a tight loop the code is keeping up with the fire hose. I always discard the first packet read as it's probably flawed so technically I read 51 packets but only process 50.

Now that I have the data, I can "slowly" analyze and parse the data without the need to return for more data. The net of the 50 packets is a data point. I don't worry about duplicates, i just let the latest packet overlay the earlier value. This technique is also insensitive to the devices on the network. if the device isn't there I don't get a packet. If it is there, I'll get a packet in the 2 second time span.

I have found this brute force approach provides a steady and stable set of data points. It's not the fastest for getting one packet but I'm more interested in getting complete information at one point in time. A 2 second delay is worth it. Since the number of packets collected is a run time setting, I can fine tune this as needed. A complex system with lots of devices may need a bigger sample size whereas one with just an inverter would use less.

Before I settled on this approach I tried various other techniques like measuring the delay between character reads and analyzing the packets and stopping when I had one of each. But all these routines had many bad packets. I just let the serial reader read the data, which in Java at least, it does very well, and store the result.

This may not be the ideal solution but it is working for me.

Refer to lines 118 through 133 of this program  https://gitlab.com/Magnum_Energy/distribution/blob/master/src/ca/godwin/magnum/RS485Reader.java#L118 (https://gitlab.com/Magnum_Energy/distribution/blob/master/src/ca/godwin/magnum/RS485Reader.java#L118) for the read loop
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: CharlesG on November 04, 2019, 04:17:55 PM
I have finally developed a functioning Python based program that seems to read all know Magnum Energy data packets. It is available here.

https://pypi.org/project/pymagnum/

Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on November 15, 2019, 09:14:46 AM
Hello Charles

It's been a while that I have been here and had a look at the thread. Nice to come in and see progress. I will have a look and try your software.  Thanks
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: CharlesG on November 16, 2019, 03:33:39 PM
Please let me know what happens. good, bad or ugly.

Thanks
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on November 18, 2019, 02:35:27 AM
Hello Charles

Heck of a time getting the software on my pi to spit something out. Most likely an error on my part.

I was not able to get pip of any flavor to work for me. I finally installed the build from the tar.gz file. After a bit of messing about, I got it to spit out some info. But only my router.  My wires oriented like they are, i can read  magnum data with my scripts. I haven't flipped the wires to check with yours but, here is some of the data using your py program.

Options:cleanpackets=True, device='/dev/ttyUSB0', packets=50, timeout=0.001
Length: 5 UNKNOWN   =>FC000075BC
Length: 6 UNKNOWN   =>01013316221E
Length: 5 UNKNOWN   =>7301040002
Length: 4 UNKNOWN   =>5900FF00
Length: 6 UNKNOWN   =>00DA8A643C20
Length: 5 UNKNOWN   =>0000D2BE88
Length: 6 UNKNOWN   =>0014005A0078
Length: 3 UNKNOWN   =>0478A2
Length: 3 UNKNOWN   =>000001
Length: 6 UNKNOWN   =>FB000079BB01
Length: 6 UNKNOWN   =>013316221E73
Length: 5 UNKNOWN   =>0100000259
Length: 3 UNKNOWN   =>00FF00
Length:20 UNKNOWN   =>00DA8A643C200000D2BE880014602800200A00A3
Length: 2 RTR_91    =>9120
Length:13 UNKNOWN   =>000001FB000079BB0100331622
Length: 5 UNKNOWN   =>1E73010000
Length: 4 UNKNOWN   =>025900FE
Length: 4 UNKNOWN   =>0000DA8A
Length: 6 UNKNOWN   =>643C200000D2
Length: 5 UNKNOWN   =>BE8800143C
Length: 6 UNKNOWN   =>3C00200000A4
Length: 4 UNKNOWN   =>000001FC
Length: 5 UNKNOWN   =>000079BB01
Length: 6 UNKNOWN   =>003316221E73
Packets:25 of 50 with 24 UNKNOWN, in 0.75 seconds

And the error i got...

/usr/bin/python3: Error while finding module specification for 'magnum/tools/magtest.py' (AttributeError: module 'magnum/tools/magtest' has no attribute '__path__')
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: CharlesG on November 18, 2019, 07:08:08 AM
I have opened an issue on the GitHub site https://github.com/CharlesGodwin/pymagnum/issues/3 (https://github.com/CharlesGodwin/pymagnum/issues/3) relating to the errors occurring while running the test program. I did this so others, not on this forum, can see the issue and the final resolution. This will help others.

What were your pip problems. I want to improve my documentation to ensure you and others have no further problems.

I assume you followed the steps described here. https://pymagnum.readthedocs.io/en/latest/installation.html#id1

Please tell me what errors messages you got.

If you cannot, for any reason, directly reply to the GitHub issue, send an email to magnum@godwin.ca and I will post your reply.

Thanks for your patience.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: Watt_ on November 18, 2019, 09:01:33 AM
I have included some errors in your thread, reading rs485.
Title: Re: Simple RS485 monitoring of Magnum Energy Inverter/Charger
Post by: CharlesG on November 18, 2019, 09:41:17 AM
I have posted more details on GitHub
https://github.com/CharlesGodwin/pymagnum/issues/3