The (short) scenario:
I'm working through developing a project that will end up using RS-485 and Modbus RTU. So far I have been developing the master and two slaves (one at a time) using just TTL. Master and Slave 1 works. Master and Slave 2 works. Now I need to combine them, but would like to do so without introducing the RS-485 boards yet.
The problem:
Master Tx to Slave 1 and 2 Rx I can just split. Slave 1 and 2 Tx to Master Rx needs to be ORed together so as to not connect two outputs together.
I don't have any 74xx32 OR gate chips, but I do have some 7400 NAND gates which are easy enough to turn into an OR gate. I tried that and it wasn't working. The chips are old, so I used a breadboard to test each chip. I have a few suspect ones and some that test good. But no luck and getting communications established (unfortunately I do not have a oscilloscope).
But...I accidentally combine the two Slave TX and the Master Rx pins and it started working.
So, the question to the group is: what gives? Why when combing the pins does it work. That indicates to me that only one slave is talking when it should. I can't think of what effect adding the OR gate could have. Is it the 7400 chips? Are the 7400s not compatible with the ATMega328? (wrong Vil/Vih and Vol/Voh values)
TTL serial is active low. So if you used an OR gate, you'd get a high (idle line) if either of the inputs was idle, and gibberish if both were sending data.
You can or them with a pair of diodes (diode from RX of master to each slave TX) - you might also need a pullup resistor on the master RX; I don't think the AVR's enable the pullup on the UART RX pin) or an AND gate, but you'll get gibberish if both transmit at the same time.
There are no other connections other than what I listed. That's all of the folks. NAND chip turn into an OR gate as found on the web and the 2 pin 9 inputs and the pin 19 output.
adwsystems:
If they outputs are tied together to the input it works. That indicates to me they are not both trying to talk at once.
I also tried a diode or gate (web says pull down at OR gate output). No joy there too.
You wired the diode ORing wrong, then, post schematic. Did you put a pullup to Vcc on on the RX line? Did you put the diodes the right way around? band should go towards the RX lines (since it's active low).
An OR gate will not work. You need an AND gate, because a TTL serial line is HIGH, not LOW when is is not transmitting. If you OR together two lines, one of which is transmitting and the other of which is not, the output will be constantly HIGH because the idle line is HIGH - HIGH OR'ed with a signal is HIGH - no signal out.
adwsystems:
There are no other connections other than what I listed. That's all of the folks. NAND chip turn into an OR gate as found on the web and the 2 pin 9 inputs and the pin 19 output.
larryd:
Attaching a proper schematic shows others exactly what's happening.
In almost all cases I agree. This would be the exception. Did you see the schematic attached above? Was it really of any help? I know you don't believe me, but that really is all there is to the system...for now.
Build programs and hardware in blocks and layers. That way I have a proven working fall back point. That's how I know exactly what was and was not working above. Little did I know that serial TTL was active low logic. Surprise on me.
RS-232 logic and voltage levels
Data circuits Control circuits Voltage
0 (space) Asserted +3 to +15 V
1 (mark) Deasserted −15 to −3 V
For TTL, asserted is 0V
I believe you. (and the seriously pertained to the CTS et al. being inverted as compared to data) I never noticed or realized the data was inverted. My hindsight is a bit dumbfounded at the moment (perhaps that's a senior moment).
Funny thing. In all my years of working with RS-232 (which was almost a full time thing between 15 and 20 years ago). I never noticed that.
Seriously, the fact that RS-232 is NEGATIVE LOGIC (-v for "1") is RS-232 101.
It is so basic, it is almost always mentioned within 15 minutes of the start of any lecture on RS-232.
To admit that you never noticed that is to admit that you didn't do your due dilligence. There could be
a thousand reasons why, but realistically, if you didn't have to troubleshoot it you probably didn't have
a reason to know because if it works, then what more do you need to know ?
Just sayiin', that is pretty basic.