pymodbus icon indicating copy to clipboard operation
pymodbus copied to clipboard

IS there any system configuration requirements for running pymodbus efficiently?

Open DevHasher opened this issue 6 years ago • 10 comments

Versions

  • Python: 3.8.3
  • OS: Windows 10 / 16gb
  • Pymodbus:2.3.0

When used the same setup in 32gb RAM - the speed of communication was pretty fast. But when switched to 16gb RAM - the speed has reduced drastically.

has anyone faced this issue previously?

DevHasher avatar Aug 07 '20 15:08 DevHasher

@dhoomakethu Do you have any idea about this. Please suggest

DevHasher avatar Aug 07 '20 15:08 DevHasher

What client are you talking about here ? Can you provide more information on your observation? What was the metrics used to identify the slowing down of communication?

dhoomakethu avatar Aug 07 '20 17:08 dhoomakethu

@dhoomakethu - So what I noticed was that first time when I had installed pymodbus on my laptop the performance was very good..as in for the read and write operations, the speed was decent.

Now when I reinstalled the setup in new laptop, the communication speed has slowed down to a large extent, that the reads itself for a single register is taking over a min, and when i try to read all the registers at once, it doesnt even respond.(Note it was working fine the first time)

Additionally I would like to point that communication works perfectly fine when working with Modbus tool or minimal modbus. Based on this, I guess it isnt a hardware issue. So now I m not able to figure out what might be the issue, as the code is same wrt to old and new pymodbus setup.

I m very new to registers and modbus communication. So if you could let me know what info I can provide so that it would help you understand the issue. Or if any of the things I mentioned makes sense, then please suggest a work around/ or a way to setup pymodbus again.

Thanks

DevHasher avatar Aug 16 '20 13:08 DevHasher

@AnkitaPadma Can you run this script https://pymodbus.readthedocs.io/en/latest/source/example/performance.html ? Please update the script with correct serial settings and register offsets. I am not sure how you are using pymodbus in your code. When you say the it works perfectly fine with modbus tool or minimal modbus , are you running the same code (read your application) with pymodbus replaced with minimal modbus or is it the standalone code that you are talking. If yes, please share the minimal modbus code you have used as well the pymodbus code.

dhoomakethu avatar Aug 17 '20 09:08 dhoomakethu

@dhoomakethu Yes using the same code, by just changing the library from pymodbus to minimal For reference

Pymodbus code

client = ModbusSerialClient(
    method='rtu',
    port=meter.port,
    baudrate=9600,
    timeout=60,
    parity='N',
    stopbits=2,
    bytesize=8
)
if client.connect():
    readVal = client.read_input_registers(reg.regAddress, 2, unit=1)
     print(readVal )
    client.close()
else:
    print('Cannot connect to the Modbus Server/Slave')

Minimal modbus code

instrument = minimalmodbus.Instrument(meter.port, 1)
instrument.serial.port = meter.port                    
instrument.serial.baudrate = 9600        
instrument.serial.bytesize = 8
instrument.serial.parity   = serial.PARITY_NONE
instrument.serial.stopbits = 2
instrument.serial.timeout  = 0.05          
instrument.mode = minimalmodbus.MODE_RTU   

try:
    readVal = instrument.read_float(reg.regAddress,4) 
    print(readVal)
except IOError:
    print("Failed to read from instrument")

instrument.serial.close()

DevHasher avatar Aug 17 '20 11:08 DevHasher

Timeout of 60s for pymodbus and 0.5 sec for minimal modbus. Is there a reason for this? What happens if you use timeout of 0.5 sec with pymodbus as well ? Also what is the slave device under test here ? Also can you use strict=False in the client initialisation if running the code on windows?

dhoomakethu avatar Aug 17 '20 13:08 dhoomakethu

For testing if the connection is getting timeout, i had set 60s in pymodbus, as it wasnt responding only. Energy meter is the slave device I m testing here

But the thing is that the same code was working fine before. What are the steps to follow when working with pymodbus.. installation process?

DevHasher avatar Aug 17 '20 14:08 DevHasher

installation process remains the same, pip install pymodbus strict=False would make the connections kind of stable on windows machine (just a hack). What is the make of energy meter/spec etc?

dhoomakethu avatar Aug 17 '20 14:08 dhoomakethu

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Mar 03 '21 02:03 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Mar 08 '21 02:03 github-actions[bot]