gonium / gosdm630

An interface for the Eastron SDM/Modbus smart meter series.
BSD 3-Clause "New" or "Revised" License
72 stars 16 forks source link

correct abb implementation #122

Closed chrostek closed 5 years ago

chrostek commented 5 years ago

corrected power and scaling, added import

andig commented 5 years ago

Thanks for this PR. ABB meter has never been tested before due to missing physical device.

andig commented 5 years ago

LGTM. Could you- last thing- check if you're happy with the cosphi reading?

chrostek commented 5 years ago

in which range should these values be? i don't know anything about cosphi. with the latest patch i have:

L1 | L2 | L3 | Total 214745087.90 | 214745087.90 | 214748364.70 | 3168665.50

andig commented 5 years ago

-100...+100. This looks... bad. Ok, its a single register only, so snip16. And it is signed (not unsigned)!

Actually, Power is signed too, so this needs be changed as well!

chrostek commented 5 years ago

With snip16 i have:

3276.70 3276.70 3276.70 49.30
andig commented 5 years ago

Did you also make it signed?

chrostek commented 5 years ago

No, how does this work?

andig commented 5 years ago

Ahh, sorry. Just convert from int instead of uint:

// snip16i creates modbus operation for single register
func (p *ABBProducer) snip16i(iec Measurement, scaler ...float64) Operation {
    snip := p.snip(iec, 1)

    snip.Transform = RTUInt16ToFloat64 // default conversion
    if len(scaler) > 0 {
        snip.Transform = MakeScaledTransform(snip.Transform, scaler[0])
    }

    return snip
}

So the cosphi (and power, but for power you need a snip32i!) need to use this function to create the "snippet" that encapsulates the bus read command.

chrostek commented 5 years ago

Ok, but the values for cospi are still

3276.70 | 3276.70 | 3276.70 | 47.70

Total is in your range, but L1-L3 not ... is this okay?

andig commented 5 years ago

Mhhm, no. Could you commit your current file? Then I can take a look.

andig commented 5 years ago

LGTM. And still strange output on cosphi? Could you show log of reading the 4 cosphi running with -v?

chrostek commented 5 years ago

2019/02/26 06:38:31 modbus: send 01 03 5b 3a 00 01 b7 23 2019/02/26 06:38:31 modbus: recv 01 03 02 02 12 39 29 2019/02/26 06:38:31 Device 1 - Cosphi: 53.00 2019/02/26 06:38:31 modbus: send 01 03 5b 3b 00 01 e6 e3 2019/02/26 06:38:31 modbus: recv 01 03 02 7f ff d8 34 2019/02/26 06:38:31 Device 1 - CosphiL1: 3276.70 2019/02/26 06:38:31 modbus: send 01 03 5b 3c 00 01 57 22 2019/02/26 06:38:31 modbus: recv 01 03 02 7f ff d8 34 2019/02/26 06:38:31 Device 1 - CosphiL2: 3276.70 2019/02/26 06:38:31 modbus: send 01 03 5b 3d 00 01 06 e2 2019/02/26 06:38:31 modbus: recv 01 03 02 7f ff d8 34 2019/02/26 06:38:31 Device 1 - CosphiL3: 3276.70

chrostek commented 5 years ago

found "Power Factor" in the display of the device. shows about 0.44 - so divider 1000 seems correct:

Power Factor (cos 𝜑) | 32.77 | 32.77 | 32.77 | 0.43

andig commented 5 years ago

Thats what the doc says (1000). They should still all be in the same range of -1..1. Anyway, I think enough progress for time being, gonna merge this as-is.

andig commented 5 years ago

Feel free to pm me (cpuidle@gmx.de) if you want this debugged further.

andig commented 5 years ago

@chrostek could you kindly share a log with -v that shows reading of cosphi with the current master? Much appreciated!

chrostek commented 5 years ago

2019/02/27 07:50:26 modbus: send 01 03 5b 3a 00 01 b7 23 2019/02/27 07:50:26 modbus: recv 01 03 02 01 b3 f8 61 2019/02/27 07:50:26 Device 1 - Cosphi: 0.43 2019/02/27 07:50:26 modbus: send 01 03 5b 3b 00 01 e6 e3 2019/02/27 07:50:26 modbus: recv 01 03 02 7f ff d8 34 2019/02/27 07:50:26 Device 1 - CosphiL1: 32.77 2019/02/27 07:50:26 modbus: send 01 03 5b 3c 00 01 57 22 2019/02/27 07:50:26 modbus: recv 01 03 02 7f ff d8 34 2019/02/27 07:50:26 Device 1 - CosphiL2: 32.77 2019/02/27 07:50:26 modbus: send 01 03 5b 3d 00 01 06 e2 2019/02/27 07:50:26 modbus: recv 01 03 02 7f ff d8 34 2019/02/27 07:50:26 Device 1 - CosphiL3: 32.77 2019/02/27 07:50:26 modbus: send 01 03 5b 14 00 02 97 2b 2019/02/27 07:50:26 modbus: recv 01 03 04 00 00 00 36 7a 25

andig commented 5 years ago

Ok, finally found it. From the manual:

Nicht verwendete Register Nicht verwendete Register innerhalb des Mapping-Bereichs, z.B. fehlende Mengen im angeschlossenen Zähler, führen zu einer normalen Modbus-Antwort, aber der Wert des Registers wird auf "ungültig" gesetzt.

Bei Mengen mit dem Datentyp "vorzeichenlos" ist der Wert in allen Registern FFFF. Bei Mengen mit dem Datentyp "vorzeichenbehaftet" ist der Wert der höchste zum Ausdrücken geeignete Wert. Das bedeutet, dass die von nur einem Register repräsentierte Menge den Wert 7FFF besitzt. Eine von zwei Registern repräsentierte Menge besitzt den Wert 7FFFFFFF, usw.

That means that the 32.77 are just "invalid" values. I'll add filtering for those in another PR, the problem is similar to Sunspec inverters that also know invalid values...

chrostek commented 5 years ago

Super, danke. Für was haben ich eigentlich mein schlechtes Englisch bemüht 😂

andig commented 5 years ago

War doch top. Hast Du evtl. noch einen Link zu einer A-Series Doku für die MODBUS Register? Ich konnte leider nix finden.

chrostek commented 5 years ago

Wir haben den A44. Die relevanten Register waren alle gleich.

https://new.abb.com/products/de/2CMA100248R1000/active-energy-class-1-or-b-for-mid-meters#documentLink

chrostek commented 5 years ago

der letzte Kommentar war vom Handy aus, war irgendwie nicht der direkte Link zur PDF: https://library.e.abb.com/public/d5cfc3727c5dcc68c1257a450045b491/2CMC486006M0101_A_de_A43_A44_Benutzerhandbuch.pdf

andig commented 5 years ago

See https://github.com/gonium/gosdm630/pull/127 for follow-up