Connect with us

Help with RS485

Discussion in 'General Electronics Discussion' started by FuzzyWombatSoup, Nov 18, 2014.

  1. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    It's been about a decade since I've done much with electronics, but I'm starting to get back into the game. What I'm wanting to do is create an RS485 network with one "master" that sends the data off to an RS232(pc serial port). Each "slave" will have a few sensors that I want to be collecting data(temperature, etc). I'm stuck at an early spot in my design phase and need some guidance :(
    • For each "slave" should I be using a serial output ADC? I'd like one ADC per sensor.
    • For each slave, should I be using an RS485 transceiver with more than 1 driver and receiver?
    • I don't need a microcontroller for the ADC to talk to the RS85 on the slave, do I?
    • For the master, is it sufficient to collect from the 485 and send it too to an RS232 converter?
    Right now I got a few MAX485, but I'm second guessing whether they are the right tool. As I currently understand it, this is the flow path:
    sensor->adc->microcontroller->rs485 transceiver->electrical bus->rs485 transceiver->rs232

    I'm looking for the simplest approach with fewest components per node. Even referencing just part numbers will give me na idea of where I need to go :)
     
  2. Fish4Fun

    Fish4Fun So long, and Thanks for all the Fish!

    436
    99
    Aug 27, 2013
    FuzzyWombatSoup,

    Welcome to EP!

    I think you might be making this A LOT harder than you need to....It would prolly be best if you just went ahead a spelled out exactly what you are trying to do....for instance, the DS18B20 temperature sensors are a popular choice for sensing a fairly large number of sensors using a simple 1-wire serial interface.....perhaps not quite as accurately as a well designed ADC/Thermistor but certainly a lot less work....there are a myriad of other sensor modules readily available that are designed to interface easily with most modern uControllers....NOT to say there is anything wrong with designing a complete ADC based sensor system...it is just frequently more effort than it is worth....if you do decide you need ADC based sensors then I would STRONGLY recommend you select a uC with a suitable ADC integrated into it...this will simplify design/debugging and should offer substantial cost savings to boot....For a low-cost approach you might consider the Arduino boards, they are based on the Atmel AVR series of micro controllers and have a huge international user base making them perhaps the most accessible uControllers currently available.....

    Fish
     
  3. Laplace

    Laplace

    1,252
    184
    Apr 4, 2010
    It's not clear how you intend to incorporate a bus master for the master/slave bus protocol. Right now I have to assume that the PC connected through the RS232 interface is the bus master running the control software that insures only one slave node transmits on the wire at any one time. Looking at the specifications for RS232 vs RS485 shows that the slowest interface will control the bus and limit data transfer rates to 20 kbps. Correct?

    For the fewest number of parts consider a microcontroller with an internal ADC, unless you need a very high resolution conversion.

    Screenshot-41.png
     
  4. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    Thanks for the responses so far! I should have just described my overall goal first. I want to build a system to monitor things like temperate, humidity, ambient light, etc in various rooms of a building and get the results back to a PC for display. There will be no requirement for wireless. I need to track where the data originated and also have it scalable so I can easily add more forms of sensors in each room and additional rooms for monitoring without any major changes. I would also be triggering relays in said rooms(toggling lights, etc). I was trying to model my design off of something like http://www.mysmarthomeblog.com/page--18.html

    I do already have the LM34 which I've been using to get readouts with sufficient accuracy.
     
  5. Fish4Fun

    Fish4Fun So long, and Thanks for all the Fish!

    436
    99
    Aug 27, 2013
    Fuzzywombatsup,

    You should prolly look @ an Arduino....it is easy to interface with a PC via USB and you can power up to ~500mA @ 5V directly from the USB...this should be a gracious plenty for a large number of sensors.....look at the Dallas Semiconductor series of 1-wire serial sensors...they are designed for exactly what you are doing...relatively cheap and very easy to use.....I can't see any reason to complicate things with a rigid implementation of the RS485 protocol...

    Fish
     
  6. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    The thing is, I'll have 30+ of these and the cost will add up fast. The other issue is that these might have a few hundred feet between the sensor and the PC and I prefer not to have to have tons of USB repeaters.

    Thanks!
     
  7. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,266
    Nov 28, 2011
  8. Fish4Fun

    Fish4Fun So long, and Thanks for all the Fish!

    436
    99
    Aug 27, 2013
    FuzzyWombatSoup.....

    You should REALLY look @ the Dallas series of 1-wire devices....lol, they are a PERFECT fit for your application...you can have a nearly infinite number of devices virtually any distance apart and use a single wire to connect ALL of them, lol, but if you are bound and determined to use RS485 it will certainly work; it will simply require more expensive wiring, typically more expensive sensors and will increase the overall system power consumption and complexity....

    Good Luck!

    Fish
     
    FuzzyWombatSoup likes this.
  9. Laplace

    Laplace

    1,252
    184
    Apr 4, 2010
    Recommend the following source to aid decision whether 1-wire is suitable for your application:

    Guidelines for Reliable Long Line 1-Wire Networks
     
    KrisBlueNZ likes this.
  10. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    Thanks for the suggestions! I've been tinkering with MAX3182 and have gotten results I'm looking for(with regards to reading temperature on my PC). I have not found standalone OW RH sensors, but I still have my 785-HIH-4010. Is it possible to use this with my OW setup? There's a handful of things I'd like to measure via OW (light levels, airflow) that I can't find sensors for.
     
  11. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,266
    Nov 28, 2011
    Hmm. That's a bit tricky. If you want to add custom devices to a one-wire bus, they will either need to operate through a generic one-wire parallel I/O device, or they will need a very small microcontroller such as a PIC. In either case, you need to find a way to power the sensor.

    That one needs at least 4.0V DC at up to 500 µA. That's far too much to provide using the standard parasite power scheme that the one-wire devices normally use. I think you would need a proper power source. You could provide that locally (e.g. two CR2032 cells) or possibly add a third wire to your one-wire bus.

    The one-wire protocol also has a strong pullup option that's designed to supply current to slaves for short periods of time, e.g. when an EEPROM write is requested, but that's not really workable for this situation. Actually it might be, in conjunction with some extra hardware and a supercapacitor, if you can tolerate a big hit to the bandwidth. Let me know if you want to pursue that idea.

    I'm beginning to wonder if it was a good idea to suggest one-wire. The material I've seen on it is all over five years old and Maxim's own micro with one-wire interface is being discontinued.

    In any case, here are some interesting pages I found while Googling the relevant keywords:

    http://www.electro-tech-online.com/threads/diy-dallas-1-wire-slave-discussion.87094/
    http://www.fabiszewski.net/1-wire-slave/
     
  12. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    I forgot to mention that I am not using parasitic power. I am indeed using an external power source and 3rd wire so that is not an issue.
     
  13. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,266
    Nov 28, 2011
    Oh. Well, in that case you need a way to convert the output voltage from the sensor into a value you can read on the one-wire bus. I can see two ways to do this. Either convert the sensor's output voltage to digital using a discrete ADC with parallel outputs (such as the ADC0820, which is still being made by Maxim - see http://www.digikey.com/product-detail/en/ADC0820CCN+/ADC0820CCN+-ND/1302674) and send those outputs to a one-wire parallel I/O device, or use a microcontroller with an internal ADC that's programmed as a one-wire slave.

    The first approach might be workable if the one-wire parallel I/O device provides an indication that it is being accessed, that could be used to trigger a conversion in the ADC. Can you point me to the one-wire generic parallel I/O IC please?

    The second approach requires some programming and development because although the 1-wire bus is slow in comparison to many other types of communication, bit-banging it does require some care in the code design. An absolute minimum device would be a PIC10F220 (see http://www.digikey.com/product-detail/en/PIC10F220T-I/OT/PIC10F220T-I/OTCT-ND/1015705) but an ATtiny13 (see http://www.digikey.com/product-detail/en/ATTINY13A-SSU/ATTINY13A-SSU-ND/1914672) would be better I think. Have you used microcontrollers? Are you interested in getting involved with them?
     
  14. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    Sorry, I got a bit confused. I don't have a parallel device(that can easily be purchased, though), I'm using the http://www.ibuttonlink.com/products/linkusb I have not worked with μCs, and my coding does not extend far beyond Java. I'd like to get my hands dirty with μCs, but I have concerns about excessive hand-holding required :)
     
  15. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,266
    Nov 28, 2011
    The "parallel device" I'm suggesting is a one-wire slave device that provides parallel I/O that could be connected to an ADC. The part number is DS2408, data sheet at http://datasheets.maximintegrated.com/en/ds/DS2408.pdf

    This could be used along with a ADC0820 to trigger then read a 7-bit conversion. That would resolve to about 1% RH for that sensor. Would that be good enough? It's certainly the simplest way to do it.

    The microcontroller method is better for future expandability, and for cost if you need a lot of these things, but there's quite a lot to learn, as you said. I would like to help, but I don't have the time to write a one-wire slave implementation. So let's try for the DS2408 + ADC0820 solution.

    What voltage are you using on your third wire?
     
  16. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    Thanks! I'll look into those more tomorrow +/-1% for RH is perfectly acceptable. Right now I'm just using 3.3V since the current sesnors are rated 3-3.8V. I plan to up the voltage to 5V and use appropriate regulators since I know there will be different voltages required.

    I just noticed the DS2408 is an SMT, is there something similar that's a DIP/through-hole?
     
  17. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,266
    Nov 28, 2011
    OK, you'll need to. The humidity sensor needs 4.0~5.8V. Also, the ADC0820 needs 5V ±5% (i.e. 4.75~5.25V) for best performance, though it will work from 4.5~5.5V.

    The ADC0820 is still available in DIP but it's a very old design. There are some alternatives that are also available in DIP, so it's probably not too risky to use an 8-bit ADC with parallel outputs in a new design.
    Maxim ADC0820: http://www.digikey.com/product-detail/en/ADC0820CCN+/ADC0820CCN+-ND/1302674
    Texas Instruments TLC0820: http://www.digikey.com/product-detail/en/TLC0820ACN/296-2849-5-ND/371711
    Analog Devices AD7819 http://www.digikey.com/product-detail/en/AD7819YNZ/AD7819YNZ-ND/997013
    No, sorry. If the DS2408 is only available in SMT, you're stuck with it I'm afraid.
     
  18. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    So I've been doing some tinkering with OW and found it's not quite as versatile as what I need. I decided to get an Arduino and have had great luck accomplishing some of my goals, I got some Atmel 328P's up and running. It was way easier than I thought :). At this point, it looks like this is going to be the best approach(having a micro) on each node. I've managed to get them to communicate on a tabletop via I2C, but I'm still stuck on the best way for the distances.

    • I want to have a star topology as having a single bus will be a PITA to maintain.
    • No single cable from the master will exceed 50 feet or will be near noise sources.
    • RS485 seems to be based on a bus type network. See point above.
    • I2C is supported by Arduino and the micros I have, but distance seems to be pretty limited.
    • I'll be using Cat5 or Cat6 cable to provide power(12VDC) and carry signals to and from each node. This seems to be the easiest option to maintain signal integrity.
    • Datarates will never exceed 100 baud per node or over 2k baud for the entire network at any given point.
    :confused::confused::confused:
     
  19. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,266
    Nov 28, 2011
    How many nodes (initially, typically, and maximum)?
     
  20. FuzzyWombatSoup

    FuzzyWombatSoup

    35
    1
    Nov 18, 2014
    Initially 75. They would all be deployed at once; I would not plan to add more after the initial 75.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-