Это старая версия документа!
Hiking DDS238-1 ZN
MegaD-2561 в качестве шлюза RS-485/Modbus RTU - Ethernet - подключение к счетчику через контроллер MegaD.
Для подключения к счетчику через RPi4 используем утилиту modbus-client.
Порт подключения для RPi4 - '/dev/ttyAMA1'
Смена адреса счетчика
Читаем регистр 0х15:
# modbus_client --debug -mrtu -pnone -s1 /dev/ttyAMA1 -a1 -t0x03 -r0x15 Opening /dev/ttyRS485-1 at 9600 bauds (N, 8, 1) [01][03][00][15][00][01][95][CE] Waiting for a confirmation… <01><03><02><01><01><78><14> SUCCESS: read 1 of elements: Data: 0x0101
Теперь в этот регистр записываем значение 0х0201:
# modbus_client --debug -mrtu -pnone -s1 /dev/ttyAMA1 -a1 -t0x10 -r0x15 0x0201 Data to write: 0x0201 Opening /dev/ttyRS485-1 at 9600 bauds (N, 8, 1) [01][10][00][15][00][01][02][02][01][64][35] Waiting for a confirmation… <01><10><00><15><00><01><10><0D> SUCCESS: written 1 elements!
После чего проверяем правильность записи уже по адресу -а2:
# modbus_client --debug -mrtu -pnone -s1 /dev/ttyAMA1 -a2 -t0x03 -r0x15 Opening /dev/ttyRS485-1 at 9600 bauds (N, 8, 1) [02][03][00][15][00][01][95][FD] Waiting for a confirmation… <02><03><02><02><01><3C> SUCCESS: read 1 of elements: Data: 0x0201
Отлично, прибору присвоен Modbus RTU ID=002
Список регистров счетчика
Данные регистры одинаковы для моделей: DDS238-4 W; DDS238 4 ZN/S; DDS238 2 ZN/S; DDS238 1 ZN
Modbus holding registers:
| Register(s) | Meaning | Scale Unit | Data format | R/W | 
|---|---|---|---|---|
| 0000h-0001h | total energy | 1/100 kWh | unsigned dword | R¹ | 
| 0002h-0003h | reserved | unsigned dword | ||
| 0004h-0005h | reserved | unsigned dword | ||
| 0006h-0007h | reserved | unsigned dword | ||
| 0008h-0009h | export energy | 1/100 kWh | unsigned dword | R¹ | 
| 000Ah-000Bh | import energy | 1/100 kWh | unsigned dword | R¹ | 
| 000Ch | voltage | 1/10 V | unsigned word | R | 
| 000Dh | current | 1/100 A | unsigned word | R | 
| 000Eh | active power | 1 W | signed word | R | 
| 000Fh | reactive power | 1 VAr | unsigned word | R | 
| 0010h | power factor | 1/1000 | unsigned word | R | 
| 0011h | frequency | 1/100 Hz | unsigned word | R | 
| 0012h | reserved | unsigned word | ||
| 0013h | reserved | unsigned word | ||
| 0014h | reserved | unsigned word | ||
| 0015h:high | station address | 1-247 | unsigned char | R/W | 
| 0015h:low | baud rate 1-4² | unsigned char | R/W | |
| 001Ah | relay³ | unsigned word | R/W | 
Notes:
1) Total, export and import energy counters can erased writing 0 in total energy registers.
2) Value mapping, default 1.
| Value | Baud rate | 
|---|---|
| 1 | 9600 Bd | 
| 2 | 4800 Bd | 
| 3 | 2400 Bd | 
| 4 | 1200 Bd | 
3) In DDS238-2 ZN/SR model the relay can be switched by 0x001A register.
| Value | Relay | 
|---|---|
| 0 | Off | 
| 1 | On | 
Data formats
| Data format | Length | Byte order | 
|---|---|---|
| char | 8 bits | |
| word | 16 bits | Big endian | 
| dword | 32 bits | Big endian | 
Writing registers
The meter does not understand the 'write sigle register' function code (06h), only the 'write multiple registers' function code (10h).