macsym
Posts: 10
Joined: Wed May 25, 2016 12:21 pm

How to properly connect many interrupters with internal pull-up resistors and long wires?

Mon Jul 09, 2018 10:03 am

Hello,

I read the status of many inputs such as push buttons, motion sensors, etc... I am using cat5e or cat6 shielded Ethernet cables to connect my inputs to the Raspberry (I usually use 7x wires for pins and 1x wire for the common GND). In average, they are ~20m far but some are ~50m far. I am using the internal pull-up resistors of the Raspberry (to avoid floating) and I connect the pins to GND directly. So a pin is at 0 if it is connected to GND (interrupter closed) and at 1 if not connected to GND (interrupter opened). I needed many pins so I am using this SPI 128 pins expander board from Pridopia: http://www.pridopia.co.uk/pi-23s17-8-v3.html

It works well but I realized I am facing problems if I connect too many "long distance" wires on a same bus of 16x pins. The chip related to the bus becomes very hot and some of the pins (always the same pins) appear as connected to GND even if they are not. As a workaround, I split these "long distance" inputs over 2 different buses but I am losing many pins doing it this way (I only connect 8x pins on a 16x pin bus) and even like that, I still get errors sometimes.

I guess the resistance is so high that the Raspberry thinks the pin is connected to GND even if it is not. Can you advise me a better way to connect my installation? I'd like to avoid using external pull-up resistors because it would be a huge mess at physical level (I understand I'd need 1x resistor for each pin). Or maybe there is a way to use a resistor or transistor on the GND wire (which is common to all)? Or maybe I could source 5v or 3.3v somewhere (there are vcc pins on the SPI board and I am powering the installation through a computer PSU so I can source 12v, 5v and 3.3v easily)?

Thanks for any help!

hippy
Posts: 5935
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Mon Jul 09, 2018 2:31 pm

It is not clear how you are using internal Pi pull-ups in conjunction with the SPI board expander board, how you have that and your buttons wired.

It sounds to me like you perhaps have the SPI expander driving one side of the buttons with the other side connected to Pi inputs. If so, two buttons closed could be shorting a high and a low expander output together which would cause the expander chip to get hot.

Some sort of circuit diagram or description of exactly what you have would help.

macsym
Posts: 10
Joined: Wed May 25, 2016 12:21 pm

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 8:05 am

Hello and thanks for your reply.

at software level, I simply set the pins as INPUTS and turn the internal pull-up resistors UP with:

Code: Select all

