Warning

This is the dev documentation for an unreleased version of MPF!

This is the documentation for MPF 0.55+, which is the “dev” (next) release of MPF that is a work-in-progress. Unless you’re specifically looking for this version, you probably want to use the version of documentation called “latest” which is for the latest released version of MPF. That documentation is at docs.missionpinball.org/en/latest.

Raspberry PI (pigpio)

Related Config File Sections
hardware:
raspberry_pi:
switches:
coils:
servos:

The rpi platform can be used to control inputs (switches), outputs (coils), I2C and servos on the RPi remotely (or locally) using pigpio.

Installation

You need to install the apigpio extension via pip to use it:

pip3 install apigpio_mpf

The pigpiod service needs to be running (in this example on localhost port 8888, which is the default setting). To install it and enable is (on debian based systems) :

apt install pigpiod
systemctl enable pigpiod.service
systemctl start pigpiod.service

The enable step gets the service running at startup, thus it is optional.

Config

This is an example config:

hardware:
  platform: rpi
raspberry_pi:
  ip: localhost
  port: 8888
switches:
  s_switch_1:
    number: 1
  s_switch_7:
    number: 7
coils:
  output_23:
    number: 23
    default_pulse_ms: 23
  output_30:
    number: 30
    default_hold_power: 1.0
  output_2:
    number: 2
    default_hold_power: 0.2
servos:
  servo_10:
    number: 10
This example is tested to be valid MPF config. However, it is not integration tested.
hardware:
  platform: rpi
raspberry_pi:
  ip: localhost
  port: 8888
switches:
  s_switch_1:
    number: 1
  s_switch_7:
    number: 7
coils:
  output_23:
    number: 23
    default_pulse_ms: 23
  output_30:
    number: 30
    default_hold_power: 1.0
  output_2:
    number: 2
    default_hold_power: 0.2
servos:
  servo_10:
    number: 10

Configure the ip of your RaspberryPi in the raspberry_pi section. You may use localhost if you are running MPF on the RPi. Any pin on the RPi can be used as either input or output. Additionally, you may use servos on any pin.

Is this a real pinball controller?

No. The RPi is not a pinball controller for various reasons:

  • Drivers are missing to drive coils
  • Inputs are unprotected and any error current will fry the CPU
  • Hardware rules are not supported by the pigpio daemon
  • A watchdog is missing

This platform is meant as a cheap interface for peripherals such as DMDs, segment displays lights, servos, steppers and more. You can also use it for inputs to some extend.

Can this be turned into a pinball controller?

Sure it can. We just did not do that here. Have a look at Arduino Pinball Controller which is kind of that already.

If you want to do it with pigpio you would have to do the following (and probably more):

  • Build a PCB with FETs to drive outputs. Add proper protection.
  • Protect your inputs against high and negative voltages.
  • Implement hardware rules in pigpio (might be possible with callbacks)
  • Run a realtime linux for proper timing of your rules
  • Add a some watchdog (either in Linux or in hardware)

What if it did not work?

Have a look at our hardware troubleshooting guide.