@@ -16,19 +16,14 @@ func NewDS100Producer() Producer {
1616 * See https://data.xn--stromzhler-v5a.eu/manuals/bg_ds100serie_de.pdf
1717 */
1818 ops := Opcodes {
19- VoltageL1 : 0x0400 ,
20- VoltageL2 : 0x0402 ,
21- VoltageL3 : 0x0404 ,
22- //VoltageL1_L2: 0x0406, //mbmd doenst know this yet?
23- //VoltageL2_L3: 0x0408, //mbmd doenst know this yet?
24- //VoltageL3_L1: 0x040A, //mbmd doenst know this yet?
25- //VoltageL_N_avg: 0x040C, //mbmd doenst know this yet?
26- //VoltageL_L_avg: 0x040E, //mbmd doenst know this yet?
27- CurrentL1 : 0x0410 ,
28- CurrentL2 : 0x0412 ,
29- CurrentL3 : 0x0414 ,
30- Current : 0x0416 ,
31- //ThreePhase_Vec_A: 0x0418, //mbmd doenst know this
19+ VoltageL1 : 0x0400 ,
20+ VoltageL2 : 0x0402 ,
21+ VoltageL3 : 0x0404 ,
22+ Voltage : 0x040C ,
23+ CurrentL1 : 0x0410 ,
24+ CurrentL2 : 0x0412 ,
25+ CurrentL3 : 0x0414 ,
26+ Current : 0x0418 ,
3227 PowerL1 : 0x041A ,
3328 PowerL2 : 0x041C ,
3429 PowerL3 : 0x041E ,
@@ -41,36 +36,23 @@ func NewDS100Producer() Producer {
4136 ReactivePowerL2 : 0x042C ,
4237 ReactivePowerL3 : 0x042E ,
4338 ReactivePower : 0x0430 ,
44- //FrequencyL1: 0x0432, //mbmd doenst know this yet?
45- //FrequencyL2: 0x0433, //mbmd doenst know this yet?
46- //FrequencyL3: 0x0434, //mbmd doenst know this yet?
47- Frequency : 0x0435 ,
48- CosphiL1 : 0x0436 ,
49- CosphiL2 : 0x0437 ,
50- CosphiL3 : 0x0438 ,
51- Cosphi : 0x0439 , //implemented from beginning till 0x0439 - 60 Registers so far
52- ImportL1 : 0x050A , //A phase forward active energy
53- ImportL2 : 0x056E , //B phase forward active energy
54- ImportL3 : 0x05D2 , //C phase forward active energy
55- Import : 0x010E , // total forward active energy
56- ExportL1 : 0x0514 , //A phase reverse active energy
57- ExportL2 : 0x0578 , //B phase reverse active energy
58- ExportL3 : 0x05DC , //C phase reverse active energy
59- Export : 0x118A , // total reverse active energy
60- SumL1 : 0x0500 , //A phase total active energy
61- SumL2 : 0x0564 , //B phase total active energy
62- SumL3 : 0x05C8 , //C phase total active energy
63- Sum : 0x0122 , // total total active energy
64-
65- //THDL1: 0x00ea, // voltage to be checked
66- //THDL2: 0x00ec, // voltage
67- //THDL3: 0x00ee, // voltage
68- //THD: 0x00F8, // voltage
69- //L1THDCurrent: 0x00F0, // current
70- //L2THDCurrent: 0x00F2, // current
71- //L3THDCurrent: 0x00F4, // current
72- //AvgTHDCurrent: 0x00Fa, // current
73- //ApparentImportPower: 0x0064,
39+ Frequency : 0x0435 ,
40+ CosphiL1 : 0x0436 ,
41+ CosphiL2 : 0x0437 ,
42+ CosphiL3 : 0x0438 ,
43+ Cosphi : 0x0439 ,
44+ ImportL1 : 0x050A , //A phase forward active energy
45+ ImportL2 : 0x056E , //B phase forward active energy
46+ ImportL3 : 0x05D2 , //C phase forward active energy
47+ Import : 0x010E , // total forward active energy
48+ ExportL1 : 0x0514 , //A phase reverse active energy
49+ ExportL2 : 0x0578 , //B phase reverse active energy
50+ ExportL3 : 0x05DC , //C phase reverse active energy
51+ Export : 0x118A , // total reverse active energy
52+ SumL1 : 0x0500 , //A phase total active energy
53+ SumL2 : 0x0564 , //B phase total active energy
54+ SumL3 : 0x05C8 , //C phase total active energy
55+ Sum : 0x0122 , // total total active energy
7456 }
7557 return & DS100Producer {Opcodes : ops }
7658}
@@ -105,25 +87,50 @@ func (p *DS100Producer) snip32u(iec Measurement, scaler ...float64) Operation {
10587 return p .snip (iec , 2 , unsigned , RTUUint32ToFloat64 , scaler ... )
10688}
10789
90+ // snip16s creates modbus operation for single register (signed)
91+ func (p * DS100Producer ) snip16s (iec Measurement , scaler ... float64 ) Operation {
92+ return p .snip (iec , 1 , signed , RTUInt16ToFloat64 , scaler ... )
93+ }
94+
95+ // snip32s creates modbus operation for double register (signed)
96+ func (p * DS100Producer ) snip32s (iec Measurement , scaler ... float64 ) Operation {
97+ return p .snip (iec , 2 , signed , RTUInt32ToFloat64 , scaler ... )
98+ }
99+
108100func (p * DS100Producer ) Probe () Operation {
109101 return p .snip32u (Voltage , 1000 )
110102}
111103
112104func (p * DS100Producer ) Produce () (res []Operation ) {
113105 for _ , op := range []Measurement {
114- Voltage , Current ,
106+ VoltageL1 , VoltageL2 , VoltageL3 , Voltage ,
115107 } {
116108 res = append (res , p .snip32u (op , 1000 ))
117109 }
118110
119111 for _ , op := range []Measurement {
120- Power , ApparentPower , ReactivePower ,
112+ CurrentL1 , CurrentL2 , CurrentL3 , Current ,
113+ } {
114+ res = append (res , p .snip32s (op , 1000 ))
115+ }
116+
117+ for _ , op := range []Measurement {
118+ PowerL1 , PowerL2 , PowerL3 , Power ,
119+ ReactivePowerL1 , ReactivePowerL2 , ReactivePowerL3 , ReactivePower ,
120+ } {
121+ res = append (res , p .snip32s (op , 1 ))
122+ }
123+
124+ for _ , op := range []Measurement {
125+ ApparentPowerL1 , ApparentPowerL2 , ApparentPowerL3 , ApparentPower ,
121126 } {
122127 res = append (res , p .snip32u (op , 1 ))
123128 }
124129
125130 for _ , op := range []Measurement {
126- Import , Export , Sum ,
131+ ImportL1 , ImportL2 , ImportL3 , Import ,
132+ ExportL1 , ExportL2 , ExportL3 , Export ,
133+ SumL1 , SumL2 , SumL3 , Sum ,
127134 } {
128135 res = append (res , p .snip32u (op , 100 ))
129136 }
@@ -135,9 +142,9 @@ func (p *DS100Producer) Produce() (res []Operation) {
135142 }
136143
137144 for _ , op := range []Measurement {
138- Cosphi ,
145+ CosphiL1 , CosphiL2 , CosphiL3 , Cosphi ,
139146 } {
140- res = append (res , p .snip16u (op , 1000 ))
147+ res = append (res , p .snip16s (op , 1000 ))
141148 }
142149
143150 return res
0 commit comments