Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Stern Spike Trough, OPP and CobraPinball

198 views
Skip to first unread message

Romain RAT

unread,
Jan 9, 2025, 12:59:26 PMJan 9
to MPF Users
Hi everyone,

I was wondering (for a friend ;) ) If the Stern Spike trough was supported by the cobrapinball controller ?

Typically, is there a way to use the SPI that is wired on switches 1-0-24 to 1-0-27 ?

It would be just in case that friend bought a Stern Spike trough... Of course he didn't ;)...

If not, I could still get the signal from before the SPI components and hard wire it to a switch input to the cobra controller I guess.

Either way, feel free to laugh to my friend.... Definitely NOT ME x)

cobra18t

unread,
Jan 9, 2025, 6:25:03 PMJan 9
to MPF Users
There is a way to do it but I haven't tried yet. Here is a place to start:

You need two outputs and one input. I do have a Stern trough so I may be able to do some testing but not until next week.

Romain RAT

unread,
Jan 10, 2025, 3:34:39 AMJan 10
to mpf-...@googlegroups.com

Thanks Cobra!
I did see that post yesterday but main concern was about the fact the cobrapin could use the SPI instead of a GPIO.
I'll try to use this code this weekend if I have a bit of time.

Also, it looks like it's not real SPI to me on the Stern side.
I'll need to "reverse engineer" the pcb to get exactly what they did.

Have a great day.
Romain


--
You received this message because you are subscribed to a topic in the Google Groups "MPF Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mpf-users/FuvYokPp_Qw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mpf-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mpf-users/eacd9918-9d26-4713-9b7e-6bb77a9158f6n%40googlegroups.com.

cobra18t

unread,
Jan 10, 2025, 8:56:15 AMJan 10
to MPF Users
Are you writing your own firmware?

OPP does not support generic SPI via the SPI peripheral (yet). It has been worked on, but not fully implemented. So you are stuck with the bit bang option until the firmware supports it.

SPI is a very loose framework, so I could not say that Stern's implementation isn't "real." The main thing is they use the traditional CS pin as a load pin.

Romain RAT

unread,
Jan 10, 2025, 4:58:26 PMJan 10
to mpf-...@googlegroups.com
I'm using OPP with the firmware you provide.

What makes me think that they don't use "real" SPI is that out of 3 connectors (one for power), they have both a Serial IN and a Serial OUT connector with both "RCK, SCK, MOSI and MISO" signals.
By the way, I noticed on a video that the Serial OUT isn't connected.
Also, mounted ICs on the PCB are inverters ( 74HC540D and 74HC14 ) and a 8-bit parallel-in/serial out shift register (74HCT165D). Obviously, none of them is SPI cabaple.

The opto receivers seem to all be connected to the 74HC540D with pull-up and is then fed into the 74HCT165D to reduce the amount of wire out the board.
The 74HC540D is also used to lit the LEDs that shows the state of each optos.

I might give a proper schematics soon so it's easier to understand.

What need to be reminded is that they accually mux their outputs but not using a SPI interface. 


Message has been deleted

Romain RAT

unread,
Jan 10, 2025, 5:32:52 PMJan 10
to MPF Users
Here is the schematic of the trough receiver side I managed to recreate. There are not yet comments on everything but should be done soon.

As said earlier, they don't use a "true" SPI interface, they serialize the data, most likely to reduce the amount of wire in the pinball.

Schematic_Stern-Trough_2025-01-10.pdf

cobra18t

unread,
Jan 10, 2025, 5:38:50 PMJan 10
to MPF Users
You can use an SPI peripheral to work with a 74HCT165. The RCK is just a variant of CS (a parallel load in this case). I have the trough and have seen the schematic before. The schematic is available on the Stern support website. Other SPIKE2 boards also use serial-in parallel-out shift register ICs (74HCT594) as output expanders. That is what the MOSI is used for. On the trough, there are no outputs, though. Daisy-chained SPI like this has been used in other applications.

Romain RAT

unread,
Jan 10, 2025, 5:54:22 PMJan 10
to mpf-...@googlegroups.com

Thanks for all the information!
Didn't know they provided some of their schematics. I feel dumb for having probed all the traces with my multimeter x)..

I hope testing the MPF code using SPI on Sunday.
Let me know if you did before me.


Romain RAT

unread,
Jan 12, 2025, 5:18:01 AMJan 12
to MPF Users
Hi,
So, I've been trying to make the SPI work.
I used the config file given in the example you sent me.

Changed the number of:
    - o_cs to 1-0-24 (RCK pin on the SPI trough connector)
    - o_clock to 1-0-25 (SCK pin on the SPI trough connector)
    - s_miso to 1-0-26 (MISO pin on the SPI trough connector)

I wired:
Cobrapin controller 1-0-24 to RCK pin on the SPI trough connector
Cobrapin controller 1-0-25 to SCK pin on the SPI trough connector
Cobrapin controller 1-0-26 to MISO pin on the SPI trough connector
Supplied the trough board with 5V (both emitter and receiver side).

For info: Using my finger I can see the LEDs of the trough turning on and off when cutting the beam between opto emitter and receiver.

I probed both RCK and SCK with a scope and none of them is moving. Flat at 3.3V.

Using the "mpf hardware scan", I got:
=================================================================
drivers:
Not implemented
---------
opp:
Connected CPUs:
 - Port: COM3 at 115200 baud. Chain Serial: COM3
 -> Board: 0x20 Firmware: 0x3000000

Input cards:
 - Chain: COM3 Board: 0x20 Card: 0 Numbers: [1, 2, 3, 8, 9, 10, 11]
 - Chain: COM3 Board: 0x20 Card: 0 Numbers: [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]

Solenoid cards:
 - Chain: COM3 Board: 0x20 Card: 0 Numbers: [0, 1, 2, 3, 4, 5, 6, 7]

LEDs:
 - Chain: COM3 Board: 0x20 Card: 0

---------
spi_bit_bang:
Not implemented
==================================================================

I assume, the issue comes from the fact both "driver" and "spi_bit_bang" are being seen as "Not implemeted".

Is there a firmware for the Cobrapin controller board 1 with the spi_bit_bang implemented ?

cobra18t

unread,
Jan 12, 2025, 1:45:16 PMJan 12
to MPF Users
I assume that you need RCK and SCK to be on output pins, but you assigned them to switch pins. Try using output (solenoid) pins instead.

Romain RAT

unread,
Jan 12, 2025, 4:00:30 PMJan 12
to mpf-...@googlegroups.com
Indeed, that's better now.
I thought it would switch the inputs (1-0-24 &  1-0-25) to outputs by coding that. My bad.

I'm now able to read information from the trough. The count of balls is off though. I'll take a look at it tomorrow to see what's wrong.
As I was only playing only with a trough in my hands, MPF was reporting error due to the fact balls were "deseapiring". I'll try to get something working in the next few days. Missing a bit of hardware right now.

Either way, thank you so much for the help ;)

cobra18t

unread,
Jan 12, 2025, 4:04:15 PMJan 12
to MPF Users
I assigned RCK to the 1-0-1 coil output and SCK to the 1-0-2 coil output and it started cycling appropriately on my hardware. The next problem to overcome is that the coil outputs are inverted since they are open-drain outputs. You either need to figure out a way to invert the logic within the spi_bit_bang in MPF or invert the outputs again in hardware.

Romain RAT

unread,
Jan 12, 2025, 4:08:36 PMJan 12
to mpf-...@googlegroups.com

That might be the reason why!
Either I invert the signal in hardware or I remove the MOS and shot the gate to the drain.
Any counter-argument not to do that?


cobra18t

