-
Notifications
You must be signed in to change notification settings - Fork 190
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
Modbus RTU - Serial Direction Pin #62
Comments
For example: https://www.ti.com/product/ISO1430 The DE and RE pins normally are connected together and this way you control the direction of the communication with just one pin. |
SORRY. I just saw you already implemented this.
Could you add a way of changing the logic? Somethins the txPin is inverted logic (like in this IC TD331S485H-E) and you need to write 0 on txPin to send data and 1 to receive. |
Hello, bool begin(SoftwareSerial* port, int16_t txPin=-1, bool direct=true);
bool begin(HardwareSerial* port, int16_t txPin=-1, bool direct=true); Changes have pushed to master branch. For inverse logic use mb.begin(&S, TX_PIN, false); |
Wow you are FAST. Thanks! I will try it during the weeking. Thanks again!! |
Ok. I tried modbusRTU as slave and as a master, using an inverted logic RS485 tranceiver. Everything works as expected. Thanks! Closing this now... |
Is there a way to add this to bool ModbusRTU::begin(Stream* port) {
_port = port;
_t = 2;
return true;
} |
Hello! First I want to congratulate you on such a great work you are doing.
Second I would like to make a request. When you are using Modbus RTU most of the times you use RS-485. And for using RS485 you need a transceiver.
The thing is, the transceivers need an extra line that tells them the dirección of the communication. When you are "hearing" for new data, the transceivers output must be in high-Z mode. So you must set this pin accordingly. When you want to send data, you must change the state of this pin. In the IC I'm using is HIGH to read, and LOW to write. But lots of other ICs use inverted logic.
What I would like you to implement is:
Add a method to tell MODBUS RTU that for writing or reading it must change the status of a pin. The pin number must be given on calling this method. Also, on calling this method you should also specify the logic (0= RECEIVING 1=SENDING or 1= RECEIVING 0=SENDING). You could make some define and specify them as NORMAL_LOGIC and INVERTED_LOGIC?
Finally, some transceivers have automatic direction recognition. So for those transceivers this pin is not needed. So if you don't call this method when creating de modbus rtu object should be Ok too.
That's all my friend. This would make your library really useful when using modbus RTU.
The text was updated successfully, but these errors were encountered: