Skip to content

Commit 94a00b2

Browse files
authored
Make delay depend on number of bits per character
As per specification, there should be always 11 bits transmitted for each character.
1 parent 7df67be commit 94a00b2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: examples/RTU/ModbusRTUClientParameters/ModbusRTUClientParameters.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ constexpr auto baudrate { 19200 };
2222
// Paragraph 2.5.1.1 MODBUS Message RTU Framing
2323
// https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
2424
constexpr auto bitduration { 1.f / baudrate };
25-
constexpr auto wordlen { 9.6f }; // try also with 10.0f
26-
constexpr auto preDelayBR { bitduration * wordlen * 3.5f * 1e6 };
27-
constexpr auto postDelayBR { bitduration * wordlen * 3.5f * 1e6 };
25+
constexpr auto charlen { 11.0f };
26+
constexpr auto preDelayBR { bitduration * charlen * 3.5f * 1e6 };
27+
constexpr auto postDelayBR { bitduration * charlen * 3.5f * 1e6 };
2828

2929
void setup() {
3030
Serial.begin(9600);

0 commit comments

Comments
 (0)