unread,
Jan 12, 2025, 4:15:51 PMJan 12
to MPF Users
If you are willing to remove the FET, maybe it would be cleaner to solder two wires directly to the relevant 2 pins on the underside of the CobraPin.

Romain RAT

unread,
Jan 12, 2025, 4:19:59 PMJan 12
to mpf-...@googlegroups.com

Oh yeah! Indeed, way smarter to use the through all footprint to get the gate. Totally forgot about it.
I'm going to try it tomorrow.

I'll let you know.


Dorus van der Linden

unread,
Jan 12, 2025, 5:45:42 PMJan 12
to MPF Users
Hi, I did (for a friend) tap into the individual switch results on the stern board with very thin (coated) wire and connected those to 7 switch positions on the cobra board. But that might not be what you want to to achieve.
Let me know if you want me to take a close up picture of the stern receiver board. 

And if you get the isp to work, I would be very interested…. (For a friend)

cobra18t

unread,
Jan 12, 2025, 9:09:06 PMJan 12
to MPF Users
I was able to get this working tonight. Apparently the spi_bit_bang logic is already inverted and assumes open drain driver outputs. Since they are open drain, you do need pullup resistors to make RCK and SCK work correctly. I got the bit time down to 15ms and it was still stable on my system. Your mileage may vary. I will make a video later showing what I did.

Romain RAT

unread,
Jan 13, 2025, 2:45:55 PMJan 13
to MPF Users
@Dorus,
First plan is to make the SPI to work. In case I can't make it happen, then I'll do what you did.

@Cobra,
I managed to get some progress. Still some issues here and there.
I pulled-up both SCK and RCK to VCC (5V of the stern trough).

How many input did you configured in the spi_bit_bang ? I currently have 7 for trough 1 to 6 and the JAM position.
Turns out sometimes I have two switches triggered even thoug I'm changing only one. Do I have to keep 8 inputs ? Does change much on my side.

Also, what number parameter you gave the trough switches ?

Thanks for the precious answers so far !

cobra18t

unread,
Jan 13, 2025, 3:26:39 PMJan 13
to MPF Users
What pullup resistors did you use? What OS are you on? I was using Linux Mint on an old I7 2600 machine.

The parameter I gave was the bit time for the spi_bit_bang. The default is 50ms, but 15ms worked well for me.

I left it at the default 8 number of switches.

Romain RAT

unread,
Jan 13, 2025, 3:37:17 PMJan 13
to mpf-...@googlegroups.com

I used 5.1k.
I'm on a windows 10 with a ryzen 7 on it.

I left 50ms as a default so far.
Okay!

For the switches I meant what number you used for them ?

switches:
    s_trough1:
        number: 6
        platform: spi_bit_bang
    s_trough2:
        number: 5
        platform: spi_bit_bang
    s_trough3:
        number: 4
        platform: spi_bit_bang
    s_trough4:
        number: 3
        platform: spi_bit_bang
    s_trough5:
        number: 2
        platform: spi_bit_bang
    s_trough6:
        number: 1
        platform: spi_bit_bang
    s_trough_jam:      # this might be also number 0
        number: 0
        platform: spi_bit_bang

cobra18t

unread,
Jan 13, 2025, 3:49:25 PMJan 13
to MPF Users
I used numbers 0 to 6 similar to that.

I used 11k for the resistors but 5.1k is probably fine. If your switches are still not stable, increase the bit time to 100ms as a test.

Romain RAT

unread,
Jan 13, 2025, 4:22:01 PMJan 13
to mpf-...@googlegroups.com

Okay.
It's not that they're not stable, it's more like s_trough1 (number: 6) doesn't turn on even though I actually have a ball in that position.
Then if I put another ball into trough, I have both s_trough1 and s_trough2 ON.
Also, I cannt get state ON of a switch if the previous is not ON. I'd assume it's due to MPF that doesn't allow a ball to be in a position N when there is no ball in N-1...
Do you have this behaviour too?
Apart from these behaviours, the switches states are really stable (not glitchy I mean).


