stephane / modbusino Goto Github PK
View Code? Open in Web Editor NEWSmall Modbus slave, RTU (serial) for Arduino
Home Page: http://libmodbus.org
License: ISC License
Small Modbus slave, RTU (serial) for Arduino
Home Page: http://libmodbus.org
License: ISC License
Bonjour
Bravo pour votre développement Modbus sur Arduino.
Je vais réaliser des vrais modules (entrées sorties tout ou rien) et j'ai besoin de faire une modification.
Je vais remplacer la saisie du numéro d'esclave qui est faite par soft, en utilisant des dip-swith sur la platine (4 dip-switch soit 16 adresses possible).
Ceci restant dans le monde du libre.
Si vous avez un conseil à me donner (je ne suis pas programmeur).
Yves
Ingénieur thermicien et GTC
Hello
Congratulation for your Modbus development Arduino.
I'll make real modules (digital inputs outputs) and I need to make a change.
I will replace the input of the slave number that is made by software, using dip swith on the board (4 dip-switch can be 16 addresses).
This remaining in the free world.
If you have any advice for me (I'm not a programmer).
Yves
HVAC and Building automation engineer
Hello,
Since the newer version of Arduino IDE It appears that the Serial.flush method doesn't clear the rx buffer but the TX Buffer:
"Waits for the transmission of outgoing serial data to complete. (Prior to Arduino 1.0, this instead removed any buffered incoming serial data.)"
(Source arduino.cc )
I use the following function with success :
static void flush(void)
{
int i = 0;//Wait 3 Char lenght after last incomming byte
while (i <= _MODBUS_3_C_TIMEOUT) {
if (Serial.available()) {
Serial.read();
i = 0;
}
else {
i++;
}
delayMicroseconds(1);
}
}
thank you.
and when it does, it starts doing it over and over again....
Hi there
Just wanted to thank you for a great tool.
I've changed Serial to be an extern to a sub classed Stream object that buffers the data from an XBee API2 request. And your library works just fine. Much appreciated.
Hello,
I'm trying to use Modbusino in attiny402 project. It consists of several slaves controlled by (for now) a PC master.
Everything works fine when tere is only one slave on the bus and it is addressed. Issue atarts when I try to provide (on purpose) wrong, non-existing slave ID. Then non addressed slave send some weird response.
Sample request: [20][03][00][00][00][0A][C3][7C]
.
Sample (wrong) answer from slave: [21][80][01][81][CA][21][8A][01][87][6A]
(sometimes only one or two bytes as response).
Clearly visible that request was sent to ID 0x20 and response comes from ID 0x21 (an error to function 00...).
I saw previous issue #7 - I already use patched version.
Arduino 1.8.19, target IC attiny402/804.
RS485 biased and terminators at both ends.
BTW, I already changed to _MODBUSINO_RTU_MAX_ADU_LENGTH 30
as tiny402 has 256B (I only need 10 registers) of RAM and declared req[_MODBUSINO_RTU_MAX_ADU_LENGTH]
as static, otherwise I had memory leaks and some random data sent.
What can be an issue? May it be a memory leakage somewhere else due to really small RAM resources?
Regards
I want to communicate with PLC(master) with other serial port and debug code with serial port 0. How can I modify your library?
I use libmodbus for linux and modbusino for my mcu. I realize that mcu does not respond to libmodbus request. As a consequences, libmodbus throw "Connection timed out". How can I solve it. Could you help me? My connection is checked and true. Both circuit common grounded.
Just wondered if you had a version of the code that wrote and read coils/bits?
Thanks
I found a logical AND error in the constructor of the Modbusino.cpp file and caused a compilation warning.
ModbusinoSlave::ModbusinoSlave(uint8_t slave)
{
if (slave >= 0 && slave <= 247) {
_slave = slave;
}
}
If you have a network with more than one slave there will be wrong responses (exception responses that shouldn't be done).
Supose that master makes a query to slave 1, then slave 2 sees the answer and sends "something", that I suppose is "response_exception".
The same applies to other slaves... more slaves more mess...
Basic solution: eliminate or comment the answer "response_exception" in Modbusino.cpp, line 191 and line 214.
Better solution: Make a better analyse of the frame to see it's not a answer from other slave...
Hope this will be corrected because it's an nice modbus library for Arduino.
I want to implement a very basic Modbus RTU slave communication to my ( 8051 ) 8bit EFM8UB2 microcontroller. If anyone done it before i would not reinvent it. Thank you.
I started using rather larger modbus tables, and starting hitting all sorts of buffer overflows :( (I have a very old fork, that was missing some of the earlier fixes for this)
But immediately, the define for RTU_MAX_ADU is just wrong. Setting this to 256 properly, as per page 5 of modbus app proto 1.1b3 results in requests for more than 64 registers succeeding, but requesting 128 registers for instance, passes validation but overflows. I know this is the "very very very cut down" version, so I'm not hanging out for a heap of fixes, just letting you know.
I see no other way to post, so post issue.
This looks like it might be something I would like to use, however the documentation, what this is of it, does not explain how this LIB works with the Arduino. Can you provide a near real world example?
For example, does this LIB only handle the comms between master and slave or will it read and write arduino inputs and output? If so what function are mapped to what I/Os?
-Ryan
It responds to everything for normal cases, and only checks for slaveid when it is considering whether to respond to an exception.
I want to use the TX1RX1 of the Arduino Mega, what should I do?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.