What's new
Pinball info

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

In Progress Mishmash self build - let’s make a pinball machine

OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
Is it Python you are coding in? You'll need to get your light displays to trigger from an event, then set off the light display in a Thread. Threads can be a head screw, but will ultimately be your friend. Well worth the effort.

Im using the arduino IDE, so not it's not python. I could pass the stuff to the 2nd processor in the ESP32s - but I've not done that before and it's probably something for me to look at in future, in the meantime, I just need to re-code the routines - I've figured out a simple way to do it for most.
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
The issue is in some of my lighting display routines, some routines you call repeatedly and they perform a quick single cycle of the lighting pattern animation then return - they are fine. When they are called a second time, then know where they were and carry on from there. Some others are single call - they will do a whole animation and then return. These need splitting to be multi call with a memory of where they are at. (I'm actually going to re-write them - probably easier).

Had a good morning so far, managed to get through a ton of coding that just needed doing to set out the stall for the next stage of the development.

My original design idea for switches and what they do seems wrong. I had attributes against a switch - e.g. points to score, lamps to light, solenoid to fire, routine to run. This is probably the wrong way of doing it. I'm going to strip all that out and just have a routine associated with each switch, and then in that routine I can decide what to do. This is much better as it allows me more control e.g. hitting a switch may not need to light a single lamp, but rather it needs to light the next lamp in a sequence iof lamps, similarly - the points it scores, may depend on other things - has it already been hit or not, have other things been hit that increase or decrease the score, etc. etc.

So more coding to rip that out and do it a different way.
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
I’ve had enough of out and out coding for today, so time to do something else. Sound!
I really want to generate sounds from a sound card that i can load the sounds on from mp3 or wav files etc.

Ive tried a couple of cards that use an sd card, but they are too slow - ie there is approx 1 second delay in the sound starting to play once you trigger the card to play a particular file. i guess it’s slow in finding opening and reading the card off the sd card.

Struggling to find something better.

I then tried one of these cheap sound generator boards. they produce 16 electronic sounds. police siren, chirps etc. ruled that out as the sounds are truly terrible.

I may just use an old bally SS sound card that i have spare, to start with.
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
I've spent a few hours looking into sound generation. I have some ideas and will set up some experiments on the bench...............
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
So, a few pints of real ale and some pork pies have given me some much needed nourishment. I’ve decided to have another go with the sd card based mp3 player board. I’m sure it should not have such a delay in picking tracks, so i’m going to mess around with it and see if i can speed it up.

All the other sound ideas i looked into the afternoon, I have discounted for one reason or another. The way to go is surely to play mp3 or wav files from a disk or sd card.
 

Judderman

Site Supporter
Joined
Mar 28, 2016
Messages
491
Location
Cheshire
So, a few pints of real ale and some pork pies have given me some much needed nourishment. I’ve decided to have another go with the sd card based mp3 player board. I’m sure it should not have such a delay in picking tracks, so i’m going to mess around with it and see if i can speed it up.

All the other sound ideas i looked into the afternoon, I have discounted for one reason or another. The way to go is surely to play mp3 or wav files from a disk or sd card.
I'm sure you've thought of this, but can't you load them into a cache (dunno how big they are, nor how much memory you have to play with)
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
I'm sure you've thought of this, but can't you load them into a cache (dunno how big they are, nor how much memory you have to play with)
Yes good idea. you can do this but then it means taking on board the sound processing itself on the main processor, or adding another one , whereas the beauty of the dedicated off the shelf sound board is that it should do it all for you, which it does but it’s slow. i’m not sure of the speed of the sd card i’ve got in the sound card, so i’ll get a really fast one and try that. there is also a sound card i can buy that has no sd card but instead it has on board ram but only 8mb - which isn’t much.
 

stevebm1

Registered
Joined
May 26, 2014
Messages
1,299
Location
uk
Alias
sjs71
what sd sound card are you using to test?,my son used mp3 trigger for a project whilst he was at college a few years ago
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
what sd sound card are you using to test?,my son used mp3 trigger for a project whilst he was at college a few years ago
The widely available DY-SV5W card

Im going to have another go with it later this weekend, first I'm in the mood for a good solid slog of programming - coding up some of the game features. See you in about 8 hours. Anyone who has ever done and coding will know the feeling, hours fly by in absolutely no time at all.........
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
2 hours in and yes ive written a few functions: inAttractMode, inGameMode, etc. now having a go at the switch trigger code procedures. starting with the Outhole switch and the Credit/Start switch.
E61C2007-2BD3-4744-BEC7-D980B3E90027.jpeg
 

Ashbo

Site Supporter
Joined
Apr 9, 2021
Messages
367
Location
Lincolnshire
Alias
Ash
The widely available DY-SV5W card

Im going to have another go with it later this weekend, first I'm in the mood for a good solid slog of programming - coding up some of the game features. See you in about 8 hours. Anyone who has ever done and coding will know the feeling, hours fly by in absolutely no time at all.........
Sure do, love it, not great for the loved ones though ;)
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
10 hours of programming and i’m still at it. getting the score displays working has caused me all sorts of issues. it’s the scrolling that has killed me.

