1

I bought an old broken pinball machine and I'm trying to control it with my Raspberry Pi 3. The pinball machine has multiple circuit boards. I removed the controller circuit board and replaced it with the Raspberry Pi.

I connected the Pi to three MCP23017 chips. With two of them I read the input switches of the pinball machine. One MCP23017 communicates with the transistor circuit board. It talks to the chips on the circuit board, which are connected to transistors, which are connected to lamps and solenoids. I connected the grounds of the Raspberry Pi and the pinball machine.

It mostly works, but: It fails now and then. It seems to fail when the pinball machine draws a lot of power, when I use the flippers or after I enabled certain solenoids. The error I get in my software is the same error I get when I give the MCP23017 chips no power. I get the error with both reading and writing registers on all three chips, also the two input chips which are besides connected to the switches not connected to the pinball machine.

What happens here and how can I fix it? Can one device mess with an other device if the grounds are connected?

I'm using a Raspberry Pi power adapter to power my Pi. It also powers the three MCP23017 chips. The transistor board has its + connected to the pinball machine power supply, so the pinball machine shouldn't draw any power from the Raspberry Pi. When I put an ampere meter between the positive pin on the Pi and the red wire, I get 1 μA when the pinball machine is off and -38 μA when the pinball machine is on, so the current flows into the Pi.

Raspberry Pi connected to MCP23017 and pinball machine

15
  • 1
    have you checked the Current that the device draws? Is there a back current that flows towards your pi that you are not aware of? This happened to me once when I was using a high current LiPo battery which was connected to the Pi. Since there is a limited 500 mA current from USB ports, the current from the battery started drawing back causing the Pi to crash. Check similar stuff in your scenarios since you might be using solenoids etc.
    – Shan-Desai
    Aug 9, 2016 at 10:23
  • Could you clarify your post and say what is being powered through the Pi. How are you powering the Pi?
    – joan
    Aug 9, 2016 at 10:26
  • 1
    I have a 3.3V powered I2C device that often resets when a light switch on the same household circuit is flicked -- but there's another 3.3V I2C device on the same Pi that's fine. The Pi is powered with a 5V 2.5A adapter sold for it. This happens with both 26 and 40 pin models. I've never bothered to deal with it, but other people have reported similar issues, and at least one of them claimed to have solved it by I think including a capacitor between the DC supply and the Pi.
    – goldilocks
    Aug 9, 2016 at 12:21
  • 1
    @goldilocks The most likely reason that current surges in other devices affects the Pi is capacitative coupling. The plug-packs typically used are double insulated, and thus the outputs "float" WRT Ground. Any voltage spike may be coupled to the Pi (which are often floating - or worse earthed via other devices e.g. Monitors). Professional quality supplies often include electrostatic screening to prevent this. The best approach to minimising this is to ensure that ALL devices connected to the Pi are powered from the same socket, by as short a connection as possible.
    – Milliways
    Aug 10, 2016 at 1:48
  • 1
    @Paul from your diagram it does seem that the only way the current reaches your Pi is from the GPIO. Take this step by step : 1. Check current rating of your ICs and check current rating of the GPIO. 2. It is good to measure the back current first and then decide how much of resistance you need to add in front of the pins. Also a quick way about this is may adding a forward biasing diode. If there is a current surging back from the solenoids then a diode would provide a higher resistance and avoid current to GPIOs
    – Shan-Desai
    Aug 10, 2016 at 12:20

1 Answer 1

1

Unfortunately I can't just give you a link to a solution. There are University courses in Electrical Engineering covering this, but even after mastering the theory it is still a bit of an art.

To make any sensible suggestions You would need to describe the circuitry to which you are connecting (and it is still an EE question).

I have listed below links to a number of related Answers.

A brief summary of the principles for working in a noisy environment

Connect to the Pi GND as common NOT the +3.3v rail.

Take measures to reduce interference.
    E.g. use twisted pair (or shielded cable or shielded twisted pair)
    - a separate cable for each input, with the only common connection the GND at the Pi end.

Use Ferrite rings for common mode rejection.

Use low impedance circuitry
    e.g. a low value pullup e.g. 1kΩ unless there is power limitation.

Use optocouplers for isolation.

Adopt bounce suppression.
    Remember this needs to be BOTH on contact closure AND contact open.
    This can be done in software and/or with capacitor to slow transitions.

Separate power and signal ground.

Use Power Supply filter capacitors to minimise noise.

The MOST IMPORTANT item is layout! Use the shortest direct wiring, and run wires parallel

https://raspberrypi.stackexchange.com/a/9771/8697 https://raspberrypi.stackexchange.com/a/9771/8697 https://raspberrypi.stackexchange.com/a/22691/8697 https://raspberrypi.stackexchange.com/a/24899/8697

3
  • This sounds like a solution to me! I'm really new to electronics, but it seems like connecting the pinball machine only via optocouplers may already solve the problem. What do you mean with "Connect to the Pi GND as common NOT the +3.3v rail"? Is this different as the wiring in my drawing?
    – Paul
    Aug 10, 2016 at 11:56
  • 1
    @Paul These are general guidelines. No one would implement all of them. Any direct (not totally electrically isolated) interconnection NEEDS a common connection, but preferably not 2 (3.3V and Gnd). I have seen others suggesting using 3.3V, but this is more subject to interference, although equally valid in a low speed application.
    – Milliways
    Aug 10, 2016 at 12:07
  • Yes, it works! Raspberry Pi and MCPs completely seperated from the rest of the pinball machine using optocouplers.
    – Paul
    Aug 13, 2016 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.