Control PWM8A04 3-channel PWM output modules via RS-485 Modbus RTU.
More...
|
def | __init__ (self, int slave_id=1, str serial_device_name=None, int baudrate=9600, **kwargs) |
|
int | get_output_frequency (self, int output_no) |
| Return the current frequency setpoint for output. More...
|
|
def | set_output_frequency (self, int output_no, int frequency) |
| Set frequency for PWM output. More...
|
|
int | get_output_duty (self, int output_no) |
| Return the current PWM duty cycle setpoint value for output. More...
|
|
def | set_output_duty (self, int output_no, int duty) |
| Set PWM duty cycle for output (high-active) 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 | FREQ_REG_OFFSET = 40000 |
|
int | DUTY_REG_OFFSET = 40112 |
|
int | SLAVE_ID_REGISTER = 40254 |
|
int | BAUDRATE_REGISTER = 40255 |
|
int | FACTORY_RESET_REGISTER = 40252 |
|
int | FACTORY_RESET_VALUE = 0 |
|
int | BROADCAST_SLAVE_ID = 0xFF |
|
dictionary | BAUDRATE_KEYS |
|
Control PWM8A04 3-channel PWM output modules via RS-485 Modbus RTU.
The PWM8A04 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_output_duty()
int cheap_modbus_rtu.cheap_modbus_io.PWM8A04.get_output_duty |
( |
|
self, |
|
|
int |
output_no |
|
) |
| |
Return the current PWM duty cycle setpoint value for output.
- Parameters
-
output_no | Output number, can be 1, 2 or 3 |
- Returns
- PWM duty cycle in percent, valid range is 0...100
◆ get_output_frequency()
int cheap_modbus_rtu.cheap_modbus_io.PWM8A04.get_output_frequency |
( |
|
self, |
|
|
int |
output_no |
|
) |
| |
Return the current frequency setpoint for output.
- Parameters
-
output_no | Output number, can be 1, 2 or 3 |
- Returns
- Frequency of PWM in Hz, valid range is 1...20000
◆ 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_output_duty()
def cheap_modbus_rtu.cheap_modbus_io.PWM8A04.set_output_duty |
( |
|
self, |
|
|
int |
output_no, |
|
|
int |
duty |
|
) |
| |
Set PWM duty cycle for output (high-active)
- Parameters
-
output_no | Output number, can be 1, 2 or 3 |
duty | PWM duty cycle in percent, valid range is 0...100 |
◆ set_output_frequency()
def cheap_modbus_rtu.cheap_modbus_io.PWM8A04.set_output_frequency |
( |
|
self, |
|
|
int |
output_no, |
|
|
int |
frequency |
|
) |
| |
Set frequency for PWM output.
- Parameters
-
output_no | Output number, can be 1, 2 or 3 |
frequency | Frequency of PWM in Hz, valid range is 1...20000 |
◆ 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.
◆ BAUDRATE_KEYS
dictionary cheap_modbus_rtu.cheap_modbus_io.PWM8A04.BAUDRATE_KEYS |
|
static |
Initial value:= {
1200: 0, 2400: 1, 4800: 2, 9600: 3, 19200: 4, 38400: 5, 57600: 6, 115200: 7
}
The documentation for this class was generated from the following file:
- src/cheap_modbus_rtu/cheap_modbus_io.py