Skip to content

Examples of interaction with Enapter devices over Modbus communication protocol

License

Notifications You must be signed in to change notification settings

Enapter/modbus-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This repository contains examples of interaction with Enapter devices over Modbus communication protocol. Writing holding registers allows to execute commands (e.g. reboot), set specific parameters or update configuration.

Reading registers (both holding and inputs) allows to get current hardware status (e.g. switches states, H2 production parameters, timings, etc.), current configuration, detect configuration problems.

All information regarding registers, events (errors/warnings), etc. is available at Enapter Handbook.

Requirements

Python is used as programming language, version >= 3.10 is required. Please refer to the actual downloads and documentation.

Git is required to clone the repository. Please refer to the actual downloads and documentation.

pyModbusTCP package is required. Please refer to the actual documentation regarding usage of virtual environments and packages installation.

Running scripts

Please refer to the actual documentation regarding general information about running Python scripts.

Each script requires two parameters - Modbus IP address and Modbus port. IP address is required parameter, default port is 502.

Running script with default port:

python3 <path_to_script>/<script_name>.py --modbus-ip <address> 

Running script with custom port:

python3 <path_to_script>/<script_name>.py --modbus-ip <address> --modbus-port <port>

Scripts description

Electrolyser

read_el_control_board_serial.py

Read and decode control board serial number input (6) to a human-readable string value (e.g. '9E25E695-A66A-61DD-6570-50DB4E73652D').

read_el_device_model.py

Read and decode device model input register (0) to a human-readable string value (e.g. 'EL21', 'EL40', etc.).

read_el_errors.py

Read and decode errors input register (832) to a list of human-readable strings with error name and hex value (e.g. 'WR_20 (0x3194)'). Since new firmwares may add new events, UNKNOWN errors may be identified by hex value.

read_el_params.py

Read and decode current hardware parameters:

  • system state (input, 18)
  • uptime (input, 22)
  • total H2 production (input, 1006)
  • production rate (holding, 1002)
  • high electrolyte level switch (input, 7000)
  • very high electrolyte level switch (input, 7001)
  • low electrolyte level switch (input, 7002)
  • medium electrolyte level switch (input, 7003)
  • electrolyte tank high pressure switch (input, 7004)
  • electronic compartment high temperature Switch (input, 7007)
  • chassis water presence switch (input, 7009)).

run_el_maintenance.py

Interactive script to perform maintenance on EL2.1/4.x by following the instructions in console.

ATTENTION! Maintenance requires manual actions with electrolyser such as electrolyte draining, flushing (for 4.x) and refilling.

If script is terminated for some reason (e.g. due to network failure), in most cases it can be re-run and maintenance will continue.

Only refilling is performed in case of first maintenance (from factory state).

write_el_production_rate.py

  • Read current value of the production rate percent holding register (1002)
  • Write random value in 90-99 range
  • Read register again to check that it contains new value

write_el_reboot.py

  • Write 1 to reboot holding register (4)
  • Wait until electrolyser is rebooted
  • Read state input register (1200)

write_el_syslog_skip_priority.py

  • Read current value of the log skip priority holding register (4042)
  • Check that there is no other configuration in progress (read configuration in progress input register (4000))
  • Begin configuration (write 1 to the configuration begin holding register (4000))
  • Ensure that configuration source is Modbus (read configuration over modbus input register (4001))
  • Write random value in 0-6 range (excluding current value) to the log skip priority holding register (4042)
  • Check that configuration is OK (read configuration last result input register (4002))
  • Read log skip priority holding register (4042) again to check that it contains new value

NOTICE. Log skip priority holding register (4042) has int32 type, so it may contain any value in the appropriate range. Values less than 0 are considered as DISABLE_LOGGING (0), values greater than 6 are considered as ALL_MESSAGES (6).

Dryer

read_dry_errors.py

Read and decode errors input register (6000) to a list of human-readable errors names (e.g. 'TT00_INVALID_VALUE, TT01_INVALID_VALUE').

read_dry_params.py

Read and decode current hardware parameters:

  • state (input, 6021)
  • dryer input pressure (input, 6010)
  • dryer output pressure (input, 6012)

write_dry_reboot.py

  • read reboot holding register (6020) and get current reboot counter
  • write 1 to reboot holding register (6020)
  • write 1 to save config holding register (6022)
  • wait until dryer is rebooted
  • read reboot holding register (6020) and get updated reboot counter

About

Examples of interaction with Enapter devices over Modbus communication protocol

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages