Author Topic: Long cables...  (Read 2203 times)

0 Members and 1 Guest are viewing this topic.

Offline guimtlTopic starter

  • Contributor
  • Posts: 17
  • Country: ca
Long cables...
« on: February 23, 2019, 05:28:37 pm »
Hi, I'm trying to figure out how to solve bellow design issues before I try physically.
I want to monitor switches that are far apart from each other, with preferably only one MCU; something like this;
each square has tree switches with common ground, I know I'll have a problem with noise and long cables if using only GPIO and I'll be missing IO as well...



I thought I could use i2c multiplexers like the MCP23017, but I know I2C don't like long cables, it's not made for that..
so adding a PCA9615DP or similar to have long Ethernet cable instead of straight i2c would solve the long cable issue.
Right now, I'm here;



reading the first pages of the spec it says << which is transparent to the SMBus/I²C-bus protocol layer >> so I'm guessing I could use similar topology and still be able to multiplex and use Interrupts for any switches changes.
it would be bellow maximal of 8 MCP23017 and still <transparent> for my readings.
1. I guess I would need to add filtering(ferrite/opto) for each switches reading right before entering the multiplexer... (really needed ?)
2. could all this be powered from the MCU ... that would be battery powered! :) 3.3v
3. is this crazy? doable? any suggestions?
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9327
  • Country: fi
Re: Long cables...
« Reply #1 on: February 23, 2019, 06:07:04 pm »
Switch as in physical switch, detecting pressing?

Such physical switches are trivial, because the data rate is inherently ridiculously low - just filter the shit out of it!

Any attempt to use an IO expander with digital communication protocol makes it less robust, until you hit an actually robust (differential) protocol, as you have correctly noted.

If the amount of wire is not a problem, why won't you consider just wiring the buttons to the IO? If you lack IOs, pick a larger device, or use any standard IO expanders locally on the same board with the MCU.

Since the switches are floating devices which consume no power, you won't have IO level or ground shift issues; since they are slow, you can RC filter them (think about 1k-10k in series, then 100n ceramic right between the IO pin and ground - this is a great ESD filter combination as well!)
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4321
  • Country: us
  • KJ7YLK
Re: Long cables...
« Reply #2 on: February 23, 2019, 06:42:13 pm »
1) Custom PC board circuit for each node.
2) Cheap, small microcontroller to sense the local inputs (switches) in each node.
3) Assignable address for each node. DIP switches, solder pads, or whatever.
4) RS-485 protocol between the nodes
5) Two (or three?) RJ-45 jacks on each node board to allow daisy-chaining the nodes.
6) Cat5 cable between the nodes. Dirt-cheap, widely available.
7) Use one pair of the cable for balanced/differential data, and all the other conductors to distribute power.
8 ) Send 12V power into the daisy-chain of nodes so that there will be sufficient voltage down at the far end to regulate down to 5V (or 3.3V or whatever)
9) ROBIN network protocol:  http://bdmicro.com/code/robin/
 

Offline guimtlTopic starter

  • Contributor
  • Posts: 17
  • Country: ca
Re: Long cables...
« Reply #3 on: February 23, 2019, 07:15:27 pm »
kind of switches, looking for open circuit.

I like the simple way of multiplex near the MCU and use long wires + filtering.
I may have over worried about the long wires and noise pickup in the 'switches'

for filtering I was suggested by a friend something similar:

placed right at the entry of the cable in my box... and use one like this for each IO.


 

Offline guimtlTopic starter

  • Contributor
  • Posts: 17
  • Country: ca
Re: Long cables...
« Reply #4 on: February 23, 2019, 07:46:47 pm »
wow, that's a bit more complex solution than I planned.  :o
of course, all boards will be custom. and I'm still in the early phase of planning/design.

I'll take a look at ROBIN for sure. but if I can keep it simple as @Siwastaja suggested, then I'll probably stick with that...
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Long cables...
« Reply #5 on: February 23, 2019, 08:22:55 pm »
Does the common of each group of three switches actually have to be ground?
If not, its well suited to wiring them all up in a matrix. Depending on whether or not you need to be able to detect more than two switches closed simultaneously, you may need a diode directly in series with each switch.

You have 4x6 squares in your matrix, and the easiest option would be to generate 6 sequential scan line signals driving the commons for each row, and have twelve  (4 x 3) input lines to read the switches in each row when its scan line selects it.  Filter the s--t out of the inputs as Siwastaja suggests and use robust drivers for the outputs with 100R in series to protect against shorted wiring or high energy EMI.  If possible screen as much as possible of the switch matrix wiring, which could be as crude as sandwiching the wiring between two sheets of grounded foil.

Depending on the switches, trying to run them at 3.3V from battery power may be unwise.  If they are mechanical switches and don't have precious metal, mercury wetted or conductive elastomer contacts, they are likely to require a significant wetting current for reliable operation.  A good rule of thumb is 10V when open, 10mA when closed, which gives enough voltage and energy to punch through mild surface oxidisation and other light contamination.  If you need to save power, you *MUST* have switches designed for 'dry' switching, which have never been abused with excess voltage or current.
« Last Edit: February 23, 2019, 08:38:36 pm by Ian.M »
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 21225
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Long cables...
« Reply #6 on: February 23, 2019, 08:26:46 pm »
"I want to monitor switches that are far apart from each other".

Define "far" in numbers!

If the switches can, for any reason, be disconnected from the MCU, then you may need to have ESD protection for the electronics. Never have an unprotected lead exposed.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4321
  • Country: us
  • KJ7YLK
Re: Long cables...
« Reply #7 on: February 23, 2019, 09:02:37 pm »
Define "far" in numbers!
The drawings cited earlier show an area of 8 by 12 feet.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9327
  • Country: fi
