Control R4DIF08 8-channel digital input modules via RS-485 Modbus RTU.
More...
|
def | __init__ (self, int slave_id=1, str serial_device_name=None, int baudrate=9600, **kwargs) |
|
bool | get_input (self, int input_no) |
| Return the state of the specified digital input. More...
|
|
tuple[bool,...] | get_inputs (self) |
| Returns the state of the 8 digital inputs. More...
|
|
def | set_input_level (self, active_high=False, delay_enabled=True) |
| Set input inverters, or voltage level for boolean True output. More...
|
|
int | get_slave_id (self) |
| Sends a broadcast query to all devices on the bus. More...
|
|
def | set_slave_id (self, int slave_id_new) |
| Set the slave ID. More...
|
|
def | set_baudrate (self, int baudrate=9600) |
| Set RS485 serial baud rate. More...
|
|
def | do_factory_reset (self) |
| Restore factory default settings. More...
|
|
|
int | INPUT_REG_OFFSET = 40129 |
|
int | INPUT_CONF_REGISTER = 40253 |
|
int | SLAVE_ID_REGISTER = 40255 |
|
int | BAUDRATE_REGISTER = 40256 |
|
int | FACTORY_RESET_REGISTER = 40256 |
|
int | FACTORY_RESET_VALUE = 5 |
|
int | BROADCAST_SLAVE_ID = 0xFF |
|
dictionary | BAUDRATE_KEYS = {1200: 0, 2400: 1, 4800: 2, 9600: 3, 19200: 4} |
|
Control R4DIF08 8-channel digital input modules via RS-485 Modbus RTU.
The R4DIF08 seem to come with a pre-set slave ID of 1.
Brand name is "eletechsup", available at https://www.eletechsup.com
This is for the three-channel variant.
◆ do_factory_reset()
def cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.do_factory_reset |
( |
|
self | ) |
|
|
inherited |
Restore factory default settings.
You must cycle the power supply after this command.
Expect a CRC mismatch error when invoking this function,
I don't know if this is always the case.
Reimplemented in cheap_modbus_rtu.cheap_modbus_io.RelayModule.
◆ get_input()
bool cheap_modbus_rtu.cheap_modbus_io.R4DIF08.get_input |
( |
|
self, |
|
|
int |
input_no |
|
) |
| |
Return the state of the specified digital input.
- Parameters
-
input_no | Input number, starts counting at 1 |
- Returns
- True if input signal is active, False if inactive
◆ get_inputs()
tuple[bool, ...] cheap_modbus_rtu.cheap_modbus_io.R4DIF08.get_inputs |
( |
|
self | ) |
|
Returns the state of the 8 digital inputs.
- Returns
- Tuple of 8 boolean flags, one for each input
◆ get_slave_id()
int cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.get_slave_id |
( |
|
self | ) |
|
|
inherited |
Sends a broadcast query to all devices on the bus.
This only works when only one device is attached to the bus
- Returns
- The first found slave ID.
◆ set_baudrate()
def cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.set_baudrate |
( |
|
self, |
|
|
int |
baudrate = 9600 |
|
) |
| |
|
inherited |
Set RS485 serial baud rate.
Most devices require cycling the power supply after running this command
before the new baud rate applies.
- Warning
- While usually undocumented, it is possible that the device writes directly to FLASH, thus frequent writes could damage the chip!
- Parameters
-
baudrate | Can be 1200, 2400, 4800, 9600 (default) or 19200 |
Reimplemented in cheap_modbus_rtu.cheap_modbus_io.RelayModule.
◆ set_input_level()
def cheap_modbus_rtu.cheap_modbus_io.R4DIF08.set_input_level |
( |
|
self, |
|
|
|
active_high = False , |
|
|
|
delay_enabled = True |
|
) |
| |
Set input inverters, or voltage level for boolean True output.
The module only supports setting all inputs at once, so this
applies to all eight inputs.
There seems to be a delay necessary in order for the module to be
re-configured and ready to answer queries after setting this register.
This is why a 0.2 second blocking delay is activated by default.
- Warning
- While undocumented, it is possible that the device writes directly to FLASH, thus frequent writes could damage the chip!
- Parameters
-
active_high | If set to False (default), Report True for low-level input (0 V, GND). If set to True, Report True for high-level input (> VCC/2). |
delay_enabled | Enable 0.2 second delay if set to True (default) |
◆ set_slave_id()
def cheap_modbus_rtu.cheap_modbus_io.ModbusModuleABC.set_slave_id |
( |
|
self, |
|
|
int |
slave_id_new |
|
) |
| |
|
inherited |
Set the slave ID.
- Warning
- While usually undocumented, it is possible that the device writes directly to FLASH, thus frequent writes could damage the chip!
- Parameters
-
slave_id_new | New Modbus slave ID |
Reimplemented in cheap_modbus_rtu.cheap_modbus_io.RelayModule.
The documentation for this class was generated from the following file:
- src/cheap_modbus_rtu/cheap_modbus_io.py