4

I have some sensors from each of which I need to - read a voltage - be able to switch them on. (They are powered by AC 220V power supply).

Distance to be covered is some 40 meters.

I don't want to use to many wires in order to achieve this.

Solutions I have been considering are as follows: - 1-wire protocol - it's quite simple but some people have reported quite a few problems;

  • rs422, works well over long distances, but it might be a pricy solution.

In case I chose 1-wire protocol, how would I get my sensors connected to a 1-wire interface?

If rs422 is not too complicated and expansive I would go with this option as I might consider extending the network over some 200-250 metres in the future.

How would I connect my sensors to an rs422 interface? How would I get my Arduino talking with RS22?Have you tested any RS422 chips? I have seen quite a few of them online, but I am not sure which to choose.

Would it be too complicated to make an RS22 cable myself? I have looked on ebay and found only wires not long enough and too expansive.

geraldCelente
  • 153
  • 3
  • 12
  • How expensive is "too" expensive? – Ignacio Vazquez-Abrams Nov 02 '14 at 22:37
  • I would go for RS485 rather than RS422 or one-wire. You can use any two-core shielded cable, you don't need anything special. Interface to RS485 is usually through UART (MAX485 chip or similar). Keep it half duplex for simplicity. Have a small MCU with each sensor to connect it to the network (ATTiny, PIC16, etc). – Majenko Nov 02 '14 at 22:38
  • I can't recommend 1-wire for 40m distance. 1-wire was intended for cheap short-distance communication. Having said that, I was surprised to find this [application note by Maxim: Guidelines for Reliable Long Line 1-Wire Networks](http://www.maximintegrated.com/en/app-notes/index.mvp/id/148). – Nick Alexeev Nov 02 '14 at 22:51
  • @Majenko-notGoogle What are the advantages of rs485 over rs422? – geraldCelente Nov 02 '14 at 22:55
  • @geraldCelente See my answer. – Majenko Nov 02 '14 at 22:56
  • @IgnacioVazquez-Abrams Over twenty dollars for a 40 meters cable. – geraldCelente Nov 02 '14 at 23:41

1 Answers1

8

Personally I wouldn't go for either RS422 or 1-wire.

RS422 is really a point-to-point connection, like RS232 (and is usually used to extend RS232), and 1-wire is really only for local connections within a PCB.

Instead you should use RS485.

RS485 is like RS422 (RS232 with differential signalling), except it's designed to be point-to-multipoint, or fully peer-to-peer.

Communication is usually half duplex (though not always, but it's simplest to keep it half duplex), and you'd usually use a MAX485 (or similar) chip to convert a microcontroller's UART connection to RS485. A single GPIO pin is used to switch into transmit mode when you want to send data on the network, and otherwise it's in constant receive mode waiting for data to arrive.

You would need a small microcontroller with each sensor to connect it to the bus - something simple, like an ATTiny, or a PIC16 - something with a hardware UART preferably, and of course whatever facilities you need to communicate with your sensor.

You'd then write a protocol (or use an existing one) whereby the Arduino sends a message with an "address" identifier in it onto the bus, along with a command, and the sensor programmed with the corresponding address reacts to that command, possibly then sending back data to the Arduino (a typical "call-response" protocol).

As for cabling, you don't need anything special. Simple two-core shielded serial cable is fine, though that can be considered overkill - if it's not too noisy an environment then any two-core wire would do. The best, though of course is twisted pair, and absolute top quality best is shielded twisted pair. A good choice is CAT5 Ethernet cable. It's cheap, comes in 305m rolls, and has 4 twisted pairs. You only need 1 of those pairs of course, so the other three could be used for other things - carrying power for instance.

Majenko
  • 55,955
  • 9
  • 105
  • 187
  • If you're not going to use (recommend) a twisted pair then why bother with differential signalling? – markt Nov 03 '14 at 07:03
  • Agree with @markt - twisted pair is better than sheilded. Also, FWIW, RS422 and RS485 use essentially the same hardware (MAX485 and family) just physically wired differently. – slebetman Nov 03 '14 at 07:12
  • Quite right, I was forgetting TP. – Majenko Nov 03 '14 at 09:46