Anthony van Winkle

unread,
Jan 13, 2025, 4:35:30 PMJan 13
to mpf-...@googlegroups.com
MPF makes no determination on an “order” of trough switches, it merely counts the number of active switches and tallies the ball count from that. It sounds like there may be some parallel wiring? Or are some switches wired NO and others NC?

Romain RAT

unread,
Jan 13, 2025, 4:42:45 PMJan 13
to mpf-...@googlegroups.com

Shit, my hypothesis was so cool to me x)..

All of them are NO (as default).
They are optos (NC) but are inverted on the trough PCB so NO in the end.

What do you mean by parallel wiring?
Because the only things I have wired are the miso, the CS and the clock. The Stern trough is default apart from the pull up I added on both CS and Clock.


Le lun. 13 janv. 2025, 22:35, Anthony van Winkle <anthonyv...@gmail.com> a écrit :
MPF makes no determination on an “order” of trough switches, it merely counts the number of active switches and tallies the ball count from that. It sounds like there may be some parallel wiring? Or are some switches wired NO and others NC?

--
You received this message because you are subscribed to a topic in the Google Groups "MPF Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mpf-users/FuvYokPp_Qw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mpf-users+...@googlegroups.com.

cobra18t

unread,
Jan 13, 2025, 9:27:00 PMJan 13
to MPF Users
How are you monitoring switch state? I am looking at mine in the MPF Monitor devices page looking at the switch states. Mine behaves normally.

Your trough power and CobraPin power share a GND, correct? Where are you picking up RCK and SCK on CobraPin?

cobra18t

unread,
Jan 13, 2025, 9:32:24 PMJan 13
to MPF Users
You only mentioned miso, CS, and SCK. So I want to make sure there is a GND in there too. Do you have a picture of your setup?

Romain RAT

unread,
Jan 14, 2025, 12:38:00 PMJan 14
to mpf-...@googlegroups.com
Hi,
Yes I have a GND that is shared between the cobrapin controller and the trough. When I only mentionned Miso, SCK and RCK, I meant signal wise.
You might see an attached file in this post.

The emitter optos are supplied by an external 5V supply. (no GND connected to anything else than the emitter board)

Receiver board is supplied from 5VD (relay) and its GND which is the GND shared between controller and trough.
I used 1-0-1 for the RCK pin and 1-0-7 for the SCK pin (From under the controller using header). On the scope, I can see them moving accordignly to what I would expected (apart from the stated that could inverted or not).
The clock is switching 8 times (for 8 switches) and stop about few ms to have the RCK switching and loading the switch state in parrallel.
However, to me, all states are inverted. The parallele load should be done on Low level, and about clock, the sampling is done on rising edges. There are rising edges but yeah... default state to me might not be high.

I would be interested to see how you wired both controller outputs so I can compare. Pretty sure there is someting there.


20250114_181149.jpg
DS1Z_QuickPrint1.png

cobra18t

unread,
Jan 14, 2025, 3:22:01 PMJan 14
to MPF Users
Did you have that board made yourself? Congrats! That is the first one that I have seen that I know I didn't make.

What power FET part number did you use for this build?

I used the relay output connector for 5VD, GND, RCK, and SCK. So RCK and SCK are assigned to 1-0-1 and 1-0-2. I added the pull-up resistors under the CobraPin to bridge the necessary relay solder jumpers and 5VD. I don't have a photo right now. I assigned MISO to 1-0-1 just like it looks like you did.

Your RCK looks fine. The parallel load happens when low, but Stern has an inverter on that signal already. I will check again tonight, but I do think your clock is inverted. Can you show your connections on the underside of the board?

You may want 5V and GND to come in on the same trough connector as the signals. That is just an optimization...likely not causing your problem.

I would also monitor the MISO with your scope to confirm it is behaving as expected.

Romain RAT

unread,
Jan 14, 2025, 4:03:42 PMJan 14
to mpf-...@googlegroups.com
I bought a partially populated PCB from a french guy (I'm french) I met on a facebook page. I would assume he made them fabricated at JLCPCB but can't be 100% sure.
As I work in an electronic field, I could quite easily get the parts to complete it.
I used IPD60N10S4L-12 for the output transistor. I built that board about 1 year ago but as far as I remember, it has pretty much the same specs (or higher) that your LSGG10R085W3.

I see ppretty much what you did. However, did you used both Q25 and Q26 ? As you said, there is an invertor on the trough meaning we might not need to invert RCK on the controller.
Did you just set 1-0-2 directly to the pin connector bypassing the transistor ?

Under the controller is just a header as I said (see the attached file).

Indeed, for optimization, I could use the same connector for all signals. Also there is a copper poor on both sides (one is GND the other is VCC).

Next test on my side, get the same output as you (1-0-1 and 1-0-2 and only use the transistor on the clock)
I'll scope MISO to see what is happening.




20250114_214733.jpg

Romain RAT

unread,
Jan 14, 2025, 4:24:18 PMJan 14
to mpf-...@googlegroups.com
It finally works !

I did, I think, what you said. Is used the relay transistor. Oen is just bypassed (the one for RCK since signal was OK) and the other one is used to invert the clock signal.
Going to bed but I can still send some screenshot of the scope if needed later on.

In the pictures what I did.

I'll explain later what exactly I did to whoever finds this post and needs to do the same.

As always, thanks for the answers, really apreciate !
20250114_221924.jpg
20250114_221938.jpg

cobra18t

unread,
Jan 14, 2025, 4:35:49 PMJan 14
to MPF Users
Why did you use a jumper wire for the one? It is the same as the solder jumper logically.

Romain RAT

unread,
Jan 14, 2025, 4:41:28 PMJan 14
to mpf-...@googlegroups.com

What do you mean?
I had to invert SCK so I used to jumper to connect the drain mos to the connector and I didn't have to invert RCK so I just wire jumped it directly to the connector.


cobra18t

unread,
Jan 14, 2025, 4:54:02 PMJan 14
to MPF Users
Using that jumper wire on the underside of the board does the same thing as the solder jumper. I was looking at the last picture of the underside of the board.

Romain RAT

unread,
Jan 14, 2025, 5:05:31 PMJan 14
to mpf-...@googlegroups.com

Oh yeah you're right, I'm so dumb x).
For some reason I rushed it and I was like 1-0-1 is the bluepill output when it's actually behind the MOS relay but not on the other side...
Meaning I actually inverted both signal and it works when it wasn't the case previously with the coil outputs.
Don't really get that right now. I'll remove that wire to solder the jumper and scope all of that tomorrow.


Dorus van der Linden

unread,
Jan 14, 2025, 5:07:12 PMJan 14
to mpf-...@googlegroups.com
Have  a great evening, and I am looking forward to the final notes, will give this a try myself.


From: mpf-...@googlegroups.com <mpf-...@googlegroups.com> on behalf of Romain RAT <romai...@gmail.com>
Sent: 14 January 2025 23:05
To: mpf-...@googlegroups.com <mpf-...@googlegroups.com>
Subject: Re: [mpf-users] Re: Stern Spike Trough, OPP and CobraPinball
 

cobra18t

unread,
Jan 14, 2025, 8:35:43 PMJan 14
to MPF Users
Since the signal wasn't inverted when you were on the coil output, I am concerned that there is a problem with your coil output. I confirmed on my board that the trough should have worked the way you had it connected before. There may be a component, solder, or PCB problem lurking there. Be sure to check that out before you start applying 48V and using that coil output for an actual coil.

cobra18t

unread,
Jan 14, 2025, 9:48:53 PMJan 14
to MPF Users
Well it looks like SCK idles high for me as well (see scope trace), so there was no inversion problem on your end. I am still not sure why it did not work for you in your original setup. Glad you got it working, though.
DS1Z_QuickPrint2.png

