-
-
Notifications
You must be signed in to change notification settings - Fork 233
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 via GPIO RPi3 #107
Comments
hi, thanks 👍 a. can you write a test program that fails because of this ? |
a) I have a test program that fails (I think) because of this. b) no... I don't know how to do that. |
I do not fully understand what is the problem ... a. the extra byte comes from the master ( computer running nodejs ) or b. the extra byte comes from the slave ( controller ) ? |
it's in the response. it adds a 00 in front of it. (b) |
Ahh..
|
@philesgilles did the |
no, with the RTU i had a CRC error code and RTU-buffered i have a "empty" then timeout |
Using a USB to RS485 switch to ttyAMA0 |
Hi ! With a USB to RS485 (2wires) no problem. I was making all the tests with that one. I bought a stratopi board (this one: https://www.sferalabs.cc/product/strato-pi-ups-board/) |
I think it's the exact same problem as here: stephane/libmodbus#302 With USB to RS485 with GPIO Is there a way to flush the buffer on port opening ? |
a. their are lots of things that can fail on ttl communication [ boud, voltage, direction ... ] you need to be very careful when connecting two hardware devices using ttl, did you try just to send "hello world" message between your two devices ? b. who is the master (the computer running nodejs) - the raspberry pi (strato pi) , a laptop ? d. what hardware is connected to the other side of the rx/tx ? |
pi is master, connected via the stratopi RS485 port to a countis counter and a arduino for testing write functions. The code up is not mine it's from the topic linked. I'll try to make a fresh install and see if something i did before is the problem. |
a. As best practice you should not connect raspberry pi to an arduino using ttl ... b. You can write a small program in your arduino that send data, listen to it on your pi (write some code that open port and listen), and see if you get that extra 0x00 ... c. Post here the code that fails using modbus-serial, maybe we can add the missing |
@philesgilles any news ? |
@philesgilles closing, if you have new info, just post it here ( we can re-open if needed ) |
I'm trying to connect Modbus Via GPIO ttyAMA0. |
@surbhigup hi, thanks for your comment, This library has no files named Please give as much information as you can about what you are doing, so we can try to help. |
hey yaacov |
I want to do this by serial ports of Raspberry Pi. Any more information needed? |
a. the raspberry will be the master ?
The easiest way to connect raspberry to a rs485 line will be using a usb to rs485 connector:
well you are asking here ... this library is called |
ya raspberry is the master. I got success by usb to rs485 connector but i want it to do with GPIO pins. |
max485 requires manual direction control view pins de and re, how do you control this pins ?
The only one that may have manual support is |
Have you made the modifications to activate the right serial port on the Pi 3? I had lot of problems using the default mini UART.
=> https://www.raspberrypi.org/documentation/configuration/uart.md
If all is working with an usb adapter, then the problem is the port on the Pi.
Satprod
Philippe Gilles
Sound engineer, Product developer
Think about the planet before printing this mail !
CONFIDENTIALITY CAUTION:
This message is intended only for the use of the individual or entity to whom it is addressed and contains information that is privileged and confidential.
If you, the reader of this message, are not the intended recipient, you should not disseminate, distribute or copy this communication. If you have received this communication in error, please notify us immediately by return email and delete the original message. Thank you.
… Le 25 mai 2018 à 13:52, surbhigup ***@***.***> a écrit :
I want to read the holding registers of the slave.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@yaacov I only try the example which is given in libmodbus library. |
@philesgilles but cant understand they are right or wrong. |
yes, max485 can not transmit unless you force the re and de pins.
yes, you can give only rx and tx from the rpi, but only if you implement the electronics that control the re and de pins for you automatically, like the usb modules do. |
@philesgilles My Rpi shows this configuration of serial ports. |
Never tried it, so I don't know ... should work in low baudrate ... |
Someone has experienced it with success and has an example of how to use MAX485 chip on ttyAMA0 port? |
using [1] https://node-serialport.github.io/node-serialport/BaseBinding.html#drain |
I was just about to try this same thing. Best thing to do would to probably be to raise events for data transmission end and start (or beforeStart) so the logic to control the pins can be handled outside of this module (using the raspberry pi GPIO module). that would keep this module more generic then. |
Good day, I'm trying to connect Modbus Via GPIO ttyAMA0.
When I check with an oscilloscope the RX pin, the message return well. So I've made a few research and it seems that there is a glitch so we receive a <0> front of the message.
I don’t know if you can change something in your code for fixing that?
=> stephane/libmodbus#302
I don’t know how to test it… But seems basically after a ‘modbus connect’, it need to to be added :
if(value == 0)
{
modbus_flush(ctx);
}
best,
The text was updated successfully, but these errors were encountered: