Shop OBEX P1 Docs P2 Docs Learn Events
Using RS485 — Parallax Forums

Using RS485

RandyRandy Posts: 79
edited 2006-07-11 01:22 in BASIC Stamp
I have a BS2PE based data logger that sends data to StampDaq. I wish to send the data to a computer that is located a couple hundred feet away from the logger using isolated RS485. The logger is in a mechanical room that has more than one power source and large motors creating spikes and noise and a possible difference in ground potential, thus the desire for the isolated RS485. I am planning on using a MAX 1480 at the logger to convert to RS485 and I have an existing RS485 to RS232 converter to put on the computer end of the line. The MAX 1480 is looking for Receiver Out, Driver Input and Driver Enable. I assume (this is automatic trouble) if I use the dedicated pins (1, 2 and 3) that ATN goes to Driver Enable. Yes, no, look for smoke? If for no good reason I was to use I/O pins instead of the dedicated serial pins would I need to use the Fpin function to determine transmit or receive at Driver Enable? This all seemed so simple until I looked at the data sheets for the 1480 and other 232-485 ICs. I have attached the data sheet from Jameco, I believe page 12 will be of help.

I have no info on the existing converter that I hope to use at the computer. It was salvaged from a connection to some equipment that was replaced a while ago. It has four screw connections, RXA, RXB, TXA, TXB and apparently uses parasitic power. Can this thing be used with a two wire connection and if so what two? If it can't be used what should I use?·I have a ten cent budget that I am already streching.

Thanks from all of us hobbyists, students and otherwise electronicly curious to Parallax and the others that answer some complex and some very basic questions. It is you guys that keep us learning with your generosity of sharing, time and knowledge.

Randy

P.S. For some reason I couldn't add the attachment. One version was a file type that isn't acceptable, the other ran into a runtime error. It can be downloaded from Jameco or Maxim-ic

