self.machine.coils.*

class mpf.devices.driver.Driver(machine: mpf.core.machine.MachineController, name: str)

Bases: mpf.core.system_wide_device.SystemWideDevice

Generic class that holds driver objects.

A ‘driver’ is any device controlled from a driver board which is typically the high-voltage stuff like coils and flashers.

This class exposes the methods you should use on these driver types of devices. Each platform module (i.e. P-ROC, FAST, etc.) subclasses this class to actually communicate with the physical hardware and perform the actions.

Args: Same as the Device parent class

Accessing coils in code

The device collection which contains the coils in your machine is available via self.machine.coils. For example, to access one called “foo”, you would use self.machine.coils.foo. You can also access coils in dictionary form, e.g. self.machine.coils['foo'].

You can also get devices by tag or hardware number. See the DeviceCollection documentation for details.

Methods & Attributes

Coils have the following methods & attributes available. Note that methods & attributes inherited from base classes are not included here.

disable(**kwargs)

Disable this driver.

enable(pulse_ms: int = None, pulse_power: float = None, hold_power: float = None, **kwargs)

Enable a driver by holding it ‘on’.

Parameters:
  • pulse_ms – The number of milliseconds the driver should be enabled for. If no value is provided, the driver will be enabled for the value specified in the config dictionary.
  • pulse_power – The pulse power. A float between 0.0 and 1.0.
  • hold_power – The pulse power. A float between 0.0 and 1.0.

If this driver is configured with a holdpatter, then this method will use that holdpatter to pwm pulse the driver.

If not, then this method will just enable the driver. As a safety precaution, if you want to enable() this driver without pwm, then you have to add the following option to this driver in your machine configuration files:

allow_enable: True

get_and_verify_hold_power(hold_power: Optional[float]) → float

Return the hold power to use.

If hold_power is None it will use the default_hold_power. Additionally it will verify the limits.

get_and_verify_pulse_ms(pulse_ms: Optional[int]) → int

Return and verify pulse_ms to use.

If pulse_ms is None return the default.

get_and_verify_pulse_power(pulse_power: Optional[float]) → float

Return the pulse power to use.

If pulse_power is None it will use the default_pulse_power. Additionally it will verify the limits.

pulse(pulse_ms: int = None, pulse_power: float = None, max_wait_ms: int = None, **kwargs) → int

Pulse this driver.

Parameters:
  • pulse_ms – The number of milliseconds the driver should be enabled for. If no value is provided, the driver will be enabled for the value specified in the config dictionary.
  • pulse_power – The pulse power. A float between 0.0 and 1.0.
raise_config_error(msg, error_no, *, context=None)

Raise a ConfigFileError exception.