gpio -x mcp23s17:128:0:0 mode 128 in && gpio -x mcp23s17:128:0:0 mode 128 up
gpio -x mcp23s17:128:0:0 mode 129 in && gpio -x mcp23s17:128:0:0 mode 129 up
gpio -x mcp23s17:128:0:0 mode 130 in && gpio -x mcp23s17:128:0:0 mode 130 up
gpio -x mcp23s17:128:0:0 mode 131 in && gpio -x mcp23s17:128:0:0 mode 131 up
gpio -x mcp23s17:128:0:0 mode 132 in && gpio -x mcp23s17:128:0:0 mode 132 up
gpio -x mcp23s17:128:0:0 mode 133 in && gpio -x mcp23s17:128:0:0 mode 133 up
gpio -x mcp23s17:128:0:0 mode 134 in && gpio -x mcp23s17:128:0:0 mode 134 up
gpio -x mcp23s17:128:0:0 mode 135 in && gpio -x mcp23s17:128:0:0 mode 135 up
gpio -x mcp23s17:128:0:0 mode 136 in && gpio -x mcp23s17:128:0:0 mode 136 up
gpio -x mcp23s17:128:0:0 mode 137 in && gpio -x mcp23s17:128:0:0 mode 137 up
gpio -x mcp23s17:128:0:0 mode 138 in && gpio -x mcp23s17:128:0:0 mode 138 up
gpio -x mcp23s17:128:0:0 mode 139 in && gpio -x mcp23s17:128:0:0 mode 139 up
gpio -x mcp23s17:128:0:0 mode 140 in && gpio -x mcp23s17:128:0:0 mode 140 up
gpio -x mcp23s17:128:0:0 mode 141 in && gpio -x mcp23s17:128:0:0 mode 141 up
gpio -x mcp23s17:128:0:0 mode 142 in && gpio -x mcp23s17:128:0:0 mode 142 up
gpio -x mcp23s17:128:0:0 mode 143 in && gpio -x mcp23s17:128:0:0 mode 143 up
gpio -x mcp23s17:128:0:1 mode 128 in && gpio -x mcp23s17:128:0:1 mode 128 up
gpio -x mcp23s17:128:0:1 mode 129 in && gpio -x mcp23s17:128:0:1 mode 129 up
gpio -x mcp23s17:128:0:1 mode 130 in && gpio -x mcp23s17:128:0:1 mode 130 up
gpio -x mcp23s17:128:0:1 mode 131 in && gpio -x mcp23s17:128:0:1 mode 131 up
gpio -x mcp23s17:128:0:1 mode 132 in && gpio -x mcp23s17:128:0:1 mode 132 up
gpio -x mcp23s17:128:0:1 mode 133 in && gpio -x mcp23s17:128:0:1 mode 133 up
gpio -x mcp23s17:128:0:1 mode 134 in && gpio -x mcp23s17:128:0:1 mode 134 up
gpio -x mcp23s17:128:0:1 mode 135 in && gpio -x mcp23s17:128:0:1 mode 135 up
gpio -x mcp23s17:128:0:1 mode 136 in && gpio -x mcp23s17:128:0:1 mode 136 up
gpio -x mcp23s17:128:0:1 mode 137 in && gpio -x mcp23s17:128:0:1 mode 137 up
gpio -x mcp23s17:128:0:1 mode 138 in && gpio -x mcp23s17:128:0:1 mode 138 up
gpio -x mcp23s17:128:0:1 mode 139 in && gpio -x mcp23s17:128:0:1 mode 139 up
gpio -x mcp23s17:128:0:1 mode 140 in && gpio -x mcp23s17:128:0:1 mode 140 up
gpio -x mcp23s17:128:0:1 mode 141 in && gpio -x mcp23s17:128:0:1 mode 141 up
gpio -x mcp23s17:128:0:1 mode 142 in && gpio -x mcp23s17:128:0:1 mode 142 up
gpio -x mcp23s17:128:0:1 mode 143 in && gpio -x mcp23s17:128:0:1 mode 143 up
gpio -x mcp23s17:128:0:2 mode 128 in && gpio -x mcp23s17:128:0:2 mode 128 up
gpio -x mcp23s17:128:0:2 mode 129 in && gpio -x mcp23s17:128:0:2 mode 129 up
etc... up to 128 pins

At hardware level. I simply plug the 128 pins board expander on top of the Raspberry like that:
pi-23x17-8-v3-n02.jpg
pi-23x17-8-v3-n02.jpg (150.87 KiB) Viewed 740 times

And I connect the pins to GND like that:
diagram.jpg
diagram.jpg (16.84 KiB) Viewed 744 times

Thanks again for any help!

hippy
Posts: 5935
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 9:31 am

Okay, so you have the pins on the expander board pulled-up, not the Pi itself. That makes sense and should work.

The problem could be with your "gpio -x mcp23s17" commands. If those are not setting all pins to input then any which are output high would short to 0V when their button is pushed and that could overheat the chips.

I am not familiar with the "gpio -x mcp23s17" command, or its parameters, and couldn't find anything with a quick Google search. So I can't say what they should be. I would be expecting to see some 255 values to set all 8-bits of a byte register but that might not be the way it works.

If you have a link to where "gpio -x mcp23s17" is documented I can take a look but otherwise it's out of my scope of experience.

macsym
Posts: 10
Joined: Wed May 25, 2016 12:21 pm

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 11:27 am

Hello and thanks again for your answer.

The board has 8x buses of 16x pins (128 pins in total). I do indeed use 5x buses for inputs (80x pins in total) and 3x buses for outputs (48x pins in total). The outputs control relay boards like these:
8ch_rel_lh00l30r.jpg
8ch_rel_lh00l30r.jpg (48.71 KiB) Viewed 700 times
But I never mix inputs and outputs on the same bus so I don't think it is related.

You can get more info about the mcp23s17 extension for the GPIO library at http://wiringpi.com/the-gpio-utility/sp ... xtensions/ and about the chip at http://www.pridopia.co.uk/pi-doc/mcp23017.pdf

