-
Notifications
You must be signed in to change notification settings - Fork 5
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
Arduino Giga not working as master #14
Comments
Update: I found the debug code you provided in this closed issue It's simply timing out every time, I've upped the Giga master's timeout but no result When I connect the Giga to my computer and monitor the serial traffic this is what it sends each update: |
There is a known issue with the ModbusRTUSlave library with the Arduino UNO R4 Minima, where the ModbusRTUMaster is also affected by this issue. I have not tested either of these libraries with the Arduino Giga, but it sounds like it could be the same issue. |
Thanks for your reply, I got very excited seeing your simple work-around, however it doesn't seem to work for me. A slight difference after adding the while loop to I'll try and do some traffic sniffing when I get a chance |
Here's what I see when I snoop the serial on the slave nano (ID:1, Write single coil)
Online parsers here and here show that the slave is seeing and sending the expected data. The Giga isn't even seeing the serial stream, it just times out every time with the check Another thing I'm observing which may be of interest; I have the DE/RE pins on both my MAX485 boards hooked up to LEDs to monitor traffic. When experimenting with adjusting delays as suggested in the issue you mentioned, the LED's for both slave and master light up simultaneously, for a longer period as set by the while loop. Shouldn't the LEDs be firing consecutively? |
I think it would be worthwhile to see what's happening on the Giga side. Yes, the LEDs should be firing consecutively. If both devices have their DE pins high at the same time, the RS-485 bus will be jammed. |
Thanks again for your reply. On second look it turns out the Tx from the slave was from a Modbus debug program I had running in the background on my computer, apologies for any confusion caused. The nano is seeing a correct modbus request, but not sending a response, although the Nano's on-board TX light and DE/RE LED's on its MAX485 are flashing. I've done a lot of experimenting with timing in your master/slave libraries but can't get this behaviour to change. The DE/RE LED's still seem to fire instantaneously, even with a long (non blocking) delay in I decided to swap the slave/master roles (giga=slave, nano=master, exact same code) to recheck things, and discovered that the nano works as before (read/write), yet for some reason the timeout flag is being triggered every time. I hadn't noticed this as I wasn't looking for it when I swapped roles last time. Going back to using the Nano as a slave, I tried a new board, the Mega 2560R3 in case the Giga/Nano microprocessor difference was causing problems. Exact same issue. Before you ask, throughout this time I've been trying different MAX485 chips to rule out faulty ones. Can I ask what setup you use for testing? I'd like to replicate it on my end and go from there as I'm currently tearing my hair out trying to get this to work. The project I'm working on would greatly benefit from many cheap arduino boards talking to a more capable master (Mega/Giga, anything with more than one serial port) Also let me know if there's anywhere I can donate to the project! I appreciate the responses here and the up-to-date library and would love to show it :) |
Update: Seems my issue has a few layers. I changed my wiring so master and slave RE is grounded all the time (as opposed to connected to DE pin), and now I seem to have write success from my Giga ( I've been experimenting with reading the serial stream directly using the following modification to
In my loop, I do one read request and a write, with 750ms in between. Here's the output:
Where Failure and Success are parsed from checking if ( What would the expected stream from the slave look like? Am I missing some data here? |
Using Serial.print(_buf[numBytes], HEX);
Serial.print(" "); instead of Serial.print(_buf[numBytes]); would yield more useful output. |
As for my test setup, I use a shield I designed that has some test IO and RS-232 and RS-485 circuitry on it. I have a collection of Arduino boards I use for testing; the Giga is not among them, however the Mega 2560 is. What code are you uploading? Can you share? |
I don't have anything setup for accepting donations and I have no plans to. |
Thanks again for your replies and time.
My apologies, decoding information at this level isn't my area of expertise. Here's the updated output (I've also been testing the other operations to see the data received):
As far as my modbus decoders are concerned, this is gibberish, any idea what might be happening here? I'm using a slightly modified version of your test code. I'm cycling through each function slowly so I can keep up with the output: Master.ino
Slave.ino
And I've made slight modifications to your library, marked with comments
Slave:
|
Ok, took me a while but I've noticed the serial output is just missing leading 0's. With this in mind, it seems readResonse is reading the request (italic) and response (bold) from the stream 11:49:22: Write singlecoil : 01 05 00 00 FF 00 8C 3A 01 05 00 00 FF 00 8C 3A END The stream only contains the request if I disconnect the TX from the slave. If I disconnect either dePin or RX I just get a timeout |
Update: the problem's definitely an odd one, but I have a workaround. It seems grounding the RE pin on the master made serial always available, which sort of explains the request echo. I wasn't able to get rid of it by changing DE pin timings, it seems to happen across all my MAX485 boards, and I can't find anyone online who's experienced echoing within the MAX485 For now, I've created a fix I'm reasonably happy with, just by filtering the echo in the Master code:
Hopefully this still works with more devices connected, I'll do some testing and get back to you |
Hello, and thanks for providing this excellent and up to date Modbus library.
I'm having problems using my Arduino giga as a master in a network of Arduino nano's. I've tried various implementations, from the examples provided in your library to even more basic read/write operations for all data types.
I would have thought the issue could be in my network (wiring/rs485 modules etc), but oddly enough simply porting the master code onto one of the Nano's, and the slave code on the Giga works flawlessly.
For now as a workaround I'm using a nano as a "relay" device to send instructions between the giga and other nanos but as you'd expect this is getting extremely cumbersome (not to mention the IO overheads.
I unfortunately don't have any other arduino boards to hand, so can't see if it's an issue with the Giga, and other Modbus libraries don't work at all with my setup.
Thanks in advance!
The text was updated successfully, but these errors were encountered: