Which Communication Bus to use?

Hi gang, I am starting to put togther a project to monitor a domestic water treatment system at my house. I have a domestic well pump, a reverse osmosis system, a rainwater collection system, a number of storage tanks, and probably (while I’m at it) a sprinkler systrem to potentially control. I want to track 4-6 different flow rates (using cheap hall effect flow pulse’ers), monitor tank levels and salinity levels using standard 4-20ma sensors (basically individual ADC’s for each sensor), monitor water softener and RO operation using digital i/o (bascially on/off status), and display and store data about the system to a micro (Spider II) located at the house, about 100feet away from the water system. I’d like to also push the data up to the web. The water system is runing now, using manual float switches etc, so the purpose of the micro(s) is to provide information as to system status, to record water consumption (domestic and irrigation), and in the future I could add some kind of irrigation - sprinkler controller - as it would be useful to do, particularly as I can measure flows which the sprinklers are in operation.

I’d like advice from the group on putting this together conceptually. Here is my concept so far:

  1. Flow measuring happens in real time (220 pulses/liter pumped x 4-6 individual flows). One way to do this is to task a picaxe micro to basically count the pulses, and increment a ‘counter’ that creates an interrupt for each liter pumped for each flow device. A Picaxe 20M2 micro has been demonstrated to do this nicely at the flows (5gpm +/- max) envisioned. The idea here is that the picaxe would braodcast an interrrupt for the main micro to update flow data when any of the flow chanels pumps cumulatively one liter of water.

  2. 4-20ma sensor data (4-6 sensors) and the couple of digital i/o’s would be polled at set intervals by the main micro (Spider II).

The main micro (Syder) would be located in the house, and would have an LCD, SD Card, provision for relay outputs for the sprinkler system, and an ethernet card for posting to the net.

The ‘water room’ is located about 100 feet away from the house, I have 2 CAT5 cables between the locations, one has an active ethernet connection runing on it (my house network), the other one is available for communications between the micros. So I have 4 pair of lines I can use between the micros for communication, in addition to ethernet comnnectivitny between the locations.

The picaxe can be set up to use I2C (but only if it’s operating in master mode), or I could use SPI, or I could use standard serial communications. I don’t think the picaxe supports CAN bus communications.

So, my first step is trying to decide which form of communication to use between the two micos. If the Spyder can be set up to function as an I2C slave (the picaxe would be the master), I could use I2c, or I could use SPI using the Syder as the master, or standard serial with an interrupt line. To save communication lines (I only have 8 I can use), I will probably add a second picaxe at the remote loaction to record the various sensors, and communicate with that as well - so two remote picaxe micros communicating with the Syder using one of the communication methods. I am leaning towards using SPI, with the Spyder acting as the master (providing the clock signal), with the one ‘flow measuring’ picaxe using an interrupt line if I need to do that. The Spyder would basically poll the sensor data picaxe once each second (using a timer), and let the flow picaxe generate interrupts to update flows, both using SPI.

The sypder would, on that 1 second timer, update sensor data, and update the LCD display and/or internet. It would do the same if it gets a flow interrupt. And a second timer woud fire at midnight to update daily flow readings etc, and woud write the daily data to the SD card and/or internet.

Anyone see any issues with this approach, or can suggest ways to make things a little simpler? I get the feeling that the flow measuring would be better not done using the Syder as it is event driven, and might not be able to handle the ‘real time’ nature of the measurments (about 200-400 pulses/second on all channels).

I could put the Spyder out at the water system, store the data out there, and publish to the web out there, but I wanted a nice LCD display in the house so I can see at a glance what is going on without logging on to a website or walking out there, and I am also not sure the Syder could do the real time stuff.

Thnaks in adcvance for your comments!


@ jscmanson - I’m still trying to process your entire post but the big issue here is the distance. 100 feet away is a bit far for SPI, I2C and other buses. CAN bus can, but that gets complicated really quick. The voltage drop across that distance may also be an issue. I know you said you had 8 data lines but at that distance I would recommend using the twisted pairs as a single line. That kind of distance is bound to collect environmental noise eventually. Use a low speed SPI. Something like 10Khz. You might also want to convert any 3V3 signals to 5V to ensure that the voltage drop across that distance doesn’t result in a signal voltage of less than 2Volts.

Can’t you use a little bridge to RS 485 that’s up to 1200 meters that’s almost 4000 feet, that should at least do the long distance trick.