But I think my problem is more electrical than software related. Maybe the Raspberry can't keep up with so many internal resistors pulled up and the long wires I am using. The problem is I don't want to use external resistors because I wouldn't know how to put them physically (I understand I'd need a resistor for each input pin). See this picture to understand the mess it already is:
cabinet.jpg
cabinet.jpg (190.09 KiB) Viewed 700 times

The Raspberry is circled in yellow. I have 4 cabinets like that in the warehourse...

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 11:34 am

Your cable management leaves a great deal to be desired. Messy is difficult to fault-find and maintain, tidy takes time at the outset but pays dividends long-term.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

macsym
Posts: 10
Joined: Wed May 25, 2016 12:21 pm

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 1:23 pm

Z80 Refugee wrote:
Tue Jul 10, 2018 11:34 am
Your cable management leaves a great deal to be desired. Messy is difficult to fault-find and maintain, tidy takes time at the outset but pays dividends long-term.
Note this picture was taken while I was working on the installation but it looks better when the derivation boxes are closed (and the cabinet is always closed anyway so you can consider it as a huge derivation box). Also, I first used an Arduino Mega at the top of the cabinet and then switched to Raspberry (which was at the bottom) so I had to lengthen all wires with dupont's

The problem is I have MANY inputs and outputs. It started all tidy and clean but it became problematic after installing more and more inputs/outputs over time as you can imagine. Every cable is numbered and every wire within every cable is identified though. The inputs wires are connected to dupont's via scotchlok's which is the best solution I found so far. I also use Wago's to merge all GND. I'd be happy if you can advise me a better solution though.

Back to the original topic, I don't think it is related to my problem because scotchlok's either work or don't work. But please do not hesitate to share any idea

pcmanbob
Posts: 6905
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 1:43 pm

I rather think you problem is related to long wires and the number of wires you have in that space.

Using internal pull-ups which are around 50KΩ often causes problems when used with long wires and electrically noisy environments.
you may have no option but to use external pull-ups of around 10KΩ and you may also end up having to add to capacitors to dampen out the electrical interference.

Having mains and the relay broads in the box will generate a lot of electrical noise.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 2:01 pm

macsym wrote:
Tue Jul 10, 2018 1:23 pm
Z80 Refugee wrote:
Tue Jul 10, 2018 11:34 am
Your cable management leaves a great deal to be desired. Messy is difficult to fault-find and maintain, tidy takes time at the outset but pays dividends long-term.
Note this picture was taken while I was working on the installation but it looks better when the derivation boxes are closed (and the cabinet is always closed anyway so you can consider it as a huge derivation box). Also, I first used an Arduino Mega at the top of the cabinet and then switched to Raspberry (which was at the bottom) so I had to lengthen all wires with dupont's

The problem is I have MANY inputs and outputs. It started all tidy and clean but it became problematic after installing more and more inputs/outputs over time as you can imagine. Every cable is numbered and every wire within every cable is identified though. The inputs wires are connected to dupont's via scotchlok's which is the best solution I found so far. I also use Wago's to merge all GND. I'd be happy if you can advise me a better solution though.

Back to the original topic, I don't think it is related to my problem because scotchlok's either work or don't work. But please do not hesitate to share any idea
All of what you say indicates a general lack of experience. Yes, of course things look neater when the covers are closed, but that doesn't mean the cable routing is tidy inside. I'm not talking about what it looks like - I'm talking about what works well and what doesn't. That it started tidy and became a rats nest over a period of time is no excuse. All that wiring is coupling across to the other wiring capacitively, apart from not being able to see what's going where.

And don't mistake DC electrical conductivity for AC performance (in this case, "AC" means a varying signal). ScotchLoks might well make a bleeper go bleep, but they introduce horrendous signal discontinuities, and the connection resistance may leave a lot to be desired (and deteriorate over time).

Your system is clearly suffering from noise, but you are ignoring the source of the noise or any proper solution to it. 1: keep wires as short as conveniently possible, and use cable management combs to route them neatly. 2: if an existing wire is too short, use a proper soldered joint and heatshrink tubing insulation to add an extension. 3: Always assume you will have noise on the lines, and design the electrical interface to accommodate it (see my previous link to suggested component values - never, ever, rely on internal pull-ups for anything that matters).
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

hippy
Posts: 5935
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 2:48 pm

macsym wrote:
Tue Jul 10, 2018 11:27 am
I think my problem is more electrical than software related. Maybe the Raspberry can't keep up with so many internal resistors pulled up and the long wires I am using.
Possibly but I would not have expected mains or EMI pickup to cause the expander chips to get hot. That to me suggests more than just interference or pickup.
macsym wrote:
Tue Jul 10, 2018 11:27 am
The problem is I don't want to use external resistors because I wouldn't know how to put them physically (I understand I'd need a resistor for each input pin).
I would personally have used screw terminal blocks on strip boards to connect all incoming and outgoing signals to, and then wired from those to the controlling Pi's expander and relay boards.

That way it would be easier to add pull ups as required, to include Schmitt triggers or other buffering as needed to make things work. You may not want to use resistors or other components but if that is the where the problem lies you won't really have much choice.

Given that the expander boards have 0.1" headers it could make sense to use ribbon cables for interconnects, even if that means adding more internal interface boards.

It may be worth considering making such changes.

macsym
Posts: 10
Joined: Wed May 25, 2016 12:21 pm

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 5:02 pm

Thank you all for your comments. I see you are all concerned about the mains which are very close. I never trusted these "Chinese" relay boards for power angry devices. So I only use them to:

- control low power devices (such as IP cameras) that only consume ~15 watts @220VAC (in case I need to reset them remotely)

- simulate a push button (by closing the relay during 100ms) to control impulse relays which are in a real electrical cabinet. I understand no current (or very little) goes from A1 to N during these 100ms (see diagram hereafter) :
sch16406-schneider-dclic-telerupteur-monophase-16a.jpg
sch16406-schneider-dclic-telerupteur-monophase-16a.jpg (12.97 KiB) Viewed 638 times
schema impulse relay.jpg
schema impulse relay.jpg (46.23 KiB) Viewed 638 times

Nevertheless, I know some of the ethernet cables I used for inputs are sometimes close to "real" mains because I had no other choice. This is why I used shielded cables only. Also, I sometimes used a same ethernet cable to power something and get its signal. For example, I installed 5x motion sensors on the same ethernet cable so 5x wires are for the signals, 1x wire is for the Raspberry GND (common to all signals), 1x wire is for the +12VDC and 1x wire is for the -12VDC. But these motion sensors consume very little current so I don't think this create much noise even if they are in the same ethernet cable.
pcmanbob wrote:
Tue Jul 10, 2018 1:43 pm
you may have no option but to use external pull-ups of around 10KΩ and you may also end up having to add to capacitors to dampen out the electrical interference.
Thanks. I was hoping a solution involving something on the common 5v or 3.3v or GND because it would be much easier to implement (would be done on 1x wire instead of my 80x inputs wires) but I'll end up doing this if there is really no other solution.
Z80 Refugee wrote:
Tue Jul 10, 2018 2:01 pm
(see my previous link to suggested component values - never, ever, rely on internal pull-ups for anything that matters).
Sorry I don't see your previous link. Can you send it again? I am interested in better components for physical connections.
hippy wrote:
Tue Jul 10, 2018 2:48 pm
I would personally have used screw terminal blocks on strip boards to connect all incoming and outgoing signals to, and then wired from those to the controlling Pi's expander and relay boards.

That way it would be easier to add pull ups as required, to include Schmitt triggers or other buffering as needed to make things work. You may not want to use resistors or other components but if that is the where the problem lies you won't really have much choice.

Given that the expander boards have 0.1" headers it could make sense to use ribbon cables for interconnects, even if that means adding more internal interface boards.

It may be worth considering making such changes.
I sounds like a very good idea that would allow me to use external pull-ups as suggested by everybody. If possible, can you send me links to what you are thinking about?

Thanks again for all your help

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: How to properly connect many interrupters with internal pull-up resistors and long wires?

Tue Jul 10, 2018 5:07 pm

macsym wrote:
Tue Jul 10, 2018 5:02 pm
Z80 Refugee wrote:
Tue Jul 10, 2018 2:01 pm
(see my previous link to suggested component values - never, ever, rely on internal pull-ups for anything that matters).
Sorry I don't see your previous link. Can you send it again? I am interested in better components for physical connections.
Apologies, I was thinking of a different thread. Beginners Guide to Wiring Things to the GPIO
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

Return to “Automation, sensing and robotics”