Re: Long cables...
« Reply #8 on: February 24, 2019, 07:21:15 am »
You can simplify your circuit by replacing the 1k ferrite + 330 ohm resistor by simply a 1.3k resistor (or of course whatever value nearby; these are arbitrary anyway). What the ferrite practically does, is to make the transition band of your filter steeper; so you get faster response for lowish frequencies (defined by the 330R) while still filtering very high-frequency noise better (defined by 1330R total). Now, you probably don't need this feature, and can just filter everything defined by that 1330R, or whatever you want to use. For filtering noise, it's as good as your ferrite solution, just reacts slower. How slowly? Well, the RC time constant is quite close to the CMOS thresholds, so let's say it's t = R*C = 130 us. I think this is good enough for mechanical switches :). You may want to make it even slower to aid in debouncing. But beware, massively big capacitors start to have increased inductance (due to their physical dimensions) and hence, start to be less effective on really hi-frequency filtering.

An RC filter with a big enough capacitor is an excellent ESD protection, and it's simple. Keep the capacitor at the trace that goes from input to the IO pin; if it's branched away far, it'll have extra inductance which prevents it from filtering quick spikes. If you place the capacitor right next to the IO pin, and have a good ground plane right there, the IO pin is going to see the same smooth voltage as the capacitor.

The ESD charge has to go into the capacitor, and most of the energy is lost in the resistor; rest is stored in the capacitor. If the values are sufficiently high, the capacitor voltage (directly dependent on the amount of charge stored to it) doesn't rise much at all, even from a severe ESD shock. I would ballpark from experience that 1k + 100n is definitely good. (Similarly, large power MOSFETs with equivalent gate capacitance around 10n and more are not very suspectible to ESD failures.)

If you want to add extra robustness to the inputs, using a schmitt trigger buffer (look at inverters as well, they may be cheaper or better and it's only about flipping the bit in software) can be a good idea; especially if you don't have time in software to do debouncing, or need to use the switches as direct interrupt signals. A schmitt trigger will have larger input hysteresis band than your normal MCU input; but even the normal input pin hysteresis is probably good enough. If you use such a buffer, you may want to look if you find a buffer with better ESD spec than your controller IO does, however, with proper RC filter in place, it shouldn't matter much.
« Last Edit: February 24, 2019, 07:31:09 am by Siwastaja »
 

Offline guimtlTopic starter

  • Contributor
  • Posts: 17
  • Country: ca
Re: Long cables...
« Reply #9 on: February 25, 2019, 10:05:55 pm »
looks like there are many ways to solve this :) I like the forum support!

I found this project that I could inspire from... https://easyeda.com/Zoolu/MCP23017-e73fd2cb972c4f2f9e39f9f881e25c72
he uses opto for each input + multiplexer. since his board is 'off' the MCU board he also uses TPD1E10B09  http://www.tij.co.jp/document-viewer/TPD1E10B09/datasheet/abstract#SLLSEB08601
for i2c & Interrupt pins... I think opto will offer a 'physical' separation that the TVS diode cannot offer on i2c because they are too slow.. but I don't care anymore since I'll place my MCU next to it in the same enclosure.

I'd like to make it as simple as possible yet robust and battery powered :phew:
'switches' will be normally closed, and I'm monitoring for when they get open.
once they are open they will stay open for a while(++days)
so I have all the time in the world for filtering the S*ht out of those long wires.  :-DD

so now I have many options
1) ferrite + cap and resistor
2) simplified cap + resistor + Schmitt trigger
3) the matrix sequential scan line signals is not possible because I might get a bigger area to monitor and some switches will be left open and I need to know which one is open or not all at the same time.
4) RS485 looks pretty heavy but very robust and uses cat5 cable. *that I planned to use. kind of the direct burial super sturdy/shielded versions.
5)opto (uses more power at the end because of the leds ? )
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9327
  • Country: fi
Re: Long cables...
« Reply #10 on: February 26, 2019, 07:26:29 am »
Optocouplers are great when you have any chance of having accidental ground loops, causing massive DC currents and blown things. They are not always that great for noise; noise is easy to filter anyway. If you are the one who wires the mechanical switches, I wouldn't care too much. Optocouplers are almost a must in industrial modules where anyone can screw any type of signal source to the connectors, often introducing ground loops.
 

Offline guimtlTopic starter

  • Contributor
  • Posts: 17
  • Country: ca
Re: Long cables...
« Reply #11 on: March 03, 2019, 04:53:45 pm »
time flys. didn't have much time last week to look into the first design tests. (*and still waiting for customer downpayments: -DD )
browsed around and found this; https://www.mouser.ca/datasheet/2/40/w2fw3f-776152.pdf
around page 10 it start to discuss the EMI filtering.
what do you guys think about those for filtering.. might get way more simple than using the ferrite.. ?!
radio <--> mcu <--> i2c / interrupt <--> multiplexer <-- filtering <--long cable <--contacts.

 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9327
  • Country: fi
Re: Long cables...
« Reply #12 on: March 04, 2019, 10:09:09 am »
Special physical arrangement capacitors like X2Y or feedthrough capacitors have been discussed multiple times. Some people do find some measurable differences, but others end up pointing that using bog standard capacitors are almost similar in performance. The trick is to use smallest physical size (0402 being a good compromise; it's still hand-solderable), and well placed ground vias (like using two instead of one for a single capacitor, as close as you can without risking tombstoning in reflow, on a 4-layer PCB. Now, using these techniques is equally important for such X2Y or feedthrough capacitors, they can't do the magic without proper layout either, so...

No, I don't think you need these overengineered parts, IMHO.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf