TTL to RS485 Project - Page 1
Forum section: electronics / projects

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 27, 2012, 01:37:53 am
content: Hey,This is my first post here but I have been watching the blog since the early days, can't say I understand it all as I am not an EE however I am working on a project I would like some feedback on, I am a super beginner so please be nice!I am trying to use the Maxim MAX1483 (CPA) chip to make a through hole PCB (my first proper one) to allow TTL to RS485 conversion for a SAAN: Small Arduino Area Network!Maxim MAX1483 DatasheetHere is my design:Click to enlargeMy plan is to have two RJ45 sockets so the boards can be daisy chained and I can use cheap Cat5 as its the closest I can get to 120ohm cable, which is the RS485 spec, (Cat 5 tends to be 100ohm).I also intend to make little RJ45 terminators which will consist of a 120 ohm resistor stuffed into one of those DIY RJ45 plugs across pins 4 and 5 of the RJ45 plug.Would be good to know what people think about the design, and if there are any glaring errors or omissions before I route the board and send it toDorkbotPDX.Thanks in advance!Tom

author: Psi
author_rank: Super Contributor
timestamp: February 27, 2012, 01:52:26 am
content: I see you have ground connected to the RJ45 socket. That would mean ground for every device in the chain will be connected together.I've not really used RS485 before, so i could be wrong about this, but i think that's not ideal.As i understand it RS485 is differential and intended so devices at different ground potentials can communicate without issue.If you try and short all the grounds together you might get conflicts between each device and mains ground vs your ground. Then you could get current flowing down your ground wire between devices.But again, i'm not sure.

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 27, 2012, 01:24:38 pm
content: From my reading about the specification it is normal to have a shared ground, for example recently in a video podcast (mikeselectricstuff) he was frustrated with the lack of ground...

author: vk6zgo
author_rank: Super Contributor
timestamp: February 27, 2012, 02:21:58 pm
content: Quote from: unknowndomain on February 27, 2012, 01:37:53 amThe last time I had anything to do with RS485,we used one pair of a 2 pair audio cable,( the factory used audio connectors),but it was a fairly slow system.Your schematic looks a lot like the one we had,but the Chinese used a Max485.We thought we had data problems,but it was internal PCB connector faults.We wasted a lot of time learning about RS485!Make sure you don't multiple terminate the cable---if you daisy chain several devices,only terminate the last one in the chain.If it is a short run & low data rate,it will usually work without terminations.I think I have a website on the other PC's favourites which gives a lot of background on RS485.I will try to find it .

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: February 27, 2012, 02:53:29 pm
content: I'd suggest :Connect ground via something like a 10R resistor - this reduces the risk of high currents circulating in the data ground if a power ground comes off where nodes share a common supply.Where nodes are spaced a long way apart on seperate supplies, galvanic isolation is the only surefire way, although if local supplies are not connected to a common (mains) ground this will generally be OK.Use an already established pinout instead of inventing one. One that comes to mind is the ESTA pinout for DMX over cat5. :pin 1 D+, pin 2 D- pins 7 & 8 ground.Line biasing is a bit of a thorny one - you generally do want it to avoid glicthes when transmitters turn on, but with bias on each node, when the line is terminated, the amount of bias depends on the number of nodes. there isn't a simple answer to this one, and it will be application dependent.

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 27, 2012, 03:21:47 pm
content: Quote from: vk6zgo on February 27, 2012, 02:21:58 pmThe MAX485 is 1 unit load, while the 1483 us 1/8 unit load which means theoretically you can drive 8x the maximum number of units on the bus, i.e. RS485 is spec'd for 32 unit loads, which means at 1/8th load you could have 256 units.Quote from: vk6zgo on February 27, 2012, 02:21:58 pmThe resistors I have used are for biasing when there is nothing connected, realistically this is probably unnecessary as the board isn't really designed for hot plugging etc, it will be integrated into another project, this is just a test module.Quote from: vk6zgo on February 27, 2012, 02:21:58 pmWould be amazing, although I have done a fair bit of reading, and most of my issues come from not understanding enough about electronics, rather than not understanding RS485.Quote from: mikeselectricstuff on February 27, 2012, 02:53:29 pmThis is intended for short range use, I will bosh together another schematic with the changes and post it later. I didn't really understand how optocoupling would work as it goes between the RS485 line and the MAX1483 right?Quote from: mikeselectricstuff on February 27, 2012, 02:53:29 pmI had been looking but didn't think to look at the DMX standard, will definitely switch to this.Quote from: mikeselectricstuff on February 27, 2012, 02:53:29 pmSo perhaps leave the resistors unpopulated on the board unless I need them later?

