Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout but slave respond #35

Open
pmolke opened this issue Dec 3, 2024 · 19 comments
Open

timeout but slave respond #35

pmolke opened this issue Dec 3, 2024 · 19 comments

Comments

@pmolke
Copy link

pmolke commented Dec 3, 2024

I get an error code 11 when I send a request to the slave.
But with a sniffer I see that the device responds correctly

image

image

@budulinek
Copy link
Owner

budulinek commented Dec 3, 2024

Did you try to send your Modbus RTU request through the built-in web interface? What was the result? Ideally, post here the request message, response message and any results you get in the "Modbus Statistics" in web UI.

What was the response you sniffed on the RS485 line? Looking at your picture, the response was 00 e9 00 02 ? That is weird. That is not a correct Modbus message (for a response).

@pmolke
Copy link
Author

pmolke commented Dec 4, 2024

The sniffer parse the modbus raw data and 00 e9 00 02 is only the payload.

image

@pmolke
Copy link
Author

pmolke commented Dec 6, 2024

No idea?

@budulinek
Copy link
Owner

Just to clarify. I assume the sniffer does not send it's own request. It detects the request sent by the gateway and then the response sent by the slave. Am I right?

@budulinek
Copy link
Owner

My suspicion is some HW issue rather than a bug in SW. What is your baud rate? Do you use RS485-TTL module with HW flow control? Maybe the response came too fast and the module did not have enough time to switch the flow 🤷

@pmolke
Copy link
Author

pmolke commented Dec 6, 2024

Correct. The sniffer is passiv.

I also suspect that the answer comes too quickly. Do you know how quickly the Modbus module needs to switch automatically? So far I've only had modules that had to be switched manually using a PIN.

@pmolke
Copy link
Author

pmolke commented Dec 6, 2024

Baud is 9600

@budulinek
Copy link
Owner

I did some tests some time ago but I do not remember the exact result. Can also vary depending on the module you use.

I had to introduce Inter-frame delay (far higher than Modbus specs) in order to deal with the switching time of the RS485 modules. The Inter-frame delay (see RTU settings) is a delay between gateway receiving response via RS485 and sending new request (stored in buffer). If the delay was set too low, the request (which was waiting to be sent in the buffer) was sent (via TTL to the module) too early, before the module could switch the flow.

I have 150 ms as default Interframe delay. This value was safe (= high enough) for the RS485 module I use.

@budulinek
Copy link
Owner

budulinek commented Dec 6, 2024

Your Modbus slave responds in 15 ms. That is very fast response. Maybe even faster than it should be according to Modbus specs. I do not remember what the minimum Interframe delay should be at baud 9600.

But the truth is that even if the slave is very fast but still within Modbus specs, the RS485 module may not detect the response because it did not have enough time to switch the flow.

@pmolke
Copy link
Author

pmolke commented Dec 6, 2024

I have now added a delay of 300 ms to the slave before it responds.

Unfortunately no success.
Unfortunately I don't know why this doesn't work. I need to test another slave device to rule out a problem with my gateway

@budulinek
Copy link
Owner

The Interframe delay setting only regulates delay between response received by the gateway and new request sent by the gateway. Changing the setting will not solve your issue.

I think you either have to use RS485-TTL module with manual switching or try to find some (really) fast module with automatic switching.

@pmolke
Copy link
Author

pmolke commented Dec 6, 2024

I have now connected another RS485 module and used PIN6.

Now it works as desired.
It's a shame, I would have preferred the other module.

Thanks for the great software.

Would it be time-consuming to add password protection to the web interface?

@budulinek
Copy link
Owner

I need to test another slave device to rule out a problem with my gateway

Good idea. PLS let me know if you have success with other device.

... and one more idea. Is it possible to lower baud on your slave? Down to let's say 300? Maybe by setting the slave to lower baud you can force the slave to extend the response time (=Interframe delay on the slave). According to Modbus specs, the minimum Interframe delay depends on baud.

@pmolke
Copy link
Author

pmolke commented Dec 6, 2024

I still have the problem that sometimes all connections are disconnected and I have to restart the Arduino to get it to work again.

@budulinek
Copy link
Owner

Do you have external power source?

@pmolke
Copy link
Author

pmolke commented Dec 6, 2024

No, the Board is connected with my Laptop over USB

You mean under-voltage is the problem ?

@budulinek
Copy link
Owner

The problem with lost connection is caused by power / reset issues of the Ethernet module. I will update readme with possible solution. Hopefully on Sunday.

@budulinek
Copy link
Owner

No, the Board is connected with my Laptop over USB

You mean under-voltage is the problem ?

Probably not. USB should provide enough current (with stable voltage) for Arduino, Ethernet module and the RS485 module.

@budulinek
Copy link
Owner

The problem with lost connection is caused by power / reset issues of the Ethernet module. I will update readme with possible solution. Hopefully on Sunday.

Please check https://github.com/budulinek/arduino-modbus-rtu-tcp-gateway/blob/master/Ethernet_SW_Reset.md

And let me know if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants