What's the "right way" to do software flips?

60 views
Skip to first unread message

kaydeeH

unread,
Nov 4, 2025, 4:19:48 PM (2 days ago) Nov 4
to MPF Users
Hi all,

I have a flipper that I want to do a 2s auto pulse when a certain event is received. Here's a sterilized version of what I currently have, then I'll talk about what's happening in the game with this setup.

flippers:
    flipper_a:
        main_coil: c_flipper_a
        hold_coil: c_flipper_a_hold
        activation_switch: s_flipper_a_button
        enable_events: e_active_event, e_special_condition_enable
        disable_events: e_inactive_event, e_special_condition_disable
        sw_flip_events: e_special_condition_flip
        sw_release_events: e_special_condition_deflip

When the mode starts, e_active_event happens, flipper enables, works normally.
Then at a certain point, the e_inactive_event occurs and the flipper disables, is disabled normally.
A moment later, I want to pulse the flipper for 2s (to release any trapped ball under the flipper, don't ask, it would take too long to explain and it's not really relevant).
So to pulse the flipper, I send the e_special_condition_enable event to enable it, this works normally.
Then 1s later, I send the e_special_condition_flip event. The logs show it enabling the main and hold driver for the coil. But it doesn't flip.
Then 2s later, I send the e_special_condition_deflip event. The logs show it disabling the drivers. But since it didn't flip, nothing happens.
Then 1s later, I send the e_special_condition_disable event to return the flipper to its normal disabled state.

So it's like it should be working, but nothing happens. But here's where it gets interesting. If I manually flip the flipper with the button during the 2s window that the flipper should be flipping on its own, it flips AND HOLDS for the rest of the 2s window until the e_special_condition_deflip occurs and releases it.

I'm at a bit of a loss. It's like it wants to work, but... doesn't... unless I "help" it a little with the flipper button. Is it that I'm not pulsing it long enough doing it this way (it's default is 21ms, which maybe isn't long enough to pulse it to where the hold coil can grab and hold it, though that works fine for an actual flip)? I don't see a way to change the pulse times.

Which leads me to the real question: Is this the way I should be trying to do this? I see that I could use a "pulse_event" directly on the coil, but I believe that will also follow the short default pulse time for the coil and won't let me "hold" it for 2s. Should I set up a second clone flipper, like in the "weak flipper" example? But if so, I still don't see a way to override the default pulse time of the coil.

Update: So I discovered the main_coil_overwrite: option for flippers, and I tried making a clone flipper like in the "weak flippers" example as follows:

flippers:
    flipper_a:
        #Removed all special condition handling
        main_coil: c_flipper_a
        hold_coil: c_flipper_a_hold
        activation_switch: s_flipper_a_button
        enable_events: e_active_event
        disable_events: e_inactive_event
    flipper_a_auto:
        #New special flipper for handing the special condition for auto flipping
        #Activation switch removed so you can't manually flip even when enabled
        main_coil: c_flipper_a
        hold_coil: c_flipper_a_hold
        enable_events: e_special_condition_enable
        disable_events: e_special_condition_disable
        sw_flip_events: e_special_condition_flip
        sw_release_events: e_special_condition_deflip
        main_coil_overwrite:
            pulse_ms: 1000

I thought for sure this was going to do it, but in the log (when running virtual on my PC), it shows it's still pulsing it for only the usual default 21ms. I also tried it using the hold_coil_overwrite set, but same thing, log shows normal pulse time for that coil.

I'll try pushing this to the physical game anyways to see what happens, but my expectations are low based on what I'm seeing on my local logs. But I suspect I'm still either missing something or misusing the coil_overwrite somehow. Any advice would be much appreciated!

Thanks,
Kaydee


kaydeeH

unread,
Nov 4, 2025, 5:22:15 PM (2 days ago) Nov 4
to MPF Users
Can confirm that it's doing the same thing in the physical game. It's like the coil_overwrite isn't doing anything and the log just shows the normal pulse time when the e_special_condition_flip event is received.

kaydeeH

unread,
Nov 4, 2025, 5:41:19 PM (2 days ago) Nov 4
to MPF Users
Ugh, it's sooo close to working. No change since the last time, but I tried putting my fingers on the flippers and I can feel them buzzing when the auto flip happens. If I manually hold them up during the buzzing, they hold up, just like with the button assisted flip, then drop when they should. So I'm just not getting a strong enough main pulse to make them flip, but the override config doesn't seem to work, so this is where I'm stuck. The events are fine and the auto flipper is responding to the 2s hold, but the main pulse is too weak...

Thanks in advance for any help!

kaydeeH

