PDA

View Full Version : Working with RS485



The Master
- 6th July 2008, 17:58
Hi, im back to my disco lights again now i have a little money. Im going to use RS485 now as recommended by people on here. Ive had a look on google and it appears there is a MAX485 chip (http://www.datasheetcatalog.org/datasheet/maxim/MAX1487-MAX491.pdf).

Ive read on the net that there is a need for a 3rd wire to link the grounds together and a shielded wire. The wires im using are XLR Mic/DMX wires. The longest is 20 meters and works fine for DMX. Im not sure if these wires are shielded or even twisted pair though. I would have thought not since there are 3 wires inside. Ive never noticed any interference while using them with DMX lights so will they work with RS485?

Does 3 wires mean i can only have a 1 way signal? The diagram at the bottom of page 7 in that datasheet almost makes it look like i can have a 2 way signal but i cant see how that would work.

How do i connect this chip to a PIC chip? Is it as simple as putting wires between the 2 or do i need resistors etc? Looking at that diagram it appears i dont need any external capacitors like i do with MAX232. Is that right?

dhouston
- 6th July 2008, 21:49
Here is a very thorough white-paper on RS485.http://www.bb-elec.com/tech_articles/rs422_485_app_note/table_of_contents.asp

The Master
- 6th July 2008, 22:18
That looks really interesting. Ive only read the first page so far but it seems to be making sense. From what i can see it looks like only 1 device can be sending at any one time but it can stop sending and allow another device to send instead. I think thats why there are 4 pins on the MAX485 chip for data. 2 of them look like they switch between sender and receiver. It sounds a bit like DMX and would explain why manuals for DMX lights say you can damage them by having 2 devices set to master at the same time.

I dont *need* bi-directional communication but it would be nice. There will be a master box which takes an input from RS232 or USB and converts it to RS485. Everything else will simply listen but it would be nice to add functionality for each device to become a master if the main box fails or the PC crashes.

I will continue reading about it tomorrow when i have more time.

Thanx for that. Even just the first page is a huge help

dhouston
- 7th July 2008, 13:21
If you also read the DMX512 specification you will see that it is essentially a variation on RS485, running at very high speed and with the master constantly repeating commands (or state table). Cables that work for DMX512 should also work for RS485 although perhaps not at the extremely long distances possible with RS485. Before interconnecting grounds you need to measure the difference in potential (i.e. voltage difference). If more than 7V, connect to local ground through a 100-ohm 1/4W resistor. This is detailed in the official RS485 specification. You might also do a web search using "Jan Axelson RS485". You should find a few magazine articles by her, including one which shows using a 555 timer chip to automatically reverse the line after a transmission. She writes very clearly.

The Master
- 7th July 2008, 19:09
Just a thought, All of these lights will almost certainly be run from the same AC socket. If not then definately in the same building. Each one will have its own transformer though. Is that what causes the ground difference?

The total distance between the master and the final slave wont be more than 50 meters.

Im not quite sure i understand ground difference properly. Each device has a transformer so its isolated from the mains. i cant see how i could get a reading accross 2 grounds unless im thinking of something different. Im sure this is explained in the rest of that document though

dhouston
- 7th July 2008, 20:57
http://en.wikipedia.org/wiki/Ground_loop_(electricity)
http://www.epanorama.net/documents/groundloop/
http://www.trinitysoundcompany.com/grounding.html
http://zone.ni.com/devzone/cda/tut/p/id/3394
http://en.wikipedia.org/wiki/DMX512-A

The Master
- 8th July 2008, 10:07
Ive read all of those documents. I understand the one about DMX but the ones about ground loops are a bit confusing. From what i can see i shouldnt have a problem because all devices are isolated from the mains using a transformer for power and opto isolators for the triacs. There are earth wires going inside the lights but they dont connect to anything since the lights are made of wood. Each light has IEC in and out sockets so all of the lights could be run from a single socket. In practice i will probably have them in 2 groups (left and right) but no matter how many groups i have they will all plug into an extension so they will all run from just one wall socket.

I wouldnt have thought i would have any problems because of all the low voltage stuff being completely isolated from the mains and the short cable distance but i have noticed problems with my speakers before. If i connect a laptop to my mixer at the same time as my speakers i get very loud buzzing until i press the ground lift button on both speakers. That happens with the laptop, mixer and speakers all plugged into the same extension

dhouston
- 8th July 2008, 13:57
Ive read on the net that there is a need for a 3rd wire to link the grounds together and a shielded wire.If you do that, then you have to be concerned about ground loops. Read the section on grounding in the B&B app note.

Ground loops are very difficult for most people to understand. If there's any current flow between "ground" points, there can be problems. And, the fact that ground loops can act like a loop antenna with currents induced by electromagnetic fields complicates things even more.

The Master
- 8th July 2008, 17:05
I think i kinda understand the problems you get with ground loops but i cant seem to relate that to an RS485 connection. As far as i know you get 2 wires (A and B) and the output to the PIC chip only changes if there is more than 200mv between A and B and it changes to 1 or 0 depending on which input has the highest voltage. Does that mean that you dont need a 3rd wire running between devices if its on a small scale?

I re-read the app note about grounding and there are 2 drawings. I think i might need the one in Figure 4.4 Isolated RS-485 Device (http://www.bb-elec.com/tech_articles/rs422_485_app_note/transient_protection.asp#ground). The only thing im not sure about is that that drawing shows the ground isolated from the circuits ground. Is it not enough to have the circuit etc isolated from the mains ground?

dhouston
- 8th July 2008, 19:38
Does that mean that you dont need a 3rd wire running between devices if its on a small scale?A 3rd wire is going to defeat your isolation. In many networks, power is supplied over the cable from a single source. That leads to mixing grounds and requires attention.If you will power each node individually, you don't have that problem.


I re-read the app note about grounding and there are 2 drawings. I think i might need the one in Figure 4.4 Isolated RS-485 Device (http://www.bb-elec.com/tech_articles/rs422_485_app_note/transient_protection.asp#ground). The only thing im not sure about is that that drawing shows the ground isolated from the circuits ground. Is it not enough to have the circuit etc isolated from the mains ground?You have to either isolate it completely or deal with the mixed grounds. A little mixing of grounds is akin to being a little bit pregnant.

The simplest thing to do is run the ground wire between nodes but connect it to each local ground through 100-ohm current limiting resistors.

I recomment Jan Axelson's Serial Port Complete which covers RS232 & RS485. The subject is complex and really cannot be covered here.

The Master
- 8th July 2008, 22:13
I will google "Jan Axelson's Serial Port Complete" tomorrow. Im off to bed now.

What exactly do you mean by "isolate it completely" is that having each device isolated from the rest of them or having each device isolated from the mains using a transformer?

You seem to be saying that i shouldnt have the 3rd wire in this case but then you say the easiest thing is to have one. I think i might have misunderstood on of those paragraphs.

You really wernt joking when you said "Ground loops are very difficult for most people to understand". I definately fit in the "most people" category