Maker Pro
Maker Pro

Help with RS485

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
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 :)
 

Fish4Fun

So long, and Thanks for all the Fish!
Aug 27, 2013
481
Joined
Aug 27, 2013
Messages
481
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
 

Laplace

Apr 4, 2010
1,252
Joined
Apr 4, 2010
Messages
1,252
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
 

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
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.
 

Fish4Fun

So long, and Thanks for all the Fish!
Aug 27, 2013
481
Joined
Aug 27, 2013
Messages
481
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
 

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
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
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!
 

Fish4Fun

So long, and Thanks for all the Fish!
Aug 27, 2013
481
Joined
Aug 27, 2013
Messages
481
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
 

Laplace

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

Guidelines for Reliable Long Line 1-Wire Networks
Maxim TUTORIAL 148 said:
The 1-Wire protocol was originally designed for communication with nearby devices on a short connection, such as adding auxiliary memory on a single microprocessor port pin. As the use of 1-Wire devices increased, methods were developed to extend the 1-Wire protocol to networked applications well beyond the size of a circuit board. A 1-Wire network is a complex arrangement of 1-Wire devices, communication lines, and connections. Every 1-Wire network is different, often both in topology (layout) and hardware.
A proper match among network components (i.e., master, network cabling, and 1-Wire slave devices, "slaves") is the precondition for reliable 1-Wire operation. When bus masters are improperly designed or implemented, or when masters intended for short-line use are pressed into service with greatly extended communication lines, then satisfactory performance cannot always be expected.
 

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
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.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
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/
 

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
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/
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.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
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?
 

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
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?
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 :)
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
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?
 

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
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?
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?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
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.
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
I just noticed the DS2408 is an SMT, is there something similar that's a DIP/through-hole?
No, sorry. If the DS2408 is only available in SMT, you're stuck with it I'm afraid.
 

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
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:
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
How many nodes (initially, typically, and maximum)?
 

FuzzyWombatSoup

Nov 18, 2014
35
Joined
Nov 18, 2014
Messages
35
Initially 75. They would all be deployed at once; I would not plan to add more after the initial 75.
 
Top