Romain RAT

unread,
Jan 15, 2025, 2:33:31 PMJan 15
to mpf-...@googlegroups.com
Hi,

Thanks for the work you did so it can work !

To sum it up :
If you're using a cobrapin pinball controller and OPP and you bought a Stern Spike Trough, don't worry !
1) Hardware side:
1-1) Soldering
Information: In my case, I used both RL0 and RL1 outputs which are connected to 1-0-1 and 1-0-2 coils outputs.
- You need to add a resistance (>5kOhms <20kOhms) between pin RCK of CN1 and VCC of the trough or a resistor (>5kOhms <20kOhms) between JP10 middle pad (under the cobrapin) and pin 5VD of J15 of the cobrapin
- You need to add a resistance (>5kOhms <20kOhms) between pin SCK of CN1 and VCC of the trough or a resistor (>5kOhms <20kOhms) between JP11 middle pad (under the cobrapin) and pin 5VD of J15 of the cobrapin
- You need to short JP10 middle pad to the pad that is the closest to "1-0-1" (under the cobrapin)
- You need to short JP11 middle pad to the pad that is the closest to "1-0-2" (under the cobrapin)

1-2) Wiring
- You need to connect RL0 of J15 (cobrapin) to RCK of CN1 (trough)
- You need to connect RL1 of J15 (cobrapin) to SCK of CN1 (trough)
- You need to connect 5VD of J15 (cobrapin) to VCC of CN1 (trough)
- You need to connect GND of J15 (cobrapin) to GND of CN1 (trough)
- You need to connect 1-0-1 of J3 (cobrapin) to MISO of CN1 (trough)

2) MPF side:
- From this configuration, you will setup:

#config_version=6
hardware:
    platform: opp, spi_bit_bang      # add your platform first here
    driverboards: gen2

spi_bit_bang:
    miso_pin: s_miso
    cs_pin: o_cs
    clock_pin: o_clock
    bit_time: xxms                          #(where xx is 50 by default but can be lowered, see chapter 3) to see what could be the lowest value)
    inputs: 8
digital_outputs:
    o_cs:
        number: 1-0-1         # adjust this for your platform
        type: driver
    o_clock:
        number: 1-0-2        # adjust this for your platform
        type: driver

opp:
  #Use the USB ports defined by your OS for the two STM32 boards
  ports: COMx, COMx 
 
switches:
    s_trough1:
        number: 5
        platform: spi_bit_bang
    s_trough2:
        number: 4
        platform: spi_bit_bang
    s_trough3:
        number: 3
        platform: spi_bit_bang
    s_trough4:
        number: 2
        platform: spi_bit_bang
    s_trough5:
        number: 1
        platform: spi_bit_bang
    s_trough6:
        number: 0

        platform: spi_bit_bang
    s_trough_jam:      # this might be also number 0
        number: 6
        platform: spi_bit_bang
    s_miso:
        number: 1-0-1       # Could be any other switch input by the way

3) Bit_time:
The bit time determines (as explained here: https://missionpinball.org/latest/hardware/spi_bit_bang/) how long MPF will wait after clocking the chip for miso_pin to settle.

This is 50ms by default but it can be lowered. The lower the better !! Yeah... Not much.
Basically try a lower value than 50ms, run MPF with no pinball in the trough and monitor your trough switches (JAM included) on MPF for about a 30 secondes/a minute.
If any of them is blinking (glitching), it means you need to increase the value of your bit_time.
If it doesn't then you can lower it until it blinks and you keep the previous value (before it blinks).
As an example, I got down to 35ms (which is not very good) and Cobra18t got down to 15ms which is better. (Obviously you'd say !)

Hope this guide helped you through the setting of a Stern Spike Trough when using a cobrapin pinball controller.

Special thanks to Cobra18t for the help ! ;)


Reply all
Reply to author
Forward
0 new messages