You are between a Rock and a Hard Place, I just went through this process. The software serial gave me an advantage that I could turn the transmitter off after the message was sent. I was not able to do that with the mega, the information that the last bit has been sent is not available. I use Nano, Uno and Mega on my network but with different purposes. What I wound up doing is modifying the eBay cheap RS484 boards so I had auto TX enable, this is working great at 19200 baud, however the boards are SMD. What I did since my system is multi master is have each unit monitor its own transmission then check if it was valid. The Mega was nice in that it would buffer the whole packet then when finished I could just compare the sent packet to what I received. The remotes would send an ACK if they received a good packet. I have the ACK but I have not done anything with them yet. Since this in a non arbitrating bus my packets are about 13 bytes in length so they go fast. I do test to see if the buss is busy, if so pause a short time.This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
Also, consider using a robust serial transfer library to automatically packetize and parse data between Arduinos. The library can be found in the Arduino IDE's Libraries Manager and is super easy to use:
If you have exactly 4 masters then you can use 1 software serial and the 3 hardware serial ports on a Mega2560. Look for the Tx/Rx labels next to pins 14-19.
If you have more than 4 masters then you will need to use multiple software serial ports and enforce 'round robin' coordination so that only one master is sending data at any point in time. You could use 'flow control' messages or hardware outputs to signal when each master is allowed to send data.
DJMatrix-HU3:
problem is occurring in the datacenter, I need to receive information from several masters at the same time
Possibly when you say info from several masters at the same time you mean simultaneous? With very limited info, yes you can.
Mega2560 has many ports that you can read 8 bits simultaneous in a fraction of a microsecond and process those with bit logic, but is that 8 masters w/1 bit each or 4 w/2 bits or can multiple ports be read quick enough to call "at the same time", is maybe 4 microsecs to get 32 bits info fast enough? Direct port read is 5x faster than Arduino digitalRead(), works in Arduino IDE.
All ATmega chip UARTs are capable of being full speed master-mode SPI ports. The Mega can keep Serial and still host 4 SPI buses to hang the slaves on but use small boards with header pins or custom PCBs, not Unos.
As a former systems analyst, I have to ask about the VALUE of the data you are dealing with? If data is missing or corrupted or incomplete, is anything of value lost? Your system seems to give NO value to the data. Is this the case?
problem is occurring in the datacenter, I need to receive information from several masters all on USB at the same time
Simple as get a powered USB HUB?
You have 2 USB ports on your PC? Plug an Uno into each and open Arduino IDE twice. Associate each to a different board/serial port. Your PC program can read them both, I hear that Python is suited.
Paul_KD7HB:
As a former systems analyst, I have to ask about the VALUE of the data you are dealing with? If data is missing or corrupted or incomplete, is anything of value lost? Your system seems to give NO value to the data. Is this the case?
Paul
yes, the data has a value and is of fundamental importance
on my master / slave test system there was no byte loss ... all slaves are mapped to c ++ software and there is a timeout that detects when a slave is not responding
DJMatrix-HU3:
yes, the data has a value and is of fundamental importance
on my master / slave test system there was no byte loss ... all slaves are mapped to c ++ software and there is a timeout that detects when a slave is not responding
Thanks for answering. Then you really need to be able to detect one or two or more bit errors in your messages. When everything is perfect during testing, then you need to be able to discover if an error ever occurs.