unread,
Nov 4, 2025, 7:51:10 PM (2 days ago) Nov 4
to MPF Users
If it helps, here's the matching coil config:

    c_flipper_a_hold :
        number: 1616_2-11
        default_pulse_ms: 40
        default_hold_power: 0.7
        tags: coils
     c_flipper_a :
        number: 1616_2-12
        default_pulse_ms: 21
        tags: coils

I'm starting to wonder if the coil_player is the answer to my quandry... I'll play with that too. I also noticed I don't have allow_enable set for the main coil, but again, the flipper works under normal conditions without it, so not sure if that's got anything to do with it.

kaydeeH

unread,
Nov 4, 2025, 9:37:18 PM (2 days ago) Nov 4
to MPF Users
Well, I thought I had something with coil_player. I got it to work on the virtualized platform and the logs indicated it was honoring my desired pulse times, so I thought I had finally cracked it. But when I went to put it on the physical hardware, it compiled and the game started, but the moment the event fired, it crashed with the following error:

  File "/home/game_dir/MyGame/venv/lib/python3.11/site-packages/mpf/core/events.py", line 755, in _run_handlers
    result = handler.callback(**merged_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/game_dir/MyGame/venv/lib/python3.11/site-packages/mpf/core/config_player.py", line 348, in config_play_callback
    return self.play(settings=settings, context=context, calling_context=calling_context, priority=priority,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/game_dir/MyGame/venv/lib/python3.11/site-packages/mpf/config_players/coil_player.py", line 44, in play
    coil.pulse(pulse_ms=s['pulse_ms'], pulse_power=s['pulse_power'], max_wait_ms=s['max_wait_ms'])
  File "/home/game_dir/MyGame/venv/lib/python3.11/site-packages/mpf/devices/driver.py", line 351, in pulse
    self._pulse_now(pulse_ms, pulse_power)
  File "/home/game_dir/MyGame/venv/lib/python3.11/site-packages/mpf/devices/driver.py", line 314, in _pulse_now
    self.hw_driver.pulse(PulseSettings(power=pulse_power, duration=pulse_ms))
  File "/home/game_dir/MyGame/venv/lib/python3.11/site-packages/mpf/platforms/fast/fast_driver.py", line 474, in pulse
    self._pulse(pulse_settings)
  File "/home/game_dir/MyGame/venv/lib/python3.11/site-packages/mpf/platforms/fast/fast_driver.py", line 494, in _pulse
    pwm1_ms = Util.int_to_hex_string(pulse_settings.duration)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/game_dir/MyGame/venv/lib/python3.11/site-packages/mpf/core/utility_functions.py", line 352, in int_to_hex_string
    raise ValueError("invalid source int: %s" % source_int)
ValueError: invalid source int: 2000

So it looks like there's some sort of MPF error parsing the pulse time. So I'm back to zero unless someone can clue me in to what I'm doing wrong here.

Here's how I set up the coil_player, FYI:

coil_player:
  e_special_condition_flip:
     c_flipper_a:
       action: pulse
       pulse_ms: 250
       pulse_power: .7
     c_flipper_a_hold:
       action: pulse
       pulse_ms: 2000
       pulse_power: .7

kaydeeH

unread,
Nov 4, 2025, 10:00:49 PM (2 days ago) Nov 4
to MPF Users
Le sigh... looks like that utility function caps out the input at 255, arbitrarily limiting the max pulse time to 255s when called by the Fast driver. That won't do, and I can't imagine a core utility function is something I want to start monkeying with. :-( Confounded at every turn!

So back to my original question I guess... how to can do auto flippy thing? :-P

kaydeeH

unread,
Nov 4, 2025, 10:26:00 PM (2 days ago) Nov 4
to MPF Users
I should mention this game was originally coded on MPF 0.57.3.dev2 and that's what it's currently running. So if someone can confirm this fast driver issue was fixed on a different version, I suppose that's one approach to get the coil_player to work unless there's an overall better way to be doing this.

Jérôme V

unread,
Nov 5, 2025, 4:42:49 AM (yesterday) Nov 5
to MPF Users
I don't know how to do that but what about the Dual Coil Diverter in the MPF doc ?

Philip Dixon

unread,
Nov 5, 2025, 8:29:19 AM (yesterday) Nov 5
to MPF Users
c_flipper_a_hold :
        number: 1616_2-11
        default_pulse_ms: 40
        default_hold_power: 0.7
        allow_enable: true
        enable_events: auto_flip_event
        disable_events: some_other_event

        tags: coils

This is how I do it.

Reply all
Reply to author
Forward
0 new messages