-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Strange behiavor on slave using write single register #72
Comments
hi, thanks for the question, and the how to fix 👍 I'm adding a "help wanted label" in case someone know the answer and can help, my guess (without checking) is that you need a delay between data frames [1] and this delay makes the data frames valid. |
Can you share the code in the |
@falahati, here you go, as you can see it's pretty straightforward:
|
Everything seems ok; the only thing that I can think of is that the master can not keep up with the speed of the slave. Try lowering the |
I don't see any time limitation or transfer time calculation on the codebase of the master's library. Maybe the library used for |
Thanks @falahati, i'm using serial hardware on both side: the Master side is a ESP32 and the slave side an arduino pro mini with ATMEGA328p running at 16Mhz. What looks weird is that lowering the baudrate the error rate increases a lot! |
Not an expert with modbus, but I'm currently reviewing multiple libraries and found this: https://github.com/angeloc/simplemodbusng/blob/master/SimpleModbusSlave/SimpleModbusSlave.cpp#L202 |
What are you experiencing with this library? it is ok? works without any issue or you need to add the additional delay? |
Thanks for pointing us in the right direction. Apparently libraries out there are not as standard as I liked them to be. In any case, I never had a problem with the code and I couldn't find anything suspicious in the code of the However, if this actually works, the fix should be easy to implement and increase the delay for communication. |
Hi,
I'm using this library on arduino in order to make it as a Modbus Slave, the slave consists in a ATMEGA328P with a bunch of neopixel leds (8) attached, periodically - every 250ms - , the master (Library: ModbusMaster) will change the led colors, generating some random colors.
The speed is: 57600-8E1
I was experiencing very often a slave timeout on the master (226 error), even if the master timeout limit is not reached (2000ms).
After some experiments, i've found that if i add to the slave a small delay(10) at the end of the write register function, the problem almost disappears (the timeout errors will appear very few times, like one every 100 writes)
This is weird, i mean: is this a normal behavior? i need to slow down the response of my slave in order to get it work?
The text was updated successfully, but these errors were encountered: