I have worked allot with RS232, and other serial protocols, but this is my first RS485 project. It seemed straight forward to me, but now I have a big problem.
I am using the max490 chip. I'm doing full duplex, 4 wire. Each of my nodes have the max490 communicating with a 16F877A pic chip. The whole project will have 25 nodes. I just built two pcb's (nodes) and individually they work as expected. However when I put both of them on the rs485 bus, I can't talk to either of them! Probably some kind of collision, but as it turns out my scope just died and I'm on a tight deadline. Any help is greatly appreciated.
Check your output enables. You can't have both on at the same time. The system must be designed to allow only one transmitter to be on at a time. The easiest way to do this is to have the master poll each device in turn. When polled, each device can then send either a NoData packet or reply with the data that it needs to send. This approach was used for several generations of point of sale systems and works quite well. You will need to have unique addresses for each device and a means of setting them.
Sounds like you are not enabling them properly. Obviously they cannot all communicate at some time and there must be some type of arbitration/negotiation.
Since it seems that it has to do with the number of devices chances are this is the problem. How are you arbitrating the chips? AFAIK there is no built in arbitration for RS485 unlike I2C so you'll have to implement it yourself.
Basically only one chip can be enabled to communicate at any one time and you do this either by selecting that chip or where each chip checks to see if the bus is free(if the enable pin is low then it can raise it and take control(for the most part as it is possible two or more devices could simultaneously take control which can cause problems)).
You really haven't given enough information to give any real help. AFAIK RS485 wasn't meant to be used as a bus(but I have done no real work with RS485 so I could be wrong and I'm not saying it can't work). If that is the case then that is your problem and you'll need to go from there.
That's the thing, there are no output enables with the max490 chip. I do have unique addresses, and I can call each board by itself with it fully functioning. Its when I put more than one board on the network(485) that I can't commmunicate with any of them. Not that it should matter, but I am using a modified RTU Modbus protocol.
There are. It's called DE, pin 3 on the SO package. You need to use those.
If you don't use the DE pins I have no idea how you'd get this working. In case you do use them, have a polling system set up like Bit Farmer described and it still doesn't work I urgently suggest you borrow a scope. Someone in the area has got to have one, it can be a fairly simple and slow 2-channel scope. Best would be a digital scope but I guess with the tight deadline you can't be picky.
Thanks for your input, Joerg, however I must disagree. There are no enables on the max490 chip. They do exist on the 489, 491 however not on the 491. The 491 is apparently auto negotiable, however I can not find documentation on how it is implemented. Thanks.
No it does not. If you look at the application info, its used for repeaters.
What you can do, is use one chip for RX and one for TX. And power down the TX chip when not transmitting. When the 490 is powered down its output might be in a high impedance state. Look at the LTC490. Or use a transceiver with enables.
You have to turn the transmitter on under processor control, and for that you have to have an enable pin on the transceiver. That chip isn't really an RS-485 transceiver at all -- it's more a 422 transceiver without internal terminations.
Sorry. That's the breaks.
Either daisy-chain everything, with board 1 transmitting to board 2 etc., back to board 1, and wait for the system failure when one board fails, or rip out the 490 and put in a real 485 transceiver, like the MAX-485.
Control system and signal processing consulting
Yeah, thats what I was affraid of. I was grabing at straws, I was hoping someone would see a way out of this. Thats what happens when you get caught up in the rush, and get talked into "not waisting time making a prototype". I think I will order the max491 and hack the hell out of 25 boards.
In a "4 wire RS-485" network, the master will always have both the Tx as well as Rx active all the time.
The slaves will always have the Rx enabled (listening for the master Tx pair), however, the slave Tx must only be activated, when that slave has been addressed and is ready to send the response to the master. Have you looked at e.g. MAX485, which has separate ReceiverEnable and DriverEnable pins, which you need for the slaves.
I do not know about the PIC UART, but make sure that actually the last stop bit for the last byte has been transmitted out of the shift register, before turning off the transmitter.
Some stupid UART designs such as the 14550 family generate an interrupt when the last byte has been loaded into the Tx shift register, however, you can not turn of the transmitter at time, but you have to wait for the last byte has actually been shifted out.
For Modbus, you should actually keep the transmitter enabled for an additional 3.5 character times after the last data byte has actually been transmitted (thus sending constant Mark state), however, with a properly terminated line, this is not necessary as the last stop bit will put the line into the Mark state and the "fail-safe" termination will keep the line in Mark state, even if the transmitter is disabled.