ArduinoRS485
ArduinoRS485 copied to clipboard
`setDelays()` is undocumented
The library's public API includes a setDelays
function:
https://github.com/arduino-libraries/ArduinoRS485/blob/9d5872eadbd3a1de8feca6b64f92cb2a08737540/src/RS485.h#L83
But this function is not mentioned in the documentation (Arduino library documentation).
The entire public API of the library must be documented.
An example sketch should be provided that demonstrates its usage, including whether it must be called before a begin()
call, after, or does it not matter?
I'm just analyzing the RS485 code. The postdelay seems to be necessary for driving the DE signal (enable transmitter in driver) because the _serial->write() returns before all bits are on the line. So the setting is dependent on the bitrate of the uart.
Yeah, that sounds consistent with my experience as well. I am setting the delay using a simple equation for Modbus:
constexpr auto ModBaud{9600};
constexpr auto bitduration{1.0f / ModBaud};
constexpr auto charlen{11.0f};
constexpr auto delay_us{bitduration * charlen * 3.5f * 1e6};
But it would be nice if the default values for delay could be calculated based on the baud of the RS485
.
Hi all. It seems this is going off topic. While it is very interesting, I will request that all further discussion on this issue thread be restricted exclusively to the subject of the missing documentation of the setDelays
function.
You are welcome to submit separate issues for reports of bugs or feature requests.
General discussion is always welcome over on Arduino Forum:
https://forum.arduino.cc/
The postdelay is essential for the RS485 to work correctly. When the delay is too short, the driver is turning off DE too early and the message is corrupted. When is delay is too long, it blocks the receiving of the ACK. The delay is performed by a wait_us() which burns cpu cycles and blocks the system. The calculation of the delay time based on the baud rate is important, only the factor 3.5 is not necessary and makes it too long, one wordlength is enough.
I don't understand why this can be off topic, This library is used in Portenta Machine Control, which claims to be a professional product. Currently, I'm evaluating the PMC for usage in industrial environment. And there it needs reliable software and clear documentation. Answers like these do not help and will shorten my evaluation period.