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

Make delay depend on number of bits per character #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int requestFrom(int id, int type, int address,int nb);

#### Parameters
- id (slave) - id of target, defaults to 0x00 if not specified
type - type of read to perform, either COILS, DISCRETE_INPUTS, HOLDING_REGISTERS, or INPUT_REGISTERS
- type - type of read to perform, either COILS, DISCRETE_INPUTS, HOLDING_REGISTERS, or INPUT_REGISTERS
- address start address to use for operation
- nb - number of values to read

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ constexpr auto baudrate { 19200 };
// Paragraph 2.5.1.1 MODBUS Message RTU Framing
// https://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
constexpr auto bitduration { 1.f / baudrate };
constexpr auto wordlen { 9.6f }; // try also with 10.0f
constexpr auto preDelayBR { bitduration * wordlen * 3.5f * 1e6 };
constexpr auto postDelayBR { bitduration * wordlen * 3.5f * 1e6 };
constexpr auto charlen { 11.0f };
constexpr auto preDelayBR { bitduration * charlen * 3.5f * 1e6 };
constexpr auto postDelayBR { bitduration * charlen * 3.5f * 1e6 };

void setup() {
Serial.begin(9600);
Expand Down