Randy

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-08 06:54
    Randy -

    I certainly stand to be corrected, but on the Stamp end, I don't think you want to be using a MAX-1480, rather you should be using a multi-protocal converter (RS-232 => RS-485) from your logger. Here is a list of the various Maxim Products which can perform that function:
    http://para.maxim-ic.com/cache/en/results/5027.html

    If you would prefer for some reason, you can go directly from PBASIC SHIFTOUT (synchronous serial) to RS-485 by using a MAX-3140 as shown here:
    http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2033

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • RandyRandy Posts: 79
    edited 2006-07-08 16:04
    Bruce

    Thanks for the response but WOW, I haven't been this confused since 1969!

    Why would I not want to use the MAX-1480?

    I took a gander at the converters you suggested and don't see why I would benifit from them. I don't have a good grasp on the different protocals or the advantage of one over another, a quick read of the specs and protocals led me to the 1969 comment. I can see I am going to spend the rest of the day doing more research, good thing I enjoy that.

    One thing I did not mention in my original question is that the only path I have available for cabling is a half inch conduit that has several individual pairs of 18 gauge unshielded twisted wires being used for 4-20ma sensors. Two pairs are available for use and I was hoping they would be suitable. I might be able to pull a cat-5 cable but I don't think there is room in the conduit.

    As I don't see too much available for isolated converters am I being overly concerned about noise and the potential ground differance? I don't want to fry a stamp and I really don't want to fry a pc.

    Randy
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-07-08 16:25
    Randy,
    Do you want to program the BS2pe data logger from a distance OR merely communicate?
    You say you wish to send data to the computer, but then you later discuss the ATN pin in the group of Pin 1, 2, and 3.

    The ATN pin is a programing requirement for PBasics IDE.
    If you use SERIN and SEROUT, you could directly hook up the TTL side of any RS-485 driver to the BS2pe. At the computer, you wond need a RS485 to RS-232 converter. This would eliminate the need to consider the ATN pin and Pins 1,2, and 3 would be available for programing.

    Of course, you wouldn't have remote programing access.

    BTW, people have sucessfully run RS-232 cables for a few hundred feet. If there are problems, one merely slows down the baud rate.· If you really want to connect the IDE, why not try a dry run on a few hundred feet of cable before you install it?· You may not need the RS-485 at all.

    The device you salvaged·likely provides only the·2 channels in full duplex·as RS-485 requires a Plus and Minus for each signal.·It would never·provide for the Attn LINE.· So I suspect you must stay off Pin 1, 2, and 3.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 7/8/2006 4:37:20 PM GMT
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-07-08 18:16
    The MAX1480 is a very nice hybrid, giving you complete line isolation but using power supplied by a Stamp. If you are on a low budget, you are lucky to have it! RS485 is a half-duplex protocol, and only one end can be talking at a time. You will NOT use the ATN line and you will NOT use the fpin option for SERIN/SEROUT. Your programs at both ends of the lines will have to be arranged with some sort of scheme to decide who has permission to speak at any given time. That will be very easy if the Stamp is just sending data to StampDAQ with no replies or command from the PC ever. But it is usually not too hard to come up with a master/slave scheme that works for your application.

    On the Stamp end, use three regular pins for the interface, lets say p0 for driver input, p1 for driver output and p2 for enable. You could also use the regular debug pins (physical pins 1 & 2) for the input and output, but the driver enable will have to be a separate pin (NOT atn!). And since the debug port is always inverted, you will have to change the sense of the (+) and (-) on the RS485 transceiver, which is okay. When the Stamp has permission to talk, it simply enables the drivers, and then starts sending data at the agreed upon baud rate. The MAX1480 takes care of translating the levels to the (+) and (-) differential. When the Stamp needs to listen, it disables the drivers and does a SERIN. RS485 systems usually include a short (~milliseconds) pause so that the line can change directions, for example, if one side sends a command, then goes to listening mode, while the other side switches to transmit mode, waits a few milliseconds, and then starts transmitting.


    It sounds like the device you mentioned for the PC end "four screw connections, RXA, RXB, TXA, TXB and apparently uses parasitic power" is an RS422 device. RS422 is a full duplex arrangement, where the drivers are active all the time, and there is no "driver enable" pin. I think a hack is possible using diodes and resistors, to make an RS422 driver fake RS485. Ordinary RS485 transceiver chips are $1. The harder part on the PC is to supply the data direction signal.

    On the PC end, you might get away with attaching the (-) tx line directly to the txd line for RS232. It makes a 0 to 5 volt transition, but most PCs will interpret that correctly. But it is not good if there is a lot of noise.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • RandyRandy Posts: 79
    edited 2006-07-08 18:25
    Kramer,

    Thank you for slowing me down and getting me to think about what I am doing. This project has been through many changes as I have discovered better ways to write programs and find what data I can gather and what is actually of use. The Stamp is in a removable carrier as I write and load programs at home but use the logger at work. The frequency that meaningfull data changes would probably allow a baud rate of 1 if there is such a thing. All I am after is trending of several temperatures that change no quicker than in several minute intervals. I will try a dry run as you suggested and worry about communicating with the space shuttle in the future (yeah that is how deluded and off track I can get thinking of the next change).

    Thanks again
    Randy
  • RandyRandy Posts: 79
    edited 2006-07-08 19:46
    Tracy

    One way comunication to StampDAQ is all I need.

    The budget thing is two sided. This whole project has evolved from learning to use stamps, clocks, A/D conversion, displays, etc. As I learned how to use these things I started having a need to give them purpose. Thus my learning project has taken residency where I work. I work in the facilities department of a building that has had several additions over the years. I am always looking at energy saving as well as improving comfort with some dated HVAC equipment. I have the cheif engineers blessing at using MY data logger to provide him with useful data as long as I limit the time I spend to a reasonable amount. I get to learn for me on his time which I call a reasonably lopsided trade. The logger is mine and as a hobby I will spend way too much if needed to grow it. Side one budget is as deep as my pocket. I have access to the only computer in the building that is not networked. The IT department will allow but they are a little nervous about connecting my homegrown gizzmo to the computer and installing StampDAQ. (What do you mean you built it? YOU programed it? PBasic? Never heard of it.) Side two budget ends there. If they see something commercialy available between my gizzmo and the computer they will feel that there is some safety, but if it is not in the closet with the unused stuff they won't purchase it. I was hoping to not buy another enclosure, power supply, etc. but am starting to think learning data conversion might have to come from my pocket.

    Anyway thanks for the info. I think I do understand how to use the MAX1480. I am going to try RS232 first and see what happens.

    Randy
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-07-08 20:29
    If the PC only has to receive data from the remote Stamp, then the converter you mentioned (four screw connections, RXA, RXB, ...) should work okay for input to the PC. Just don't connect the TXA TXB to anything.

    It is the differences in ground potential over that couple hundred feet, and possible spikes from the mechanical equipment that are indeed worrisome. The MAX1490 provides 1600 volts RMS isolation. I would not feel comfortable trusting that to the port 16 debug port of the Stamp, which has not much more isolation than the breakdown voltage of a transistor. If you need to add an RS232 driver, like the MAX232, you might as well go to RS485 and get all the advantages. RS485 drivers don't require the external voltage multiplier capacitors, and most of them don't offer ground mode isolation.

    I'm just in the process of intalling an ultrasonic anemometer that is mounted on a communications tower on the east peak of Mt. Tamalpais, surrounded by radio equipment, and it communicates via RS485 through shielded twisted pair with an OWL2pe in a control bunker several hundred feed away. I'm using the LT1785 for the RS485 on the Stamp end, which can work with a +/- 60 volt common mode ground differential, and withstands >4kV ESD. Your isolated MAX1490 hybrid can work through a 1600 volt RMS common mode ground differential. The anemometer includes an RS485 driver.

    It is not unusual to see several volts differential of ground potential between two buildings. You can sample that just to see by temporarily hooking one of your free wires to earth ground at the mechanical building, and then at the other end measure the voltage between that wire and the other earth ground. Unusual events, such as lightning strikes, can increase that voltage manyfold for an instant.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • RandyRandy Posts: 79
    edited 2006-07-08 22:47
    Tracy

    Thanks a bunch. You have renenforced my reasoning for wanting to do this as I originally planned. I believe that with the responses I have gotten I should have no problem putting this together. Too much research confused me. It is starting to organize itself in this mess I call my mind.

    Being able to use just the RX solves lots of problems. I understand the Stamps electronics fairly well, It is the computers needs that I am not wanting to get into.

    I have measured the ground differences in the past which is why I was concerned. Also I am in Colorado where we not only have thunderstorms, we often have humidity in the single digits - STATIC. We are not slap happy, we are just discharging.

    Randy
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-09 00:48
    Tracy,

    ·· This is good information...I just looked up the LT1785 datasheet...I have been looking for a good network driver for an application myself.· Since you actually use this stuff in the field you're a good source of tried-and-true information.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-07-09 09:32
    Tracy really knows how to help you with getting your applications working. Stick with his advice.

    BTW, when I first got into BasicStamps I thought everything required 256,000 baud and that I had to have RS-485 rather than RS-232.
    Some of it was a love affair with 'state of the art', some of it was more speed and impressively big numbers, some of it was that the RS-485 chips are both easier to network and a bit simpler than the MAX232.

    Several old-timers, especially Guenter, kept saying 'Why?' 'You don't need the speed, and you can do distance just fine with the BasicStamp in RS-232'. It took a lot of discussion to set me straight.

    I was hung up on using that RS-485 driver chip and wasted a lot of everyone's energy in debate.
    If you need isolation, I may be able to refer you to or PM you some schematics of DIY RS-232 isolators [noparse][[/noparse]including one supplied by Guenter].

    I still love the RS-485[noparse][[/noparse]or RS-422/485]·[noparse][[/noparse]and Tracy recommends it for toughness in this case].

    I·am also greatly intrigued by the CANbus as an extremely faulty tolerant network system for any of Parallax's microcontroller. But it requires its own device to manage and buffer all the communications AND a lot of the BS2s EEPROM space. I have wanted to get such a system going, but it is two years later and I still haven't gotten my CANbus/RS-485 into operation.·The costs and learning curve climb and things get·bogged down.

    Keep it simple if you have an immediate development need.
    The isolation is quite important if you need to protect your computer and/or the BasicStamp -- otherwise it is an added distraction.

    Also, Dr. Tracy Allen, the designer of your data logger,·correctly pointed out that you have a RS-422 device.·

    To quote a document I overlooked, "What is the difference between RS-422 and RS-485?· The electical principle is the same.... However, RS-422 is intended for point-to-point communications, like RS-232.· RS-422 uses two separate TP wires. data can be transferred in both directions simultaneously.· RS-422 is often used to extend RS-232 lines, or in industrial environments."

    It seems that you and I have taken RS-485 to be the usual adaption of RS-232.· I suspect that advertizing is to blame.· An RS-422 driver chip with an RX/TX pair could simplify wiring and be transparent to·your application.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 7/9/2006 11:58:03 AM GMT
  • RandyRandy Posts: 79
    edited 2006-07-09 16:47
    Tracy

    After re-reading your response were you suggesting that I should not be comfortable with the 1600 volt isolation from the MAX1490 but might be better off with something like the LT1785 ? Or just that the LT1785 should be sufficient?

    Randy
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-07-10 21:15
    Hi Randy,

    The MAX1490 is better than the LT1785, because the MAX1490 is truly isolated, not just protected. As a hybrid circuit, it has a transformer built into the package to power the side of the circuit that is connected to the outside world, and the signals are transferred to/from the Stamp via optocouplers. So the logic ground connected to your Stamp is isolated from the ground of the RS485 loop and the PC at the other end. Linear Tech has a similar fully isolated part, the LT1585, but that requres an external transformer.

    Those are bigger chips than the 8 pin non-isolated RS485 drivers. There are lots of those to choose from, generally pin compatible replacements for the old standard SN75176. The SN75176 is a power hog. The second generation chips like the LT1785 require much less current and have better ESD protection. Another one (I have not tried) is the TI

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • RandyRandy Posts: 79
    edited 2006-07-11 01:22
    Thanks yet again Tracy. As soon as the parts arive I will be using the MAX1490 and the salvaged converter now that I know how to use them. I will post a new thread as soon as I know that it works so others with similar needs will have a model to follow. Of course if I have problems I will be back begging for help once more.

    Randy
Sign In or Register to comment.