Problem Interfacing multiple devices into the Yun using UART and RS-485

Components: UART LCD (16x2), Matrix keypad (4x3 - 7 pin), RadioShack PIR Sensor - 2760347, and a UART RadioShack® JPEG Color Camera Board - 2760248)

Description: Basically what i'm doing is the "Crittergram Capture Cam" but with some modifications using the Yun. e.g. Adding a keypad with LCD readout and (eventually) an electronic lock for the door. This is essentially two projects working in collaboration with one microcontroller uart interface in order to save physical pins on the microcontroller. First part crittercam, and second part pin code door entry. I'll need about 50+ feet of spacing between hardware. (see Figure 1.A)

I'm researching RS-485. (half duplex, though) This will cover distance problems caused with SPI and I2C. https://www.sparkfun.com/products/11959 (RS-485 Shield) https://www.sparkfun.com/products/10124 (RS-485 BoB)

My next issue is connecting everything. Is there such an IC or component that will effectively convert my camera and LCD's UART compatibility into an RS-485 standard that will pipe everything through a single wire into one RS-485 port on the microcontroller? (see Figure 1.B)

Figure 1.A UART Digital Pins v RS-485 Wire v [CAM]==\ v ======= [uC] ------[PIR/Keypad] [LCD] ==/

Figure 1.B


KEY:

[IC?] = Integrated Controller needed here?

UART v RS-485 Wire [CAM]===[IC?]\ v |==== uC [LCD] ===[IC?]/ ^ ~18 m. of wire

Apple’s Home Automation (HomeKit)

The home security is included.

RS485 can be full duplex. See Max488, page 8 http://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf http://www.digikey.com/product-search/en?FV=fff40027%2Cfff801a4&k=max488&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25 May need cd74HC4050 or similar to convert 0-5V output fromRS485 chip to 0-3.3V level for Yun. If slower speeds beiing used then a simple resistor devider might be all that is needed.

CrossRoads: RS485 can be full duplex. See Max488, page 8 http://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf http://www.digikey.com/product-search/en?FV=fff40027%2Cfff801a4&k=max488&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25 May need cd74HC4050 or similar to convert 0-5V output fromRS485 chip to 0-3.3V level for Yun. If slower speeds beiing used then a simple resistor devider might be all that is needed.

Problem is that there isn't any readily available RS-485 shield or break outboard that includes a proper screw terminal or phone jack style connection that properly connects to ground, which is a requirement to in turn run RS-485 in full-duplex mode. Without proper ground, only RX and TX connected, it will not work reliably (or not at all), at least on any connection over more than a couple feet...

Ralf

So let's make one! I've often thought about making one since elektor magazine ran a series of articles 2 years ago. Each card will have MAX488, or another full duplex part, 5 screw terminals for RS485 connections, or RJ45 jack in parallel , or two - what do we put for smarts on the other side? 328P, ICSP header, FTDI header - what else? Relay or relay controller? Screw terminals for sensor inputs?

Think it over, I gotta run, be back online later...

CrossRoads: So let's make one! I've often thought about making one since elektor magazine ran a series of articles 2 years ago. Each card will have MAX488, or another full duplex part, 5 screw terminals for RS485 connections, or RJ45 jack in parallel , or two - what do we put for smarts on the other side? 328P, ICSP header, FTDI header - what else? Relay or relay controller? Screw terminals for sensor inputs?

I tried to use these bricks with a home automation project, nice to work with (termination of the node by a simple sliding switch) but unfortunately, they did not have a ground on either the screw terminals nor on the phone jacks... https://arduino-info.wikispaces.com/RS485-Brick Original FlamingoEDA site (in Chinese only though :( ) http://www.flamingoeda.com/2012/07/12/%E7%94%B5%E5%AD%90%E7%A7%AF%E6%9C%A8-rs485/

Ralf

For a small home security project i'm wondering if it's even necessary to have a full-duplex connection. It would be ideal of course if such a shield or even better yet if such a breakout board existed. My next issue is connecting everything. Is there such an IC or component that will effectively convert my camera and LCD's UART compatibility into an RS-485 standard that will pipe everything through a single wire into one RS-485 port on the microcontroller? I really appreciate the insight by the way, i've learned quite a bit these last couple days.

For the record i'de rather stay away from anything proprietary. It defeats the purpose of prototyping open source in my opinion. I'de like to keep everything simple and modifiable for security purposes. I don't exactly trust most business developers to secure my home, they aren't in the business for spending hours securing things until it's a problem.

