⚠️ This library is not perfect. Sometimes the returned values do not match with the requests if the communiction is fast.
⚠️ pyserial has to be installed usepip install pyserial
from mtecConnectModbus import mtecConnectModbus
pump = mtecConnectModbus("01");
def connect():
#pump.serial_port = '/dev/cu.usbmodem1431201'
pump.serial_port = 'COM3'
pump.connect()
def stop():
pump.speed = 0
def changeSpeed(newSpeed):
pump.speed = newSpeed
Creates the Object to use the library.
from mtecConnectModbus import mtecConnectModbus
pump = mtecConnectModbus("01");result:
- mtecConnectModbus, conatins everything used to communicate via modbus
Connects to the serial converter.
connected = pump.connect()result:
- bool, connection to serial interface sucessful?
📝 While the pump is running, a valid command has to be sent at least every second
If activated, the keep alive feature sends a command some time (interval) after the last command.
This feature can be tweaked in the settings:
- bool
pump.settings_keepAlive_active, if keep alive feature is enabled, default: true - int
pump.settings_keepAlive_interval, interval after which the command is sent (in ms), default: 250 - string (or function with return string)
pump.settings.keepAlive.command(length: 10), action number (2) + parameter number (4) + value (4), default: "03FD000001" - function
pump.settings_keepAlive_callback, gets called with return value as parameter, optional
Starts or stops the pump (target frequency has to be set)
# target frequency has to be set
pump.start() # starts the pump
pump.startReverse() # starts the pump in reverse
pump.stop() # stops the pump
Sets the target frequency
pump.frequency = frequencyparameters:
- float, positive (resolution: 0.01), target frequency in Hz
Gets the actual frequency
f = pump.frequencyresult:
- float, positive (resolution: 0.01), actual frequency in Hz
Starts (or stops) the pump in the desired direction
⚠️ Do not switch betweenset frequencyandset speed
pump.speed = speedparameters:
- float, negative to reverse (resolution: 0.01), target frequency
Gets the readiness of the machine (on)
f = pump.readyresult:
- bool, machine is ready for operation
Gets the actual output voltage
f = pump.voltageresult:
- float, positive (resolution: 0.01), actual voltage in % of voltage rating
Gets the actual output current
f = pump.currentresult:
- float, positive (resolution: 0.01), actual voltage in % of current rating
Gets the actual torque
f = pump.torqueresult:
- float, positive (resolution: 0.01), actual voltage in % of torque rating
Sends custom command to inverter
answer = pump.sendCommand(parameter, value)parameters:
- string (length: 6), action number (2) + parameter number (4), example: "03FD00"
- int, value
result:
- int, answer value (equals input value if write command)