hello,
I am trying to interface with a World Drive G2 VFD via rs485 with a Waveshare USB to rs485 module from a Rpi5 to turn a pump on and change the frequency of the pump at various times throughout the run of a program based on sensor data. When I run my code, the pump does turn on and is set to the correct frequency, but I get the following Error while the vf.d.write_registers line of code is being exicuted and it does not move past this line:
device reports readiness to read but returned no data (device disconnected or multiple access on port?) (same as subject)
then the port, in this case /dev/ttyUSB0, seems to be occupied by the VFD and can not be accessed. I have to reboot the pi to have access to the same port again, sometimes unplugging the rs485 module for a bit works too.
I have verified that all physical connections are correct, the VFD settings are also correct to the best of my knowledge.
here is my code:
Thank you for your help in adavance.
I am trying to interface with a World Drive G2 VFD via rs485 with a Waveshare USB to rs485 module from a Rpi5 to turn a pump on and change the frequency of the pump at various times throughout the run of a program based on sensor data. When I run my code, the pump does turn on and is set to the correct frequency, but I get the following Error while the vf.d.write_registers line of code is being exicuted and it does not move past this line:
device reports readiness to read but returned no data (device disconnected or multiple access on port?) (same as subject)
then the port, in this case /dev/ttyUSB0, seems to be occupied by the VFD and can not be accessed. I have to reboot the pi to have access to the same port again, sometimes unplugging the rs485 module for a bit works too.
I have verified that all physical connections are correct, the VFD settings are also correct to the best of my knowledge.
here is my code:
Code:
import minimalmodbusimport serialimport timeUSB_PORT = '/dev/ttyUSB0'BAUDRATE = 9600TIMEOUT = 2WRITE_START = 4# One shared instrumentvfd = minimalmodbus.Instrument(USB_PORT, 10) # Default address, will changevfd.serial.baudrate = BAUDRATEvfd.serial.bytesize = 8vfd.serial.parity = serial.PARITY_NONEvfd.serial.stopbits = 1vfd.serial.timeout = TIMEOUTvfd.mode = minimalmodbus.MODE_RTUvfd.clear_buffers_before_each_transaction = Truevfd.close_port_after_each_call = Truedef set_speed(address, drive_mode, speed): try: print(f"Setting speed for address {address}") vfd.address = address vfd.serial.close() # Force close the port before each operation time.sleep(0.1) # Give some time before reopening vfd.serial.open() # Reopen the port vfd.write_registers(WRITE_START, [speed, drive_mode]) except Exception as e: print(f"Error setting speed for address {address}: {e}")def stop_pump(address): try: print(f"Stopping pump at address {address}") vfd.address = address vfd.serial.close() # Force close the port before each operation time.sleep(0.1) # Give some time before reopening vfd.serial.open() # Reopen the port vfd.write_registers(WRITE_START, [0, 1]) # speed = 0, mode = stop except Exception as e: print(f"Error stopping pump at address {address}: {e}")try: while True: set_speed(10, 2, 4500) # SOL VFD time.sleep(180) stop_pump(10) time.sleep(90)except KeyboardInterrupt: stop_pump(10) print("Exiting gracefully")
Statistics: Posted by ASliceOfRhubarb — Thu Apr 10, 2025 7:41 pm