EDIT: Updated main post. Clarified everything and made it much easier to read.

ViLeGlyph:
For a small home security project i’m wondering if it’s even necessary to have a full-duplex connection. It would be ideal of course if such a shield or even better yet if such a breakout board existed. My next issue is connecting everything. Is there such an IC or component that will effectively convert my camera and LCD’s UART compatibility into an RS-485 standard that will pipe everything through a single wire into one RS-485 port on the microcontroller?

There is no such thing as a “single wire RS-485”. You need at the least one wire each for the RX and TX lines, ground is recommended for any longer distance and a necessity for full-duplex.
The IC/chip that is commonly used today for a lot of (Arduino/Raspberry Pi related) RS-485 stuff is the MAX-485 or MAX-488 chip. A link to the datasheet for that chip should be in one of the two links for the breakout board I posted the other day…

Also please note that RS-485 is only defined/standardized on the signal level, not on any protocol level…

Ralf

You probably mean 1 wire each for the high and low differential signals on a half duplex, since the send and receive share the same pipe. You would need another set of high/low differentials to have full duplex, so it takes 4 wires (before the ground) for the 2 pipes, one sending one receiving.

But, I agree that full duplex is not really needed either, unless you are setting up 1 master and the rest slaves. If all the nodes can initiate communication, they are going to need to wait anyways until it's all clear. You need to build in collision detection, but there are libraries for that already. Think of it as a hub or coaxial Ethernet network, there is no switching so to speak to avoid collisions.

the Arduino ICSC library is where it's at...

miketedeschi: But, I agree that full duplex is not really needed either, unless you are setting up 1 master and the rest slaves. If all the nodes can initiate communication, they are going to need to wait anyways until it's all clear. You need to build in collision detection, but there are libraries for that already. Think of it as a hub or coaxial Ethernet network, there is no switching so to speak to avoid collisions.

the Arduino ICSC library is where it's at...

I am indeed setting up one master with multiple slaves. I've read up something on Modbus enabling this somehow. I don't know enough about it yet so i'm going to do some more reading on that to figure out if I can still do this.

Just to clarify, each device needs it's own TX/RX port directly on the arduino board? or can i use just the TX/RX in the same TX/RX ports for all devices like a ground for any other basic electronic? provided the software handles it of course i would like to connect 3 devices on the same TX/RX lines going into two ports on the arduino (assume it's all grounded)

e.g. TX | TX======[u ] RX======[ C] | RX

ViLeGlyph: Just to clarify, each device needs it's own TX/RX port directly on the arduino board? or can i use just the TX/RX in the same TX/RX ports for all devices like a ground for any other basic electronic? provided the software handles it of course i would like to connect 3 devices on the same TX/RX lines going into two ports on the arduino (assume it's all grounded)

Assuming that you are still talking about RS-485, the point you seem to be missing about RS-485 (and a major difference to RS-232 or RS-422) is that it is a bus system. You always will have only one pair of connections (A+B) with your Arduino...

Ralf

PCWorxLA:
Assuming that you are still talking about RS-485, the point you seem to be missing about RS-485 (and a major difference to RS-232 or RS-422) is that it is a bus system. You always will have only one pair of connections (A+B) with your Arduino…

Ralf

No, this is only true for half-duplex, and this is why I am suggesting most people just forget full duplex for arduino <-> arduino purposes.

For full duplex, you would have 2 pairs of A/B connected to each arduino. 1 pair for the Tx, and 1 pair for the Rx. (EDIT: not directly to each arduino, there is an RS485 chip ALWAYS. RS485 communications lines don’t go direct to the arduino board)

To clarify even further, the master arduino in full duplex would be wired backwards compared to all the slaves. The master arduino would have it’s TX port connected to the master out differential pair, and the slaves would have their Rx connected to this same pair. The master has it’s Rx port connected to the other differential pair, which is connected to all the Tx ports on all the slaves.

In half duplex, imagine a single A/B pair of wires as 1 of those (single) PVC pipes at a children’s playground that kids can yell into from multiple places. All of the devices share the same pipe for 2-way communication, to any other location, by using it for both talking and listening, and they all must wait until it’s silent to talk.

I didn't want to say anything last week, but I have been working on a similar board.

Kickstarter launched today, it will be open source afterwards.

https://www.kickstarter.com/projects/1370454848/chainduino