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.