Simple RS485 monitoring of Magnum Energy Inverter/Charger

Started by cpfl, May 01, 2015, 04:15:04 PM

Previous topic - Next topic

Watt_

~ $ 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

Watt_

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.


cpfl

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.
Off-Grid in a 320 sqft tiny home (plus 320 sqft attached workshop) in Texas, USA: Midnite Solar Classic 150, Magnum Energy MS4448PAE, 9 x Kyocera KD240 (2160 watts) + 9 x Kyocera KU265 (2385 watts), 16 x GC2 (400AH 48V), Raspberry Pi (ethernet & RS485 monitoring).

Watt_

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.


cpfl

Watt_,

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

Chris.
Off-Grid in a 320 sqft tiny home (plus 320 sqft attached workshop) in Texas, USA: Midnite Solar Classic 150, Magnum Energy MS4448PAE, 9 x Kyocera KD240 (2160 watts) + 9 x Kyocera KU265 (2385 watts), 16 x GC2 (400AH 48V), Raspberry Pi (ethernet & RS485 monitoring).

Watt_

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.

Watt_

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.

Watt_

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)

jamesmc

Thanks for the effort and keeping this thread alive.  I am hoping to start testing this out.  Will help give you some feedback.

Watt_

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.


Watt_

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.

Zardiw

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
Faster horses, yw, ow, mm..........

CharlesG

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 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.

boB

K7IQ 🌛  He/She/Me

Vic

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
Off Grid - Sys 1: 2ea SW+ 5548, Surrette 4KS25 1280 AH, 5.25 KW PV, Classic 150,WB, Beta Barcelona, Beta KID
Sys 2: SW+ 5548s, 4KS25s, 5.88 KW PV, 2 ea. Classic 150, WB, HB CC-needs remote Monitoring/Control, site=remote.
 MN Bkrs/Bxs/Combiners. Thanks MN for Great Products/Svc/Support&This Forum!!