# SDM630 Emulation

### Defaults

* Modbus device id: `1`
* Baudrate: `9600`
* Function codes: `FC03` and `FC04`
* Data format: mainly `float32`

### Important note

* The code comment describes the SDM630 default serial mode as `8N1`.
* In `p1m.h`, the current `SDM630` build is configured as `SERIAL_8E1`.
* If you publish this page, it is worth deciding which one should be considered the intended default.

### FC04 - measurement registers

| Register | Description            | Unit / encoding                                   |
| -------- | ---------------------- | ------------------------------------------------- |
| 0        | voltage\_l1            | V                                                 |
| 2        | voltage\_l2            | V                                                 |
| 4        | voltage\_l3            | V                                                 |
| 6        | current\_l1            | A                                                 |
| 8        | current\_l2            | A                                                 |
| 10       | current\_l3            | A                                                 |
| 12       | active\_power\_l1      | W                                                 |
| 14       | active\_power\_l2      | W                                                 |
| 16       | active\_power\_l3      | W                                                 |
| 24       | reactive\_power\_l1    | mirrored from active power sign/value logic       |
| 26       | reactive\_power\_l2    | mirrored from active power sign/value logic       |
| 28       | reactive\_power\_l3    | mirrored from active power sign/value logic       |
| 30       | power\_factor\_l1      | `1.0` or `-1.0`                                   |
| 32       | power\_factor\_l2      | `1.0` or `-1.0`                                   |
| 34       | power\_factor\_l3      | `1.0` or `-1.0`                                   |
| 48       | total\_current         | A                                                 |
| 52       | total\_active\_power   | W                                                 |
| 60       | total\_reactive\_power | mirrored from total active power sign/value logic |
| 62       | total\_power\_factor   | `1.0` or `-1.0`                                   |
| 70       | frequency              | `50.0` Hz                                         |
| 72       | import\_energy\_active | kWh                                               |
| 74       | export\_energy\_active | kWh                                               |
| 200      | line\_voltage\_l1\_l2  | V                                                 |
| 202      | line\_voltage\_l2\_l3  | V                                                 |
| 204      | line\_voltage\_l3\_l1  | V                                                 |
| 342      | total\_energy\_sum     | kWh = import + export                             |
| 406      | pre4 meter flag        | integer-like float                                |
| 408      | firmware version       | packed `MMmmpp` as raw 32-bit                     |
| 410      | dongle name            | packed `P1M3`                                     |

### FC03 - holding / configuration style registers

| Register | Description         | Value                           |
| -------- | ------------------- | ------------------------------- |
| `0x00`   | demand time         | `42`                            |
| `0x02`   | demand period       | `60`                            |
| `0x04`   | relay pulse width   | `0`                             |
| `0x06`   | network parity stop | `220`                           |
| `0x08`   | meter id mirror     | `5`                             |
| `0x0A`   | baud mirror         | `3`                             |
| `0x0C`   | p1 output mode      | `200`                           |
| `0x12`   | stop/parity config  | currently fixed `0`             |
| `0x14`   | device id           | current `DevID`                 |
| `0x16`   | pulse per tick      | `1`                             |
| `0x18`   | password / pin code | `1000`                          |
| `0x1C`   | baud selector       | `0-4` based on current baudrate |
| `0x56`   | output config       | `39`                            |
| `0xF010` | reset max demand    | `0`                             |
| `0xFC00` | serial number       | fixed `22502976`                |

### Notes

* Registers are implemented exactly as used by the emulation code; this is not a full SDM630 register map.
* With `NEGATIEF` enabled, the sign of active and reactive power is inverted.