author: Psi
author_rank: Super Contributor
timestamp: February 27, 2012, 11:32:42 pm
content: Interesting about the ground and RS485, i didn't know thatJust a point about optoisolators, you don't have to use the typical single-transistor optos and then muck around with pullup resistors and signal inversion issues etc.There's a wide range of proper digital push/pull output optoisolators. Some of them handle up to 2A of output current which can be good for long distance cable runs.

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 28, 2012, 12:07:25 am
content: Quote from: Psi on February 27, 2012, 11:32:42 pmNever seen these, I am still somewhat confused as to why you'd bother using a 1/8th load driver if your going to optoisolate, perhaps I would be better using a cheaper single load driver with said optoisoloator, however I am confused as to how you would know how many units you could have on the bus as you can't predict how many units they count for.Showing my lack of knowledge now... Anyone know any London based evening classes that I can take?

author: vk6zgo
author_rank: Super Contributor
timestamp: February 28, 2012, 01:00:40 am
content: Here's the website I was talking about.Of course,they have an ulterior motive because they sell stuff,but the info is still good.http://www.bb-elec.com/technical_library.asp

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 28, 2012, 01:18:14 am
content: I saw that website but because the pop up window is so quick I closed it and didn't realise I had actually gotten access to this info, will be having a good read of this, I though I had to pay for the content!

author: Unknown
author_rank: Unknown
timestamp: February 28, 2012, 01:33:06 am
content: Quote from: mikeselectricstuff on February 27, 2012, 02:53:29 pmGood advice, RS485 comms is often though of as a black art. It is not! All common problems can be clearly identified and explained.On the bench you can hook up multiple devices with anything up from damp string. On short runs Cat5e will OK but for longer runs you'd want to be using a properly specified twisted screened pair cable. Screened Audio cable while better in noisy environments is also unsuitable for long runs, a good quality low capacitance data cable is essential.RS485 has a maximum length, a minimum cable spec and a maximum number of devices per segment. Only fools and salesmen attempt to fully populate a segment of minimum spec cable over the maximum distance. It may work for some simple ping tests, but will fail dismally as data traffic increases.

author: gxti
author_rank: Frequent Contributor
timestamp: February 28, 2012, 01:40:46 am
content: I imagine that the easiest and most reliable way to galvanically isolate is to put the transceiver on the far side of the barrier, along with a DC-DC converter to bring power across. You can get a potted 5V-5V converter with 1kV isolation for $5.24 here, for example:http://search.digikey.com/us/en/products/VBSD1-S5-S5-SIP/102-1360-ND/989815. I'm somewhat suspicious of the 1kV rating on a device where the pins are only 100 mils apart, but the main goal of preventing ground loops doesn't require mains-rated clearance and there are also models with proper spacing for only a little bit more money.I happen to have been poking at something like this earlier, here's the schematic I drew up:http://partiallystapled.com/~gxti/circuits/2012/02/27-rs485.png

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 28, 2012, 01:52:48 am
content: I dont really understand why I need to isolate devices?

author: gxti
author_rank: Frequent Contributor
timestamp: February 28, 2012, 02:05:00 am
content: Isolation is necessary because you can't always guarantee that the grounds on all your devices will be equal. If you're running RS485 across a thousand feet of factory floor (which, granted, you probably are not) you can guarantee that your grounds will not be equal! This means that if you connect a ground wire between two points with different ground potential, a current will flow in your ground wire, which is not good. Even if you take the ground wire out, you risk damaging equipment because the common-mode voltage on the data lines is too great.You don't have to isolate, but if you do, it will make your system more reliable. Maybe not required for an "Arduino area network" but it's essential for industrial equipment. I wouldn't lose any sleep over it.By the way, don't bother with the termination resistors. They're unnecessary at low speeds and/or short distances, and if you do need them, they should not be soldered to the board because they must only be installed at the ends of the chain.

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 28, 2012, 02:14:51 am
content: Everyone thinks I am song terminator resistors on every device!The resistors in the schematic are for biasing, pull up / down. The terminator will be in a empty rj45 plug with a bit of glue and hackery.

