|
1 |
| -# modbus-scripts |
2 |
| -Examples of interaction with Enapter devices over Modbus communication protocol |
| 1 | +## Introduction |
| 2 | + |
| 3 | +This repository contains examples of interaction with Enapter devices over |
| 4 | +Modbus communication protocol. Writing holding registers allows to execute |
| 5 | +commands (e.g. reboot), set specific parameters or update configuration. |
| 6 | + |
| 7 | +Reading registers (both holding and inputs) allows to get current hardware status |
| 8 | +(e.g. switches states, H2 production parameters, timings, etc.), current configuration, |
| 9 | +detect configuration problems. |
| 10 | + |
| 11 | +All information regarding registers, events (errors/warnings), etc. is available at [Enapter Handbook](https://handbook.enapter.com). |
| 12 | + |
| 13 | +### Requirements |
| 14 | + |
| 15 | +Python is used as programming language, version >= 3.10 is required. |
| 16 | +Please refer to the actual [downloads](https://www.python.org/downloads/) and [documentation](https://www.python.org/doc/). |
| 17 | + |
| 18 | +Git is required to clone the repository. |
| 19 | +Please refer to the actual [downloads](https://www.git-scm.com/downloads) and [documentation](https://www.git-scm.com/doc). |
| 20 | + |
| 21 | +[pyModbusTCP](https://pypi.org/project/pyModbusTCP/0.2.1/) package is required. |
| 22 | +Please refer to the actual documentation regarding [usage of virtual environments](https://docs.python.org/3/library/venv.html) and [packages installation](https://packaging.python.org/en/latest/tutorials/installing-packages/). |
| 23 | + |
| 24 | +### Running scripts |
| 25 | + |
| 26 | +Please refer to the actual [documentation](https://docs.python.org/3/using/cmdline.html) regarding general information about running Python scripts. |
| 27 | + |
| 28 | +Each script requires two parameters - Modbus IP address and Modbus port. |
| 29 | +IP address is required parameter, default port is _502_. |
| 30 | + |
| 31 | +**Running script with default port:** |
| 32 | +``` |
| 33 | +python3 <path_to_script>/<script_name>.py --modbus-ip <address> |
| 34 | +``` |
| 35 | + |
| 36 | +**Running script with custom port:** |
| 37 | +``` |
| 38 | +python3 <path_to_script>/<script_name>.py --modbus-ip <address> --modbus-port <port> |
| 39 | +``` |
| 40 | + |
| 41 | +### Scripts description |
| 42 | + |
| 43 | +**_read_el_control_board_serial.py_** |
| 44 | + |
| 45 | +Read and decode control board serial number input (6) to a human-readable string value (e.g. '9E25E695-A66A-61DD-6570-50DB4E73652D'). |
| 46 | + |
| 47 | +**_read_el_device_model.py_** |
| 48 | + |
| 49 | +Read and decode device model input register (0) to a human-readable string value (e.g. 'EL21', 'EL40', etc.). |
| 50 | + |
| 51 | +**_read_el_errors.py_** |
| 52 | + |
| 53 | +Read and decode errors input register (832) to a list of human-readable strings with error name and hex |
| 54 | +value (e.g. 'WR_20 (0x3194)'). Since new firmwares may add new events, UNKNOWN errors may be identified by hex value. |
| 55 | + |
| 56 | +**_read_el_params.py_** |
| 57 | + |
| 58 | +Read and decode current hardware parameters: |
| 59 | +- system state (input, 18) |
| 60 | +- uptime (input, 22) |
| 61 | +- total H2 production (input, 1006) |
| 62 | +- production rate (holding, 1002) |
| 63 | +- high electrolyte level switch (input, 7000) |
| 64 | +- very high electrolyte level switch (input, 7001) |
| 65 | +- low electrolyte level switch (input, 7002) |
| 66 | +- medium electrolyte level switch (input, 7003) |
| 67 | +- electrolyte tank high pressure switch (input, 7004) |
| 68 | +- electronic compartment high temperature Switch (input, 7007) |
| 69 | +- chassis water presence switch (input, 7009)). |
| 70 | + |
| 71 | +**_run_el_maintenance.py_** |
| 72 | + |
| 73 | +Interactive script to perform maintenance on EL2.1/4.x by following the instructions in console. |
| 74 | + |
| 75 | +**ATTENTION!** Maintenance requires manual actions with electrolyser such as electrolyte draining, |
| 76 | +flushing (for 4.x) and refilling. |
| 77 | + |
| 78 | +If script is terminated for some reason (e.g. due to network failure), in most cases it can be re-run and |
| 79 | +maintenance will continue. |
| 80 | + |
| 81 | +Only refilling is performed in case of first maintenance (from factory state). |
| 82 | + |
| 83 | +**_write_el_production_rate.py_** |
| 84 | + |
| 85 | +- Read current value of the production rate percent holding register (1002) |
| 86 | +- Write random value in 90-99 range |
| 87 | +- Read register again to check that it contains new value |
| 88 | + |
| 89 | +- write_el_reboot.py |
| 90 | + |
| 91 | +- Write 1 to reboot holding register (4) |
| 92 | +- Wait until electrolyser is rebooted |
| 93 | +- Read state input register (1200) |
| 94 | + |
| 95 | +**_write_el_syslog_skip_priority.py_** |
| 96 | + |
| 97 | +- Read current value of the log skip priority holding register (4042) |
| 98 | +- Check that there is no other configuration in progress (read configuration in progress input register (4000)) |
| 99 | +- Begin configuration (write 1 to the configuration begin holding register (4000)) |
| 100 | +- Ensure that configuration source is Modbus (read configuration over modbus input register (4001)) |
| 101 | +- Write random value in 0-6 range (excluding current value) to the log skip priority holding register (4042) |
| 102 | +- Check that configuration is OK (read configuration last result input register (4002)) |
| 103 | +- Read log skip priority holding register (4042) again to check that it contains new value |
| 104 | + |
| 105 | +NOTICE. Log skip priority holding register (4042) has int32 type, so it may contain any value in the appropriate |
| 106 | +range. Values less than 0 are considered as DISABLE_LOGGING (0), values greater than 6 are considered as ALL_MESSAGES (6). |
0 commit comments