Thanks John - I have some level shifters so I can run the SPI at 5 volts… I’ll start with a prototype setup using the same length of wire and see if it runs OK.

I also like Peter’s idea of the RS485, I could get the gadgeteer module, and buy a Max13487EESA for the other end to use with the picaxes. If I go with 485, using twisted pairs for the tx/rx, do I still need to concern myself with bus speed over that distance?

@ jscmanson - The bus speed may still be an issue. The signal propagation delays get worse at higher speeds. If it doesn’t work at high speeds, just go slower.

@ jscmanson - it is appx 10 Mbps for 15 meters and 100 kbps for 1200 meters, your speed will be somewhere in between. I reckon closer to 10 Mbps. And use four wires for full duplex.

I’d use UART over RS485 for even that short distance. UART comms is far easier to handle and deal with and you don’t have to worry about encoding your data to binary either if you don’t want to deal with it that way. It will easily run at 115,200 bps which should be fast enough for what you plan to do. Use 3 wires for the link, you need a GND for RS485 contrary to what some people think, especially if the devices are not on the same power supply with a common ground.

I like your choice of 4-20mA sensors. They make wiring simple and you only need 1 resistor to convert the current to a voltage. The only downside is that you don’t get the full range of the ADC input compared to a voltage output sensor that probably outputs over the range of the ADC input.

Sounds like an interesting project so we hope we can see postings of your progress.

Is there a benefit to RS-485 over RS-232 if there are only two nodes on the line?

@ godefroi - RS485 can have a much longer cable. Thousands of feet. I think RS232 is limited in cable length. We always used RS485 for our installations when we needed a communications bus with several rfid controllers spaced around a manufacturing plant. Some of the cables were up to 4k feet long.

I wrote our own communications protocol for over the RS485 network. It had some pretty cool features.

Ah, thanks. RS-422 would also be an option (it’s basically differential RS-232), but it looks like RS-232 to RS-422 converters are no cheaper than converters for RS-485.

Thanks everyone. On the duplex thing for RS485 - it looks like the gadgeteer RS485 module is half duplex (uses a Max 13487EESA chip), I presume half duplex will just result in slower thoughput which may not be an issue for me.

@ jscmanson - that and you can not send and receive at the same time. which pretty much halfs the throughput.

If most/all of your traffic is one-way, half-duplex won’t affect you at all.

If you care about the amount of time you have to spend coding, one very easy thing to do is stick with the standard serial port communication class built into .NET Micro, the standard GHI RS232 adapter board and a couple of RS232 to RS422 converters to convert the single ended RS232 signal to differential RS422. You can use the standard GHI RS232 driver board and plug the converter right into it. You’ll need 4 wires, 2 for RX and 2 for TX for each serial port connection between the house and the remote site plus a ground wire. You said you have 2 CAT5 cable running between your house and the remote site. Usually there are 4 pairs in a CAT5 cable so you should have plenty of pairs. The advantage is you use totally standard .NET Micro serial port code and you get the advantage of differential signals. RS485 does give you the advantage of being able to put multiple devices on one pair of wires but your code has to manage which devices are active and that is code you’ll have to add over the top of the standard .NET Micro serial port code.

B&B Electronics makes some decent converters at a reasonable price. Moxa makes industrial quality converters but cost more. I’m sure you can find some cheapies on the web that will probably work fine. Many of these converters handle RS422 and RS485 with the flip of a switch so you can go either way.

Good luck and let us know what you decide and how it works out.

1 Like

After additional research, I have decided to set up the picaxe in the remote site as an I2C Slave (The Pic 28x2 products allow slave operation, allows read/write into scratchpad memory on the device). The Syder at the house would just use I2c comms, would read the picaxe every few seconds to update data, and coud write a memory location to the picaxe if it wants the picaxe to do anything. The picaxe would just periodically read the memory location, if it sees new data there it would carry out the command etc.

I have ordered a pair of T.I. P82B715 chips, called “I2C Bus Expander’s”, which sounds like it works like the RS-422/485 setup, but is designed to directly use I2C instead of generic serial comms. It also ups the voltage on the bus to 12 volts, similar to the RS-485 converters… So I will set this up and give it a try…


I have a B&B Electronics RS232/RS485/RS422 converter (485BAT3) that I am about to list on ebay.

It is this one:

Let me know if you are interested. Will sell cheap.