author: Psi
author_rank: Super Contributor
timestamp: February 28, 2012, 02:26:57 am
content: It doesn't need to be isolated to work, it's just the correct way to do it.The 10R resistors Mike recommended is fine for hobby/short runs in a non-industrial environment.

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 28, 2012, 02:31:43 am
content: Okay. And that's 10R in series with ground onto the cat5

author: vk6zgo
author_rank: Super Contributor
timestamp: February 28, 2012, 05:33:24 am
content: Quote from: unknowndomain on February 28, 2012, 01:18:14 amYou shouldn't have to pay,just close the pop up that asks you to register ,& the stuff should be ready to download.I must admit,I didn't look closely this time,but we never had to pay before!I registered,& they've been sending me e-mail updates ever since.PS:I just checked,it only brings up that page once,then if you click "close this page", you can go on & read the info online,or download it,free.

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 28, 2012, 02:14:21 pm
content: Quote from: vk6zgo on February 28, 2012, 05:33:24 amYeah, I know super annoying but I guess if I register then it would stop pestering me, was a great read, they have an eBook which covers everything @mikeselectricalstuff and others have said.100ohm ground series resistorOptoisolate only for large runsTermination is not necessary at this low speed / distanceCAT5 is perfect for thisDaisy chaining like I have done is the norm.Biasing resistors are only necessary if there is a situation where all your drivers switch off, in my circuit there is only one driver and its enabled permanently.So looks like common sense and a fair amount of reading and conversation has helped me get what the eBook recommends!Tonights plan after work is to update the schematic and start routing a small PCB.

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 29, 2012, 12:21:51 am
content: I have removed the biasing resistors from my design, as I said before because I will be using a jumper to enable the receiver / driver which means that the the line will always have a driver enabled so the line won't end up floating, additionally I have added the 100ohm resistor as suggested by @mikeselectricalstuff and the aforementioned ebook. I have also switched to the DMX standard.Click to enlarge

author: unknowndomain
author_rank: Regular Contributor
timestamp: February 29, 2012, 01:17:19 am
content: Here is my first route of the board, and I have fixed an issue with the above schematic and updated in place.

author: steve_w
author_rank: Regular Contributor
timestamp: March 10, 2012, 10:48:01 am
content: Have a look at the elektor magazine series called "here comes the bus", lots of good RS 485 info there.

author: unknowndomain
author_rank: Regular Contributor
timestamp: July 25, 2012, 08:22:48 pm
content: Since my last post I have received the boards I designed, built them up and tested them, they work but the data I get back isn't what I put in, which is strange.I bought a Phillips PM3216 oscilloscope and learnt the basics of using it so that I could trace the path of the signal through the circuit to ensure everything was as it should be, the test setup I have features a program transmitting 0x55 through my board and using a RS-485 to USB converter to see what comes back, which unfortunately isn't 0x55 but 0x66, 0x33. Some how my data is going wrong in transit, and I need help to fix it.This image shows the RS-485 A and B channels are working, the signal is inverted correctly and the two are in sync.The next image shows the waveform of the software TTL serial being sent into my board, and TTL level serial coming out of the UART pins on the other side. They match just fine, and to proveSo this begs the question, why do I get 0x66, 0x33 out repeatedly for every one 0x55 I put in. Furthermore why is it that for any single byte I put in I get a unrelated pair of bytes back out?I am totally baffled at this stage, help, advice and guidance very, very much appreciated.

author: unknowndomain
author_rank: Regular Contributor
timestamp: July 25, 2012, 09:35:25 pm
content: FIXED: The issue was I was using one of the example Arduino sketches to make the Arduino spit out what it received backout on the SoftwareSerial port, this was a mistake because the default sketch only transmits at 4800 baud which explains why the above image was .2ms per div (5000baud) and actually it should have been .1ms per div.Thanks to icee on Freenode #electronics for the tip!