i’m not stopping today until i get a game simulation going. ie start a game, add a player, score something, drain a ball and onto next player/next ball etc. that’s a milestone i really want to achieve.
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
Finished for the day - another mammoth day of coding, started at 5:45 this morning so a full 12 hours. Now need to give the mrs some of my time, oh and eat!.

I've got the game code going, starting a game, adding players, a lot of the scoring and lamp lighting is there and then when ball drains, it moves onto next player, and repeats until the game ends.

I haven't done all of the switch coding - so there is the 8 ball saucer to do, the end of ball bonus to add, etc. etc. Then there is all the lighting effects and sound stuff to add. Ive tested some of the solenoid triggers - but at the moment they are
not wired in, from a safety point of view - I need to ensure no coils can get locked on, before I hook them up. The flipper controls are written, they're a little more complex than the other solenoids, which fire for a short period of time. I need to detect when the flipper buttons are released, which isnt handled by the switch matrix reader - it only looks for switches that have been made, not released.
 

russdx1

Site Supporter
Joined
Jul 7, 2018
Messages
1,098
Location
Bristol
Alias
russdx
Installing a string of addressable leds is ok, but there is quite a lot of work involved afterwards in addressing these. First we want to know what each led does on the playfield. some are GI lamps, most are “feature” lights, with a specific meaning. eg “shoot again”. 2X bonus, special , etc. so i have to figure out which led number in the string, is in which position. that then allows me to program up the game and switch the relevant feature leds on at the appropriate time.

In addition to this, i also want some led animations - an animation is where a group of leds or, even the whole playfield of leds, are controlled in sequence. All the example scripts you find generally just process the leds in led # order, but for a playfield this doesn’t work because we’ve wired the playfield up in any old random order, so the led number is meaningless. What has more meaning is the position of the led on the playfield, or another meaningful way is to group leds that are similar eg if there is a line of yellow arrow inserts you may want to light those in sequence. This means we need to hold positional coordinates for each led and also group leds together. It’s taken me a few hours to map out the coordinates of the leds on the playfield. i marked the playfield into 2.5cm squares and then figured out the X and Y co ordinates of each led. So now i can fairly easily program some light animations that run from side to side, top to bottom, diagonally, etc.

I’ve also coded in some test for the coil triggers and they seem to be firing off ok.

I need to test the coils themselves as i’m sure a couple are broken (i tested them a few months ago and remember some were not working)

I am now at the stage where I feel I can start on the actual game code. To start with I am going to aim to get a game going that has similar rules to the original game of the playfield. 8 ball champ. this makes sense to me as a first attempt because i don’t have to really do much thinking about the game rules, they are already designed and documented.
I used to do this a lot on slots / fruit machines, we just drew the lamps in there correct position in some software like flash or photoshop then recorded there x y positions. Then write loads of animations that used those x y positions to create the sweeps and spirals effects etc…
 

Chefsolid

Registered
Joined
Sep 12, 2021
Messages
1
Location
Manchester
Finished for the day - another mammoth day of coding, started at 5:45 this morning so a full 12 hours. Now need to give the mrs some of my time, oh and eat!.

I've got the game code going, starting a game, adding players, a lot of the scoring and lamp lighting is there and then when ball drains, it moves onto next player, and repeats until the game ends.

I haven't done all of the switch coding - so there is the 8 ball saucer to do, the end of ball bonus to add, etc. etc. Then there is all the lighting effects and sound stuff to add. Ive tested some of the solenoid triggers - but at the moment they are
not wired in, from a safety point of view - I need to ensure no coils can get locked on, before I hook them up. The flipper controls are written, they're a little more complex than the other solenoids, which fire for a short period of time. I need to detect when the flipper buttons are released, which isnt handled by the switch matrix reader - it only looks for switches that have been made, not released.
I've just read this complete thread and this is nothing short of incredible! great work sir, keep plugging away!
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
In my wisdom I decided to use 4 X 8X8 led matrix displays for each score display. The character set I am using is generally 6 pixels wide (including a single pixel space between characters. So 4 X8 = 32 which gives me 5 and a bit characters. No problem I though - I can easily scroll the displays to show bigger scores etc. This works, but the problem is, it looks a bit confusing. So, I've decided to bite the bullet and upgrade to 6 X 8X8 which gives 48 pixel width = 8 characters = 99 million score capability (without commas).

I may as well connect players 1&2 and players 3&4 displays together and make a single run of 12 X 8X8 - this gives me even more versatility. Might have to upgrade the 5v power supply as Im going to have 24 X 8 X8 = 1,536 leds to power. 20Ma would draw 30A fully lit, but even at around 30% will still draw 10A -I'll test what each led pixel draws and do some better calculations.
 

Judderman

Site Supporter
Joined
Mar 28, 2016
Messages
491
Location
Cheshire
If using an Object Oriented language you may want to play around with some design patterns to organise the code to assist with maintenance etc, a couple that come to mind are State Pattern and Observer Pattern;



Impressive work so far 👍
State machine pattern was exactly what sprang into my mind - gonna be a complex one tho.
 
OP
AlanJ

AlanJ

Site Supporter
Joined
Dec 27, 2017
Messages
4,340
Location
Leeds, West Yorkshire
Alias
Alan
Yes i realised that. in future i’ll probably swap to one of those rgb led panels. they’re something i’ve never wired up or programmed though so will be another learning curve!!!
 
Top Bottom